Using strings

For questions regarding programming in the EViews programming language.

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

PacNW
Posts: 21
Joined: Fri Apr 01, 2011 4:31 pm

Using strings

Postby PacNW » Mon Apr 11, 2011 11:27 am

I have a program that uses a specific word string in the options section of wfopen, in the range command in the wfopen line, in the close command, in the wfcreate command, in the group command, in the write command, in the pagesave command, and in the wfsave command

For example:

wfopen(wf=Alpha) "C:\a.xlsx" range=alpha!a1 colhead=2 namepos=all @freq 7 12/1/2009

"Alpha" is used in that line and all of the typed of eviews commands I listed above.

Is it possible to run a loop that would do everything for Alpha, then run the program over for Beta, etc.?

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

Re: Using strings

Postby EViews Gareth » Mon Apr 11, 2011 11:59 am

Code: Select all

for %mystr "alpha" "beta" "gamma" wfopen(wf={%mystr} import(wf={%mtstr} next
etc...

PacNW
Posts: 21
Joined: Fri Apr 01, 2011 4:31 pm

Re: Using strings

Postby PacNW » Mon Apr 11, 2011 2:42 pm

Great, thanks!

PacNW
Posts: 21
Joined: Fri Apr 01, 2011 4:31 pm

Re: Using strings

Postby PacNW » Mon Apr 11, 2011 7:11 pm

This appears to work for all of the commands in my program with the exception of the WRITE command. The name of the output xls file ended up including %mystr, possibly because the name of the file was in quotes and enclosed the {%mystr}

Is there any way around this?

I'd like to write a new csv file for each loop of the program.

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

Using strings

Postby EViews Gareth » Mon Apr 11, 2011 7:39 pm

Create a new string equal to the full path:

Code: Select all

%path="c:\my path\" + %mystr + "\file.xls" Write %path

PacNW
Posts: 21
Joined: Fri Apr 01, 2011 4:31 pm

Re: Using strings

Postby PacNW » Mon Apr 11, 2011 8:06 pm

Thank you!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests