Odd GetFileList behavior

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
alan1mtnview
Newbie
Posts: 19
Joined: Tue Jan 29, 2008 3:34 am
Location: Mtn View, Arkansas, USA
Contact:

Odd GetFileList behavior

Post by alan1mtnview » Tue Dec 21, 2010 4:40 pm

Happy Holidays, everybody!

As my gift to the forum, I have an oddity in GetFileList that I was hoping someone else could verify.

To see it:

1. create a new folder anywhere that you and MS have full access to. I created "Test" under %Temp_Dir%.

2. In that folder, create several sequentially-named files (1.txt, 2.txt, 3.txt, or A.txt, B.txt, C.txt, etc, etc, etc.) and put something in them simple to display, to verify that you are seeing the correct file. (If A.txt, I put in "1", "2" in B.txt, etc, to make sure that I wasn't seeing the file name rather than the file contents.)

3. Run a GetfileList on that dir, but as the delimiter, choose CRLF rather than the default ";"

4. Separate them by CRLF.

5. Create a "Repeat-Until" loop, straight out of the help file, that displays the file name and path in a MDL message each loop, but add a "Length" command to get the number of characters for each entry, and a "ReadFile" to show the file contents, and display that as well.

6. Here's the oddity: In the lowest-named file (displayed last by GetFileList), the Length is reported as being one character longer (with the assumption that all the file names were the same length to begin with.)

7. This only happens when I use CRLF as the delimiter, and only to the lowest-named file. If I use ";" the length reported is correct, and everything works as expected.

8. If I try to use the result of GetFileList for that lowest-named file as a path for ReadFile or ReadLn, it fails with ##NOFILE##.

Here's my demo code:

Code: Select all

GetFileList>%Temp_Dir%Test\*.txt,TestFiles,CRLF
Sep>TestFiles,CRLF,TestFilesList
Let>L=0
Repeat>L
    Let>L=L+1
    Len>TestFilesList_%L%,Len
    Let>FileName=TestFilesList_%L%
    ReadFile>%FileName%,FileContents      
Mdl>PathLength:%Len%%CRLF%Path:%FileName%%CRLF%FileContents:%FileContents%
Until>L=%TestFilesList_Count%

I'm a CRLF-user for EVERYTHING, and I'm not going to embarrass myself by admitting how much time I spent trying to figure out why I couldn't read certain files in my script... :oops:

I'm on Windows 7 x64, with MS Pro 12.1.2.

That's it.
If I'm missing something obvious, feel free to harass me-I deserve it.
Thanks to all!

Alan

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Dec 21, 2010 5:03 pm

I can confirm that I can reproduce this. It's obviously a bug. And appears to happen if the delimiter is made up of more than one differing character. So in your case CR and LF. You can see the issue more easily by using two different visible chars. E.g.:

GetFileList>%USERDOCUMENTS_DIR%\Test\*.txt,TestFiles,|^
Sep>TestFiles,|^,TestFilesList

So. We'll get it sorted in the next maintenance release.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
alan1mtnview
Newbie
Posts: 19
Joined: Tue Jan 29, 2008 3:34 am
Location: Mtn View, Arkansas, USA
Contact:

Re: Odd GetFileList behavior

Post by alan1mtnview » Tue Dec 21, 2010 8:52 pm

Ah. I have a blind spot where CRLF is concerned; I keep treating it as a single entity even when I know it's not. It never occurred to me to look at the behavior from a number-of-delimiters perspective. I was just relieved that I wasn't doing something dumb. :D

Thanks, and Merry Christmas, Marcus!
Thanks,
Alan

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Tue Dec 21, 2010 9:07 pm

Hi alan1mtnview,

Thanks for posting about this bug... and now we see it has been replicated and will soon be fixed. This improves MS for us all so as a way of saying thanks for taking the time and trouble to post about it, here's +2 reputation points...

...and if anyone else out there has a potential bug they have been meaning to post about... please do.

All the best of the season everyone and take care
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
alan1mtnview
Newbie
Posts: 19
Joined: Tue Jan 29, 2008 3:34 am
Location: Mtn View, Arkansas, USA
Contact:

Post by alan1mtnview » Tue Dec 21, 2010 11:12 pm

Thanks, jpuziano. That's nice of you, and I appreciate it.
I was on the fence about posting it, but just couldn't find anything that I had missed while testing.
Happy Holidays to You and Yours!
Thanks,
Alan

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