CBOOL function
Purpose: The CBOOL function returns the evaluation of an expression as a Boolean. If the expression evaluates to a nonzero value, CBOOL returns 1; otherwise, it returns 0.
Syntax: RetVal% = CBOOL(Expression) Parameters:
|
Example:
DIM int1%, int2%, RetVal% DIM str1$, str2$ int1% = 1 int2% = 2 RetVal% = CBOOL(int1% <> int2%) PRINT RetVal% ' RetVal contains 1. int1% = 0 RetVal% = CBOOL(int1%) PRINT RetVal% ' RetVal contains 0. str1$ = "1" str2$ = "2" RetVal% = CBOOL(str1$ = str2$) PRINT RetVal% ' RetVal contains 0.
Here is is a sample using CBOOL with strings and a pointer.
DIM RAW c$, z AS LPSTR ' Init the c$ c$ = "El gato esta aqui!" ' Check if z is used or not...(uninitialized)? ? CBOOL(z) ' Should be FALSE ' Short-circuit z to c$(initialized) z = c$ ? CBOOL(z) ' Should be TRUE ' Unplug the LPSTR(once again uninitialized) CLEAR(z) ? CBOOL(z) ' Should be FALSE KEYPRESS