Functions Index :: C :: CBool
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 x | Result | |
---|---|---|
true | false | |
clip | x.Framecount > 0 | x.Framecount == 0 |
float | x <> 0.0 | x == 0.0 |
int | x > 0 | x == 0 |
bool | x unchanged | |
string | x <> "" | 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