constant(
FORMULA
)

The constant( function converts an expression into a constant value (that can be plugged into a new formula).

Parameters

This function has one parameter:

formula – is the formula you want to convert into a constant.

Description

The constant( function converts an expression into a constant value. It determines the type of value generated by the expression, then adds quoting as necessary to make a valid constant that can be used to assemble a formula.

Suppose a program initialized two variables a and b like this:

``````let a = 1
let b = "hello"
``````

Then various incancations of the constant( function will produce these results.

``````constant(a) ☞ 1
constant(b) ☞ "hello"
constant(b+a) ☞ "hello1"
constant(c) ☞ error("Field or Variable [c] does not exist.")
``````

Essentially the constant( function provides a way to “freeze” the current value of a variable, so that it could be used later. In fact, the constant( function is used internally by the convertvariablestoconstants statement for just this purpose.