I have one folder which holds the PDF files for calculated W2 forms.
Each file name starts with the client code, which is 3 character.
The listed files in folder looks like this (part of listing):
A27_0154_USW2_4CR_1231.PDF
A27_0154_USW2_4CR_1231.PDF
A28_0154_USW2_4CR_1231.PDF
A28_0154_USW2_4CR_1231.PDF
A29_0154_USW2_4CR_1231.PDF
A29_0154_USW2_4CR_1231.PDF
A29_0154_USW2_4CR_1231.PDF
A29_0154_USW2_4CR_1231.PDF
A29_0154_USW2_4CR_1231.PDF
A29_0154_USW2_4CR_1231.PDF
A24_0154_USW2_4CR_1231.PDF
A24_0154_USW2_4CR_1231.PDF
A24_0154_USW2_4CR_1231.PDF
A24_0154_USW2_4CR_1231.PDF
A29_0154_USW2_4CR_1231.PDF
A24_0154_USW2_4CR_1231.PDF
...
The folder name is for example: cFind := "c:\pdffiles\W2forms\"
The client code I want to extract: cUserID := "A29"
When I want to extract only the PDF files which starts with client code for example "A29" I do it like this
af1 := cFind + cUserID + "*.PDF"
aMyFiles := DIRECTROY( af1 )
I expect in "aMyFiles" array all PDF files which name starts with "A29"
On my huge surprise the array contains something like tihs, after I made some debug breakpoint:
I cannot even think to explain how this happened???
This error cause me a lot of problems, I simply cannot relay on DIRECTORY() function any more. If some clients can see some other clinets W2 forms, I can close my business in the payroll area.... So I disabled for now this feature.
I tested this behaviour and select another user ID, for example "A24" and it shows all A24 but also some of A29 and A27... And so forth.
For some user ID it shows ok, only what I select to be the USer ID....
I can't find any pattern, maybe the length of file names??
For now I will "filter" this wrong results
- Code: Select all Expand view
FOR := 1 to LEN(aMyFiles)
IF UPPER(SUBS(aMyFiles[i][1],1,3) == UPPER(cUserID)
- use this element (file) for workig with
ENDIF
NEXT i
which is not I ever dreamed of as necessary after the DIRECTORY() function call...
Not to mention it took me almost 10 days of hard tries to find out what causes the list to be "mixed" with different user ID PDF files. Finally, I was desperate and checked what exactly comes out as the result of DIRECTORY() function. It is not enaugh to say I was astonished..
Any similar experiences?
I am totaly confused...