Getting Started      USPExpress .NET Pro   USPExpress .NET

You should take the following two steps when applying USPExpress .NET 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):

  1. Declare and create USPExpress.USPExpression object:

    USPExpress.USPExpression cParser;
    cParser = new USPExpress.USPExpression();
  2. 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"};
  3. Parse the expression:

    try
    {
       cParser.Parse(sExpression, sVariables);
    }
    catch(USPExpress.ParseException ex)
    {
       //  ...
    }
    
    ParseException is raised, if the expression is not parsed successfully.

  4. Assign actual values to the variables that you specified on step 2:

    double[] dValues = new double[]{35, 2, 3};
    Or, if you want to evaluate an expression containing DateTime variables:
    object[] oValues = new object[3];
    oValues[0]= 35;
    oValues[1] = 2;
    oValues[2] = Convert.ToDateTime("12.12.2003");
  5. Calculate:

    double dExpValue;
    try
    {
       dExpValue = cParser.Evaluate(dValues);
    }
    catch(UXPExpress.EvaluateException ex)
    {
       //  ...
    }
    
    Or, if you want to evaluate an expression containing DateTime variables:
    string sExpValue;
    try
    {
       sExpValue = cParser.EvaluateEx(oValues);
    }
    catch(UXPExpress.EvaluateException ex)
    {
       //  ...
    }
    
    EvaluateException is raised, if the expression is not evaluated successfully.

You may also refer to the Sample projects and the Programmer's Guide document that comes with the library.

Contact Us: Product | Download | Order | Programmer's Guide | About Us | License
to top^
UNISOFT Plus Ltd.
E-mail:
Web: http://www.unisoftplus.com

  © 1999-2008, UNISOFT Plus Ltd.
Home