dictionaryfromvariables(
VARIABLES
)

The dictionaryfromvariables( function builds a new dictionary and initializes it from a list of variables (carriage return delimited).


Parameters

This function has one parameter:

variables – carriage return separated list of variables to be copied into the new dictionary. Any kind of variable may be listed: local, windowglobal, fileglobal, permanent or global.


Description

The dictionaryfromvariables( function creates a new collection of values (dictionary) and initializes it with the contents of one or more variables. The variables to be included are specified by a carriage return delimited list.

This example creates a new dictionary collection containing all of the local variables that currently exist in the current procedure.

dictionaryfromvariables(info("localvariables"))

When combined with the setlocalsfromdictionary statement, this function can be used to quickly transfer multiple variables from one procedure to another.

call mySubroutine,dictionaryfromvariables(info("localvariables"))

The first line of the mySubroutine procedure can use the setlocalsfromdictionary statement to turn the values back into variables.

setlocalsfromdictionary parameter(1)
// mySubroutine now has all the same variables that the calling procedure had

Important Note: Keep in mind that the mySubroutine procedure now has a copy of the variables in the calling procedure, not the original variables. If you have programmed using other languages, these variables have been passed by value, not by reference. So if you modify any of these variables, the modified value will not be passed back to the original procedure when the subroutine is finished. The original procedure will still have its original, unmodified variables. Of course you could pass the new values back the same way.


See Also


History

VersionStatusNotes
10.2NewNew in this version.