Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Element Order in ADIR

Status
Not open for further replies.

SGLong

Programmer
Jun 6, 2000
405
0
0
US
I have a series of files that I'm loading into an array using ADIR (currently the file names are 79420-005MS29AL_0001.TXT, 79420-005MS29AL_0002.TXT, and 79420-005MS29AL_0003.TXT). Once loaded into the array I need to process them. By design there is 'header information' in file #1 (_0001.TXT), but for some reason the ADIR command occasionally puts them in some order other than name ascending. Currently the files are in reverse order (3,2,1), but I have had 2,1,3 and 2,3,1. The file date/time stamps are in ascending order by 1,2,3 and even the file sizes are ascending order by 1,2,3. The obvious solution is to ASORT the array, but why should I need to?

Steve
 
SGLong

The obvious solution is to ASORT the array, but why should I need to?

Because ASORT will give you a consistant result?


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Why are you assuming that VFP should populate the ADIR array in name ascending order? It doesn't say that in the documentation.

Mike Krausnick
Dublin, California
 
Just because they may show up in name ascending order in say Explorer, that doesn't mean they are physically placed on the hard drive in any particular order other than the order they were created.
Now if one of them gets deleted then recreated, depending on the files' size, it may get recreated in the location it was originally or it may get created at the end of the list.


-Dave S.-
[cheers]
Even more Fox stuff at:
 
Mike K - You're right - it doesn't say that in the documentation - it doesn't say anything about retrieval order. It's just that until the past week I haven't had any issues since the application launched over 5 months ago and all of a sudden something changed and I started getting files "out of sequence". The only thing that's changed is we've done some Windows updates lately (both Pre-Blaster and Post-Blaster).

I've put the the ASORT into place because that way I can ensure the proper sequence...
 
As a general rule in any database-style work, unless an order is explicitly stated, never expect the results to be in the order you want them to be. Even if you've run it a million times and it always worked the same way, you still should explicitly sort the results.

Ian
 
It would appear that the file names are static. Why not just dimension an array and then populate the array with the files in the order you wish. You don't even have to be stuck with name order.

Just a thought - the order change is not random - there has to be a reason. Have you been sorting the directory in windows? I haven't tried testing it, but you may find that the directory is displayed in creation date order.
 
TheMissionary:
Just a thought - the order change is not random - there has to be a reason. Have you been sorting the directory in windows? I haven't tried testing it, but you may find that the directory is displayed in creation date order.

I've thought of that... I tried playing with the folder view options and didn't notice anything different.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top