Replacement variable in double quoted string

For questions regarding programming in the EViews programming language.

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

rdwest
Posts: 18
Joined: Wed Dec 23, 2009 11:35 am

Replacement variable in double quoted string

Postby rdwest » Fri Jan 28, 2011 11:37 am

Hello,

I'm having trouble getting Eviews to recognize my workfile's name, which contains a replacement variable, in the "open" and "save" commands. I realize that it's expecting a string in double quotes, but I don't understand why this generates an error (nor how I should be expressing the filename).

%var = jan_2011_update

open "data_file_"+%var+".wf1"
....[program code]....
wfsave(2) "data_file_"+%var+".wf1"


Many thanks,
R.

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

Re: Replacement variable in double quoted string

Postby EViews Gareth » Fri Jan 28, 2011 11:46 am

Put them in a temporary string beforehand. Many EViews command won't accept string manipulation:

Code: Select all

%var = jan_2011_update %fullname = "data_file_" + %var + ".wf1" wfopen %fullname wfsave(2) %fullname

rdwest
Posts: 18
Joined: Wed Dec 23, 2009 11:35 am

Re: Replacement variable in double quoted string

Postby rdwest » Fri Jan 28, 2011 12:00 pm

Thanks, Gareth. That's what I've been doing, but it's getting a little cumbersome to create a new string variable every time I want to use the open or save files, or change the current directory (which happens multiple times throughout the program).

Does this imply that there's no way to directly insert a replacement variable into a quoted string?

Thank you,
R.

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

Re: Replacement variable in double quoted string

Postby EViews Gareth » Fri Jan 28, 2011 12:21 pm

Sort of. It implies that the wfopen and wfsave command will not let you do string arithmetic on their arguments. Inserting a replacement variable into a quoted string uses string arithmetic.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests