Please enable JavaScript to view this site.

Vensim Help

Lookup Arguments should appear before any Vector arguments or regular arguments but after any literal arguments.  They are passed as a pointer to a TAB_TYPE structure.

typedef struct tag_tab_type  

REAL base ; /* the base val */

REAL xgap ; /* the time gap to the next x value */

REAL ygap ; /* the value gap the next y value */

REAL lstx ; /* the x value of the  base */

REAL nextx ; /* the x value of the next entry after base */

BLK_OFFSET x ; /* pointer to the x values */

BLK_OFFSET y ; /* pointer to the y values */

V4BYTES curind ; /* the current index value (matches base) */

V4BYTES lstind ; /* the number of value for the lookup */

TABLE_RANGE range[1] ; /* used for reporting over under and in messages */

} TAB_TYPE ;

To reference the values for the x and y elements use

xvals = (float *)(GV->tabbase+tab->x) ;

yvals = (float *)(GV->tabbase+tab->y) ;

NOTEYou should use REAL or float here not COMPREAL since the lookup table values are floats even for the double precision version of Vensim.

The other elements of the TAB_TYPE structure are used internally by Vensim to speed computation and manage error messages.  If you are using the Lookup in any built in Vensim function you should not change any other values as this will cause unpredictable behavior.