Statement/BASIC Program

Command Statement/BASIC Program
Applicable release versions: AP, AP 6.1, R83
Category BASIC Program (486)
Description transfers control to an external Pick/BASIC subroutine and optionally passes a list of arguments to it.

Arguments must be separated by commas (,). When passing arguments, the same number must occur in the "call" statement as are declared in the "subroutine" statement, which must occur as the first executable line of the external subroutine. There is a maximum of about 200 arguments. The subroutine can return values to the calling program in variable arguments.

The external subroutine must ultimately execute a "return" statement to continue program execution at the statement immediately following the "call" statement. Subroutines which do not return will simply terminate execution.

The "call @", or "indirect call" form allows the statement to use the subroutine name assigned to a specific variable.

Called subroutines must be compiled and cataloged separately from the calling program. The arguments passed between (to and from) the program and subroutine are not label-sensitive, but are order-sensitive. The arguments listed in the "subroutine" statement and the arguments listed in the "call" statement may be different. The subroutine receives the results of arguments in the order that they are specified in the argument list.

Variable arguments are passed to the subroutine at "call" time and from the subroutine at "return" time.

Arrays may be passed between programs and subroutines. The array in the program and called subroutine must contain the same number of elements. If dimensioned arrays are used, the arrays should be dimensioned exactly the same in both the program and subroutine (see the "dim" statement). Alternately, a "dim" statement may be specified without the actual number of elements. The array is properly initialized at run-time.

Arguments listed in both the "call" and "subroutine" statements should not be duplicated in the argument lists. Arguments that are also defined as "common" variables in both calling programs and subroutine programs should not be used in argument lists since the data is already accessible through the common allocations. Violation of these rules can result in unpredictable values being passed between the programs.

On releases 6.1.0 and above, it is possible to specify the file path name followed by a space followed by the actual subroutine name. To do this, the file path and program name can be passed via a variable to an indirect call, or the string can be enclosed in quotes and embedded directly into the program text. Specifying a direct file reference and program name eliminates the need for cataloging subroutines when an application is used from other accounts.

On releases 6.1.0 and above, if the subroutine is not catalog'ed, then BASIC will attempt to locate the subroutine in the current program's dictionary. This obviates the need to catalog most subroutines.
Syntax call{(argument{,argument...})}
call "file.reference"{(argument{,argument...})}
direct call: 

call process.lines(id,order.item(1)) 
call "process.lines"(id,order.item(1)) 

With or without quotes, this example still calls the "process.lines" 

indirect call: 

program.variable = "process.lines"
call @program.variable(id,order.item(1)) 

This example calls the subroutine name held as a string in the variable 

indirect call with full path name

program.variable = "dm,bp, process.lines"
call @program.variable(id,order.item(1))
Related basic.statements