Blitz3D+ Command Reference

Stop

Parameters

None.

Description

Pauses the program and breaks into the debugger.

Stop is a breakpoint you write in code. When the program runs from the IDE in debug mode and hits a Stop, it suspends and the debugger takes over - you can inspect variables, step through the code that follows, and resume when you are ready. Because it is just a statement, you can make it conditional: If health<0 Then Stop is a great way to catch "impossible" states right where they happen.

Be careful: outside the IDE's debug mode there is no debugger to resume the program, so a leftover Stop simply freezes it. Strip Stop lines out (or guard them) before building a release.

See also: DebugLog, RuntimeError, End.

Example

; Stop Example
; ------------

; Stop halts the program and opens the IDE debugger, where you can
; step through code and inspect variables. It needs debug mode on.

Print "This example can halt itself with Stop."
Print ""
Print "Press and hold Y to hit the Stop, or any other key to skip"
WaitKey

; WaitKey returns as the key goes down, so the chosen key is still held
If KeyDown(21) Then
    counter=123
    ; In debug mode the debugger opens here - inspect counter in the
    ; IDE, then resume the program
    Stop
    Print "Resumed after Stop - counter is "+counter
Else
    Print "Skipped the Stop."
EndIf

Print ""
Print "Press any key to close the example"
WaitKey

End

Index