Documentation component by John Kelly
QDEBUG   

QDEBUG Component
Included in RAPIDQ2.INC

QDEBUG  is a self-contained form that is handy for debugging loops, and code without interrupting program flow.
Written by John Kelly but based on code from Pete Kleinschmidt and Michael Zito.
To close the form while the programming is running use QDEBUG.Visible = False or QDEBUG.Form.Close. 
To make sure the user doesn't close the form set methods use QDEBUG.Enabled = False or QDEBUG.Visible =False. 
Use the .SetError(0) to clear out any previous windows error. 
See limitations.

QDEBUG Properties


Read/Write Default
Clear INTEGER      Clears entire text

Enabled
LONG       Determines if the form is 
                      0 (or False) = fixed/read-only 
                     1 (or True) = Debug window can be moved by user/closed etc
R/W True
Form QFORM       You can reset the Debug form just like any other form:
                        Debug.Form.Width = 100
                        Debug.Form.Font = myQFont, etc.
R/W  
Visible LONG R/W True
WatchTime  Number of milliseconds to update watch variables
R/W 10
TestSockets  INTEGER     Allow for checking of Windows Socket errors R/W False

QDEBUG Methods
Method Type Description Params




Bug  SUB (Str AS STRING)  Same as PrintStr, (compatible with previous release) 1
Clear SUB () Clear contents of the Form 0
ClearWatch SUB () Clear all watch variables
0
Err$ FUNCTION () AS STRING
Gets Windows GETLASTERROR API and formats it into a text message. CAUTION  if your program doesn't create an error, it will report the previous error. 0
ErrNum FUNCTION () AS DWORD  Returns the last Windows Error, if you want to see the code for Err$ 0
Print SUBI (...) Print out standard variable types and strings infinite
PrintStr SUB (Str AS STRING) Print out a string or variable converted to string 1
PrintWrap SUB (Str AS STRING) Print a string and wrap it inside the Form 1
SetError SUB (NewErr AS LONG) Generate a windows system error. Use 0& to clear Last Error 1
WatchDouble
SUB(addr, Tag$) Add a DOUBLE variable to the watch list (Tag$ is optional)
2
WatchInt
SUB(addr, Tag$) Add a INTEGER, LONG, or DWORD variable to the watch list
(Tag$ is optional)
2
WatchSingle
SUB(addr, Tag$) Add a SINGLE variable to the watch list, (Tag$ is optional) 2
WatchString
SUB(addr, Tag$) Add a STRING variable to the watch list, (Tag$ is optional) 2

QDEBUG Events
Event Type Occurs when... Params





None  ...

QDEBUG Example



$INCLUDE "RAPIDQ2.INC"
DECLARE SUB btnTestClick
DIM Debug AS QDEBUG         'Should declare as global
CREATE frmTest AS QFORM
Caption = "Debug Test Program"
Center
CREATE btnTest AS QBUTTON
Caption = "OK"
Top = 30
Left = 30
Height = 20
OnClick = btnTestClick
END CREATE
END CREATE

SUB btnTestClick
DIM I AS INTEGER
DIM J AS INTEGER
FOR J = 1 TO 3
FOR I = 1 TO 20
Debug.Print("Run ", I, " through Loop", J) 'strings AND varaibles to debug object
' Debug.ErrNum
' Debug.Err$ 'default output to window
NEXT I
NEXT J
END SUB

frmTest.ShowModal



QDEBUG Example #2
'create an error
$INCLUDE "RAPIDQ2.INC"
DIM Debug AS QDEBUG 'Should declare as global
Debug.Form.Left = 20
Debug.Form.Top = 120
Debug.Form.Height = 186
Debug.SetError ERROR_BAD_USERNAME
Showmessage "debug error = " + Debug.Err$


QDEBUG Example #3
'add variables to a watchlist
$INCLUDE "RAPIDQ2.INC"
DECLARE SUB doCalc
DIM d AS QDebug
DIM mainform AS QFORM
DIM abutton AS QBUTTON
abutton.Parent = mainform
abutton.OnClick = doCalc
DEFINT i
d.WatchInt(VARPTR(i) , "i")
DEFSTR s$ = "hello"
d.WatchString(VARPTR(s$) , "s$")

SUB doCalc
i = INT(RND(500))
s$ = "hi " + STR$(i)
END SUB
mainform.ShowModal

                       Contents