The following illustrate some possible applications of command scripts.
Note that, while command scripts do not support iteration and branching, it is often possible to achieve the same thing by automatically generating the command script code (spreadsheets are good at this). More advanced automation can be achieved with the Vensim DLL.
Reading Changes from Files
{base}
SIMULATE>RUNNAME|F8Juncont.vdf
SIMULATE>READCIN|j.cin
SIMULATE>ADDCIN|fullDeplRent.cin
SIMULATE>ADDCIN|retrofit05.cin
SIMULATE>ADDCIN|tax2002.cin
SIMULATE>SETVAL|Zero Base Utility=0
SIMULATE>SAVELIST|baseline.lst
MENU>RUN|o
Running Scenarios with SETVAL changes
SPECIAL>LOADMODEL|DataView3.vmf
SPECIAL>CLEARRUNS
SIMULATE>RUNNAME|Reference BAU
SIMULATE>SETVAL|SelectedConstraint=3
SIMULATE>SETVAL|SelectedTechnology=1
MENU>RUN|o
SIMULATE>RUNNAME|Reference 550
SIMULATE>SETVAL|SelectedConstraint=2
SIMULATE>SETVAL|SelectedTechnology=1
MENU>RUN|o
Multiple Optimizations
SPECIAL>NOINTERACTION|1
SIMULATE>RUNNAME|HistGDP
SIMULATE>READCIN|fitHistGDP.cin
SIMULATE>PAYOFF|fitHistGDP.vpd
SIMULATE>OPTPARM|fitHistGDP.voc
MENU>RUN_OPTIMIZE|o
SIMULATE>RUNNAME|EMF22 ETSAP-TIAM
SIMULATE>READCIN|HistGDP.out
SIMULATE>SETVAL|EMF SelectedModel=1
SIMULATE>PAYOFF|fitEMFGDP.vpd
SIMULATE>OPTPARM|fitEMFgdp6.voc
MENU>RUN_OPTIMIZE|o
Multiple Optimizations, Appending Output to a Table
SPECIAL>NOINTERACTION|1
SIMULATE>READCIN|
SIMULATE>SETVAL|active day=0
SIMULATE>RUNNAME|ManyDay
SIMULATE>PAYOFF|logLike.vpd
SIMULATE>OPTPARM|estParm.voc
MENU>RUN_OPTIMIZE|o
MENU>VDF2XLS|ManyDay.vdf|DPLN.xls|params.lst||0|0
SIMULATE>READCIN|
SIMULATE>SETVAL|active day=1
SIMULATE>RUNNAME|ManyDay
SIMULATE>PAYOFF|logLike.vpd
SIMULATE>OPTPARM|estParm.voc
MENU>RUN_OPTIMIZE|o
MENU>VDF2XLS|ManyDay.vdf|DPLN.xls|params.lst|!+|0|0
SIMULATE>READCIN|
SIMULATE>SETVAL|active day=2
SIMULATE>RUNNAME|ManyDay
SIMULATE>PAYOFF|logLike.vpd
SIMULATE>OPTPARM|estParm.voc
MENU>RUN_OPTIMIZE|o
MENU>VDF2XLS|ManyDay.vdf|DPLN.xls|params.lst|!+|0|0
Preparing Venapp Files for Publishing
The following example is obsolete since the way to prepare files for the Vensim Model Reader is to publish the Venapp. However, it is still instructive it converts files to binary format and copies them to a subdirectory. Note that you must first create this subdirectory outside of Vensim and make sure it is empty.
For example suppose you have a simple venapp flicker.vcd you want to pepare. The following script does this.
FILE>MDL2VMF|flicker.mdl
!FILE>ENCRYPT|flicker.vmf
FILE>RENAME|flicker.vmf|ship\flicker.mdl
FILE>VGD2VGF|flicker.vgd
!FILE>ENCRYPT|flicker.vgf
FILE>RENAME|flicker.vgf|ship\flicker.vgd
FIlE>VCD2VCF|flicker.vcd
!FILE>ENCRYPT|flicker.vcf
FILE>RENAME|flicker.vcf|ship\flicker.vcd
FILE>copy|flicker.vts|ship\flicker.vts
NOTE The script will fail if the ship directory does not exist or is not empty.
What this script does is make binary files from all the source files and then put them in the ship directory with the names of the source files. Renaming in this way allows you to use the same Venapp so you do not have to load .vmf and .vgf files in the Venapp. If you do want to load those files anyway do not rename the model to .mdl with this script.
If you have a redistribution license the FILE>ENCRYPT lines will prepare the files for use with the redistributable application runtime.