To order Alpha Four or Alpha Five, click above to go directly to Alpha, or call 800.451.1018 or 781.229.4500

             
Alpha Newsletter

Wednesday, May 1, 2002 Issue 3   VOLUME 1 ISSUE 3  
HOME
TOPICS
News & Notes
Learn Alpha Five
Tips & Tricks
Tech Corner
Developer Spotlight
CONTENTS
QUICK NOTES
Alpha User Groups
Alpha Consultants
Alpha Four to Alpha Five - Chapter 3
An Interview with Tom Henkel
A New Trick for an Old Friend
Searchable Multi-Value Field
Add Fields to a Table via Xbasic
Auto-Increment Script for Special Situations
Format Your Xbasic Scripts
Alpha Four's Script Recorder
A New Trick for an Old Friend
TC019
by Jim Chapman

Of all the tools to help the Xbasic programmer, the one tool I couldn't do without is the debugger. I don't care how good you are, you still need the debugger. If you are learning Xbasic and are not familiar with the debugger, stop everything and spend some time with it. You will find that your learning process will be much improved. The debugger displays a script and executes it one step at a time upon your command. As well as seeing the script execute, you can, via the Watch Window, look at any values currently available to the script environment. The Xbasic manual lists three methods to invoke the debugger. I will not repeat those three here, but I want to add a fourth method that I find helpful. Many times the difficult errors are not syntactical errors, or even errors of logic, but are errors of what I'm going to call 'circumstance'. Many times your syntax is good, and your logic is good, you just haven't taken into consideration all possible values or outcomes that the script might encounter. Your script may work for 99% of your fields' values, but then encounters unexpected or blank values. The beauty and the bain of using the debugger is that it executes each xbasic command in 'human' time. Of course, it has to be this slow, otherwise it would be of no use to us. Even when telling debug to 'run', it is still very slow. The problem comes when you have a large script, or have a large number of records that the script processes, getting to the point where there is a problem can be a lengthy process. For these situations I suggest using this 'fourth' technique. Assume you have a lengthy script that is giving you an error. Make sure that the debugger is not turned on in the body of the script. To your troubled script, add an error handling routine such as this:

On error goto StartDebugger

'the body of your script

END

StartDebugger:
Debug(1)
Resume 0

The script executes at 'Alpha' speed (fast), until it runs into the error. The error handler starts the debugger and returns to the line that caused the error. This will allow you all the benefits of using the debugger without the painful wait of paging through thousands of records.

Even more specific is the similar technique of using an embedded IF…..THEN statement to turn on the debugger if a certain situation or value exists. At times you might find that your script is producing unexpected results. It might not appear to be consistent. By embedding an IF…..THEN statement, you can tell the script to 'look' for this unusual result and if it appears, then run debug(1).

Using these two 'Fourth' methods will give you the ability to quickly find and fix your Xbasic errors. Happy hunting!
[PRINTER FRIENDLY VERSION]

Powered by iMakeNews.com