TR batch command sets ON or OFF value to environment variable TR.
Normally every batch command starts with "@ECHO OFF" to suppress batch tracing. When it is necessary to release tracing, OFF can be changed temporarily to ON, and then back to OFF, after debugging is over.
This process quickly becomes annoying when several linked batch commands are involved in processing. There is an old technique, to start every batch command with "@ECHO %TR%", which gives the ability to switch tracing OFF/ON easily by setting an appropriate value to the TR environment variable ("SET TR=ON" or "SET TR=OFF").
TR command used with the appropriate parameter can simplify this setting procedure (if parameter is omitted, tracing mode is toggled from the current one).
Demo of TR command operation can be found below the command text.
Note: | AUTOEXEC.BAT or AUTOEXEC.NT should contain command "SET TR=OFF" — Tracing is OFF. |
: TR Switch Batch Command Tracing Mode ON/OFF 01/07/1993-08/27/1999 : ------------------------------------------------------------------- : Copyright (C) 1993-1999 by Vladimir Veytsel www.davar.net : 1. Tracing mode manipulation parameter: : "?" or "/" - Display TR batch command text : "=" or "C" - Display current tracing mode : "0" or "OFF" - Switch tracing mode OFF : "1" or "ON" - Switch tracing mode ON : Other - Toggle current tracing mode OFF/ON : Note: AUTOEXEC.BAT or AUTOEXEC.NT should contain command : "SET TR=OFF" - Tracing is OFF @ECHO %TR% IF %1.==/. .OR. %1.==?. (LIST %_BATCHNAME ^ GOTO Finish) IF "%1"=="=" .OR. %@UPPER[%1].==C. GOTO Finish IF %1.==0. .OR. %@UPPER[%1].==OFF. (SET TR=OFF ^ GOTO Finish) IF %1.==1. .OR. %@UPPER[%1].==ON. (SET TR=ON ^ GOTO Finish) IFF %TR%.==OFF. THEN SET TR=ON ELSE SET TR=OFF ENDIFF :Finish @ECHO %S%%B%Batch command %C%tracing %B%mode is now %C%%TR%%D%
Tue 9/28/99 20:32 C:\> TR |
Batch command tracing mode is now ON |
Tue 9/28/99 20:33 C:\> TR |
IF %1.==/. .OR. %1.==?. (LIST %_BATCHNAME ^ GOTO Finish) IF "%1"=="=" .OR. %@UPPER[%1].==C. GOTO Finish IF %1.==0. .OR. %@UPPER[%1].==OFF. (SET TR=OFF ^ GOTO Finish) IF %1.==1. .OR. %@UPPER[%1].==ON. (SET TR=ON ^ GOTO Finish) IFF %TR%.==OFF. THEN SET TR=OFF Batch command tracing mode is now OFF |