Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is there an alternative to ADIR()?
Message
De
30/04/2004 10:12:54
 
 
À
30/04/2004 07:40:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00899669
Message ID:
00899753
Vues:
27
Richard,

Quite funny, I run into the same issue a few days ago. After failing to convince the users to change their filing system, I had no choice but finding a replacment for ADIR() since the volume keeps increasing and the limitation of ADIR is actually *only* 13K files ;-)

I've looked at different solutions like mentioned by Hilmar and others. The problem with WSH and Filer is performance. The DOS DIR command is very fast, but the output is different depending the OS and it returns the 8.3 filename.

I finally used SYS(2000) as suggested by Hilmar. It's extremely fast and returns the long filenames. Here's the code:
*) Program...........: CDIR.PRG
*  Author............: Daniel Gramunt
*  Created...........: 22.04.2004 - 15:50:44 (Visual FoxPro 07.00.0000.9465)
*  Copyright.........: (c) Nokia, 2004
*) Description.......: Creates a cursor with files that match the specified
*)                   : file pattern. For performance reasons, we currently
*)                   : only return the filename. Could be enhanced to
*)                   : return other info if required, though it would be
*)                   : rather expensive in terms of performance.
*)                   : This method can be used to work around the array
*)                   : limitation of ADIR() when processing folders with
*)                   : more than 13K files.
*)                   : 
*  Calling Samples...:
*  Parameter List....:
*  Major change list.:
*--------------------------------------------------------------------------------------------------
LPARAMETERS tcFolder, tcFilePattern, tcCursor

ASSERT VARTYPE(tcFolder) = "C" AND DIRECTORY(tcFolder);
       MESSAGE "Parameter < tcFolder > : Parameter missing, wrong type or folder not found"
ASSERT VARTYPE(tcFilePattern) = "C";
       MESSAGE "Parameter < tcFilePattern > : Parameter missing or wrong type (Expecting 'C')"

LOCAL lcFolder, lcFilePattern, lcCursor, lcOldDir, lcFileName, lnFileCount

lcFolder = ADDBS(UPPER(ALLTRIM(tcFolder)))
lcFilePattern = IIF(VARTYPE(tcFilePattern) = "C", tcFilePattern, "*.*")
lcCursor = IIF(VARTYPE(tcCursor) = "C", tcCursor, "aFiles")

lcOldDir = SYS(5) + SYS(2003) 
SET DEFAULT TO (lcFolder)

CREATE CURSOR (lcCursor) (cJustPath C(254) , cJustFName C(254))
 
lcFileName = SYS(2000, lcFilePattern)
lnFileCount = 0

DO WHILE NOT EMPTY(lcFileName)
   IF LIKE(lcFilePattern, lcFileName)
      lnFileCount = lnFileCount + 1
      INSERT INTO (lcCursor) (cJustPath, cJustFName) VALUES(lcFolder, lcFileName)      
   ENDIF
   lcFileName = SYS(2000, lcFilePattern, 1)
ENDDO

SET DEFAULT TO (lcOldDir)

RETURN lnFileCount
*-- EOF CDIR.PRG ----------------------------------------------------------------------------------
>Hi guys,
> I have a program that gets the names of files store in a network directory and puts them in a dbf(table). Am using the function ADIR() to do so but if the records are more than 20,000, I get an error "Too many variables". Is there an alternative to doing so? This is the program :
>
>
>CLOSE DATABASES
>CLOSE TABLES ALL
>
>CREATE TABLE "C:\Documents and Settings\Rndivo.CRC\My Documents\s01A_img.DBF" (FILENUM C(30,0))
>CLOSE TABLES ALL
>
>gnIMAGEnumber = ADIR(gaImages, 'E:\Projects\SCANNED IMAGES\KiBS\01. Screening\01A - ANC Screening Forms\*.TIF')
>
>CLEAR
>USE "C:\Documents and Settings\Rndivo.CRC\My Documents\s01A_img.DBF" IN 1
>FOR nCount = 1 TO gnIMAGEnumber
> APPEND BLANK IN 1
> REPLACE s01A_img.FILENUM WITH gaImages(nCount,1)
>ENDFOR
>CLEAR ALL
>RELEASE ALL
Daniel
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform