callwithin
callwithin
PROCEDURE
,
LABEL
,
PARAMETERS

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

Parameters

This statement has three parameters:

procedure – is the name of the procedure to call. If the mini-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-procedure. (The end of the mini-procedure is defined by a rtn or return statement or the end of the main procedure). A label is a unique series of letters and numbers that identifies a location within the procedure. The label must start with a letter, 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 call 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 can be called.

    callwithin Calculate,Total
    callwithin Calculate,Tax
    callwithin 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:

    callwithin UserInterface,replace(info("trigger")," ","")

This example assumes that the UserInterface procedure includes labels something like this:

    Button.Ok:
        ...
        ...
        ...
        return

    Button.Cancel:
        ...
        ...
        ...
        return

    Button.NewUser
        ...
        ...
        ...
        return

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","LABELS"),userTrigger,cr())
        callwithin UserInterface,userTrigger
    else
        returnerror userTrigger+" not implemented yet!"
    endif

#### Parameters

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

    callwithin 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 "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.
- farcallwithin -- allows a procedure to call a mini-procedure within a separate procedure in 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.