Example
The following example shows how to compile, load, and then run a model from another model. After having started the execution, it waits for 60 seconds before stopping the secondary model if the latter has not yet finished.
model "mmjobs example"
uses "mmjobs","mmsystem"
declarations
mymod: Model
event: Event
end-declarations
! Compile 'mymod.mos' to memory
if compile("","mymod.mos","shmem:bim")<>0
then
exit(1)
end-if
load(mymod,"shmem:bim") ! Load bim file from memory...
fdelete("shmem:bim") ! ... and release the memory block
! Disable model output
setdefstream(mymod,"","null:","null:")
run(mymod) ! Start execution and
wait(60) ! wait 1 min for an event
if waitexpired then ! No event has been sent...
writeln("Model too long: stopping it!")
stop(mymod) ! ... stop the model then wait
wait
end-if
! An event is available: model finished
event:=getnextevent
writeln("Exit status: ", getvalue(event))
writeln("Exit code : ", getexitcode(mymod))
unload(mymod)
end-model
