Page 1 of 1

Spaces in file path

Posted: Fri Mar 27, 2020 12:28 am
by pecenak21
Hello,

I am trying to 'compartmentalize' my GAMS code. In doing so, I am building a 'Main.gms' script, which call several sub-files. An example of this looks like

Code: Select all

* Main.gms

*Define output to the IDE
$setglobal ide "ide=%gams.ide% lo=%gams.lo% errorlog=%gams.errorlog% errmsg=1"

loop( cases,

*This bit of code creates the GDX files from CSVs which are read into the solver
execute "gams Path To File\CreateGDXFile.gms s=wf1" %ide%"     ;

*This is a portion of the code
execute "gams Path To File/SubFile1.gms r=wf1 %ide%"  ;

... and so on
The issue I am running into is that the 'PATH TO FILE' causes this command to fail, due to the spaces. There error is

Code: Select all

Error: Parameter error(s), Reading parameter(s) from "command line", **** Error Unkown option "To" 
Is there any work around to getting the code to run? Is there a different approach I should be using other than 'execute'. I think the loop aspect makes execute a necessity.

P.S. According to https://support.gams.com/platform:space ... _file_name, GAMS should be able to handle spaces as of 2018.

Re: Spaces in file path

Posted: Fri Mar 27, 2020 5:33 am
by bussieck
execute (as $call) calls the shell of the system. Do what you need to do to protect the spaces. For example:

Code: Select all

execute 'gams "Path To File/SubFile1.gms" r=wf1 %ide%'  ;
-Michael

Re: Spaces in file path

Posted: Fri Mar 27, 2020 1:46 pm
by pecenak21
I am confirming this works. Thanks for the fast response.