change default directory

For questions regarding programming in the EViews programming language.

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

QIO
Posts: 7
Joined: Sat Feb 27, 2021 11:26 am

change default directory

Postby QIO » Mon Sep 27, 2021 2:19 am

I am trying to build a separate sub routine library that I can call later via “include”;
for “include” to work I need to change the default directory, this, however, simply does not work and when executing the following execution.prg it will give me an error message that the sub (called here static_system) is not in the folder (which it is);
the problem is that it searches in the folder where this execution.prg is located and not where I have put the change directory call

why is this the case? thx!
M

Code: Select all

cd "C:\users\default\OneDrive\work"
include static_system

EViews Steve
EViews Developer
Posts: 657
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: change default directory

Postby EViews Steve » Mon Sep 27, 2021 8:18 am

Internally, all includes in a program are performed BEFORE the program is actually run. So having an include that depends on a previous call to CD won't work. Our docs actually mention this by saying INCLUDE only uses current program folder, not the current working directory.

While not ideal, you should either use explicit paths to your included programs or use multiple copies of your initial program in each of the different folders you want to run from. The initial program could just be a list of includes that use relative paths to bring in all related programs under the current folder.

QIO
Posts: 7
Joined: Sat Feb 27, 2021 11:26 am

Re: change default directory

Postby QIO » Wed Sep 29, 2021 12:16 am

hi Steve
thx very much for your quick answer -

Code: Select all

include "C:\users\default\OneDrive\work\static_system.prg"
seems to work fine and solves the problem;
best greetings
Michael


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 26 guests