Sometimes I wonder if everything in my programs run as I planned it. One easy way to follow-up what the EXE is just performing
is to put a MESSAGE() or a STOP() in the source with some meaningful text. That way I can see whether a variable has got the right value or not
But that is a quite pedestrian and, I have to confess, rather clumsy way to "debug" a program.
With the help from the guys on the Clarion-Chat on Skype, namely Mark Goldberg and Olivier Cretey, I found a very easy way to improve my debugging.
First of all, you need a Third-Party-Tool called DebugView. It was written by Mark Russinovich and Bryce Cogswell, who distributed their tools under the label SysInternals for free. These guys were so smart that Microsoft finally hired them. Mark and Bryce agreed with Microsoft that their toolbox is continued and remains free! You can get the entire toolbox from this website http://www.sysinternals.com/ which then redirects you to Microsofts TechNet. Go there and pick DebugView (its under "Miscellanous Utilities") or better get the entire Sysinternals Suite and install it on your machine!
Back to Clarion, your first step is to open Global Properties -> Embeds and insert this into your Global Map:
module('') OutputDebugString(*CString),raw,pascal,Name('OutputDebugStringA') end dbgView(String DebugString)The next step is to put the following into an embed in Program Procedures:
dbgView Procedure(String DebugString) DB CString(SIZE(DebugString)+1) ! define a variable that has the same size as the parameter we receive plus 1 character Code DB = DebugString OutPutDebugString(DB)
dbgView Procedure(String DebugString) DB &CSTRING ! define a variable that has the same size as the parameter we receive plus 1 character CODE DB &= NEW CSTRING( SIZE(DebugString) + 1) DB = DebugString OutputDebugString(DB) DISPOSE(DB)Now you can use DebugView to watch right into your EXE using this new function dbgView()!
? dbgView('The LOOP starts in the very next line') LOOP i = 1 TO RECORDS(CUSTOMERS) BY 1 IF somecondition THEN ? dbgView('somecondition found, Break should happen now') BREAK END END ? dbgView('The LOOP has just finished at Record-No. ' & i)You will now see the messages in your dbgView()-statements being displayed in the DebugView window.
Thats all! Add salt and pepper as you like....
You can download the sample source (Clarion 6.3 EE). This page was made on 16.05.2011.
DebugView works well with Clarion 5.5 also.
Dave Schwartz: "Well, I would say that this was a few minutes very well spent. 'DebugView' was just the leg up I needed in getting started."