A batch file can also include debugging information,
even though there aren??™t specific statements to perform the task. The following code shows
one method you can use.
@IF NOT DEFINED DEBUG @ECHO OFF
ECHO
@ECHO ON
In this case, the debug trigger is an environment variable named DEBUG. You can set this environment
variable to any value desired by using the Set command. Type Set DEBUG= and press
Enter to turn off debugging. The purpose of this debugging statement is to keep echo on when
you??™re debugging the batch file. During the debugging cycle, you want to see all of the statements,
so you display them by keeping the echo on. When the batch file runs normally, the user won??™t have
an environment variable named DEBUG, and the batch file turns off echo so the user doesn??™t see all
of the intervening commands. Using the ECHO command by itself displays the current echo state so
you can easily test this technique for yourself.
Notice that the batch file doesn??™t include anything special for the @ECHO ON statement. It??™s bad
practice to use conditional statements with commands that set the system back to a default state. In
this case, you can set echo on without considering the current echo state because having echo on is
the default setting.
Pages:
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401