call
PROCEDURE
,
PARAMETERS

The call statement allows a procedure to call a separate procedure within the current database as a subroutine.


Parameters

This statement has two parameters:

procedure – is the name of the procedure to call. If the procedure name does not have any spaces or punctuation, no quotes are required. You can also use a formula to calculate the procedure name “on the fly.”

parameters – is a list of parameters to be passed to the subroutine. This list is optional, you don’t have to pass any parameters if you don’t need to. See parameter( and setparameter for more information on accessing parameters within a subroutine.


Description

This statement allows a procedure programmer to execute a second procedure as a subroutine to the first procedure. Subroutines become important when you wish to use the same code at different times within the same procedure or from within multiple procedures. Creating a subroutine allows you to write the code once and use it again and again rather than duplicating the same code over and over again.

Subroutines normally finish when the end of the procedure is reached. To stop the subroutine before the end of the procedure, use the return statement. The return statement makes Panorama return control to the original procedure.

This simple example shows how to call a procedure called Summarize.

call Summarize

This example calls a subroutine named Calculate %. The subroutine’s name is more than one word and contains symbol characters.

call "Calculate %"

Parameters

When you call a subroutine you can supply one or more parameters to be passed to the subroutine (each parameter must be separated by a comma). When using the call statement the parameters are listed after the procedure name, like this:

call procedure,parameter1,parameter2,parameter3, ... parameterN

Within the procedure’s source code you can access the parameters with the parameter( function, or change the value of a parameter with the setparameter statement. This is especially useful for accessing the main program’s local variables within the subroutine procedure. Normally the local variables in the calling procedure cannot be accessed within the subroutine, but parameters provide a way to do this. For example, you could create a procedure called AddMultipleRecords to add several records at once:

for i,1,parameter(1)
    addrecord
endloop

In any other procedure in the main database you can call this procedure to add multiple records. Here’s how you would add a dozen records:

call AddMultipleRecords,12

You can also use the setparameter statement to modify the value of a parameter passed to the subroutine.


See Also


History

VersionStatusNotes
10.0No ChangeCarried over from Panorama 6.0