We receive orders throughout the day and those files go into a directory. Using FileInfoToArray ("*.*") I create an array and then sort it. The goal is to create a very brief report that simply summarizes number of orders by hour. To get it done I'm currently going row by row, extract the modified time and see if it's between hour 00:00 and 01:00, count those that are. Then hour 01:00 to 02:00, and on and on. Is there a way, using the array, to search for all of the between 00:00 and 01:00 or 01:00 and 02:00, etc. When we get up to 400 orders between 18:00 and 19:00 and so on this is pretty slow.
Is there a more efficient way to do this?
Fabricated RecordSet or import to a database?
Jim
I suggest one pass through the filearray totalling to a second array indexed by hour number. I'm guessing for 10K files, that might take half a second. The FileInfoToArray statement itself will take 10x longer than the totalling operation anyway, since it will be IO bound. Fortunately, you only have to do that once.
$0.02,
Kirby
Assuming that the array is sorted on the modify date column using ArraySort, the single pass approach should be relatively efficient.
even if it were not sorted, you could total into another array that is indexed by the hour number. that way, even if the files were in random order, after one pass, you would have all the totals.
for each file
h = hour number of this file
tarray[h] = tarray[h] + 1
next file
right? or am i missing something.
I don't think you missed anything. I am the one that missed something. ArraySort is very efficient and there are a few cute tricks that you can sometime use with ArraySearch on sorted arrays to avoid having to iterate tens of thousands of times ( it is no secret that WIL loops are big time time burners.) However, after a morning cup or three, it is apparent that having WIL dates in the targeted field throws a wrench into the whole idea unless you can make some fairly unrealistic assumptions about the file dates in those fields.
This problem does make a case for being able to perform linear wild card searches of arrays...