Purpose

CALL calls a step within a logic routine. 
 

Syntax

CALL step-number
 

Operation

step-number is the number, or a variable or expression representing the number, of the step to which control is to be passed.  It has a value between 1 and 99 inclusive.
 

Remarks

The step called may be processed with an optional RETURN.  If a RETURN is specified, control returns to the statement following the calling statement.

It is recommended that all called steps end with a RETURN to ensure that logic is kept modular and easy to read.
 

Example

CALL 1
IF $A = $B THEN CALL 2;
IF $J = $K THEN EXIT;
CALL #X
 
 .
:1
#X = 3
RETURN
:2
$D = ‘DEF’
:3
$E = ‘GHI’
RETURN

Step 1 is called.  X is set to 3.  RETURN causes control to be returned to the statement following CALL 1.

If the condition $A = $B is true, Step 2 is called and $D is set to ‘DEF’.  The logic routine is exited because there is no RETURN statement in step 2.
If the condition $A = $B is false, the next sequential statement is executed.

If the condition $J = $K is true, the logic routine is exited.
If the condition J = K is false, the next sequential statement, CALL #X, is executed and as #X was set to 3 in Step 1, Step 3 is called.

In Step 3 $E is set to GHI.  Control is returned to the statement following the calling statement. The remaining statements in the logic routine, up to but not including Step 1, are processed.

The practice of omitting a RETURN is not recommended.  In this example an EXIT can be inserted after step 2 (instead of RETURN) to ensure step 2 ends with a RETURN without changing the meaning of the overall logic.
 

 

The use of CALL should be limited; it can produce disjointed code that is difficult to read.  Consider using Global Logic instead.

 

Comment on this topic

Topic ID: 520025