| Navigation: Language Reference > 10 - Expressions > Runtime Expression Evaluation >====== EVALUATE (return runtime expression string result) ====== | ![]() ![]() |
EVALUATE(expression)
| EVALUATE | Evaluates runtime expression strings. |
| expression | A string constant or variable containing the expression to evaluate. |
The EVALUATE procedure evaluates the expression and returns the result as a STRING value. If the expression does not meet the rules of a valid Clarion expression, the result is a null string (''), and ERRORCODE is set. A logical expression returns a string containing either zero ('0') or one ('1'), while an arithmetic expression returns the actual result of the expression (in a string). The more variables are bound at one time, the slower the EVALUATE procedure works. Therefore, BIND(group) should only be used when most of the group's fields are needed, and UNBIND should be used to free all variables and user-defined procedures not currently required for use in dynamic expressions. PATH(), SHORTPATH() and LONGPATH() can now be used in expressions evaluated by the EVALUATE statements in runtime application and in the templates.
Field Qualification syntax (dot syntax) cannot be used in the expression. Variables should be binded using the standard prefix notation.
Return Data Type: STRING
Errors Posted:
| 1010 | Illegal Expression |
| 1011 | Variable Not Found |
| 1012 | Mismatched |
| 1015 | Some parameters of built-in functions that are used in the expression are omitted |
Example:
MAP
AllCapsFunc PROCEDURE(STRING),STRING !Clarion procedure
END
Header FILE,DRIVER('Clarion'),PRE(Hea),BINDABLE !Declare header file layout
OrderKey KEY(Hea:OrderNumber)
Record RECORD
OrderNumber LONG
ShipToName STRING(20)
END
END
StringVar STRING(20)
CODE
BIND('ShipName',Hea:ShipToName)
BIND('SomeFunc',AllCapsFunc)
BIND('StringVar',StringVar)
StringVar = 'SMITH'
CASE EVALUATE('StringVar = SomeFunc(ShipName)')
OF ''
IF ERRORCODE()
MESSAGE('Error ' & ERRORCODE() & ' -- ' & ERROR())
END
OF '0'
DO NonSmithProcess
OF '1'
DO SmithProcess
END
AllCapsFunc PROCEDURE(PassedString)
CODE
RETURN(UPPER(PassedString))
!***Additional Examples
BIND('Value1',Self.Value1)
BIND('StrVar',StringVar)
Self.Value1 = '15 + 10'
Evaluate(Value1) !Returns 25
StringVar = 'True'
Evaluate('StrVar') !Returns the characters 'True' (without the quotes)
See Also:




