Developer Documentation Library > Data Model > UNICOM Intelligence Data Model reference > Evaluate object reference
 
Evaluate object reference
The Evaluate component implements expression parsing and evaluation. The component is used by both the Case Data Model and the Metadata Model.
The ExpressionProgram object created by parsing an expression contains a p-code representation of the expression. The ValueStack Peek, Pop, and Push methods are used to evaluate the p-code and create the result.
Examples
The following mrScriptBasic examples demonstrate how to use the Evaluate component.
Parsing and executing an expression
Dim Evaluate, Program, Result, Cat1[]

Set Evaluate = CreateObject("mrEvaluate.Evaluate")

' Parse the expression into a program
Set Program = Evaluate.Parse("Q1 + Q2")

' Set the identifier values
' NOTE: Type determined from constant type
Program["Q1"] = 23
Program["Q2"] = 5

' Run the program (Result = 28)
Result = Evaluate.Execute(Program)

' Perform a categorical based request
' Two different approaches to assigning categoricals

Program["Q1"].Type = 3 'mtCategorical
Program["Q1"] = "{5,2,8}"

Cat1[0] = 9
Cat1[1] = 3
Cat1[2] = 4
Program["Q2"].Type = 3 'mtCategorical
Program["Q2"] = Cat1

' Run the program (Result = {5,2,8,9,3,4})
Result = Evaluate.Execute(Program)
Calling a registered function
Dim Evaluate, MyFunction, MyParameters[], lngResult

Set Evaluate = CreateObject("mrEvaluate.Evaluate")

' Obtain the function
Set MyFunction = Evaluate.Functions["Len"]

' Set the parameters
MyParameters[0] = "Get the string length of this string"

' Call the function (lngResult = 36)
lngResult = MyFunction.Execute(MyParameters)
See
Evaluate component: Object Model
See also
Expression evaluation
UNICOM Intelligence Data Model reference