_CP_debug is equivalent to the debug BASIC statement.


int _CP_debug(int expression)


The C function differs slightly, however. The expression passed to _CP_debug displays as a pseudo line number within the BASIC/FlashBASIC debugger. Variables within the C program are not known to the BASIC/FlashBASIC debugger. For access to these, the user should use a system debugger such as dbx or sdb. The _CP_debug statement is useful however, as it can be used to set breakpoints in FlashBASIC subroutines that will be called later.

This function returns -1 if an error occurs. The error code is contained in _CP_errno.


When run, the user can enter breakpoints for the not-yet-executed subroutine mysub. For example, to stop when mysub reaches line number 3, the user should type mysub:b$=3 followed by g at the debugger prompts. The BASIC/FlashBASIC debugger then breaks within mysub at line number 3.

/* Enters the BASIC/FlashBASIC debugger and then calls routine "mysub". */
CPSTR * s = _CP_mkstr("mysub");
int i = -1;