メインコンテンツまでスキップ
バージョン:23.5

Evaluating Expressions at Runtime

Value Function

Behavior: Returns the value of its parameter evaluated as a SenseTalk expression. One use of this would be to accept text entered by a user that might contain an expression (such as "12.95 + 6%") and calculate its value. Another would be to read a file containing a list or property list and quickly convert it from the text format stored in the file into a useful collection of values.

The expression is evaluated in the context of the current handler. It may include variables (such as total in the second example above), operators, function calls, and so forth. If the evaluationContext property is set to "Global" or "Universal", variables are treated as global or universal rather than local. If an error occurs while obtaining the value of the expression, the result function returns an exception object describing the problem.

Syntax:
value( expr )
{the} value of expr

Examples:

put the value of "51+93" into sum -- sets sum to 144
put value("total is greater than quarter" & bestQtrNum) into best
put value("(" & commaSeparatedText &")") into myList
put the value of file "storedProperties" into pList

Related: