next up previous contents index
Next: ENTRY Statement Up: Obsolete and Deprecated Features Previous: PAUSE Statement

Alternate RETURN

 

The alternate RETURN mechanism can be used in subroutines (but not external functions) to arrange a transfer of control to some labelled statement on completion of a CALL statement. In order to use it the arguments of the CALL statement must include a list of labels, each preceded by an asterisk. These labels are attached to points in the calling program unit at which execution may resume after the CALL statement is executed. For example:

 
       CALL BAD(X, Y, Z, *150, *220, *390)

The corresponding subroutine statement will have asterisks as dummy arguments for each label specification:

 
       SUBROUTINE BAD(A, B, C, *, *, *)

The return point depends on the value of an integer expression given in the RETURN statement. Thus:

 
       RETURN 2

will cause execution to be resumed at the statement attached to the second label argument, 220 in this case. If the value of the integer expression in the RETURN statement is not in the range 1 to n (where there are n label arguments) or a plain RETURN statement is executed, then execution resumes at the statement after the CALL in the usual way.

The mechanism can be used for error-handling but is not very flexible as information cannot be passed through more than one procedure level. It is better to use an integer argument to return a status value and use that with an IF (or even a computed GO TO statement) in the calling program.



Mario Storti
Wed Nov 4 19:32:56 ART 1998