Skip to content
Permalink
Browse files

Fix file reading logic in LoadArray()

Check for EOF before reading the first line. For some reason execution
was silently being stopped after the line input statement, which
resulted in the file handle not being closed.

Also remove missed comment from last commit.

I'm pretty sure this entirely fixes #59 now.
  • Loading branch information...
Davnit committed May 6, 2018
1 parent 81065b2 commit bd75fc1a5d7156a2aa24cb229c36dc04229eb647
Showing with 9 additions and 9 deletions.
  1. +9 −8 trunk/frmChat.frm
  2. +0 −1 trunk/modCommandsOps.bas
@@ -7580,16 +7580,17 @@ Sub LoadArray(ByVal Mode As Byte, ByRef tArray() As String)
Next i
End If
Case Else
' Read each line of the file into a row in the array.
iFileHandle = FreeFile

' Read each line of the file into a row in the array.
Open sFilePath For Input As #iFileHandle
Do
Line Input #iFileHandle, sTemp
If LenB(sTemp) > 0 Then
tArray(UBound(tArray)) = sTemp
ReDim Preserve tArray(UBound(tArray) + 1)
End If
Loop While Not EOF(iFileHandle)
Do While Not EOF(iFileHandle)
Line Input #iFileHandle, sTemp
If LenB(sTemp) > 0 Then
tArray(UBound(tArray)) = sTemp
ReDim Preserve tArray(UBound(tArray) + 1)
End If
Loop
Close #iFileHandle
End Select

@@ -15,7 +15,6 @@ Public Sub OnAddPhrase(Command As clsCommandObj)
Dim i As Integer
Dim iFile As Integer

' grab free file handle
If (Command.IsValid) Then
sPhrase = Command.Argument("Phrase")

0 comments on commit bd75fc1

Please sign in to comment.
You can’t perform that action at this time.