Page 1 of 1

Replacement variable in double quoted string

Posted: Fri Jan 28, 2011 11:37 am
by rdwest
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.

Re: Replacement variable in double quoted string

Posted: Fri Jan 28, 2011 11:46 am
by EViews Gareth
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

Re: Replacement variable in double quoted string

Posted: Fri Jan 28, 2011 12:00 pm
by rdwest
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.

Re: Replacement variable in double quoted string

Posted: Fri Jan 28, 2011 12:21 pm
by EViews Gareth
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.