Colleagues:
Have anyone ever encountered the following:
ADIR(SomeArray, SomePath, "D"
returns number of rows greater than the array actually holds - or so it seems?
I have the following function in my program to determine if the given directory is empty:
Now, this thing has been working perfectly on all directories at all customers' - until today: one customer calls and says he's getting an error #31, "Invalid subscript reference" from this function. He tried it on another directory - no problem.
Hard as I tried, I could not reproduce this behavior.
I even created the same directory on my machine. I even made some or all files in that directory invisible - every time this function returned correct result whether I added "H" clause to the 3rd parameter (counted hidden files) or not (skipped the hidden files).
Any clue?
Thanks!
Regards,
Ilya
Have anyone ever encountered the following:
ADIR(SomeArray, SomePath, "D"
I have the following function in my program to determine if the given directory is empty:
Code:
******************************************************************************************************************************
FUNCTION IsEmptyDir(tcDir)
******************************************************************************************************************************
** Function Name : Is Empty Dir
** Purpose : Verifies if the given directory is empty.
** Description : Checks presence of any files and/or subdirectories in the given directory by running ADIR() and checking
** the contents of the resulting array. If there's anything in the first cell in any array's row different
** from "." and ".." - directory is not empty.
** Parameter(s) : Directory in ? as string.
** Return : "Empty" flag as Boolean.
** Side Effect(s): None.
** Notes: : 1. Silent function.
** 2. It's assumed that the path/dir existence has been already verified by the calling subroutine.
******************************************************************************************************************************
LOCAL lnMax, I, llRet
LOCAL ARRAY laDir[1]
llRet = .T. && Initially
tcDir = ADDBS(ALLTRIM(tcDir))
lnMax = ADIR(laDir, tcDir + "*.*", "D")
FOR I = 1 TO lnMax
IF !(laDir[I, 1] == "." .OR. laDir[I, 1] == "..") && Skipping reference to the tcDir itself
llRet = .F.
EXIT && FOR...NEXT CYCLE
ENDIF
NEXT I
RETURN llRet
ENDFUNC
******************************************************************************************************************************
Now, this thing has been working perfectly on all directories at all customers' - until today: one customer calls and says he's getting an error #31, "Invalid subscript reference" from this function. He tried it on another directory - no problem.
Hard as I tried, I could not reproduce this behavior.
I even created the same directory on my machine. I even made some or all files in that directory invisible - every time this function returned correct result whether I added "H" clause to the 3rd parameter (counted hidden files) or not (skipped the hidden files).
Any clue?
Thanks!
Regards,
Ilya