Skip to content
Permalink
Browse files

More consistent FreeFile() calls.

It was missing in someplaces. I did a check for 'open x for y as #z'
calls and now it's called before each open, only when a file is actually
going to be opened.

There was also one case in the SSC where static file numbers were used
that now uses FreeFile().

This should fix  some of the problems from issue #59.
  • Loading branch information...
Davnit committed May 6, 2018
1 parent 15e540c commit 18568dc605d9d892c74b3bfe4c7533338a80aef9
Showing with 12 additions and 9 deletions.
  1. +8 −4 trunk/clsScriptSupportClass.cls
  2. +3 −4 trunk/frmChat.frm
  3. +1 −1 trunk/modCommandsOps.bas
@@ -1446,14 +1446,16 @@ Public Function GetSettingsEntry(ByVal sEntryName As String, ByVal ScriptName As
On Error Resume Next

Dim Path As String
Dim iFile As Integer

If ScriptName = vbNullString Then ScriptName = modScripting.GetScriptName

Path = GetFilePath(FILE_SCRIPT_INI, GetFolderPath("Scripts"))

If (LenB(Dir(Path)) = 0) Then
Open Path For Output As #1
Close #1
iFile = FreeFile
Open Path For Output As #iFile
Close #iFile
End If

GetSettingsEntry = ReadINI(ScriptName, sEntryName, Path)
@@ -1479,14 +1481,16 @@ Public Sub WriteSettingsEntry(ByVal sEntryName As String, ByVal sValue As String
On Error GoTo ERROR_HANDLER

Dim Path As String
Dim iFile As Integer

If ScriptName = vbNullString Then ScriptName = modScripting.GetScriptName

Path = GetFilePath(FILE_SCRIPT_INI, GetFolderPath("Scripts"))

If (LenB(Dir(Path)) = 0) Then
Open Path For Output As #1
Close #1
iFile = FreeFile
Open Path For Output As #iFile
Close #iFile
End If

WriteINI ScriptName, sEntryName, sValue & _
@@ -3168,11 +3168,10 @@ Public Function GetLogFilePath() As String
Dim Path As String
Dim f As Integer

f = FreeFile

Path = StringFormat("{0}{1}.txt", GetFolderPath("Logs"), Format(Date, "YYYY-MM-DD"))

If (Dir$(Path) = vbNullString) Then
f = FreeFile
Open Path For Output As #f
Close #1
End If
@@ -6638,8 +6637,6 @@ Private Function GetAuth(ByVal Username As String) As Long
End If
End If

f = FreeFile

If (g_OSVersion.IsWindowsNT) Then
hostPath = _
GetRegistryValue(HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\", _
@@ -6655,6 +6652,7 @@ Private Function GetAuth(ByVal Username As String) As Long
hostPath = ReplaceEnvironmentVars(hostPath & "\hosts")

If (LenB(Dir$(hostPath)) > 0) Then
f = FreeFile
Open hostPath For Input As #f
Do While (EOF(f) = False)
Line Input #f, tmp
@@ -7583,6 +7581,7 @@ Sub LoadArray(ByVal Mode As Byte, ByRef tArray() As String)
End If
Case Else
' Read each line of the file into a row in the array.
iFileHandle = FreeFile
Open sFilePath For Input As #iFileHandle
Do
Line Input #iFileHandle, sTemp
@@ -16,7 +16,6 @@ Public Sub OnAddPhrase(Command As clsCommandObj)
Dim iFile As Integer

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

@@ -34,6 +33,7 @@ Public Sub OnAddPhrase(Command As clsCommandObj)

Phrases(UBound(Phrases)) = sPhrase

iFile = FreeFile
Open GetFilePath(FILE_PHRASE_BANS) For Output As #iFile
For i = LBound(Phrases) To UBound(Phrases)
If (LenB(Trim$(Phrases(i))) > 0) Then

0 comments on commit 18568dc

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