User Tools

Site Tools


runtime_expression_evaluation.htm
Navigation:  Language Reference > 10 - Expressions > Runtime Expression Evaluation >====== Runtime Expression Evaluation ====== Previous pageReturn to chapter overviewNext page

Clarion has the ability to evaluate expressions dynamically created at runtime, rather than at development time. This allows a Clarion program to contruct expressions “on the fly.” This also makes it possible to allow an end-user to enter the expression to evaluate.

An expression is a mathematical or logical formula that produces a value; it is not a complete Clarion language statement. Expressions may only contain constant values, variables, or procedure calls which return a value, all connected by logical and/or arithmetic operators. An expression may be used as the source side of an assignment statement, a parameter of a procedure, a subscript of an array (a dimensioned variable), or the conditions of IF, CASE, LOOP, or EXECUTE structures.

Any program variable, and most of the internal Clarion procedures, can be used as part of a runtime expression string. User-defined procedures that fall within certain specific guidelines (described in the BIND statement documentation) may also be used in runtime expression strings.

All of the standard Clarion expression syntax is available for use in runtime expression strings. This includes parenthetical grouping and all the arithmetic, logical, and string operators. Dynamic expressions are evaluated just as any other Clarion expression and all the standard operator precedence level rules described in the Expression Evaluation section (see page 3) apply.

It takes three steps to use runtime expression strings:

·The variables that are allowed to be used in the expressions must be explicitly declared with the BIND statement.

·The expression must be built. This may involve concatenating user choices or allowing the user to directly type in their own expression.

·The expression is passed to the EVALUATE procedure which returns the result. If the expression is not a valid Clarion expression, ERRORCODE is set.

Once the expression is evaluated, its result is used just as the result of any hard-coded expression would be. For example, a runtime expression string could provide a filter expression to eliminate certain records when viewing or printing a database (the FILTER expression of a VIEW structure is an implicit runtime expression string).

See Also:

BIND (declare runtime expression string variable)

EVALUATE (return runtime expression string result)

POPBIND (restore runtime expression string name space)

PUSHBIND (save runtime expression string name space)

UNBIND (free runtime expression string variable)

runtime_expression_evaluation.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1