Functions Index :: C :: CBool

[<< up one level]

Module:

base :: conversion

Definition:

CBool(val "x", bool "force")

Description:

Converts any variable to a bool type variable. The conversion follows the rules of the table below:

Type of xResult
truefalse
clipx.Framecount > 0x.Framecount == 0
floatx <> 0.0x == 0.0
intx > 0x == 0
boolx unchanged
stringx <> ""x == ""

Arguments:

"x": The variable to convert.

"force" (Optional, defaults to false): If true and x is an fined variable (ie Defined(x) returns false) then the function returns false. Else the function propagates the undefined variable to the caller, ie it returns an undefined value.

Examples:

i1 = 0

i2 = 12

f1 = 2.34

s1 = "test"

s2 = ""

u = Undef()

b1 = CBool(i1) # b1 == false

b2 = CBool(i2) # b2 == true

b3 = CBool(f1) # b3 == true

b4 = CBool(s1) # b4 == true

b5 = CBool(s2) # b5 == false

b6 = CBool(u) # Defined(b6) == false

b7 = CBool(u, true) # b7 == false

 

[<< top]