Skip to main content
Version: Next

Bool

Bool ( expression ) : Boolean

ParameterTypeDescription
expressionExpressionExpression for which to return the boolean form
Function resultBooleanBoolean form of the expression

Description

The Bool command returns the boolean form of the expression you passed in expression.

The command can return the following values, depending on the expression result type:

Expression result typeReturn of the Bool command
UndefinedFalse
NullFalse
BooleanFalse if false, otherwise True
NumberFalse if 0, other True
Other typesFalse

This command is useful when the code expects a boolean value, and when the evaluation of the expression could result in a different type (e.g. if it evaluates to null or undefined).

Example

You select a value depending on the contents of an object field attribute, anticipating the case where the attribute is missing:

 var $married : Text
 $married:=Choose(Bool([Person]data.married);"Married";"Single")
  //"Single" if the "married" attribute is not found in the field
 ALERT("This person is "+$married)

See also

Date
Num
String
Time