Do Until EOF(filenum) generates type mismatch at end of file

Hi there,

I’m having problems reading a text file with lotusscript. First, I’m creating a text file with an external process, then I’m reading the text file in like this:

Open resultfile For Input As resultfilenumber

count = 0

Do Until Eof(resultfilenumber)

Line Input #resultfilenumber, ResultLine

If count = 0 Then

Redim resultarray(0)

resultarray(0) = ResultLine

count = count + 1

Else

Redim Preserve resultarray((Ubound(resultarray)+1))

resultarray(Ubound(resultarray)) = ResultLine

count = count + 1

End If

Loop

When it gets to the end, I get a “Type Mismatch” error. I opened the text file in Word to see what kind of formatting there is, and I see the “Carriage Return” character at the end of each line, as well as one on a line by itself at the bottom of the file.

What am I doing wrong? After searching the forums, it doesn’t seem like this is a common problem…

Thanks in advance,

Scott

Subject: Do Until EOF(filenum) generates type mismatch at end of file

Hey Scott, I have been using the code below to retrieve large text files and it has been working under heavy use without incident. HTH.

countTotal = 1

izFile% = Freefile()

'file has been retreived, proceed

Open fileName$ For Input As izFile%

'here, we populate a dynamic array with each line from the text file

Do Until Eof(1)	

	Line Input #1, text$

	If text$ <> "" Then

		Redim Preserve arrWhole(countTotal)

		arrWhole(countTotal - 1) = Fulltrim(text$)

		countTotal = countTotal + 1

	End If

Loop

Close izFile%

Subject: RE: Do Until EOF(filenum) generates type mismatch at end of file

Thanks for the response. I found that the code was actually bombing on “close resultfile” which should have been “close resultfilenumber”

Regards,

Scott

Subject: RE: Do Until EOF(filenum) generates type mismatch at end of file

Which serves you right for not using Option Declare.