This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v20 R7
Bool
|
Bool ( expression ) -> Function result | ||||||||
Parameter | Type | Description | ||||||
expression | Expression |
![]() |
Expression for which to return the boolean form | |||||
Function result | Boolean |
![]() |
Boolean form of the expression | |||||
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 type | Return of the Bool command |
Undefined | False |
Null | False |
Boolean | False if false, otherwise True |
Number | False if 0, other True |
Other types | False |
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).
You select a value depending on the contents of an object field attribute, anticipating the case where the attribute is missing:
C_TEXT($married)
$married:=Choose(Bool([Person]data.married);"Married";"Single")
//"Single" if the "married" attribute is not found in the field
ALERT("This person is "+$married)
Product: 4D
Theme: Boolean
Number:
1537
Created: 4D v16 R5
4D Language Reference ( 4D v20 R7)