Previous Topic: SORT()

Next Topic: SRVCALL()

SPAWN()

Use the SPAWN() function to start the execution of another IMOD task. Spawned IMODs run concurrently with the spawning IMOD task.

Important! Do not create a situation where an IMOD task spawns itself. An unlimited number of IMOD tasks may be created, swamping the ISERVE address space.

Syntax

The SPAWN() function has this syntax:

imod_id = (SPAWN,imodname,[{COPYQ|NEWQ|PASSQ}],[args])

Arguments

The SPAWN() function takes these arguments:

imod_id

ID assigned to the new IMOD task. This IMOD ID is a unique number that can be used to reference an executing IMOD task. It is used to access the IMOD task's stacks externally and as an argument in the command CANCEL IMOD.

imodname

Name of the IMOD to be executed. This IMOD must be marked as CALLABLE by including the #CALLABLE compiler directive in the IMOD's source code.

COPYQ

Starts with a copy of the current stack. If NEWSTACK has been used, only the current stack is copied.

NEWQ

Starts with a new, empty stack. This is the default.

PASSQ

Transfers the existing stack to the new IMOD. If NEWSTACK has been used, only the current stack is transferred.

args

Text string, to be passed to the spawned task as an initial argument string.

Usage Notes

Return Codes

The SPAWN() function produces these return codes:

40 INCORRECT CALL TO ROUTINE (NOT CALLABLE)

40 INCORRECT CALL TO ROUTINE (NOT ACTIVE)

40 INCORRECT CALL TO ROUTINE (NOT ALLOWED)

101 - 103 ARG n MISSING OR INVALID

121 REQUESTED IMOD NOT FOUND

Example

queue 'Some data to work on'     /* Get data ready  */
spawn(async_work,'PASSQ') == '00000016'
                                 /* Returns IMOD internal name */