Examples of the eval statement
Use these examples to learn how to use the eval statement.
Example 1
The following example evaluates the contents
of the m_Creator database column (held one level of scope
away from the current scope) and inserts the value into myVariable,
a previously declared variable of type text.
myVariable = eval( text , '&m_Creator' )Example 2
The following example declares an integer
variable called portNum and assigns to it the value extracted
from m_LocalNbrPort held within an object called m_LocalNbr that
is known two levels away from the present scope. m_LocalNbrPort is
extracted from the object using the target identifier.
int portNum = eval( int, "&&m_LocalNbr->m_LocalNbrPort" )Example 3
The following example shows an eval statement
in the stitcher language within two foreach loops.
foreach( connected )
{
foreach( uniqueConnector )
{
ExecuteOQL
(
"update tempFull.connected
set m_RelatedTo = eval(text, '&m_NbrName')
where m_Name = eval(text, '&&m_RelatedTo')
);"
);
}
}Where:
- Each of the
foreachloops in the above example specifies a variable of typeRecordListthat has already been assigned the results of an OQL query. The first loop repeats everything within its curly braces for each record in theRecordListvariableconnected. Nested within theforeach( connected ){ }loop is a second loop, that repeats everything within its curly braces for each record in theRecordListvariableuniqueConnector. - The
ExecuteOQLstatement that is nested inside both loops updates thetempFull.connecteddatabase using an eval statement to extract columns from the records held in the two variables:- The statement
eval(text,'&m_NbrName')refers to them_NbrNamecolumn contained within the local scope, that is, held in theuniqueConnectorvariable. - The statement
eval(text,'&&m_RelatedTo')refers to them_RelatedTocolumn contained one level away from the local scope, that is, held in theconnectedvariable.
- The statement