*----------------------------------------------------------------- * FUNCTION ASubDir(taArray, tcRoot) *----------------------------------------------------------------- * Return in an Array passed through reference all the all their * subdirectory and file names of the directory "tcRoot" * The names are of the form: [Drive]:\[Directory]\[File Name] * * RETURN: The number of archives in the Array. If it did not find * any file or the directory "tcRoot" does not exist, * returns 0 (zero)´ * AUTHOR: LMG * * EXAMPLE OF USE: * DIMENSION laMiArray[1] * lnC = ASubDir(@laMiArray, "C:\Program files") * FOR lnI = 1 to lnC * ? laMiArray[lnI] * ENDFOR *----------------------------------------------------------------- FUNCTION ASubDir(taArray, tcRoot) IF EMPTY(tcRoot) tcRoot = SYS(5) + CURDIR() ENDIF DIMENSION taArray[1] =ARecur(@taArray, tcRoot) IF ALEN(taArray) > 1 DIMENSION taArray[ALEN(taArray) - 1] RETURN ALEN(taArray) ELSE RETURN 0 ENDIF ENDFUNC *----------------------------------------------------------------- * FUNCTION ARecur(taArray, tcRoot) *----------------------------------------------------------------- * Recursive function called by ASubDir() *----------------------------------------------------------------- FUNCTION ARecur(taArray, tcRoot) PRIVATE lnI, lnCant, laAux tcRoot = ADDBS(tcRoot) lnCant = ADIR(laAux, tcRoot+"*.*", "D") FOR lnI = 1 TO lnCant IF "D" $ laAux[lnI, 5] IF laAux[lnI, 1] == "." OR laAux[lnI, 1] == ".." LOOP ELSE lcSubDir = tcRoot + laAux[lnI, 1] =ARecur(@taArray, lcSubDir) LOOP ENDIF ENDIF taArray[ALEN(taArray)] = tcRoot + laAux[lnI, 1] DIMENSION taArray[ALEN(taArray) + 1] ENDFOR RETURN ENDFUNC *-----------------------------------------------------------------