Example
We would like to initialize an array of integers in a Mosel program with data held in the C program that executes it:
model "Test initialization in memory" uses "meminit" parameters MEMDAT='' ! Location of data in memory MEMSIZ=0 ! Size of the data block (nb of integers) end-parameters declarations a:array(1..20) of integer end-declarations writeln("Data located at ", MEMDAT, " contains ", MEMSIZ, " integers") meminit(a, MEMDAT, MEMSIZ) writeln("a=", a) end-model
A C program to execute the Mosel program meminit_test.mos printed above may look as follows:
int main() { XPRMmodel mod; int result; char params[80]; static int tabinit[]= {23,78,45,90,234,111,900,68,110}; XPRMinit(); /* Initialize Mosel */ XPRMcompmod("", "meminit_test.mos", NULL, NULL); /* Compile the model */ mod=XPRMloadmod("meminit_test.bim", NULL); /* Load the model */ /* Parameters: the address of the data table and its size */ sprintf(params, "MEMDAT='%p', MEMSIZ=%d", tabinit, sizeof(tabinit)/sizeof(int)); XPRMrunmod(mod, &result, params); /* Run the model */ return result; }
© 2001-2019 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.