usefunctioncallerslocalvariables

The usefunctioncallerslocalvariables statement temporarily swaps out a procedures current local variables with the local variables of the procedure that called this the call(, callwithin( or execute( function.


Parameters

No parameters.


Description

Any local variables created in a procedure can normally only be accessed in that procedure and not any other. In some special cases, however, it can be useful for a function code to access the local variables of the code that invoked it. This is especially true when you are writing custom functions.

Panorama has two statements that allow a procedure to access the local variables of the procedure that called the current procedure: UseFunctionCallersLocalVariables and UseMyLocalVariables. These statements are normally used as a pair. The UseFunctionCallersLocalVariables statement temporarily swaps out a procedures current local variables with the local variables of the procedure that called this function. The UseMyLocalVariables statement swaps the variables back again. While the variables are swapped you have full access to the local variables of the caller. You can even create new local variables, which become local variables belonging to the calling procedure. Here is an example that creates a local variable named alphabet and initializes it with 26 letters.

usefunctioncallerslocalvariables
local alphabet
alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
functionvalue alphabet
usemylocalvariables

A procedure could call this function as shown below.

message call(MakeAlphabet)
message alphabet

This code will display ABCDEFGHIJKLMNOPQRSTUVWXYZ twice, even though this local variable wasn’t created in this procedure.

Note: In this example we could have left off the final usemylocalvariables statement. Panorama will automatically switch the variables back when the end of the function is encountered, or when a return statement is executed.


Error Messages

UseFunctionCallersLocalVariables can only be called from Function code. – If the current procedure was not called as a function, there are no “callers” variables, so an error occurs.


See Also


History

VersionStatusNotes
10.2NewNew in this version.