News
November 1, 2019
Version 2.404 of Dentist Assistance 2 (DA2) is released.
March 7, 2019
Version 2.384 of Dentist Assistance 2 (DA2) is released.
August 27, 2018
Support of USPExpress .NET CFE products is discontinued.
USPExpress: getting started
You should take the following two steps when applying USPExpress to an expression:
- Parse the expression.
Parsing results in producing an expression tree. Once the tree is built, the expression can be evaluated many times against various variable values. - Evaluate the expression.
Since the expression tree is already built, evaluation of the expression is performed with maximum possible speed - no additional overhead is involved.
Below is a step-by-step guide to USPExpress usage (in C# syntax). You may also refer to the Sample projects and the Class Reference document, which are enclosed with the installation package.
USPExpress .NET Pro
- Declare and create USP.Express.Pro.Parser object:
using USP.Express.Pro;
...
Parser m_cParser = new Parser(); - Specify variables which you intend to use in your expression.
Four variables named X1, X2, X3, X4 are specified in the example below:m_cParser.Variables.Add(new Variable("x1", typeof(Double)));
m_cParser.Variables.Add(new Variable("x2", typeof(DateTime)));
m_cParser.Variables.Add(new Variable("x3", typeof(String)));
m_cParser.Variables.Add(new Variable("x4", typeof(Boolean)));m_cParser.Variables.Item(2).Aliases.Add("OrderDate");
- Parse the expression and obtain an expression tree:
ExpressionTree m_oExpressionTree = null;
try
{
m_oExpressionTree = m_cParser.Parse("Your Expression");
}
catch(Exceptions.ParseException ex)
{
...
}
catch(Exception ex)
{
...
}
- Assign actual values to the variables that you specified on step 2:
object[] m_aValues = new object[4];
m_aValues[0] = 1.0;
m_aValues[1] = DateTime.Now;
m_aValues[2] = "test string";
m_aValues[3] = true; - Evaluate the expression:
string sResult;
try
{
sResult = m_oExpressionTree.Evaluate(m_aValues).ToString();
}
catch(Exceptions.EvaluateException ex)
{
MessageBox.Show(ex.Message);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
USPExpress Math Parser .NET
- Declare and create USPExpress.USPExpression object:
USPExpress.USPExpression cParser;
cParser = new USPExpress.USPExpression(); - Specify variables, which you intend to use in your expression. Three variables named X1, X2, X3 are specified in the example below:
string[] sVariables = new string[]{"X1", "X2", "X3"};
- Parse the expression:
try
{
cParser.Parse(sExpression, sVariables);
}
catch(USPExpress.ParseException ex)
{
// ...
}
- Assign actual values to the variables that you specified on step 2:
double[] dValues = new double[]{35, 2, 3};
object[] oValues = new object[3];
oValues[0]= 35;
oValues[1] = 2;
oValues[2] = Convert.ToDateTime("12.12.2003"); - Calculate:
double dExpValue;
try
{
dExpValue = cParser.Evaluate(dValues);
}
catch(UXPExpress.EvaluateException ex)
{
// ...
}string sExpValue;
try
{
sExpValue = cParser.EvaluateEx(oValues);
}
catch(UXPExpress.EvaluateException ex)
{
// ...
}