debugging.md 1.4 KB


id: debugging title: Debugging

sidebar_label: Debugging

BlitzMax provides several commands to help with debugging your programs:

Command Description
DebugStop In debug mode, causes the program to stop executing and activates the debugger. In release mode, no effect.
DebugLog StringExpression In debug mode, causes StringExpression to be printed to the debugger output window. In release mode, no effect.
RuntimeError StringExpression Causes a runtime error exception (see: Exceptions ) to be thrown with the specified string.
Assert Expression Else StringExpression In debug mode, causes a RuntimeError if Expression evaluates to false. No effect in release mode.

Assert is particularly useful for validating function arguments. For example:

Function SetAlpha( alpha# )
    Assert alpha>=0 And alpha<=1 Else "Alpha value out of range"
    ' rest of function here...
End Function

However, since asserts are taken out in release mode, be careful that your asserts don't have any side effects - code that may affect the execution of the program.