Previous Topic: SORT()Next Topic: SRVCALL()


SPAWN()

This function starts 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 can be created, swamping the ISERVE address space.

Syntax

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

Parameters

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 task stacks for the IMOD 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 source code for the IMOD.

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.

PASSQ

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

args

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

Default: NEWQ

Usage Notes

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 */