Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with array to find files

Status
Not open for further replies.

button71

Programmer
Nov 8, 2006
69
AU
I have found the following code

But I want the full number of columns in the original to be added to the final array - rather than just the fname

Code:
=ADIR(aryTemp,"*.*","AHRSD",1)
logging('GetSomeFiles folder '+cDirectory)

nMax = ALEN(aryTemp,1)
FOR nCount = 1 TO nMax
	cFile = ALLTRIM(aryTemp(nCount,1))
	
	IF !(cFile == ".") AND !(cFile == "..")
		IF "D" $ aryTemp(nCount,5)
		ELSE
			nLen = ALEN(aryParam)
			IF !EMPTY(aryParam(nLen))
				DIMENSION aryParam(nLen + 1)
				nLen = nLen + 1
			ENDIF
			aryParam(nLen) = cDirectory + cFile
		ENDIF
	ENDIF
ENDFOR

Anyone help please?

William
 
My apologies

the code is

Code:
LOCAL ARRAY aryTemp(1,5)
LOCAL nCount, nMax, nLen, cFile
SET DEFAULT TO (cDirectory)
readpwini(inifile,'write','Paths','SearchPath',curdir() )
=ADIR(aryTemp, "*.*","AHRSD",1)
logging('GetSomeFiles folder '+cDirectory)
nMax = ALEN(aryTemp,1)
FOR nCount = 1 TO nMax
	cFile = ALLTRIM(aryTemp(nCount,1))
	
	IF !(cFile == ".") AND !(cFile == "..")
		IF "D" $ aryTemp(nCount,5)
		ELSE
			nLen = ALEN(aryParam)
			IF !EMPTY(aryParam(nLen))
				DIMENSION aryParam(nLen + 1)
				nLen = nLen + 1
			ENDIF
			aryParam(nLen) = cDirectory + cFile
		ENDIF
	ENDIF
ENDFOR

ENDFUNC

I am trying

Code:
IF !EMPTY(aryTemp(nLen))
				DIMENSION aryParam[(nLen + 1),5]
				nLen = nLen + 1
			ENDIF
			aryParam(nLen,1) = aryTemp (nLen,1)
			aryParam(nLen,2) = aryTemp (nLen,2)
			aryParam(nLen,3) = aryTemp (nLen,3)
			aryParam(nLen,4) = aryParam (nLen,4)
			aryParam(nLen,5) = aryParam (nLen,5)

but get an error - subscript out of range

William

 
Code:
*** I dont know what cDirectory is But try this:

=Adir(aryTemp,"*.*","AHRSD",1)
logging('GetSomeFiles folder '+cDirectory)
Dimension aryparam[1,5]
nMax = Alen(aryTemp,1)
For nCount = 1 To nMax
	cFile = Alltrim(aryTemp(nCount,1))
	cFile1 = Alltrim(aryTemp(nCount,2))
	cFile2 = Alltrim(aryTemp(nCount,3))
	cFile3 = Alltrim(aryTemp(nCount,4))
	cFile4 = Alltrim(aryTemp(nCount,5))
	If Not Inlist(cFile.".","..") And "D" $ aryTemp(nCount,5)
		nLen = Alen(aryparam,1)
		aryParam(nLen,1) = cDirectory + cFile
		aryParam(nLen,2) = cDirectory + cFile1
		aryParam(nLen,3) = cDirectory + cFile2
		aryParam(nLen,4) = cDirectory + cFile3
		aryParam(nLen,5) = cDirectory + cFile4
		Dimension aryParam(nLen+1,5)
	Endif
Endfor

Again: this is to give you an idea, you will have to fine tune
 
May be you can just use ACOPY() to copy all 5 elements at once.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top