Parameters
In Part Using the Mosel language the concept of parameters in Mosel has been introduced: when a Mosel model is executed from the command line, it is possible to pass new values for its parameters into the model. The same is possible with a model run in C. If, for instance, we want to run model `Prime' from Section Working with sets to obtain all prime numbers up to 500 (instead of the default value 100 set for the parameter LIMIT in the model), we may start a program with the following lines:
XPRMmodel mod; int result; if(XPRMinit()) /* Initialize Mosel */ return 1; if((mod=XPRMloadmod("prime.bim",NULL))==NULL) /* Load a BIM file */ return 2; if(XPRMrunmod(mod,&result,"LIMIT=500")) /* Run the model */ return 3;
To use function XPRMexecmod instead of the compile/load/run sequence we have:
int result; if(XPRMinit()) /* Initialize Mosel */ return 1; /* Execute with new parameter settings */ if(XPRMexecmod(NULL,"prime.mos","LIMIT=500",&result,NULL)) return 2;