Liberty BASIC Help Online

TRACE n
 
TRACE number
 
Description:
This statement sets the trace level for its application program. This is only effective if the program is run using the Debug menu selection (instead of RUN).  If Run is used, then any TRACE statements are ignored. It allows you to mark places in code that will cause the debugger to change modes between "step", "animate" and "run."  This allows you to use the "run" button to debug a program, and when it hits a "TRACE 2" command in the code, it will automatically drop down into "step" mode. See Using the Debugger.
 
There are three trace levels: 0, 1, and 2.  Here are the effects of these levels:
 
  0 = full speed no trace or RUN
  1 = animated trace or ANIMATE, logs variables and highlights current line
  2 = single step mode or STEP, requires programmer to click STEP button to continue to next line of code to execute, logs variables
 
When any Liberty BASIC program first starts under Debug mode, the trace level is always initially 2 (STEP).  You can then click on any of the buttons to determine what mode to continue in. When a TRACE statement is encountered, the trace level is set accordingly, but you can recover from this new trace level by clicking again on the desired button.
 
If you are having trouble debugging code at a certain spot, then you can add a TRACE statement (usually level 2) just before that location, run in Debug mode and then click on the RUN button in the debugger.  When the TRACE statement is reached, the debugger will kick in at that point, slowing the debugging process to STEP mode.
 
Usage:
 
  open "wave" for graphics as #graph
  print #graph, "down"
  for index = 1 to 200
      if index = 20 then trace 2  'Here is the trouble spot
    print #graph, "goto "; index ; " "; 100+int(100*sin(index/20))
  next index
  wait
 


Copyright (C) 2003 Shoptalk Systems
Liberty BASIC - http://www.libertybasic.com/