<% OpenBracketCount = 0 CloseBracketCount = 0 LineBracket = 0 QuotationMarks = 0 LineCount = 0 ErrorCount = 0 BlockErrorCount = 0 FirstPass = 0 OpenParenCount = 0 CloseParenCount = 0 LineParen = 0 sOutput = "" origscript = "" comment = 0 Function EventCheck If InStr(strLine,"event") = 1 Then arrEventCheck = Split(strLine," ") If arrEventCheck(0) = "event" Then FirstPass = FirstPass + 1 If FirstPass > 1 Then CloseCurrentBlock End If If UBound(arrEventCheck) = 1 Then CurrentBlock = arrEventCheck(1) sOutput = sOutput + "<----------| event " & CurrentBlock sOutput = sOutput + "
" End If End If End If End Function Sub BlockCheck If InStr(strLine, "block") = 1 Then arrBlockCheck = Split(strLine, " ") If arrBlockCheck(0) = "block" Then FirstPass = FirstPass + 1 If FirstPass > 1 Then CloseCurrentBlock End If If UBound(arrBlockCheck) = 1 Then CurrentBlock = arrBlockCheck(1) sOutput = sOutput + "<----------| block " & CurrentBlock sOutput = sOutput + "
" End If End If End If End Sub Sub CloseCurrentBlock If OpenBracketCount <> CloseBracketCount Then ErrorCount = ErrorCount + 1 BlockErrorCount = BlockErrorCount + 1 sOutput = sOutput + "" + CStr(BlockErrorCount) & "." & " " & "There are missing or extra brackets in this block:
" & _ " { = " & CStr(OpenBracketCount) & "
" & _ " } = " & CStr(CloseBracketCount) + "
" End If 'sOutput = sOutput + "
" OpenBracketCount = 0 CloseBracketCount = 0 QuotationMarks = 0 BlockErrorCount = 0 End Sub Function GetLine(strString) InStr() End Function Function In1(strIn, strFind) If (InStr(strIn, strFind) > 0) Then In1 = True End If End Function Function DoWarning(strString) ' & "ma_cexec_all has been deprecated by latest Mani versions. Use es_cexec_all or ma_cexec #all instead. sOutput = sOutput + "Warning: Line #" & CStr(LineCount) & ":" & vbTab & CStr(BlockErrorCount) & "." & vbTab + strString + "
" End Function Function DoError(strString) sOutput = sOutput + "Error: Line #" & CStr(LineCount) & ":" & vbTab & CStr(BlockErrorCount) & "." & vbTab + strString + "
" End Function Function StripComments(script) newscript = "" xlines = Split(script, vbCrLf) For i = LBound(xlines) to UBound(xlines) strLine = Trim(xlines(i)) comment = InStr(strLine, "//") If comment > 0 Then stripped = Trim(Mid(strLine, 1, comment-1)) if (Len(stripped) > 0) then newscript = newscript + Mid(strLine, 1, comment-1) + vbCrLf End If Else newscript = newscript + strLine + vbCrLf End If Next StripComments = newscript End Function script = Request.Form("script") if Len(script) > 0 then origscript = script 'Strip comments script = StripComments(script) sOutput = sOutput + "
Parsing... (results below)

" lines = Split(script, vbCrLf) For i = LBound(lines) to UBound(lines) strLine = lines(i) strLine = LTrim(strLine) LineCount = LineCount + 1 EventCheck BlockCheck If (OpenBracketCount = CloseBracketCount) AND Len(Trim(strLine))>0 And (InStr(strLine, "event")=0 And InStr(strLine, "block")=0 And InStr(strLine, "{")=0 And InStr(strLine, "}")=0) Then DoWarning("Unreachable code not in a block: " + Left(Trim(strLine),15) + " ...") 'Else 'Response.Write ("
"+strLine+"
o" + CStr(OpenBracketCount) + " c" + CStr(CloseBracketCount)) End If '85 If InStr(strLine, "{") > 0 Then OpenBracketCount = OpenBracketCount + 1 arrOpenBracket = Split(strLine, "{") LineBracket = LineBracket + UBound(arrOpenBracket) End If If InStr(strLine, "}") > 0 Then CloseBracketCount = CloseBracketCount + 1 arrCloseBracket = Split(strLine, "}") LineBracket = LineBracket + UBound(arrCloseBracket) End If If LineBracket > 1 Then ErrorCount = ErrorCount + 1 BlockErrorCount = BlockErrorCount + 1 sOutput = sOutput + "Line #" & CStr(LineCount) & ":" & vbTab & CStr(BlockErrorCount) & "." & vbTab & "More than 1 { or } on a single line.
" End If LineBracket = 0 If InStr(strLine, "(") > 0 Then OpenParenCount = OpenParenCount + 1 arrOpenParen = Split(strLine, "(") LineParen = LineParen + UBound(arrOpenParen) End If If InStr(strLine, ")") > 0 Then CloseParenCount = CloseParenCount + 1 arrCloseParen = Split(strLine, ")") LineParen = LineParen - UBound(arrCloseParen) End If If LineParen <> 0 Then ErrorCount = ErrorCount + 1 BlockErrorCount = BlockErrorCount + 1 If LineParen > 0 Then sOutput = sOutput + "Line #" & CStr(LineCount) & ":" & vbTab & CStr(BlockErrorCount) & "." & vbTab & "Missing " + CStr(LineParen) + " close parentheses.
" Else sOutput = sOutput + "Line #" & CStr(LineCount) & ":" & vbTab & CStr(BlockErrorCount) & "." & vbTab & "Too many (" + CStr(Abs(LineParen)) + ") close parentheses.
" End If End If LineParen = 0 'Warnings. 'ma_cexec_all If InStr(strLine, "ma_cexec_all") > 0 Then DoWarning("ma_cexec_all has been deprecated by latest Mani versions. Use es_cexec_all or ma_cexec #all instead.") End If If InStr(strLine, "eventscripts_noisy") > 0 Then DoWarning("eventscripts_noisy should rarely be referenced directly. See the corelib documentation for enabling/disabling it.") End If If InStr(strLine, chr(34)) Then arrQuotations = Split(strLine, chr(34)) QuotationMarks = QuotationMarks + UBound(arrQuotations) If QuotationMarks Mod 2 <> 0 Then ErrorCount = ErrorCount + 1 BlockErrorCount = BlockErrorCount + 1 sOutput = sOutput + "Line #" & CStr(LineCount) & ":" & vbTab & CStr(BlockErrorCount) & "." & vbTab & "Uneven amount of quotation marks.
" End If End If QuotationMarks = 0 Next CloseCurrentBlock Dim sColor if ErrorCount > 0 Then sColor = "red" Else sColor = "green" End if sOutput = sOutput + "
<----------------->" sOutput = sOutput + " Total Errors = " & CStr(ErrorCount) & "" sOutput = sOutput+ " <----------------->

" Response.Write(sOutput) end if %>

ScriptChecker by XE_ManUp and Mattie

This syntax checker scans for the following errors in your script addon syntax:

  1. Unclosed brackets
  2. Unclosed quotes
  3. Unclosed parentheses
  4. More than one bracket on a line
  5. Detection for some known deprecated commands
  6. Unreachable code

Paste your script below: