$TRACE directive

Purpose: $TRACE provides CONSOLE MODE runtime line number tracing, reminiscent of the old TRACE ON and TRACE OFF commands of past decades.

This is a really handy feature when you are trying to track down the "hot spots" in your program. Like many of the other BCX meta-statements, the $TRACE command is like a toggle. You sandwich the lines of code that you want to trace between two $TRACE statements.

You will generate lots of errors if you try tracing around variable declarations(DIM, LOCAL, GLOBAL, UNION, TYPE,...) Stick to tracing code :-)

If modules are being included using the $INCLUDE directive, adding the -m command line switch will turn on tracking of the module name and module line number and this information will be reported with the $TRACE ouput.

Here is a simple CONSOLE MODE program that demonstrates $TRACE. $TRACE causes your BASIC line numbers to be displayed as your program executes at runtime.


 CLS

 $TRACE

 FOR INTEGER I = 0 TO 31
   FOR INTEGER J = 0 TO 2
     SLEEP(30)
   NEXT
 NEXT
 KEYPRESS

 $TRACE

 PRINT:PRINT:PRINT "  Neat, huh?"