SUBROUTINE

SUBROUTINE statement is used at the start of any program that will be called externally by the CALL statement. It also declares any parameters to the compiler.

COMMAND SYNTAX

    SUB{ROUTINE} Name {({ MAT } variable{,{ MAT } variable...})}

SYNTAX ELEMENTS

Name is the identifier by which the subroutine will be known to the compilation process. It should always be present as this name (not the source file name), will be used to call it by. However, if the name is left out, the compiler will name subroutine as the source file name (without suffixes). Default naming is not encouraged as it can cause problems if source files are renamed.

Each comma separated variable in the optional parenthesized list is used to identify parameters to the compiler. These variables will be assigned the values passed to the subroutine by a CALL statement.

NOTES

The SUBROUTINE statement must be the first code line in a subroutine.

All the variables declared using the COMMON statement will be inherited providing an equivalent common area is declared within the subroutine source file. The program will fail to compile if the number of common variables used in each common area exceeds the number defined in the equivalent area in the main program.

Subroutines can only be called via the jBC CALL statement.

PRECISION can be redefined but the new setting will not persist when the subroutine returns to the calling program.

The control will be returned to the CALLing program if the subroutine reaches the logical end of the program or a RETURN is executed with no outstanding GOSUB statement.

The control will not be returned to the calling program if a STOP or ABORT statement is executed.

See also: CALL, CATALOG Command, COMMON, RETURN.

EXAMPLES

    SUBROUTINE DialUp(Number, MAT Results)
    DIM Results(8)
    ....
Last update: Sat, 16 Jul 2022 15:34