GetVar Method
Description
Returns the value of a SPEL+ global preserve variable in the Controller.
Syntax
Function GetVar(VarName As String) As Object
Parameters
- VarName
The name of the SPEL+ global preserve variable. For an array, the entire array can be returned or just one element.
Return Value
You can use GetVar to retrieve values of any global preserve variables in the Controller's current project. Before you can retrieve values, the project must be successfully built.
If you want to retrieve an entire array, then supply the array name in VarName. To retrieve one element of an array, supply the subscript in VarName.
Remarks
You can use GetVar to retrieve values of any global preserve variables in the Controller's current project. Before you can retrieve values, the project must be successfully built.
See Also
SetVar Method
GetVar Example
In the SPEL+ project, the variable is declared:
Global Preserve Integer g_myIntVar
Global Preserve Real g_myRealArray(10)
Global Preserve String g_myStringVar$
Function main
...
Fend
In the Visual Basic project:
Since g_myIntVar is declared as in integer, the Visual Basic variable used to retrieve the value of g_myInVar must be declared as an Integer. For g_myRealArray, the Visual Basic variable must be declared as a Single array.
Dim myIntVar As Integer
Dim myRealArray() As Single
Dim myStringVar As String
myIntVar = m_spel.GetVar("g_myIntVar")
myRealArray = m_spel.GetVar("g_myRealArray")
myStringVar = m_spel.GetVar("g_myStringVar$")
In the C# project:
Since g_myIntVar is declared as in integer, the C# variable used to retrieve the value of g_myInVar must be declared as an int. For g_myRealArray, the C# variable must be declared as a float array.
int myIntVar;
float[] myRealArray;
string myStringVar;
myIntVar = m_spel.GetVar("g_myIntVar");
myRealArray = m_spel.GetVar("g_myRealArray");
myStringVar = m_spel.GetVar("g_myStringVar$");