| Directives |
|
| Formats |
Where:
|
||||||
| Description | The RETURN
directive is used to terminate a subroutine. This
directive can also be used to pass a value back from a
multi-line function, an embedded I/O procedure, or OOP
method logic..
|
||||||
| Format 1 | Terminate
Subroutine The RETURN directive is used as the terminator for a GOSUB or SETESC suboutine. Control is returned to the initiating statement. If the subroutine has been accessed externally via the PERFORM directive, the RETURN statement will both terminate the subroutine, and return control to the initiating program. If ProvideX encounters a RETURN directive without an associated subroutine, ProvideX returns an Error #27: Unexpected or incorrect WEND, RETURN, or NEXT. RETURN must be the final directive in a compound statement. Use the *RETURN label to emulate this directive in a statement reference.. |
||||||
| Format 2 | Terminate
Procedure, Specify Value
The RETURN directive serves a similar purpose in a multi-line function, embedded I/O, or OOP function procedure as it does in a typical subroutine. However, this version of a RETURN statement also passes back a value, expression[$]. Multi-Line Function When used in a multi-line definition of a user-defined function (DEF FN), the RETURN directive terminates the function procedure and passes back a result. The specified value must match the data type of the function definition itself. Embedded I/O Procedure The RETURN directive terminates an embedded I/O procedure and returns a value to the file handler, which it may use to determine the next operation. This is explained in greater detail in the User's Guide. OOP Method Logic In Object Oriented Programming, the RETURN directive terminates the method logic and passes back a result. See Object Oriented Programming. |
||||||
| See Also | GOSUB.. Execute Subroutine SETESC Set Interrupt Processing Labels/Logical Statement References |
||||||
| Example | Use in
terminating/exiting a subroutine
Use in terminating function and returning value:
|