This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v20 R7
Bool

Bool 


 

Bool ( expression ) -> Function result 
Parameter Type   Description
expression  Expression in Expression for which to return the boolean form
Function result  Boolean in 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 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:

 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)



See also 

Date
Num
String
Time

 
PROPERTIES 

Product: 4D
Theme: Boolean
Number: 1537

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v16 R5

 
ARTICLE USAGE

4D Language Reference ( 4D v20 R7)