breaking lines of code with " _ " in program not working

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

mamo
Posts: 192
Joined: Wed Nov 07, 2012 9:11 am

breaking lines of code with " _ " in program not working

Postby mamo » Thu Feb 20, 2020 8:22 am

Dear Eviews team,

I use EVIEWS 11 Sept 19 build, 64 bit.

Manually breaking long lines of code with the underscore character in a program does not seem to work as described in the documentation (c.f., quotation below): the example code below yields an error.

Best, mamo

Code: Select all

wfcreate a 2000 2010
series x=nrnd
series y=3*x+4+nrnd
equation eq1.ls _
y x c

Err.jpg
Err.jpg (14.38 KiB) Viewed 5992 times


http://www.eviews.com/help/helpintro.html#page/content%2Fcprogram-Program_Basics.html%23ww175823:
If you desire greater control over the appearance of your lines, you can manually break long lines using the ENTER key, and then use the underscore continuation character “_” as the last character on the line to join the multiple lines. For example, the three separate lines of text
equation eq1.ls _
y x c _
ar(1) ar(2)
are equivalent to the single line
equation eq1.ls y x c ar(1) ar(2)

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13315
Joined: Tue Sep 16, 2008 5:38 pm

Re: breaking lines of code with " _ " in program not working

Postby EViews Gareth » Thu Feb 20, 2020 9:05 am

Works fine for me.

Try updating to the latest version.
Follow us on Twitter @IHSEViews

mamo
Posts: 192
Joined: Wed Nov 07, 2012 9:11 am

Re: breaking lines of code with " _ " in program not working

Postby mamo » Wed Feb 26, 2020 5:18 am

... okay, will update to the latest build.
With the current build, the trick seems to be that there must not be a space character immediately following the underscore ("_") sign in the first line in which the underscore is used.
In the following lies, the underscore sign can be followed by as many spaces as one may wish without creating an error.
(see example code below),
mamo

Code: Select all

wfcreate a 2000 2010
series x=nrnd
series y=3*x+4+nrnd
' There must not be an empty space after the underscore sign in the following line:
equation eq1.ls _
' The underscore sign in the following line may be followed by one or more empty spaces:
y x _     
c

mamo
Posts: 192
Joined: Wed Nov 07, 2012 9:11 am

Re: breaking lines of code with " _ " in program not working

Postby mamo » Wed Feb 26, 2020 6:09 am

... and, unfortunately, breaking program lines within the definition of string variables with the underscore sign does not seem to work (irrespective of zero or spaces after the underscore character).

Code: Select all

%test="One Two Three _ 
 Four"


Err.jpg
Err.jpg (10.38 KiB) Viewed 5916 times

EViews Matt
EViews Developer
Posts: 562
Joined: Thu Apr 25, 2013 7:48 pm

Re: breaking lines of code with " _ " in program not working

Postby EViews Matt » Wed Feb 26, 2020 9:57 am

Hello,

Correct, the underscore character loses its special meaning for line continuation within a string literal. However, you can use a combination of string concatenation and continuation to achieve the desired result, e.g.,

Code: Select all

%test="One Two Three " + _
"Four"


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 24 guests