Author Topic: FileYmdHms() Function errors  (Read 1947 times)


  • Newbie
  • *
  • Posts: 1
FileYmdHms() Function errors
« on: March 02, 2017, 07:58:14 am »
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)
      Message("Error", "Copy Failed")

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   


  • Tech Support
  • *****
  • Posts: 3985
    • WinBatch
Re: FileYmdHms() Function errors
« Reply #1 on: March 02, 2017, 08:57:46 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.

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:

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade