Repository navigation
Home
Ronald Hoek edited this page Nov 18, 2018
·
3 revisions
Welcome to the ExprEval wiki!
I recently updated this page with some basic understanding of the prExpr library.
For more detail and background information, you should read the manual created by Martin Lafferty, which is located inside to projects /Docs folder.
The basics of this expression evaluator can be split into two part:
- construction of the expression object chain
- execution of the object chain
As these two things are really separated, you have some neat advantages as a developer.
The expression is defined as a string, using Excel-like formulas
if(variabel=3,'This is true','This is false')
When an expression string is available, the next step is to create an object chain, based on the expression string
procedure ParseExpressionString(const myexpression: string; myidentifierfunction: TIdentifierFunction);
var
val: IValue
begin
val := CreateExpression(myexpression, myidentifierfunction);
end;
After the expression chain has been created, you want to get the result of the expression.
Basically, there are two ways of getting the value:
- Using the inial routines created by Martin Lafferty:
- 'Aks' the expression, which type the return value will be (See 'ExprType')
- Then then use the appropriate 'As...' routine to get the correctly typed value
- USe the 'AsVariant' routine to get the basic-typed value (string, boolean, integer, float)
- NOTE: object-types value must always be returned by 'AsObject'