C/C++ | int VEFCC vensim_get_data(char *filename,char *varname,char *tname,float *vval,float *tval,int maxn) ; |
int VEFCC VensimCGetData(int context,const char *filename,const char *varname,const char *tname,float *vval,float *tval,int maxn) ;
Java | public static native int get_data( String fileName, String varName, String timeAxisName, float vectorOfValues[], float timeVectorValues[], int maxNumberValues ); |
public static native int CGetData(int context, String fileName, String varName, String timeAxisName, float vectorOfValues[], float timeVectorValues[], int maxNumberValues );
VB | Private Declare Function vensim_get_data Lib "vendll32.dll" (ByVal filename$, ByVal varname$, ByVal timename$, varvals As Single, timevals As Single, ByVal maxpoints As Integer) As Long |
Pascal | function vensim_get_data(filename: PChar; varname:PChar; timename:PChar; varvals: SinglePtr;timevals:SinglePtr;maxpoints:Integer ): Integer ; stdcall ; external 'vendll32.dll' ; |
Retrieves data from simulation runs or imported datasets.
Arguments
filename | the name of the file containing the data. This names a .vdf file. |
varname | the name of the variable to retrieve data on. This must be a fully subscripted variable name. |
tname | the name of the time axis against which to pull the data. This is normally "Time", but could name a different time axis if one has been defined in simulation or data conversion from which the dataset originated. |
vval | the vector of values for the variable. This is a single precision vector of numbers. |
tval | the vector of values for the designated time axis. It is important to remember that these numbers will not necessarily be evenly spaced. |
maxn | the maximum number of values that can be filled in. Use this to prevent any overruns on the vval and tval vectors. If this value is 0 the function will return the required buffer size for any variable. In this case the values specified for varname and tname do not matter. |
Returns
The number of values retrieved or, if maxn is 0, the required buffer size to fetch values from the dataset. A return value of 0 indicates that the variable was not found in the dataset. If the return value is the same as maxn and maxn is positive there may be insufficient room to return all values.
Notes
If the variable name is a Lookup in the model the x,y values will be returned. If a model variable is Auxiliary With Lookup you can use #variable name# to retrieve the Lookup values. When called with a NULL or empty filename the current Lookup settings for any pending simulation are returned.
If vensim_get_data is called with a NULL or empty filename it can be used to retrieve SyntheSim results without having to save these to disk. Note that the first time this is called for a given variable it will return the saved value until another simulation is performed. This is because Vensim is basically building a save list based on these calls. It is therefore good practice to call the data retrieval functions directly upon starting SyntheSim even though the results may not yet be needed.
vensim_command("MENU>SYNTHESIM") ;
vensim_command("SYNTHESIM>AUTO|0") ;
call a function to retrieve data – values in .vdf file returned
vensim_command("SYNTHESIM>GO|0") ;
call same function to retrieve data – current values returned
This function can be used after a play in a game has occurred to retrieve all values up till the current time.
vensim_get_data will lock the vdf file that data is being retrieved from. This will speed requests for values of other variables. To unlock the vdf file pass a null or empty vname to the function.
See Also
vensim_get_val