I am using the following routine to extract file names from a directory. If the file count is zero, the macro should skip the file listing sub-routine and process another directory found at label>LOFILE.
Problem is that my test for the file count will always return one (FNCOUNT=1) when the directory is empty, when it should return zero. The file count not being zero allows the script to proceed the the file list sub-routine which fails because there is no file to list.
I inserted the two messageModal commands to see the count and a dump of the file names.
The dump of the file names displays a blank and the file list sub-routine returns an invalid file error.
Is this a bug, or am I doing something wrong?
------------------------------
Label>HDFILE
Let>HDFILES=V:\Data\FTP\HD\*.*
GetFileList>HDFILES,files
Separate>files,;,file_names
MessageModal>%HDFILES%%CRLF%Num Files: %file_names_count%
MessageModal>%files%
Let>FNCOUNT=%file_names_count%
If>FNCOUNT=0,LOFILE
Gosub>FileList
File count returns one instead of zero
Moderators: JRL, Dorian (MJT support)
- tony_smith
- Pro Scripter
- Posts: 70
- Joined: Wed May 14, 2003 8:25 pm
- Location: Vancouver BC Canada
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
I get the same results. This looks like a real bug to me.
If more than 0 files in the folder, result comes back correct. It only fails with 0 files.
When I single step through, I can see some "hidden" variables after running the Separate> command. There is a variable for each file name: FILE_NAMES_1, FILE_NAMES_2, etc.
And there is the variable FILE_NAMES_COUNT.
When there is one file, the file name is shown for FILE_NAMES_1 and FILE_NAMES_COUNT=1.
When there is no file, a blank value is shown for FILE_NAMES_1 and FILE_NAMES_COUNT=1.
At least, it looks blank. Perhaps it is a "null" which is making the count?
If more than 0 files in the folder, result comes back correct. It only fails with 0 files.
When I single step through, I can see some "hidden" variables after running the Separate> command. There is a variable for each file name: FILE_NAMES_1, FILE_NAMES_2, etc.
And there is the variable FILE_NAMES_COUNT.
When there is one file, the file name is shown for FILE_NAMES_1 and FILE_NAMES_COUNT=1.
When there is no file, a blank value is shown for FILE_NAMES_1 and FILE_NAMES_COUNT=1.
At least, it looks blank. Perhaps it is a "null" which is making the count?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
- tony_smith
- Pro Scripter
- Posts: 70
- Joined: Wed May 14, 2003 8:25 pm
- Location: Vancouver BC Canada