Command line options
Alternatively, you
can launch FlexSim from a Command Prompt or a batch file, by executing a
line like this (this text probably wraps in this web view, but in the command prompt it should all go on a single line):
"C:\Program Files\FlexSim 2016\program\flexsim.exe"
"C:\Users\username\Documents\Flexsim 16 Projects\test.fsm" /maintenance
nogui_disablemsg_runscript /scriptpath C:\myscript.txt
This will open FlexSim, open the model at the specified path, set a flag
to suppress showing FlexSim's interface, set a flag to suppress any
msg() command popups from appearing, and execute the file C:\myscript.txt as
FlexScript.
All of those command line features are optional. For
instance, remove
the nogui flag to launch FlexSim with the normal interface. You can put
FlexScript code into myscript.txt to run custom behaviors in the model,
such as resetting and running the model, but that is optional. Remove
the runscript flag, plus the "/scriptpath
C:\myscript.txt" portion from the line if you don't wish to run a
FlexScript file on model load.
Using an external
script file that runs upon opening the model is an alternative to having
the OnModelOpen trigger coded into your model. Instead you can have an
external script file that can run upon model open, that can be
separately and independently edited without modifying anything inside
the model file.
Attached is a zip file containing 3 files that show an example of how you can
silently run a FlexSim model without an interface and then export
results to a text file.
Extract these 3 files to your computer somewhere (I put them on my Desktop).
Edit
runScriptDemo.bat so that it has correct paths to where you have
installed FlexSim, where the model is, and where the script file is.
"C:\Program Files\FlexSim 2016\program\flexsim.exe" "C:\Users\username\Desktop\test.fsm" /maintenance nogui_disablemsg_runscript /scriptpath "C:\Users\username\Desktop\script.txt"
The script file (script.txt) has code to run the model:
resetmodel();
runspeed(10000);
go();
The Sink's OnEntry trigger in the test.fsm model has code that exports results as a file and closes FlexSim.
cmdexit();