farcallwithin
DATABASE
,
PROCEDURE
,
LABEL
,
PARAMETERS

The farcallwithin statement allows a procedure to call a mini-procedure within a separate procedure in a different database as a subroutine.


Parameters

This statement has four parameters:

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

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.”

label – identifies the beginning of the mini-subroutine. (The end of the mini-subroutine is defined by a rtn statement or the end of the procedure.) A label is a unique series of letters and numbers that identifies a location within the procedure. The label may not contain any spaces or punctuation except for ., _ and %, and must always end with a colon. The colon is not actually part of the label, it simply identifies the series of letters and numbers as a label instead of a field or variable.

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 is a combination of the farcall and shortcall statements. It effectively allows you to combine a bunch of “mini-procedures” into a single procedure.

This example shows how three different mini-procedures within the Calculate procedure in the Math database can be called.

farcallwithin Math,Calculate,Total
farcallwithin Math,Calculate,Tax
farcallwithin Math,Calculate,Shipping 

In the example above the procedure name and label are fixed, but you can use a formula to calculate either of these, as shown here:

farcallwithin UserInterface,Buttons,replace(info("trigger")," ","")

This example assumes that the Buttons procedure in the "UserInterface* database includes labels something like this:

Button.Ok:
    ...
    ...
    ...
    rtn

Button.Cancel:
    ...
    ...
    ...
    rtn

Button.NewUser 
    ...
    ...
    ...
    rtn

If the specified label does not exist, an error occurs. You can check the labels in advance with the getprocedureoption( function.

local userTrigger
userTrigger = replace(info("trigger")," ","")
if arraycontains(getprocedureoption("UserInterface","Buttons","LABELS"),userTrigger,cr())
    callwithin UserInterface,Buttons,userTrigger
else
    rtnerror userTrigger+" not implemented yet!"
endif

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 farcallwithin statement the parameters are listed after the label name, like this:

farcallwithin database,procedure,label,parameter1,parameter2,parameter3, ... parameterN

See the call statement for more information about accessing and modifying parameters.


See Also


History

VersionStatusNotes
10.0NewNew in this version.