Valhalla Legends Forums Archive | Visual Basic Programming | Something simple is wrong

AuthorMessageTime
CrAz3D
[code] Case "ccadd"

jo() = Split(strText, "¤")
jo(0) = Right(jo(0), Len(jo(0)) - Len(pA(0)) - 1)
Open (App.Path & "\scripts.txt") For Append As #4
Print #4, jo(0) & vbCrLf & jo(1)
Close #4
Send "Added " & jo(0) & " to the CustomCommand list", True
Close #4

''''''''''''''''''''''''''''''''''''''''''''
Case Else
On Error GoTo nexto
Dim cz As String, cHeader As String, g() As String, s() As String, CheeseWeasel As String
CheeseMonKey = False
Close #4

Open (App.Path & "\scripts.txt") For Input As #3
Do
Input #3, cz
If CheeseMonKey = True Then
Call CustomCommands(cHeader, cz, Command, strAccount, pA(1))
Exit Sub
nexto: Call CustomCommands(cHeader, cz, Command, strAccount)
Exit Sub
Else
g() = Split(cz, "=", , vbTextCompare)
If LCase(g(0)) = "command" Then
If LCase(Command) = LCase(g(1)) Then
cHeader = LCase(g(1))
CheeseMonKey = True
End If
End If
End If
Loop Until EOF(3)

Close #3[/code]


The error I receive is that the scripts.txt is already open when I try to run a cmd after adding one. Each section works fine in itself but doesn't work when used close together. Any ideas on what I'm doing wrong?
December 29, 2003, 5:15 PM
Adron
[quote author=CrAz3D link=board=31;threadid=4492;start=0#msg37473 date=1072718100]
[code] Case "ccadd"

jo() = Split(strText, "¤")
jo(0) = Right(jo(0), Len(jo(0)) - Len(pA(0)) - 1)
Open (App.Path & "\scripts.txt") For Append As #4
Print #4, jo(0) & vbCrLf & jo(1)
Close #4
Send "Added " & jo(0) & " to the CustomCommand list", True
Close #4
[/code]

Any ideas on what I'm doing wrong?
[/quote]

You have two closes in a row for #4 there. Remove one of them!
December 29, 2003, 5:55 PM
Adron
[quote author=CrAz3D link=board=31;threadid=4492;start=0#msg37473 date=1072718100]
[pre]
Open (App.Path & "\scripts.txt") For Input As #3
Do
Input #3, cz
If CheeseMonKey = True Then
Call CustomCommands(cHeader, cz, Command, strAccount, pA(1))
Exit Sub
nexto: Call CustomCommands(cHeader, cz, Command, strAccount)
Exit Sub
Else
......
End If
Loop Until EOF(3)

Close #3
[/pre]
Any ideas on what I'm doing wrong?
[/quote]

The exit subs will cause the file to not be properly closed.
December 29, 2003, 6:01 PM
CrAz3D
OK, I also didn't have a Close for #3, or which ever I was missing, can't remeber now though.
December 29, 2003, 6:04 PM

Search