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 foreach loops in the above example specifies a variable of type RecordList that has already been assigned the results of an OQL query. The first loop repeats everything within its curly braces for each record in the RecordList variable connected. Nested within the foreach( connected ){ } loop is a second loop, that repeats everything within its curly braces for each record in the RecordList variable uniqueConnector.
  • The ExecuteOQL statement that is nested inside both loops updates the tempFull.connected database using an eval statement to extract columns from the records held in the two variables:
    • The statement eval(text,'&m_NbrName') refers to the m_NbrName column contained within the local scope, that is, held in the uniqueConnector variable.
    • The statement eval(text,'&&m_RelatedTo') refers to the m_RelatedTo column contained one level away from the local scope, that is, held in the connected variable.