Printer Version Table of Contents Project Home Page
.APPENDIX....: Fdate's Error Handling
.DISCUSSION..:
If Fdate detects an error:

(1) it will return an errorlevel of 1 (rather than 0), and

(2) its output will be 3 lines:

If Fdate output is displayed directly, or redirected to NUL, you can detect an error by testing the errorlevel for a value of 1.

If Fdate output is piped to an environment manipulation utility such as STRINGS or GET, the environment variable will be set to ERROR. Errorlevel will be set by STRINGS/GET, and will probably be 0. In such a case, the only way to detect an error is to test the environment variable for the value ERROR.

If Fdate output is redirected to a batch file, which is then CALLed to set an environment variable, the batch file will:

You can detect an error by testing errorlevel for the value 1 either before or after you CALL the batch file, or by testing the environment variable for the value ERROR, AFTER you have CALLed the batch file.

.EXAMPLE.....:
   rem use Fdate to check validity of year in parm %1
   Fdate /Fv /Imm-dd-ccyy /ATT-TT-%1 > nul
   if errorlevel 1 echo Year parm [%1] is not valid.
   if errorlevel 1 goto endit

.EXAMPLE.....:
   rem use GET with Fdate, to put Fdate output into %year%
   Fdate /Ff /Imm-dd-ccyy /ATT-TT-%1 /Occyy | GET ZE /V%year% >nul
   if (%year%)==(ERROR) echo Year parm [%1] is not valid.
   if (%year%)==(ERROR) goto endit

.EXAMPLE.....:
   rem use a batch file with Fdate, to put Fdate output into %year%
   Fdate /Ff /Imm-dd-ccyy /ATT-TT-%1 /Occyy /P"@set year=">junktemp.bat
   call junktemp.bat
   del  junktemp.bat
   if errorlevel 1 echo Year parm [%1] is not valid.
   if errorlevel 1 goto endit