farcallwithin
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.”. The database must be open.

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. A label must begin with a letter.

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

- call -- allows a procedure to call a separate procedure within the current database as a subroutine.
- call( -- allows a procedure to be called as a subroutine within a formula and return a result.
- calledby( -- returns true if this function is in code called by the specified database, the specified procedure, or both.
- callingdatabase( -- returns the name of the database that called this procedure as a subroutine, if any.
- callingprocedure( -- returns the name of the procedure that called this procedure as a subroutine, if any.
- callwithin -- allows a procedure to call a mini-procedure within a separate procedure within the current database as a subroutine.
- callwithin( -- allows a "mini-procedure" to be called as a subroutine within a formula and return a result.
- callwithindatabase( -- returns true if the current procedure was called by another procedure in the same database, false if it was called by a procedure in another database.
- Custom Statements -- creating your own custom statements that can be used in your code.
- execute -- allows a procedure to call a sequence of statements within the current procedure as a "mini-subroutine".
- execute( -- allows a formula to execute a sequence of statements and return a result.
- executeasap -- executes the specified code at the first possible opportunity, non-atomically.
- executecatcherrors -- is the same as the execute statement, except for the fact that if an error occurs while running, it can be trapped by an if error statement immediately following the executecatcherrors statement.
- executelocal -- is the same as the execute statement, but it shares local variables with the procedure that called it.
- farcall -- allows a procedure to call a separate procedure within a different database as a subroutine.
- getproceduretext( -- gets the contents (source code) of a procedure.
- info("parameters") -- returns the number of parameters passed to a subroutine.
- info("procedurestack") -- returns the contents of Panorama's procedure call stack.
- parameter( -- is used to transfer data between a main procedure and a subroutine.
- parameterentity( -- returns the entity (field or variable) associated with a subroutine parameter, if any.
- return -- ends a subroutine.
- returnerror -- passes an error back to the current subroutines calling procedure.
- setparameter -- is used to transfer data from a subroutine back to the main procedure that called it.
- shortcall -- allows a procedure to call a sequence of statements within the current procedure as a "mini-subroutine".

History

Version | Status | Notes
10.0 | New | New in this version.