FileYmdHms() Function errors

Started by vancewatkins, March 02, 2017, 07:58:14 AM

Previous topic - Next topic

vancewatkins

FROM = "Drive:\Folder\File_that_does_not_exist.txt"
TO = "Drive:\Folder\File_that_does_exist.txt"
IF FileYmdHms(FROM) > FileYmdHms(TO)
   RESULTS = FileCopy(FROM, TO, @False)
   IF !RESULTS
      Message("Error", "Copy Failed")
   ENDIF
ENDIF

The first problem I found was that the "IF FileYmdHms..." statement returns as True even though the FROM File does not exist.
The second problem I found during DEBUGGING, was that while the Results of the FileCopy does return False.
If I Change it to True and then continue running with the "IF !RESULTS" statement you will get an Error on the second ENDIF statement of 3357: End Error: No match found endif.
I am running Winbatch 2017A   

td

Quote from: vancewatkins on March 02, 2017, 07:58:14 AM
FROM = "Drive:\Folder\File_that_does_not_exist.txt"

Attempting to obtain the date of a non existent file causes  an 1152 error.  This causes the return value of the  FileYmdHms function to be undefined because the parser stops processing the line containing the error.  This also means that the "if" statement is not fully processed which is the cause of the subsequent "endif" structure error.

Quote
TO = "Drive:\Folder\File_that_does_exist.txt"
IF FileYmdHms(FROM) > FileYmdHms(TO)

"To" is a reserved word and treating it as a variable causes an 3362 fatal error.  The "3" at the beginning of an error number indicates that it is a sever (fatal) error.


There are several discussions of error handling  in the Consolidate WIL Help file and at the Tech Database website: 

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch+Two~Minute~Lecture~on~ErrorMode~No-Nos.txt

and

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+Tutorials+Trap~Errors.txt
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade