One feature I like in Visual Basic is the Debug.Print command,
which lets you print anything (a variable's contents, a message, etc)
to a window for viewing during your app's execution. This would be
great to see in PureBasic's debugger (hint, hint) because it really
aids in debugging an app. Yes, PureBasic has a variable viewing option
but the need to print messages during execution is essential, IMO.
Anyway, here's an example procedure that does exactly this, but prints
it to a text file (c:\debug.txt) instead of a window. Fred, if you could
add something like this to the debugger in a "Debug" window,
it would be truly appreciated!
Code: Select all
; Debug procedure for PureBasic (by PB; feel free to use).
; Usage: Debug(msg$)
; msg$ can be anything: a variable's contents, a message, etc.
; Output of msg$ is written to c:\debug.txt, which is always deleted
; whenever you compile+run your application.
; To show a message during program execution: Debug("message")
; To show the contents of a string variable : Debug("var$="+var$)
; To show the contents of a numeric variable: Debug("var="+str(var))
;
Global debug
Procedure Debug(msg$)
if debug=0 : debug=1 : DeleteFile("c:\debug.txt") : endif
f=FileSize("c:\debug.txt")
If f=-1 : f=0 : EndIf
r=OpenFile(0,"c:\debug.txt")
If r0
FileSeek(f)
WriteStringN(msg$)
CloseFile(0)
EndIf
EndProcedure