A special
condition isn??™t always an error; it??™s simply not complete success. In fact, you might expect an
application, batch file, or script to exit with a special condition. For an example of a command that
exits with special conditions, review the Choice command in the ???Using the Choice Command???
section of the chapter. Error conditions can represent a user, system, or application failure. For
example, consider the XCopy error levels shown in Table 5.5.
As you can see, the cause of an error varies greatly depending on conditions. In all cases, you
could rightfully say that the application has experienced an error. However, notice that error level
2 could actually occur by design. The user recognizes an error and presses Ctrl+C to stop the copying
process before it completes. In this case, you have to consider whether the error level defines a
special condition or an error by prompting the user and handle it appropriately. Listing 5.2 shows
examples of the various If statement forms at work. You can obtain this example on the Sybex Web
site at http://www.sybex.com/WileyCDA/.
Listing 5.2: Using the If Statement in Batch Files
Echo Off
REM Verify the user has provided an action.
Pages:
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388