The CALL command allows the currently active entity to jump to a procedure and execute it immediately.
When it finishes, the entity returns exactly to the next step after the call.
This is the simplest and most direct behavior of the subprocess system.
Syntax:
CALL procedureName, parameterA, parameterB, ...
- Parameters are received inside the procedure as
P$PARAM_A,P$PARAM_B, etc. - The value returned by the procedure is automatically stored in a variable named after the last fragment of the PROCEDURE name.
Procedure name → result variable examples:
CALL calculate, 10 → P$calculate CALL client.add, 20,30 → P$add CALL robot.motor.start → P$start
Procedure termination:
ENDPROCEDURE value
Ends execution and returns the specified value:
ENDPROCEDURE 3 ; P$calculate = 3
RETURN value
Does the same thing, but is more explicit and readable:
RETURN 3 ENDPROCEDURE
Both forms are equivalent when using CALL.
Accessing parameters:
Inside the procedure:
P$PARAM_Areturns the evaluated value.V$PARAM_Areturns the raw value (arrays, objects, unevaluated strings).
Examples:
P$(PARAM_A.name)if you passed an object.P$(PARAM_B.2)if you passed an array.
Example
/* CALL */
POSITION {NAME:POS1, X:286, Y:244}
initial posY,500
Graphic {NAME:Text1,Type:TEXT,X:324,Y:X$posY - 0}
Graphic {NAME:Text2,Type:TEXT,X:324,Y:X$posY - 20}
Graphic {NAME:Text3,Type:TEXT,X:324,Y:X$posY - 40}
Graphic {NAME:Text4,Type:TEXT,X:324,Y:X$posY - 60}
Graphic {NAME:Text5,Type:TEXT,X:324,Y:X$posY - 80}
Graphic {NAME:Text6,Type:TEXT,X:324,Y:X$posY - 100}
START 1
GENERATE 10,0,0,1 {NAME:GA, X:100, Y:70}
ASSIGN data, {name:"Ana", age:30}
ASSIGN number, 123
ASSIGN colors, ["red","green"]
CALL process, V$data, V$number, V$colors, 30
move {name:Text1, text:"Procedure result: P$(process)"}
ADVANCE 10 {to:POS1}
ENDGENERATE 1
;---------------------------------------
PROCEDURE process
move {name:Text2, text:"Name: P$(PARAM_A.name)"}
move {name:Text3, text:"Age: P$(PARAM_A.age)"}
move {name:Text4, text:"Number: P$PARAM_B"}
move {name:Text5, text:"First color: P$(PARAM_C.0)"}
move {name:Text6, text:"Direct value: P$(PARAM_D)"}
RETURN "OK"
ENDPROCEDURE