Spaces in file path

Problems with syntax of GAMS
Post Reply
pecenak21
User
User
Posts: 6
Joined: 1 year ago

Spaces in file path

Post by pecenak21 » 1 week ago

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.

User avatar
bussieck
Moderator
Moderator
Posts: 388
Joined: 3 years ago

Re: Spaces in file path

Post by bussieck » 1 week ago

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

pecenak21
User
User
Posts: 6
Joined: 1 year ago

Re: Spaces in file path

Post by pecenak21 » 1 week ago

I am confirming this works. Thanks for the fast response.

Post Reply