Importing multiple text files

I am missing something here. I have a folder that has several text files. Each one will be used to create a doc in a Notes db.I open the first one, input the data and write the record. Then, I go to the next text file. But, the open does not work. Here is some relevent code.

On Error Resume Next

fileNum% = Freefile()



pathName$ = "/opt/lotus/challenger/TUCC/IFP/*"

FilePath$ = "/opt/lotus/challenger/TUCC/IFP/"

fileName$ = Dir$(pathName$, 0)



Do While fileName <> ""

	FName = FilePath$ & FileName		

	Call rtitem.AppendText(FName)

	Call rtitem.AddNewLine( 1 )			

	Call rtitem.AppendText("fileNum% " & Str(fileNum%))

	Call rtitem.AddNewLine( 1 )			

	Open FName For Input As fileNum%	

	

	ImportData = Input$(1000, fileNum% )	

	Do Until EndfoFile = "Y"

		CNT = CNT + 1

		If CNT > 10 Goto NextFile

		Call rtitem.AppendText(ImportData)



                    If RecType = "090" Goto NextFile



		ImportData = Input$(1000, fileNum% )	

’ End If ’ ACD = A

	Loop

NextFile:

	EndofFile = "N"		

’ Call ODoc.Save(True, False)

	fileName$ = Dir$()

	fileNum% = Freefile()

	ItemNbr = 0

	

Loop

There is other code not written here.

The email I receive shows all the processing. It shows that the variable ImportData does not change from the last record in the first file. I have moved the close around to no avail. The fileNum stays at 2 after the first file is completed. So it appears that the second text file is not opening. The filename is changing, so I know that the loop is correctly finding the next text file.

Subject: RE: Importing multiple text files

You don’t seem to be closing the first file. I don’t know why Freefile wouldn’t return you a different number since the first number it returned is no longer free, but you certainly can’t open another file with the same number if the first one is still open.