ComponentOne Sizer 8.0
Eval Property

Evaluates a string containing a numeric expression and returns the result.

Syntax

val# = [form!]C1Awk.Eval(Expression As String)

Remarks

This property evaluates the mathematical expression in Expression parameter and returns its value as a double. The expression may contain variables, provided you handle the Variable event.

The following operators are supported, according to their priority:

Operator

Meaning

()

subexpressions

^

power

*, /

multiplication, division

%

modulus (remainder)

\

integer divide

+, -

addition, subtraction

>, >=, <, <=, <>

logical comparison

&, |

logical "and", logical "or"

In addition to the standard operators, the following built-in functions are supported (they are not case sensitive): Abs, Sin, Cos, Tan, ACos, ASin, Atn, Log, Log10, Exp, Sqr, Int, Frac, Ceil, and Floor. Trigonometric functions accept and return angles expressed in radians or degrees, depending on the setting of the AngleUnits property.

The Awk expression evaluator allows you to define your own variables. This is done in a very simple way. Whenever the parser encounters a string that is not a number, operator, or built-in function, it fires the Variable event. The event handler gets the variable name and is responsible for returning its value.

If an error occurs while evaluating an expression, the Error property is set to an appropriate code. See the description of the Error property to find out what each code means.

For example:

Example Title
Copy Code
debug.print awk.Eval("(1+2)*3^2")
27

Note: This property is functionally equivalent to the Val property, except it allows you to pass the expression as a parameter, instead of relying on the L property.

Data Type

Double

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback