Val

Val(exprText)

Takes a text string containing an expression. Returns the result of the expression. This provides a way of deferring the evaluation of expensive calculations, or ones with side effects, on either side of an If function.

Result Type
The result of exprText

Example

val(if(c, "calculate:nthPrime(n)", 0))

will only calculate the nth Prime if c is true. Without the val() the (presumably expensive) calculation would happen regardless of the value of c, with the result being discarded if c was false. This is because if() is a function, so all parameters will be evaluated.

Posted in Functions | Comments Off on Val