PERFORM


ANSI

 

The PERFORM instruction initiates a subroutine based on an index. When the instruction is executed, the address of the next sequential instruction is placed in the top element of the subroutine call stack. The instruction uses the following format:

 

 

[label]

PERFORM

{index}{sep}{targets}

 

Where:

label

Optional. A Program Execution Label.

index

Required. A previously defined Numeric Variable or Expression used in selecting a Program Execution Label that is CALLed,

sep

Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, or INTO.

targets

Required. A list of Program Execution Label, EXTERNALs, or LABELs from which a subroutine is selected and called.

Flags Affected: NONE

Note the following:

  1. The value of {index} remains unchanged and designates which Program Execution Label in {labels} designates the subroutine to initiate. If the value is one, the subroutine designated by the first Program Execution Label in {labels} is initiated. If the value is two, the subroutine designated by the second label in {labels} is initiated, etc.

  2. If {index} has a negative value, a zero value or a value greater than the number of Program Execution Labels in {labels}, control is passed to the next sequential instruction.

  3. The number of Program Execution Labels in {labels} is limited to 2047. Additional lines may be used by ending each continued line with a colon (:).

  4. If a FILEPI instruction is active, the FILEPI count is not decremented by this instruction.

  5. If {index} is not a decimal integer, only the integer portion of the variable is used. For example, if it has a value of 3.6, 3 is used.

  6. A RETURN instruction within the destination subroutine returns the execution to the next sequential instruction after the PERFORM. A NORETURN within the destination subroutine removes the stack return reference of the last PERFORM.

  7. Null entries in the list are allowed and are signified by two commas with no label name between them. When the index value is associated with a null entry, no PERFORM operation is performed the same as when the index value is out of range or invalid.

 

 

See Also: Example Code, BRANCH, PERFORMF, Program Control Instructions

 



PL/B Language Reference PAUSE PERFORMF