There are a number of JavaScript functions provided to you so that you can interact with the WASM file that Vensim generates.
function SetConstant(strParameter, fValue) |
This sets a constant internally to the Vensim model. For example, to set the initial population in a model, you could call
|
function GetVariableIndex(strParameter) |
Internally, each parameter has an ID number, this function allows you to find the ID number of a variable.
|
function GetNumVariables() |
This function returns the number of variables you have in your model.
|
function GetVariableName(nIndex) |
This function returns the variable name associated with an ID number.
|
function GetVariableType(nIndex) |
Each variable has a type. This function returns the type number for each variable. Values are as follows.
5 = Data 8 = Level 15 = Time base 17 = Auxiliary 19 = Game variable 22 = Initial 23 = Constant 24 = Unchangable constant 26 = Lookup table 27 = String variable
|
function InitializeModel() |
This function resets the model and marks it ready for another simulation.
|
function RunSim() |
This function runs the simulation.
|
function GetSeriesNumVals(strVarName) |
When a simulation is complete, this function returns the number of values stored in the time series for a specific variable.
|
function GetSeries(strVarName) |
This function returns an array of values for a specific variable.
|
function AddCINFileFromServer(strFileName)
|
This function loads a CIN file into a model. The CIN file must reside on the server in the same folder as the WASM file. |
function GetValueAtTime(strVarName, fTime) |
This function returns the value of a parameter calculated at a specific time.
|