Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: CrAz3D on December 29, 2003, 11:15 AM

Title: Something simple is wrong
Post by: CrAz3D on December 29, 2003, 11:15 AM
       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



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?
Title: Re:Something simple is wrong
Post by: Adron on December 29, 2003, 11:55 AM
Quote from: CrAz3D on December 29, 2003, 11:15 AM
       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


Any ideas on what I'm doing wrong?

You have two closes in a row for #4 there. Remove one of them!
Title: Re:Something simple is wrong
Post by: Adron on December 29, 2003, 12:01 PM
Quote from: CrAz3D on December 29, 2003, 11:15 AM

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

Any ideas on what I'm doing wrong?

The exit subs will cause the file to not be properly closed.
Title: Re:Something simple is wrong
Post by: CrAz3D on December 29, 2003, 12:04 PM
OK, I also didn't have a Close for #3, or which ever I was missing, can't remeber now though.