Table of Contents

CBOOL

"Converts" to a boolean value a given expression or value of other type

Implemented by: FreeBASIC, Gambas

With variations:

Also written as:

Usage

As part of a number of type conversion functions, CBOOL more precisely evaluates a value or expression to a true or false value.

bVar = CBOOL(arg)

The BASICs that implement it, though, perform the evaluation differently.

In Gambas, CBOOL will return boolean false if:

FreeBASIC's CBOOL will also return true for a numeric expression or value different than 0, but for strings it will return a boolean true only if the argument is the proper string "true" in any capitalization:

PRINT CBOOL(0)		'false
PRINT CBOOL(-1)		'true
PRINT CBOOL(1)		'true
PRINT CBOOL("")		'false
PRINT CBOOL("truth")	'false
PRINT CBOOL("false")	'false
PRINT CBOOL("TrUe")	'true

Comments

It might be worth noting, even if it does not conflict with the results of CBOOL in known implementations, that the -1 numeric value is used for representing the boolean true value in some older BASICs.

Similar keywords

In other languages...

References