Commodore‎ > ‎BASIC‎ > ‎Keywords‎ > ‎

TRON

Keyword Abbreviation Token (hex) Version(s) Classification
TRON TR{Shift+O} D8 3.5, 7.0 Command and Statement
RENAME RE{Shift+N}  D8  4.x  Command and Statement 

  Syntax  
TRON
 
  Purpose  
Debugging; enable program tracing.

 
  Remarks  
TRON turns on program tracing.  Attempting to supply an argument to TRON will generate SYNTAX ERROR.
 
When tracing is active, each statement exectuted in a BASIC program line will print the text "[line#]" (without quotes) to the current output device (usually the active video display screen; but see CMD).  This is usefull to follow or verify the sequence of instructions executed by BASIC; particularly helpfull to debug complex IF/THEN/ELSE, ON...GOTO/GOSUB, or DO/EXIT/LOOP statements.
 
However tracing can rapidly fill up the screen with [line#] messages and makes reading text of normal CHAR / PRINT commands difficult.  In (non-split-screen) bitmap modes, the line number messages are usually not visible (an exception is possible with two monitors on the C128).
 
For IF/THEN/ELSE, the IF keyword (which evaluates a condition) always causes a line# message to be printed.  THEN never generates a line# message.  ELSE will generate a line# message when it acts like REM (that is, when the IF condition was true and the THEN clause was executed).  When the IF condition is false (i.e., the ELSE clause is selected) there will be no line# message corresponding to ELSE (similar to THEN).
 
Note that the implied GOTO forms of THEN/ELSE never print a line# message.  BEGIN never generates a line# message because it is a preposition to THEN/ELSE.  BEND will generate a line# message when it ends an active BEGIN (i.e., it is acting like REM and is similar to ELSE), but BEND will not generate a message when BASIC is simply searching for a BEND (matching a previous BEGIN) in order to find an ELSE clause.
 
Commands entered in direct mode will not generate a line# message, even when tracing is turned on.  Statements in a program which are skipped also do not print a line# message.
 
TROFF is normally used to turn off program tracing.  The NEW command also turns off tracing, presumably to hide the fact that it changes the secret variable Text Pointer to the first line of the (just deleted) program.
 
Example:
10 IF 1 THEN PRINT "TRUE" : ELSE PRINT "FALSE"
TRON : RUN
[10][10]TRUE          first is for IF, nothing for THEN, second is for PRINT
[10]                  this is for ELSE (acts like REM)
READY.

10 IF 0 THEN PRINT "TRUE" : ELSE PRINT "FALSE"
RUN
[10][10]FALSE         first is for IF, nothing for THEN/ELSE, second is for PRINT

READY.
10 IF 1 THEN 20 : ELSE PRINT"FALSE"
20 END
RUN
[10][20]              [10] is for IF, nothing for implied GOTO
                      the ELSE was skipped by GOTO, [20] is for END
READY.
 
  Compare With  
 
  Contrast With  
 
  See Also  
AUTO, CMDELELSEHELPIF, THEN

© H2Obsession, 2014
Comments