File count returns one instead of zero

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
tony_smith
Pro Scripter
Posts: 70
Joined: Wed May 14, 2003 8:25 pm
Location: Vancouver BC Canada

File count returns one instead of zero

Post by tony_smith » Fri Dec 19, 2003 11:26 pm

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

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Dec 20, 2003 12:16 am

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?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
tony_smith
Pro Scripter
Posts: 70
Joined: Wed May 14, 2003 8:25 pm
Location: Vancouver BC Canada

Post by tony_smith » Wed Dec 24, 2003 3:20 pm

From support via email;

"This is a bug which has been fixed for the next maintenance release. We are working on other features at the moment and will release this update in the new year. In the mean time if you wish to test for no files just use the Length command to see if the file list is empty."

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts