With command scripts is it possible to update an equation (specifically a string) without the model doing a simulation first?
For Background: We have a single model (mdl) which we use for multiple countries but each country has a different excel input file. We copy the file over into separate folders where the excel input file resides and want to update a variable with the name of the input file in that folder but if I use the SIMULATE>SETVAL it tries to run the model and falls over as the variable name is wrong. Is there an equivalent command I can use without the model running first? I know we could use the same name for the input file for every country but would prefer to avoid that if possible!
Thanks for your help in advance.
Edit equations using scripts
-
- Super Administrator
- Posts: 4847
- Joined: Wed Mar 05, 2003 3:10 am
Is this what you need?
SIMULATE>SPREADALIAS|?alias=filename.xls
Sets an alias for a filename used in any of the GET XLS…or GET 123... functions. When the filename specified by ?alias is encountered the filename filename.xls will be substituted. The alias term must begin with a ?, and you can use just a ? (or a blank) for the empty alias reference. If filename is empty any alias that did exist will be removed (so that the user will be prompted for a filename when the model is run).
SIMULATE>SPREADALIAS|?alias=filename.xls
Sets an alias for a filename used in any of the GET XLS…or GET 123... functions. When the filename specified by ?alias is encountered the filename filename.xls will be substituted. The alias term must begin with a ?, and you can use just a ? (or a blank) for the empty alias reference. If filename is empty any alias that did exist will be removed (so that the user will be prompted for a filename when the model is run).
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
Thanks so much for the suggestion. After a bit of fiddling around I was able to get a workable solution. Did find I had to replicate the file first in the existing folder and do the copy to the appropriate directory in a separate batch file later. Example below in case people interested.
So I used:
FILE>COPY|C:\path\Example1.mdl|Example2.mdl
SPECIAL>LOADMODEL|C:\path\Example2.mdl
SIMULATE>SPREADALIAS|?Input=Input2.xlsb
FILE>COPY|C:\path\Example1.mdl|Example3.mdl
SPECIAL>LOADMODEL|C:\path\Example3.mdl
SIMULATE>SPREADALIAS|?Input=Input3.xlsb
and so on...
So I used:
FILE>COPY|C:\path\Example1.mdl|Example2.mdl
SPECIAL>LOADMODEL|C:\path\Example2.mdl
SIMULATE>SPREADALIAS|?Input=Input2.xlsb
FILE>COPY|C:\path\Example1.mdl|Example3.mdl
SPECIAL>LOADMODEL|C:\path\Example3.mdl
SIMULATE>SPREADALIAS|?Input=Input3.xlsb
and so on...
Re: Edit equations using scripts
I am using Mac DSS version 6.00
I want to use "SPREADALIAS" command using sample model "GET XLS DATA.mdl"
1)Make a "work" directory under the "GET XLS DATA.mdl"
2)Copy "simpleInputs.xlsx" to "work" directory and change the name to simple.xlsx and change value.
make under cmd script
++
FIlE>copy|/path/GET XLS DATA.mdl|/path/work/new.mdl
SPECIAL>LOADMODEL|/path/work/new.mdl
SIMULATE>SPREADALIAS|?simpleInput.xlsx=simple.xlsx
++
To Run command,
created new.mdl and it was loaded.
but not simulating.
And there are no error message.
Please tell me how to correct
Yusuke Tarumoto
I want to use "SPREADALIAS" command using sample model "GET XLS DATA.mdl"
1)Make a "work" directory under the "GET XLS DATA.mdl"
2)Copy "simpleInputs.xlsx" to "work" directory and change the name to simple.xlsx and change value.
make under cmd script
++
FIlE>copy|/path/GET XLS DATA.mdl|/path/work/new.mdl
SPECIAL>LOADMODEL|/path/work/new.mdl
SIMULATE>SPREADALIAS|?simpleInput.xlsx=simple.xlsx
++
To Run command,
created new.mdl and it was loaded.
but not simulating.
And there are no error message.
Please tell me how to correct
Yusuke Tarumoto
Re: Edit equations using scripts
That sample model doesn't use aliases, so you'll need to modify the equations first. For each GET XLS call that references 'simpleInputs.xlsx' you need to replace the reference with an alias like '?input' and then define the alias to point to your spreadsheet by running the model or using Model>Settings>XLS Files.
Then your method should work.
Then your method should work.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
-
- Super Administrator
- Posts: 4847
- Joined: Wed Mar 05, 2003 3:10 am
Re: Edit equations using scripts
SPREADALIAS only works when you have set up a spreadsheet alias. Eg, in an equation, you might have something like
this gets changed to
Now you can call
Code: Select all
some constant = GET XLS CONSTANTS('book1.xlsx','Sheet1','A1')
Code: Select all
some constant = GET XLS CONSTANTS('?XLSFILE','Sheet1','A1')
Code: Select all
SIMULATE>SPREADALIAS|?XLSFILE=simple.xlsx
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Re: Edit equations using scripts
Thank you a lot.
I understand "SPREADALIAS" effect to
Model > Settings > XLS FIles
Yusuke
I understand "SPREADALIAS" effect to
Model > Settings > XLS FIles
Yusuke