setcallerslocal
setcallerslocal
VARIABLE
,
VARIABLE

The setcallerslocal statement allows a subroutine to modify a local variable in the procedure that called it.

Parameters

This statement has two parameters:

variable – name of the variable to be modified. This name must be quoted.

variable – new value to be placed into the local variable.

Description

This statement allows a subroutine to modify a local variable in the procedure that called it. Normally a procedure can only modify its own local variables, all others are out of bounds. For example, consider this code which sets up two local varaibles and then calls a subroutine.

    let color = "Blue"
    let shape = "Star"
    call tweak
    message color+" "+shape

Normally the tweak procedure would have no access to the local variables set up in the procedure above, but with the setcallerslocal statement the subroutine can modify these varibles, like this:

    setcallerslocal "color","Red"
    setcallerslocal "shape","Triangle"

When the original code is run, it will display the message Red Triangle.

Warning: The setcallerslocal( function is a very unstructured way to handle data (as are its counterparts, callerslocalvariablevalue( and info(“callerslocalvariables”)). Usually a much better way to pass a value from a subroutine is to use a parameter (see the setparameter statement). However, if you write your own custom statements, this feature can be very useful to allow a custom statement to access a local variable in the procedure it is used in.

Error Messages

SetCallersLocal can only be called from inside a subroutine – This statement can only be used in a subroutine, if not in a subroutine, there are no caller’s local variables to modify!

See Also

- call -- allows a procedure to call a separate procedure within the current database as a subroutine.
- callerslocalvariablevalue( -- allows a subroutine to access a local variable in the procedure that called it.
- execute -- allows a procedure to call a sequence of statements within the current procedure as a "mini-subroutine".
- executelocal -- is the same as the execute statement, but it shares local variables with the procedure that called it.
- info("callerslocalvariables") -- returns a list of local variables defined in the procedure that called the current procedure.
- return -- ends a subroutine.
- shortcall -- allows a procedure to call a sequence of statements within the current procedure as a "mini-subroutine".
- usecallerslocalvariables -- temporarily swaps out a subroutine's current local variables with the local variables of the procedure that called this subroutine. The statement can be used only in a subroutine, not in a calling procedure.
- usemylocalvariables -- reverses the action of the UseCallersLocalVariables statement, switching back to the current procedure's normal local variables.

History

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