Updated: 11/30/2021, 7:00:45 PM
Created: 11/30/2021, 7:00:45 PM
Last Updated By: Jake Tuttle
Read Time: 2 minute(s)
The statement transfers program execution to an external SUBROUTINE. It usually takes the form:
CALL subroutine_name(argument, argument…. )
CALL @subroutine_name(argument, argument ...)
Where subroutine_name is the subroutine to be called. It can either be quoted or unquoted.
The @ variant of this statement assumes that subroutine.name is a variable that contains the name of the subroutine to call.
The CALL statement may optionally pass a number of parameters to the target subroutine. These parameters can consist of any valid expression or variable name. If a variable name is used then the called program may return a value to the variable by changing the value of the equivalent variable in its own parameter list.
- When using an expression to pass a parameter to the subroutine, built-in functions of jBASE BASIC (such as COUNT), cannot be used within the expression.
- An unlimited number of parameters can be passed to an external subroutine. The number of parameters in the CALL statement must match exactly the number expected in the SUBROUTINE statement declaring the external subroutine.
- It is not required that the calling program and the external subroutine be compiled with the same PRECISION. However, any changes to precision in a subroutine will not persist when control returns to the calling program.
- Variables passed, as parameters to the subroutine may not reside in any COMMON areas declared in the program.
- If it is desired to pass a DIMensioned array as an argument use the MAT keyword as:
CALL subroutine.name(arg1, MAT myarray, arg3, ...)1
An example of use can be as follows:
calling subroutine Hello:
defining subroutine Hello:
SUBROUTINE Hello(Message) CRT "Hello " : Message RETURN
Go back to jBASE BASIC
Go back to Programmers' Reference Guide