Page 1 of 1

Relative Paths

Posted: Wed Nov 20, 2013 1:34 pm
by TimGrun
Hi All,

I would like to use relative paths in my programs. The paths should be relative to the directory of the program I am running and NOT the current path as shown in the bottom right corner of the EViews window.

We are going to distribute a zip file with many programs, include files and data files in a directory structure. Programs in the programs sub-directory will include files in an include directory. They will read data from a data directory. All directory references should be relative since we won't know where users will unzip the zip file.

Within a program, am I able to obtain the directory path of the program I am running?

Thanks,
Tim

Re: Relative Paths

Posted: Wed Nov 20, 2013 2:02 pm
by EViews Gareth

Re: Relative Paths

Posted: Thu Nov 21, 2013 11:53 am
by TimGrun
Gareth,

Wow. That is some documentation. Kind of makes your head spin. :roll:

There is a problem.
Using File->Open->Programs... to start a program gives results as per the documentation.
Typing run c:\filepath\prog.prg from the command window or c:\eviews8path\eviews.exe c:\filepath\prog.prg from a windows command prompt, assigns "c:\" to both the @runpath and @linepath. Also, .\..\ is relative to c:\ and is NOT referencing "above linepath".

Is this something that can be fixed in the next patch?

Thanks,
Tim

Re: Relative Paths

Posted: Thu Nov 21, 2013 12:05 pm
by EViews Gareth
I cannot replicate that behaviour. In my testing, linepath is the path of the current running program, whether that program is run via open->program, the command line, or a dos prompt.

Re: Relative Paths

Posted: Thu Nov 21, 2013 1:13 pm
by TimGrun
I am running the Jul 11 2013 build.

As an example, the following test program gives different results depending on how it is initiated. Linepath is "c:\" unless initiated from via open->program.
wfcreate(wf=aaa,page="main") q 1947 2020

string runpath = @runpath
string linepath = @linepath
string datapath = @datapath
string addinspath = @addinspath
show runpath
show linepath
show datapath
show addinspath

Re: Relative Paths

Posted: Thu Nov 21, 2013 2:08 pm
by EViews Gareth
Works fine for me.

You should update to the latest version, just in case.

@linepath issues (program directory, not the file)

Posted: Mon Nov 11, 2019 5:40 am
by fmramos
Hi everybody,

When I run the command @linepath inside a PRG to get a string with path/file.prg, I'm getting just the path. Any clues about why this happens (version 10 Enterprise here, Oct 17, 2019 version).

Thanks in advance,
Best, Fabio

Re: Relative Paths

Posted: Mon Nov 11, 2019 8:29 am
by EViews Gareth
That's what it is supposed to do (Despite the documentation's example suggesting otherwise).

Re: Relative Paths

Posted: Tue Nov 12, 2019 9:22 am
by fmramos
Tks, Gareth. Is there a way to get the running program file name?

Best, F

Re: Relative Paths

Posted: Tue Nov 12, 2019 9:28 am
by EViews Gareth
Not sure there is. We should probably add one.

Re: Relative Paths

Posted: Tue Nov 12, 2019 9:50 am
by fmramos
Tks! F

Re: Relative Paths

Posted: Tue Nov 12, 2019 10:17 am
by EViews Matt
Hello,

There is also the undocumented command @runname that returns the file name of the "top-level" program running (ignoring the effects of include or exec as documented for @runpath).

Re: Relative Paths

Posted: Tue Nov 12, 2019 10:32 am
by fmramos
Tks Matt. Ultra helpful. It will solve my problem!! F