Relative Paths

For questions regarding programming in the EViews programming language.

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

TimGrun
Posts: 36
Joined: Wed Sep 16, 2009 8:01 am

Relative Paths

Postby TimGrun » Wed Nov 20, 2013 1:34 pm

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

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

Re: Relative Paths

Postby EViews Gareth » Wed Nov 20, 2013 2:02 pm

Follow us on Twitter @IHSEViews

TimGrun
Posts: 36
Joined: Wed Sep 16, 2009 8:01 am

Re: Relative Paths

Postby TimGrun » Thu Nov 21, 2013 11:53 am

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

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

Re: Relative Paths

Postby EViews Gareth » Thu Nov 21, 2013 12:05 pm

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.
Follow us on Twitter @IHSEViews

TimGrun
Posts: 36
Joined: Wed Sep 16, 2009 8:01 am

Re: Relative Paths

Postby TimGrun » Thu Nov 21, 2013 1:13 pm

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

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

Re: Relative Paths

Postby EViews Gareth » Thu Nov 21, 2013 2:08 pm

Works fine for me.

You should update to the latest version, just in case.
Follow us on Twitter @IHSEViews

fmramos
Posts: 113
Joined: Fri Sep 19, 2008 7:30 am
Location: Sao Paulo / Brazil
Contact:

@linepath issues (program directory, not the file)

Postby fmramos » Mon Nov 11, 2019 5:40 am

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

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

Re: Relative Paths

Postby EViews Gareth » Mon Nov 11, 2019 8:29 am

That's what it is supposed to do (Despite the documentation's example suggesting otherwise).
Follow us on Twitter @IHSEViews

fmramos
Posts: 113
Joined: Fri Sep 19, 2008 7:30 am
Location: Sao Paulo / Brazil
Contact:

Re: Relative Paths

Postby fmramos » Tue Nov 12, 2019 9:22 am

Tks, Gareth. Is there a way to get the running program file name?

Best, F

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

Re: Relative Paths

Postby EViews Gareth » Tue Nov 12, 2019 9:28 am

Not sure there is. We should probably add one.
Follow us on Twitter @IHSEViews

fmramos
Posts: 113
Joined: Fri Sep 19, 2008 7:30 am
Location: Sao Paulo / Brazil
Contact:

Re: Relative Paths

Postby fmramos » Tue Nov 12, 2019 9:50 am

Tks! F

EViews Matt
EViews Developer
Posts: 562
Joined: Thu Apr 25, 2013 7:48 pm

Re: Relative Paths

Postby EViews Matt » Tue Nov 12, 2019 10:17 am

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).

fmramos
Posts: 113
Joined: Fri Sep 19, 2008 7:30 am
Location: Sao Paulo / Brazil
Contact:

Re: Relative Paths

Postby fmramos » Tue Nov 12, 2019 10:32 am

Tks Matt. Ultra helpful. It will solve my problem!! F


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 17 guests