bool

Prev Next

Function Names

bool

Description

This function converts a value to a voolean value.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

1

Parameters

No.TypeDescription
1
input
valid types Value

Strings returning true:true, yes, '1' (not case sensitive, and also in other supported languages)
Strings returning false:false, no, '0', '-', '' (blank) (not case sensitive, and also in other supported languages)
Numerals: 0 (including near 0 as ruled by epsilon as defined in the systeml variable runtime settings[epsilon]<.br> Booleans are passed through.
Date: Blank dates return false, otherwise true. Parameter sets: If purely empty (no element inside, not even a nested empty set), then false, otherwise true. Dates are converted to a number in YYYYMMDD. Time will be added as fraction of 1, e.g. 0.5 for 12:00 noon.

Return value

TypeDescription
boolean Result

Identified boolean value

Examples

      echo( bool(TRUE), " ", bool(Falsch) );    // true, false
      echo( bool("Ja"), " ", bool("No") );  // true, false
      echo( bool("1"), " ",  bool(0) );       // true, false
      echo( bool({{}}), " ", bool({}) );        // true, false
      echo( bool( date( '10:30:00' )), " ", bool( date("") ) );   // true, fasle

Output

true false
true false
true false
true false
true false
Try it yourself: Open LIB_Function_bool.b4p in B4P_Examples.zip. Decompress before use.