mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 417
O
Othello Offline OP
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Dec 2002
Posts: 417
I am making a script to scan for common errors within a script
I know the most common erros of missed placed (), [], }} [color:black] and [color:red] {{

Does anyone have any other suggestions of common errors within
a script outside of miss spelled variables?




Intelligence: It's better to ask a stupid question, then to prove it by not asking....
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Not using = in /var

Joined: Dec 2002
Posts: 417
O
Othello Offline OP
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Dec 2002
Posts: 417
I agree with yeah on that one....
Let me post what I have....
Then I can use all the good input to compile a script




Intelligence: It's better to ask a stupid question, then to prove it by not asking....
Joined: Dec 2002
Posts: 417
O
Othello Offline OP
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Dec 2002
Posts: 417
Ok this is what I have come up with so far. Everything seems
to be working fine. What I am looking for is more input as to
enhancing the script.

Code:
  [color:red]
menu status,channel, {
Brackets Checker: brackets
}
menu @Brackets {
  Check Script: { 
    clear @Brackets
    brackets
  }
}


 [color:blue] 
alias Brackets {
  if (@$window(@Brackets)) { window -k0 @Brackets }
  titlebar @Brackets Right click to select file
  if ($?!="Check a specific file?") {
    set %t.file $dir $mircdir 
    var %t.n = 1, %t.pe = 0, %t.ebe = 0, %t.be = 0, %t.be1 = 0, %t.be2 = 0
    titlebar @Brackets Scanning $nopath(%t.file) $+ ...
    while (%t.n <= $lines(%t.file)) {
      titlebar @Brackets Scanning $nopath(%t.file) line %t.n
      var %t.line = $read -nl $+ %t.n %t.file
      if $count(%t.line,$chr(40)) != $count(%t.line,$chr(41)) && $left(%t.line,1) != $chr(59) {
        inc %t.pe
        echo @Brackets $tclr1 (ERROR) $tclr2 mismatch (parentheses) in4 $nopath(%t.file) 12on line:4 %t.n
        aline -p @Brackets $replace($strip(%t.line,bruc),$chr(40),$+(4,$chr(40),1),$chr(41),$+(4,$chr(41),1))
      }
      if $count(%t.line,$chr(91)) != $count(%t.line,$chr(93)) && $left(%t.line,1) != $chr(59) {
        inc %t.ebe
        echo @Brackets $tclr1 [ERROR] $tclr2 mismatch [evaluation brackets] in2 $nopath(%t.file) 12on line:4 %t.n
        aline -p @Brackets $replace($strip(%t.line,bruc),$chr(91),$+(4,$chr(91),1),$chr(93),$+(4,$chr(93),1))
      }
      if $count(%t.line,$chr(123)) { inc %t.be1 1 }
      if $count(%t.line,$chr(125)) { inc %t.be2 1 }
      if ($+($chr(123),$chr(123)) isin %t.line) || ($+($chr(125),$chr(125)) isin %t.line) {
        inc %t.be
        echo @Brackets $tclr1 {ERROR} $tclr2 mismatch [brackets] in2 $nopath(%t.file) 12on line:4 %t.n
        aline -p @Brackets $replace(%t.line,$+($chr(123),$chr(123)),$+(4,$+($chr(123),$chr(123)),1),$+($chr(125),$chr(125)),$+(4,$+($chr(125),$chr(125)),1))
      }
      inc %t.n
    }
    echo @Brackets 4* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    echo @Brackets 4*12 Finished checking4 %t.n 12lines in2 $script $+ 4.
    if (%t.pe != 0) { echo @Brackets 4* ( $+ %t.pe $+ ) 12parentheses error(s) found. } 
    if (%t.ebe != 0) { echo @Brackets 4* $chr(91) $+ %t.ebe $+ $chr(93) 12evaluation bracket error(s) found. }
    if (%t.eb != 0) { echo @Brackets 4* $chr(123) $+ %t.be $+ $chr(125) 12bracket error(s) found. }
    if %t.be1 > %t.be2 { echo @Brackets 4* $chr(123) $+ $calc(%t.be1 - %t.be2) $+ $chr(123) 12possible errors of too many4 $chr(123) 12in $script } | else { echo @Brackets 4* $chr(125) $+ $calc(%t.be2 - %t.be1) $+ $chr(125) 12possible errors of too many4 $chr(125) 12in $script }
    }  
    echo @Brackets 4* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    titlebar @Brackets Scan Complete...
    unset %t.*
    halt
  }
  titlebar @Brackets Scan Aborted...
  unset %t.*
}
alias -l tclr1 { return 04,00 }
alias -l tclr2 { return 12,00 }
 [/color] 


  [/color]  




Intelligence: It's better to ask a stupid question, then to prove it by not asking....
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Another thing that can cause problems is not putting a space after { or before }. It doesn't happen often, but it can cause frustration when trying to find the problem.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard