Welcome to jBASE's new documentation site! Many answers to your questions can be found by searching the Knowledgebase or viewing the jBASE Documentation. We also have a Google Group for peer discussion about jBASE. If you are unable to find the information you are looking for, jBASE Support will be glad to assist in resolving your technical problems. Enjoy and please provide comments and feedback .

How can we help you?

SUBROUTINE

Description

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. It takes the general form: 

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


Where: 

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.

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 jBASE BASIC 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 is executed with no outstanding GOSUB statement.

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

An example of use is as: 

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


See also: CALL, CATALOG, COMMON, RETURN

Go back to jBASE BASIC.

Was this article helpful?