Please enable JavaScript to view this site.

Vensim Help

Navigation: Reference Guide > Functions > Data Functions

GET VDF CONSTANTS('file','varname',attime) GET CONSTANTS from VDF file

Scroll Prev Top Next More

Returns a number, vector or 2-dimensional array of Constant values by querying the named vdf file. The number of values brought in is determined by the subscripts that are used in the left hand side.  If subscripts are used on the left hand side then ‘varname’ must also be subscripted so that the total number of values matches that as determined by the left hand side (normally these subscripts would be the same). The argument attime is used when the variable in the .vdf file is not a constant to determine which value to use. If attime is before the beginning of the times in the file the first is used, if after then end the last is used.  If file is empty then attime is returned.

Restrictions:  Must appear directly following the equal sign = and not be followed by anything else. ‘filename’ and ‘varname’ must be either Literals or String variables. attime must be a number (constants and expressions are not allowed).

When a subscripted variable name is passed in varname the subscripts are expanded in the context of the current model. For example, if varname is pop[age,gender] then Vensim will look at the subscripts age and gender in the model to determine what elements they have. The variable will then be expanded (say to pop[young,male], pop[young,female], pop[old,male] and pop[old,female]) and the .vdf file will be queried for these names. If a Subscript is not a Subscript range in the model, it will be treated as a Subscript Element (even if it does not appear in the model at all). The variable name itself does not need to appear in the model, nor be subscripted in any specific manner in the model. Subscript range definitions, if any, associated with the vdf file being read are not used.

When a model is checked, GET VDF CONSTANTS reads the values from the .vdf file returning an error if the values are not available. The values are also read each time a simulation is made and a warning is given if the values are not obtainable. In this case Vensim will use the values obtained during the last model check.

NOTE if you make changes in setup mode or specify constant input (.cin) files these values will override the values from the .vdf file. If Stringvars are used to specify the file or variable name to query the model value of these will be used even if these values have been updated using a changes file (or through a Venapp command).


Units: GET VDF CONSTANTS is not part of units checking.  Specify units for the left hand side variable.


size : small,med,large ~~|

shape : round,square ~~|

Init Inventory[shape,size] = GET VDF CONSTANTS('base.vdf',

         'Inventory[shape,size]',80) ~~|

Availability:  Not PLE.


Sample model: GET VDF CONSTANTS DATA LOOKUPS.mdl and GET VDF CONSTANTS DATA LOOKUPS[ss].mdl in FunctionExamples