info("callerslocalvariables")
info("callerslocalvariables")

The info(“callerslocalvariables”) function returns a list of local variables defined in the procedure that called the current procedure.

Description

This function returns a list of local variables defined in the procedure that called the current procedure. Each variable name is on a separate line (separated by carriage returns). For example, consider this code which sets up two local varaibles and then calls a subroutine.

    let color = "Blue"
    let shape = "Star"
    call dispatch
    message color

The code in the dispatch procedure can find out what local variables exist in the original procedure by using the info(“callerslocalvariables”) function. For example, here’s a version of dispatch that checks to see if there is a local variable named color, and if so, sets it to Red. If not, it returns an error (see Error Handling).

    if arraycontains(info("callerslocalvariables"),"color",cr())
        setcallerslocal "color","Red"
    else
        returnerror "No color variable!!"
    endif

Warning: The info(“callerslocalvaraibles”) function is a very unstructured way to handle data (as are its counterparts, callerslocalvariablevalue( and setcallerslocal). Usually a much better way to pass a value from a subroutine is to use a parameters (see the parameter( function and 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.

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.
- return -- ends a subroutine.
- setcallerslocal -- allows a subroutine to modify a local variable in the procedure that called it.
- 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.