Debugging macro that halts program execution if an expression is evaluated to 0 (false).

#define ASSERT(expression) if (expression) = 0 then : fb_Assert( __FILE__, __LINE__, __FUNCTION__, #expression ) : end if

ASSERT( expression )

Any valid conditional/numeric expression. If expression evaluates to 0 (i.e. "false"), execution is halted.

The ASSERT macro is intended for use in debugging and works only if the -g option is selected in the FBC command line. In this case it prints an error message and stops the program execution if expression evaluates to 0.

Its normal use is to check the correct value of the variables during debugging.

If -g is not passed to fbc, the macro does not generate any code, and has no effect.

Note: If an ASSERT fails while the program is in a graphics Screen, the error message will not be visible as it will be printed to the graphics screen, which will be closed immediately after.

Sub foo
 Dim a As Integer
End Sub


'' If -g is used this code stops with: test.bas(3): assertion failed at FOO: a=1

Dialect Differences:
Differences from QB:
See also:

Back to Miscellaneous
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki phatcode