CD to path in string
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
CD to path in string
I would like to have a program register the path from where it is being run, and then save this as a string. This part is straightforward using @runpath and a string variable. However I would like the main program to include subprograms held in a folder within the main path.
For example:
path for main program C:\Program
path for subprograms C:\Program\subprograms
I have written a string which contains the full path for the subprograms, but I cannot get Eviews to cd to that path by reading the string, and hence cannot have the subprogram run. Any help with this please?
Thanks
W
For example:
path for main program C:\Program
path for subprograms C:\Program\subprograms
I have written a string which contains the full path for the subprograms, but I cannot get Eviews to cd to that path by reading the string, and hence cannot have the subprogram run. Any help with this please?
Thanks
W
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13584
- Joined: Tue Sep 16, 2008 5:38 pm
Re: CD to path in string
I don't follow.
Re: CD to path in string
I think I am having a similar issue.
I want to loop through a group of strings as variables in order to access different workfile pages. I previously got this to work for creating pages and importing excel files, but never tried directories.
My code [that is NOT working] is
for %Area "Tacoma" "Seattle" "Snohomish"
%PageArea="ZZ_"+%Area
wfopen(page=%PageArea) [Workfile_Path]
[estimation stuff]
next
Right now the workfile only opens to the last save paged because, as I've found, there is a difference between %PageArea and ZZ_Tacoma, as typing ZZ_Tacoma directly in (or using straight pageselect ZZ_Tacoma) with this works.
SO, how can I convert a string variable such that page= will recognize it as a page name and not a string? I need to iterate through like 15 pages for at least 10 different things, so, I need to figure this out.
THANKS!!!!!!
I want to loop through a group of strings as variables in order to access different workfile pages. I previously got this to work for creating pages and importing excel files, but never tried directories.
My code [that is NOT working] is
for %Area "Tacoma" "Seattle" "Snohomish"
%PageArea="ZZ_"+%Area
wfopen(page=%PageArea) [Workfile_Path]
[estimation stuff]
next
Right now the workfile only opens to the last save paged because, as I've found, there is a difference between %PageArea and ZZ_Tacoma, as typing ZZ_Tacoma directly in (or using straight pageselect ZZ_Tacoma) with this works.
SO, how can I convert a string variable such that page= will recognize it as a page name and not a string? I need to iterate through like 15 pages for at least 10 different things, so, I need to figure this out.
THANKS!!!!!!
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13584
- Joined: Tue Sep 16, 2008 5:38 pm
Re: CD to path in string
Code: Select all
wfopen(page={%PageArea})
Re: CD to path in string
Probably best if I show you the code:I don't follow.
Code: Select all
%run_path = @runpath
cd %run_path
[code here]
string routine_path = "''" + %run_path + "routines\" + "''"
cd {routine_path}
include preliminaries.prg
Thanks
Re: CD to path in string
You do not need to create the string. Just use the following code after your code.
Code: Select all
cd routines
include preliminaries.prgRe: CD to path in string
Thanks for your reply, indeed that does change the path easily, however it turns out that as you run the main program, Eviews checks for the existence of the program called by 'include' in the main directory during the compile(?) stage, before it actually executes anything, and crashes as it does not find it. Still a dead end.
Using 'exec' instead of 'include' works, but from what I understand 'exec' does not cause Eviews to pass on any control/string variables to that program being executed, so no progress there either as Eviews also crashes.
I ended up writing a program holding all the routines I need as subroutines, and I 'call' them when needed in the main program. I still can't get the subroutines program to be in a different path, which is back to my main problem, but at least this is more elegant than having various program files in the main folder.
Thanks
W
Using 'exec' instead of 'include' works, but from what I understand 'exec' does not cause Eviews to pass on any control/string variables to that program being executed, so no progress there either as Eviews also crashes.
I ended up writing a program holding all the routines I need as subroutines, and I 'call' them when needed in the main program. I still can't get the subroutines program to be in a different path, which is back to my main problem, but at least this is more elegant than having various program files in the main folder.
Thanks
W
Re: CD to path in string
Code: Select all
cd routines
include preliminaries.prg
cd %run_pathRe: CD to path in string
That doesn't work for me unfortunately. I'm on Eviews 9.5 Mar 17 build; maybe I need to install the latest patches. Thanks for your help.
Re: CD to path in string
great thanks!Code: Select all
wfopen(page={%PageArea})
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13584
- Joined: Tue Sep 16, 2008 5:38 pm
Re: CD to path in string
Include happens before anything else, including (pun intended) string allocations, so you cannot include a program dynamically.
You might be able to get away with relative paths:
http://www.eviews.com/download/whitepapers/Paths.pdf
You might be able to get away with relative paths:
http://www.eviews.com/download/whitepapers/Paths.pdf
Re: CD to path in string
Yes that seems to have solved my issue, thanks Gareth!
W
W
Who is online
Users browsing this forum: No registered users and 2 guests
