Description: This function accesses a variable by its text name; its return value is optional.
Returns: Varies – see comments
Usage: Script
Format: Variable(Name)
Parameters: Name { text } { required } { no default: }
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, square brackets [ ] or the scope resolution operator \. Thus, the Variable function may only affect simple variables within the current scope (variables in the current module, or any parent module). Public members outside the current scope or array elements are not accessible. The Variable function may always access members of system. If Variable is passed the name of a module, it will return an invalid value.
Variable can use module name.
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.
See Also: