Results 1 to 3 of 3

Thread: program wont write to file

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    12

    program wont write to file

    im attempting to make a program that will examine each line from a server log on my counter strike source server, and write to another text file everything an admin does...

    here is an example of a server log:

    Code:
     
    
    L 04/23/2006 - 16:51:18: [SBSRC] Player with ID  was checked recently, ignoring.
    L 04/23/2006 - 16:51:19: "†AiDeN†<304><STEAM_0:0:8268692><Unassigned>" joined team "CT"
    L 04/23/2006 - 16:51:19:  Admin [-'TbC| Bang.] [STEAM_0:1:8215145] Executed :  ma_givecash : Player [-'TbC| Bang.] [STEAM_0:1:8215145] had [800] cash, now has [16000] cash
    L 04/23/2006 - 16:51:19: [MANI_ADMIN_PLUGIN] Admin [-'TbC| Bang.] [STEAM_0:1:8215145] Executed :  ma_givecash : Player [|TAG|=>Ownerer Noobe^[Owners]] [STEAM_0:1:397838] had [30] cash, now has [16000] cash
    the 4th line is an example of what i want written, in this case, the admin gave everyone $16000, the line is identified as an admin command by the program by detecting the"[MANI_ADMIN_PLUGIN]" text heild within... but for some reason, with the code ive made, it will not print to the second file

    VB Code:
    1. Private Sub Form_Load()
    2. Dim tmp() As String
    3. Dim splittmp As String
    4. Dim printtofile1 As String
    5. End Sub
    6.  
    7. Private Sub command1_Click()
    8.  
    9. Dim tmp() As String
    10. Open "c:\L0423004.txt" For Input As #1
    11. Open "c:\l0423004-admin.txt" For Output As #2
    12.      tmp = Split(Input(LOF(1), 1), vbCrLf)
    13. Close #1
    14. For x = 0 To UBound(tmp)
    15.  
    16. splittmp = Split(tmp(x), " ")
    17.  
    18.         If Manicheck1 = True Then
    19.        
    20.             If splittmp(4) = "[MANI_ADMIN_PLUGIN]" Then
    21.            
    22.                 printtofile1 = tmp(x) & vbNewLine
    23.                 Print #2, printtofile1
    24.                 printtofile1 = ""
    25.                
    26.             End If
    27.            
    28.         End If
    29.        
    30. Close #2
    31.  
    32. Next
    33.    
    34. MsgBox " Finished. "
    35.  
    36. End Sub
    any idea whats wrong?

  2. #2
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: program wont write to file

    try this:
    you had some things out of order...

    VB Code:
    1. Dim tmp() As String
    2.     Open "c:\L0423004.txt" For Input As #1
    3.         tmp = Split(Input(LOF(1), 1), vbCrLf)
    4.     Close #1
    5.     Open "c:\l0423004-admin.txt" For Output As #2
    6.         For x = 0 To UBound(tmp)
    7.             splittmp = Split(tmp(x), " ")
    8.             If Manicheck1 = True Then
    9.                 If splittmp(4) = "[MANI_ADMIN_PLUGIN]" Then
    10.                     printtofile1 = tmp(x) & vbNewLine
    11.                     Print #2, printtofile1
    12.                     printtofile1 = ""
    13.                 End If
    14.             End If
    15.         Next
    16.     Close #2
    17.     MsgBox " Finished. "
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    12

    Re: program wont write to file

    Tried your code, l0423004-admin.txt was empty

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width