Returns to a higher nesting level passing the nominated variables.
&RETURN [ &var1 &var2 .... &varn ]
To return to a higher NCL nesting level, optionally passing the nominated variables.
Operands:
names of user variables that are to be returned to the higher nesting level. The variables must be specified including the leading ampersand (&). Resolution of complex variables (for example, &&1) is not supported on this statement. Any number of user variables is nominated.
Following an &RETURN statement in a nested procedure, processing will resume in the higher nesting level (the invoking procedure). The variables specified on the &RETURN statement will then be available to this higher level. If a variable of the same name existed in the higher level before the &RETURN statement was processed, it will be updated to reflect the value in the lower nesting level when the &RETURN statement was processed. If no variable of that name existed in the higher level, then a new variable will be created containing the data from the lower level. If the variable had a null value in the lower level when the &RETURN statement was issued a null value will also be set in the higher level when processing resumes.
Examples: &RETURN
& IF &RETCODE EQ 4 &THEN +
&DO
&SYSMSG = &STR DETAILS NOT ON FILE
&RETCODE 8
&RETURN &SYSMSG
&DOEND
&RETCODE 0
&RETURN &DEVICEID &DEVICELOCN &DEVICEADDR
Notes:
If no variables are nominated, the &RETURN statement acts as an &END.
An &RETURN statement processed in a non-nested NCL procedure will act as an &END statement. If &CONTROL ENDMSG is in effect, messages indicating the return variables and their values will be generated. This allows processing of subroutine procedures to be verified by direct invocation.
The &RETURN statement makes it possible to develop modular procedures that perform common functions. Such procedures is invoked passing data using the EXEC statement. Having completed processing the procedure can return control using the &RETURN statement to return required data.
An &RETURN statement does not modify or change the names of the variables being returned. They must be referenced in the higher level procedure using the names specified on the &RETURN statement.
An alternative to the use of variables on &RETURN, is &CONTROL SHRVARS, which allows selected groups of user variables to be shared between nested levels.
If &CONTROL SHRVARS is in effect when a procedure is invoked, any variables specified on an &RETURN statement are returned and will supplement any variables returned as a result of SHRVARS processing.
The &RETCODE value returned to the calling procedure, will be the value that is current at the time &RETURN is executed.
| Copyright © 2009 CA. All rights reserved. |
|