Advertisement
JeffryUGP

[jTool] Alle Befehle auslesen

Sep 11th, 2014
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '-------------------------------------------------------------------------'
  2. '                                                                         '
  3. '                     [jTool] - Alle Befehle auslesen                     '
  4. '                           j_cmdsAusgeben.vbs                            '
  5. '                                                                         '
  6. '                         Version 1.1 - 11.12.2014                        '
  7. '                                                                         '
  8. '                                © Jeffry                                 '
  9. '                                                                         '
  10. '-------------------------------------------------------------------------'
  11.  
  12.  
  13. Set fs = CreateObject("Scripting.FileSystemObject")
  14. pfad = fs.GetParentFolderName(Wscript.ScriptFullName)
  15.  
  16. If(fs.FileExists(pfad & "\AlleBefehle.txt")) Then
  17.     Set wFile = fs.OpenTextFile(pfad & "\AlleBefehle.txt", 8)
  18.     wFile.WriteLine ""
  19.     wFile.WriteLine ""
  20. Else
  21.     Set wFile = fs.CreateTextFile(pfad & "\AlleBefehle.txt", True)
  22. End If
  23.  
  24. wFile.WriteLine "----" & CStr(Now) & "----"
  25. cmds = 0
  26.  
  27. Set sDir = fs.getfolder(pfad)
  28. For Each file In sDir.Files
  29.     If(LCase(Right(file.path, 4)) = ".pwn") Then
  30.    
  31.         Set rFile = fs.OpenTextFile(file.path, 1)
  32.         blockcomment = false
  33.        
  34.         Do While rFile.AtEndOfStream <> true
  35.             str = ""
  36.             str = rFile.ReadLine
  37.             If(InStr(str, "*/") And blockcomment = true) Then blockcomment = false
  38.            
  39.             If(blockcomment = false) Then
  40.                 comment = InStr(str, "//")
  41.                 bcomment = InStr(str, "/*")
  42.                 ccomment = InStr(str, "*/")
  43.                 If(bcomment <> 0 And ccomment = 0) Then comment = bcomment
  44.                
  45.                 tmp = InStr(str, "dcmd_")
  46.                 If(tmp And (comment > tmp Or comment = 0) And (ccomment < tmp Or bcomment > tmp) And (bcomment > tmp Or bcomment = 0)) Then
  47.                     If(InStr(tmp, str, "),") = 0 And InStr(tmp, str, ");") = 0 And InStr(str, "#define") = 0) Then
  48.                         tmpstr = Mid(str, tmp+5, InStr(tmp, str, "(")-(tmp+5))
  49.                         wFile.WriteLine "/" & tmpstr
  50.                         cmds = cmds + 1
  51.                     End If
  52.                 End If
  53.                
  54.                 tmp = InStr(str, "ocmd:")
  55.                 If(tmp And (comment > tmp Or comment = 0) And (ccomment < tmp Or bcomment > tmp) And (bcomment > tmp Or bcomment = 0)) Then
  56.                     tmpstr = Mid(str, tmp+5, InStr(tmp, str, "(")-(tmp+5))
  57.                     wFile.WriteLine "/" & tmpstr
  58.                     cmds = cmds + 1
  59.                 End If
  60.                    
  61.                 tmp = InStr(str, "ocmd@")
  62.                 If(tmp And InStr(tmp+1, str, ":") = (tmp+6)) Then
  63.                     again = true
  64.                     start = InStr(tmp+1, str, ":")
  65.                     Do While again <> false
  66.                         again = false
  67.                         If(tmp And (comment > tmp Or comment = 0) And (ccomment < tmp Or bcomment > tmp) And (bcomment > tmp Or bcomment = 0)) Then
  68.                             If(start And InStr(start+1, str, ",") < InStr(start+1, str, "(")) Then
  69.                                 tmpstr = Mid(str, start+1, InStr(start+1, str, ",")-(start+1))
  70.                                 wFile.WriteLine "/" & tmpstr
  71.                                 cmds = cmds + 1
  72.                                 again = true
  73.                             Else
  74.                                 If(start) Then
  75.                                     tmpstr = Mid(str, start+1, InStr(start+1, str, "(")-(start+1))
  76.                                     wFile.WriteLine "/" & tmpstr
  77.                                     cmds = cmds + 1
  78.                                 End If
  79.                             End If
  80.                         End If
  81.                         start = InStr(start+1, str, ",")
  82.                     Loop
  83.                 End If
  84.                
  85.                 tmp = InStr(str, "YCMD:")
  86.                 If(tmp And (comment > tmp Or comment = 0) And (ccomment < tmp Or bcomment > tmp) And (bcomment > tmp Or bcomment = 0)) Then
  87.                     tmpstr = Mid(str, tmp+5, InStr(tmp, str, "(")-(tmp+5))
  88.                     wFile.WriteLine "/" & tmpstr
  89.                     cmds = cmds + 1
  90.                 End If
  91.                
  92.                 if(tmp = 0) Then
  93.                     tmp = InStr(str, "CMD:")
  94.                 Else
  95.                     tmp = 0
  96.                 End If
  97.                 If(tmp And (comment > tmp Or comment = 0) And (ccomment < tmp Or bcomment > tmp) And (bcomment > tmp Or bcomment = 0)) Then
  98.                     tmpstr = Mid(str, tmp+4, InStr(tmp, str, "(")-(tmp+4))
  99.                     wFile.WriteLine "/" & tmpstr
  100.                     cmds = cmds + 1
  101.                 End If
  102.                
  103.                 tmp = 0
  104.                 again = true
  105.                 Do While again <> false
  106.                     tmp = InStr(tmp+1, str, "strcmp(cmd")
  107.                     If(tmp) Then start = InStr(tmp, str, """")
  108.                     again = false
  109.                     If(tmp And (comment > tmp Or comment = 0) And (ccomment < tmp Or bcomment > tmp) And (bcomment > tmp Or bcomment = 0)) Then
  110.                         If(InStr(tmp, str, "/") = (start+1)) Then
  111.                             tmpstr = Mid(str, start+2, InStr(start+1, str, """")-(start+2))
  112.                             wFile.WriteLine "/" & tmpstr
  113.                             cmds = cmds + 1
  114.                             again = true
  115.                         End If
  116.                     End If
  117.                 Loop
  118.                
  119.                 tmp = 0
  120.                 again = true
  121.                 Do While again <> false
  122.                     tmp = InStr(tmp+1, str, "strcmp(""/")
  123.                     If(tmp And InStr(tmp+1, str, "cmd")) Then start = InStr(tmp, str, """")
  124.                     again = false
  125.                     If(tmp And (comment > tmp Or comment = 0) And (ccomment < tmp Or bcomment > tmp) And (bcomment > tmp Or bcomment = 0)) Then
  126.                         If(InStr(tmp, str, "/") = (start+1)) Then
  127.                             tmpstr = Mid(str, start+2, InStr(start+1, str, """")-(start+2))
  128.                             wFile.WriteLine "/" & tmpstr
  129.                             cmds = cmds + 1
  130.                             again = true
  131.                         End If
  132.                     End If
  133.                 Loop
  134.                
  135.                 If(InStr(str, "/*") And InStr(str, "*/") = 0 And blockcomment = false) Then blockcomment = true
  136.                
  137.             End If
  138.         Loop
  139.        
  140.         rFile.Close()
  141.        
  142.     End If
  143. Next
  144.  
  145. wFile.close()
  146.  
  147. If(cmds > 0) Then
  148.     MsgBox "Es wurden " & cmds & " Befehle gefunden und gespeichert."
  149. Else
  150.     MsgBox "Es wurden keine Befehle gefunden."
  151. End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement