evalf()

Function groupExecute on clientPlatform(s)
GeneralNOAll

Syntax

evalf(variable)

Description

Evaluates a calculation passed as a string in a character or binary variable and returns the result. If variable is of type binary,evalf() returns the tokenized calculation in variable for faster execution of subsequent calls

The function evalf() is faster than the equivalent eval(); you should use it when your code will repeat an evaluation several times. You should use it in the Set search as calculation command and as the calculation for a window list field.

evalf() takes a single argument that must be a fieldname or variable. If the contents of this field or variable is the text for a valid calculation, evalf() returns the result of the calculation, else a runtime error occurs. At the same time, the tokenized form of the calculation is stored back in the field or variable, so that next time evalf() is called, there is no need to tokenize or check the string. Tokenizing a string is part of the interpretation process; once done, Omnis can evaluate the calculation quickly. If you change the contents of the field or variable evalf() uses, Omnis will recognize that the new string requires checking and tokenizing.

Example

Test for valid calculation
 
evalf
(
lSearch
)

If flag true
  
Set search as calculation
 
evalf
(
lSearch
)

End If
Find first
 
on 
lTown
 (
Use search
)

 
Calculate
 
lVar1
 as 
'lTax*100'

Calculate
 
lTotal
 as 
lVar2
+
evalf
(
lVar1
)