Now that you know the file exists, the batch file can process it. This batch file provides two options:
displaying the file and deleting it. The problem with batch files is that they use case-sensitive string
comparisons??”the word delete is different from the word Delete so error trapping can cause false
problems. Some developers resolve this problem by using single character command line switches
for batch files. That way, all you need to do is perform two checks, one for uppercase and another for
lowercase. The example uses a full word for the purpose of demonstration. To see how this works,
type Delete at the command line instead of delete??”the code displays a failure message. When
the user does type delete, the batch file erases the file and displays a success message. Likewise,
when the user types display, the code sends the content of MyFile.TXT to the display. In both
cases, the code goes to TheEnd where the batch file turns Echo back on.
So far, the chapter has discussed the standard form of the If command that you can execute
even at the DOS prompt. The If command has the following additional syntax forms when you use
command line extensions.
Pages:
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392