Defining Path

For questions regarding programming in the EViews programming language.

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

fmgoto
Posts: 76
Joined: Thu Jan 15, 2009 5:01 am
Location: Brasilia, Brazil

Defining Path

Postby fmgoto » Wed Jan 21, 2009 11:03 am

Hey, I need to move (.prg) files quite often and I wonder if I could define a path-variable such as:

%path = "C:/Program Files/Eviews/2009-01-20/main.prg",

so that I could change the file path only once and it would change the path within every other code which are included in my main.prg.

How?

Thank You, Goto

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

Re: Defining Path

Postby EViews Gareth » Wed Jan 21, 2009 11:11 am

I think you're talking about the CD command?
Follow us on Twitter @IHSEViews

fmgoto
Posts: 76
Joined: Thu Jan 15, 2009 5:01 am
Location: Brasilia, Brazil

Re: Defining Path

Postby fmgoto » Fri Jan 23, 2009 11:56 am

Sort of.

What if I need to read, write and save into a given folder?

cd "c/data/"
read(...) "c/data/subfolder/spreadsheet.xls" 2
write(...) "c/data/output/spreadsheet2.xls" y_hat
wfsave "c/data/subolder/spreadsheet3.xls"

Thanks!

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

Re: Defining Path

Postby EViews Gareth » Fri Jan 23, 2009 12:30 pm

Then I guess you can use replacement variables:

%savepath = "c/data/subolder/spreadsheet3.xls"
%writepath = "c/data/output/spreadsheet2.xls"
%readpath = "c/data/subfolder/spreadsheet.xls" 2

read %readpath 2
write %writepath y_hat
wfsave %savepath


or something along those lines.
Follow us on Twitter @IHSEViews

fmgoto
Posts: 76
Joined: Thu Jan 15, 2009 5:01 am
Location: Brasilia, Brazil

Re: Defining Path

Postby fmgoto » Fri Jan 23, 2009 2:01 pm

That is (a lot) closer!

Except for I need to concatenate two strings: the whole path and the subfolder path. That is,

%path = "C:/.../"

read(...) %path + "spreadsheet.xls" 2

How do I concatenate the main %path and the subfolder + spreadsheet.xls within the same command (read, write or save). That is the question!

Thank you very much!

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

Re: Defining Path

Postby EViews Gareth » Fri Jan 23, 2009 2:09 pm

%path = "c:\...\"

%temppath = %path + "spreadsheet.xls"

read %temppath 2
Follow us on Twitter @IHSEViews

fmgoto
Posts: 76
Joined: Thu Jan 15, 2009 5:01 am
Location: Brasilia, Brazil

Re: Defining Path

Postby fmgoto » Fri Jan 23, 2009 2:26 pm

GREAT! Thanks!

fmgoto
Posts: 76
Joined: Thu Jan 15, 2009 5:01 am
Location: Brasilia, Brazil

Re: Defining Path

Postby fmgoto » Fri Apr 03, 2009 5:53 am

Gareth, I'm back again!

We are working with Eviews in Brazil and there are some special characters Eviews does not recognizes when running from the command prompt. Surprisingly, that is not an issue when running the exact same code line by line.

I wonder if there is some ASC or ANSI to EVIEWS table so that I could turn "ÁÂÃ" into something that and Eviews.prg would read without haulting.

Thank You, Fábio, with an Á!

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

Re: Defining Path

Postby EViews Gareth » Fri Apr 03, 2009 2:26 pm

In general EViews has dodgy handling of special characters. To be honest you're probably best off trying not to use them.
Follow us on Twitter @IHSEViews

fmgoto
Posts: 76
Joined: Thu Jan 15, 2009 5:01 am
Location: Brasilia, Brazil

Re: Defining Path

Postby fmgoto » Tue Aug 18, 2009 6:04 am

What if I need to specify paths that include spaces (" "), such as "C:/Program Files".

%root = "C:\Program Files"
%month = "2009_08"
%folder = %root + %month

cd %folder

The thing, though, is that the "cd %folder" command considers "C:\Program " as the root folder, since there is a space between "Program" and "File". Thus, Eviews cannot read the %folder string as I would like it to read.

I tried the double "" trick, but it didnot work either.

Thanks, Fabio

fmgoto
Posts: 76
Joined: Thu Jan 15, 2009 5:01 am
Location: Brasilia, Brazil

Re: Defining Path

Postby fmgoto » Tue Aug 18, 2009 7:39 am

Got it!

%aspas = """"
%folder = "C:\Program Files\"
%subfolder = "2009_05"
%path = %aspas + %defaule_folder + %subfolder + %aspas
cd %path

Thanks!

tho_mi
Posts: 61
Joined: Sat May 12, 2012 2:41 am

Re: Defining Path

Postby tho_mi » Fri Jun 08, 2012 10:18 am

Sorry for digging out this old thread, but i don't want to create a new one.

I have just one short question, is there a possibility to do the concatenation without the intermediate step with a temporary variable?

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

Re: Defining Path

Postby EViews Gareth » Fri Jun 08, 2012 10:28 am

Generally, no.
Follow us on Twitter @IHSEViews

tho_mi
Posts: 61
Joined: Sat May 12, 2012 2:41 am

Re: Defining Path

Postby tho_mi » Fri Jun 08, 2012 10:32 am

EViews Gareth wrote:Generally, no.


Ok, thanks.

gio.ortolani
Posts: 14
Joined: Wed Apr 25, 2012 7:34 am

Re: Defining Path

Postby gio.ortolani » Mon Jun 16, 2014 12:33 pm

Is there a way to concatenate a string to a scalar with replacement variables?


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 30 guests