The setcallerslocal statement allows a subroutine to modify a local variable in the procedure that called it.
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.
This statement allows a subroutine to modify a local variable in the procedure that called it. Normally a procedure can only modify it’s 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
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.
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!
|10.2||New||New in this version.|