# CALL

Syntax:

Then: CALL "name"

Then: CALL "path-to-prc-table"

Then: CALL NOAUTO

Name = processing table in the current filePro file

path = full path to processing table in any filePro file

Version Ref: 4.0 (not included in filePro Lite)

4.8 Enhancement - Added CALL path

5.0 Enhancement - Added CALL NOAUTO

Description:

CALL calls another processing table as a subroutine. When the called processing is done, control returns to the original processing table to the next statement after the CALL statement.

CALL "path" allows you to call a processing table in another filePro file or even in a library of processing tables by identifying the specific path e.g. "c:\filepro\fpcust\test.prc".

CALL NOAUTO ignores the dummy fields defined in automatic processing. This allows you to re-use field labels as defined in the CALLed processing table.

CALL is only one level deep; you cannot call another processing table from a called table (or CHAIN from a called table). The called processing table uses the token area reserved for printing a form from Inquire, Update, Add.

Dummy fields

Called processing tables have their own set of dummy fields. It cannot use dummy fields defined in the original (calling) processing unless the calling processing is automatic processing. (Dummy fields defined in automatic processing are available to all other types of processing.) When control returns to the calling processing, the original dummy fields and values are restored.

This function can be useful in modularizing code. Single tables can be "called" into multiple applications. In other words, it is easier to develop a "library" of tables that perform various functions, and CALL these functions, as needed, from into your other applications.

Note: The CHAIN command cannot be used in called processing tables.

Examples:

The key to using CALL effectively, is understanding how CALL tables work with dummy variables. The easiest way to learn this functionality is by setting some variables and tracking their values from the INPUT table to the CALL table and back again.

The only rule of thumb is this: All variables are cleared upon entry to a CALL table EXCEPT global variables, which have been defined, on the current AUTOMATIC table. Variables defined in this manner will pass their values between the CALL and INPUT table, all others will only keep their values in normal filePro fashion.

The following code will demonstrate this clearly.

The AUTOMATIC table can be critical to running sophisticated CALL tables.

Then: cc(3,,g)

The global variables defined on the AUTOMATIC table will have their values passed to any CALLED table. If these variables are assigned values on a CALL table, the values will be available to the INPUT table. No other variables, (even global variables defined on the INPUT table) will have their values passed between INPUT and CALL tables.

The FIRST time this code is run by pressing the T key, the variables aa, bb and cc will all be empty. After that, successive presses of the T key will show that the CALL table has passed a new value back to the INPUT table. These values can be tested in various ways, one place for this test might be @entsel as shown in the code on lines 7 to 10.

Then: end

@keyT If:
Then: show "@aa=" { aa { ", bb=" { bb { ", cc=" { cc
Then: aa(3)="111" ; bb(3,,g)="222" ; cc="333"
Then: show "@On the input table aa=" { aa { ", bb=" { bb { ", cc=" { cc
Then: call "fred"
If: 'this end is superfluous, it will never be executed
Then: end

@entsel If: aa eq "123"

Then: show "@The call table will not pass this variable back to INPUT."
If: bb eq "123"
Then: show "@The call table will not pass this variable back to INPUT."
If: cc eq "123"
Then: show "@GLOBAL variables defined on the AUTO table will be passed!"
Then: end

The CALL table itself in this example does nothing but assign values to three different variables, a regular variable, a global variable, and a global variable defined on the AUTOMATIC table.

Then: show "@Begin call table, aa=" { aa { ", bb=" { bb { ", cc=" { cc
Then: show "@ Now set aa, bb and cc equal to 123"
Then: aa="123" ; bb="123" ; cc="123"
Then: end