SUBROUTINE


The 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.

A subroutine will inherit all the variables declared using the COMMON statement 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

A subroutine can redefine PRECISION but the new precision will not persist when the subroutine returns to the calling program.

A subroutine will return to the CALLing program if it reaches the logical end of the program or a RETURN statement is executed with no outstanding GOSUB statement.

A SUBROUTINE will not return to the calling program if a STOP or ABORT statement is executed.

In order for a subroutine to be visible to the user, the library to which it is cataloged must be included in the JBCOBJECTLIST environment variable.

See also: CALL, CATALOG, COMMON, RETURN

 

EXAMPLES

SUBROUTINE DialUp(Number, MAT Results)
   DIM Results(8)
....


jBC