Here's a variant of Trond's most excellent Assert.
It's piggybacking fully on the Debugger, so if you compile without the debugger then assert is not compiled either.
Likewise, if an assert failure happen it will use the debug output instead of a requester.
And I removed the End, thus allowing you to choose Continue or Kill from the debug menu instead. (assuming you don't have auto kill enabled that is).
Would be cool if this was available as part of the debugger, but this way rocks too, I may actually find a use for this
Code: Select all
Macro QUOTE
"
EndMacro
Macro Assert(Expression)
CompilerIf #PB_Compiler_Debugger
If Not (Expression)
Debug "Assert: "+QUOTE Expression QUOTE
Debug "Line "+Str(#PB_Compiler_Line)+" in "+#PB_Compiler_File
CallDebugger
EndIf
CompilerEndIf
EndMacro
Apple=1
Orange=2
Assert(Apple = Orange)