Evaluate

Revision as of 22:27, 24 February 2007 by Lchrisman (talk | contribs) (Copy/pasted from user guide)


Evaluate(t)

Evaluate expects a text value t, and evaluates it as though it were an expression in a definition. It returns the value resulting from evaluating the expression. For example:

Evaluate('10M /10') → 1M

If t contains any syntax errors, Evaluate returns Null; it will not flag a syntax error.

One use for Evaluate is to convert (coerce) a text representation of a number into the number itself, for example:

Evaluate('100M') → 100M

Like most other functions, it returns the deterministic (Mid) or probabilistic value, according to the context in which it is called. Evaluate is powerful, and useful for a variety of purposes, but, it has some subtle aspects. Consider:

Variable A := 99
Variable B := (VAR A := 0; Evaluate('A + 1'))
B → 100

The Variable A in the evaluated text 'A + 1' refers to the global A, not the local A defined in B. More generally:

  • Evaluate(t) creates its own context for parsing t (at

evaluation time), which is quite separate from the context of the expression in which the Evaluate(t) appears.e.g., the definition of B above.

  • So, text t cannot refer to local Variables, indexes, or function

parameters defined in the context in which the Evaluate(t) function appears.

  • If the text value of t refers to any global Variables—e.g., A in

the definition of B above—these will not appear as Inputs of B, nor will any changes to A cause automatic re-evaluation of B.

  • Text t may itself define local Variables and indexes, and refer

to them, but these will not be available outside t.

  • When Evaluate references another variable, Analytica will

not be able to track the dependency. For example:

B := A+1
C := Evaluate('A+1')

When A changes, Analytica will automatically ensure that B is updated, but it has no way of knowing C should also be recomputed.

Text t may itself be an expression that creates a text value to be evaluated by Evaluate. This text expression appears in the definition of V and is not subject to the above limitations, so, for example:

Variable V :=(Var x:= ’10’; Evaluate(x & x))
V → 1010
Comments


You are not allowed to post comments.