Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ADIR optimization
Message
De
13/08/2001 14:01:13
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00542818
Message ID:
00543157
Vues:
21
I am very sorry Nadya, I posted a reply before it was tested fully. The ultimate result was functional but it was not as "clean" as others posted here, so I deleted it before I got eaten by the code sharks ;>


>Glenn,
>
>Excuse me, what did you say? :)
>
>>>>>I am using ADIR to get a specific number of files from a directory based on a criteria. So, ADIR(laFile,gcFat+'thread\*.*') will create an array and I can now use ALEN(laFile,1) to get the file count. However, on big directory this is causing a big array to be created just to get the number of files. How can I optimize that?
>>>>
>>>>Michel,
>>>>As Nadya posted, ADir() oes return the number of rows in the array. But as you already sigthed, the array still gets built and this could a significant amount of time on large directories. It could also fail on very large directories because of the 65000 element limit of arrays.
>>>>
>>>>You can use the old Sys(2000) function.
>>>>local lxx, lcfile
>>>>lxx = 0
>>>>lcfile = sys(2000,gcFat+'thread\*.*')
>>>>do while !(lcfile=='')
>>>>   lcfile = sys(2000,gcFat+'thread\*.*',1)
>>>>   lxx = lxx + 1
>>>>enddo
>>>>
>>>>If you only need the count, this should give you what you want.
>>>
>>>I tried it and it works well.
>>>
>>>However, it would be nice is the FileSystemObject would allow that in one command.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform