Casting Booleans
· Aug 28, 02:35 PMQuite often I need to convert a Boolean to an Integer for use with external functions or SQL. My solution has long been to extend the Boolean datatype.
Function IntegerValue(extends b as Boolean) as Integer
if b then
return 1
else
return 0
end if
End Function
The addition of the CType keyword to the REALbasic language provides an even easier solution.
CType(b, Integer)
returns 1, if b is true, or 0, if b is false.
Commenting is closed for this article.