Variable

(Engine-Level Function)

Description: Accesses a variable by its text name. The return value is optional.
Returns: Varies - see comments
Usage: Script or Steady State
Function Groups: Variable
Related to: FindVariable | Scope | SetDefault
Format: Variable(Name)
Parameters:  
Name
Required. Any text expression giving the name of the variable.
Comments:

This function can be used on the left side of an assignment, in which case the value will be assigned to the variable named in the Name parameter. This function can be used for debugging, or to create sophisticated data logging and monitoring packages which access any variable by its typed-in name.
Note that the string containing the name may not contain leading or trailing spaces, or square brackets [ ].

This function is the same as the '\' operator, when the '\' operator is before a single operand. (\Member).

This function is able to resolve variables that have the PROTECTED attribute.

 

LocalVariable

A related function, LocalVariable() exists, but will be used rarely. No documentation is provided beyond the following note:

LocalVariable(Name) is the same as Scope(Self, Name, TRUE). This expression is useful only in the case that there is a value containing the name of a variable, which is added after the module is compiled and is referenced within the local module. LocalVariable is the same as the '.' operator.

.Member (i.e. without an object before the dot) compiles to LocalVariable("Member"), which is the equivalent of Variable("Member", TRUE).

Example:

trendValue = Variable(trendPointName);

The variable trendValue is set equal to the value of the variable named by variable trendPointName. The variable trendPointName is a text variable, which might hold the text name of a point entered by the operator from the keyboard.

Variable(motorSPName) = newSP;

This shows how to set the value of a variable given its text name. The variable motorSPName is a text variable that holds the name of the destination variable.