Please enable JavaScript to view this site.

Vensim Help

Instead of being passed a Vector Argument Constant Definition functions are passed a pointer to a CONSTANT_MATRIX structure as their first argument (all remaining arguments must be literals).

typedef struct

unsigned long keyval ;

char *varname ;

REAL **vals ;

long ncol ;

long nrow ;

} CONSTANT_MATRIX ;

keyval is must be equal to CONSTANT_MATRIX_KEY (0xF722438E).  You can use this to check that you have received a valid CONSTANT_MATRIX.

varname is the name of the variable, fully subscripted with the first subscript to have its value filled.  This is passed to make it easier to report errors, and can also be parsed if this is appropriate.

vals is the matrix of vals to be filled.  When a Constant Definition function is first called each row of this matrix will be empty (that is vals[0] will be null, as will vals[1] and so on).  You can call vensim_alloc_simmem and pass the CONSTANT MATRIX received as the second argument to allocate the rows.

ncol is the number of columns to be filled - this is passed from Vensim and is determined by the last varying subscript.  for scalars this will be one.

nrow is the number of rows to be filled - this is passed from Vensim and is determined by the first varying subscript  for scalars and vectors this will be one.