mIRC Home    About    Download    Register    News    Help

Print Thread
parenthesis error script #47088 04/09/03 03:20 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
Code:
alias isloaded {
  var %d 1,%script $1,%result
  while (%d <= $script(0)) {
    if ($nopath($script(%d)) == %script) {
      %result = 1
    }
    inc %d
  }
  return $iif(%result,%result,0)
}
alias getpath {
  var %i 1,%script $1,%result
  while (%i <= $script(0)) {
    if ($nopath($script(%i)) == %script) {
      %result = $+(",$script(%i),")
    }
    inc %i
  }
  return $iif(%result,%result,0)
}
alias error {
  var %g 1
  var %file $1
  var %file.path $getpath(%file)
  var %error 0
  if (!$isloaded(%file)) { return $1 Is Not Loaded }
  while (%g <= $lines(%file.path)) {
    if ($+(*,$chr(123),*) iswm $read(%file.path,%g)) {
      inc %error $count($read(%file.path,%g),$chr(123))
    }
    if ($+(*,$chr(125),*) iswm $read(%file.path,%g)) {
      dec %error $count($read(%file.path,%g),$chr(125))
    }
    inc %g
  }
  return %error
}

that script is supposed to increase a variable called "%error" when a { is found, then decrease it when a } is found, i used it on a file with NO errors, it returned "-13", anyone have any ideas how the hell it returned this?


new username: tidy_trax
Re: parenthesis error script #47089 04/09/03 03:23 PM
Joined: Jan 2003
Posts: 249
C
ClickHeRe Offline
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
It found 13 more } than { eheh

Looking at the script rapidly I do not see anything wrong.

Re: parenthesis error script #47090 04/09/03 03:26 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
it "half" works, it returns -12 if there is an error, -11 if there are 2, etc etc


new username: tidy_trax
Re: parenthesis error script #47091 04/09/03 03:45 PM
Joined: Dec 2002
Posts: 29
N
Nem3sis Offline
Ameglian cow
Offline
Ameglian cow
N
Joined: Dec 2002
Posts: 29
you problem is maybe that somewhere in the script u might have something to the effect of

If (%r0ar == bigabob) { echo -a thisisanexample} }

it would then increase %error by 1 and then decrease %error incorrectly by 2

just a suggestion

although to avoid this and other similar problems it would be rather difficult and u would have masses of if's unless u used a regex

Re: parenthesis error script #47092 04/09/03 03:47 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
like i said, the file had no errors, so even if it did find 1 of them in the file, it should of been corrected later on...


new username: tidy_trax
Re: parenthesis error script #47093 04/09/03 07:45 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
the problem was it was evaluating the text, heh.
just in case anybody wants it :\
Code:
alias isloaded {
  var %i 1,%file $1,%loaded 0
  while (%i <= $script(0)) {
    if ($nopath($script(%i)) == %file) {
      %loaded = 1
    }
    inc %i
  }
  return %loaded
}
alias getpath {
  var %i 1,%file $1,%path 0
  while (%i <= $script(0)) {
    if ($nopath($script(%i)) == %file) {
      %path = $script(%i)
    }
    inc %i
  }
  return %path
}
alias winerr {
  var %x 1,%file $1
  window -h @error
  while (%x <= $lines($+(",$getpath(%file),"))) {
    aline @error $strip($read($+(",$getpath(%file),"),n,%x))
    inc %x
  }
}
alias error {
  var %g 1,%error 0,%file $1, %error.line
  if (!$isloaded(%file)) || (!$getpath(%file)) { return * $!error $+ : Invalid Parameters }
  winerr %file
  while (%g <= $line(@error,0)) {
    if (%error == 0) { %error.line = $calc(%g - 1) }
    if (*{* iswm $line(@error,%g)) { inc %error }
    if (*}* iswm $line(@error,%g)) { dec %error }
    inc %g
  }
  window -c @error
  return $iif(%error,%error - %error.line,%error)
}


new username: tidy_trax
Re: parenthesis error script #47094 04/09/03 09:02 PM
Joined: Jun 2003
Posts: 67
D
demitrix Offline
Babel fish
Offline
Babel fish
D
Joined: Jun 2003
Posts: 67
%x = $count(stuff here,{)
%y = $count(stuff here,})
if {%x == %y) {
no error
}
else if (%x != %y) {
error
}
)


while (demi == nub) {
inc %skill
}
Re: parenthesis error script #47095 04/09/03 09:16 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
i already fixed it, thanks though.


new username: tidy_trax
Re: parenthesis error script #47096 04/09/03 09:35 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
now im having another problem frown
Code:
alias isloaded {
  var %i 1,%file $1,%loaded 0
  while (%i <= $script(0)) {
    if ($nopath($script(%i)) == %file) {
      %loaded = 1
    }
    inc %i
  }
  return %loaded
}
alias getpath {
  var %i 1,%file $1,%path 0
  while (%i <= $script(0)) {
    if ($nopath($script(%i)) == %file) {
      %path = $script(%i)
    }
    inc %i
  }
  return %path
}
alias winerr {
  var %x 1,%file $1
  window -h @error
  while (%x <= $lines($+(",$getpath(%file),"))) {
    aline @error $strip($read($+(",$getpath(%file),"),n,%x))
    inc %x
  }
}
alias error {
  var %g 1,%error 0,%file $1,%t 1
  if (!$isloaded(%file)) || (!$getpath(%file)) { return * $!error $+ : Invalid Parameters }
  if (!$dialog(error)) { dialog -m error error }
  unset %error.line.*
  did -r error 1
  winerr %file
  while (%g <= $line(@error,0)) {
    if (*{* iswm $line(@error,%g)) { inc %error }
    if (*}* iswm $line(@error,%g)) { dec %error }
    if (%error > 1) && (*{* !iswm $line(@error,%g)) && (*on*{* iswm $line(@error,$calc(%g - 1))) || (*alias*{* iswm $line(@error,$calc(%g - 1))) { set %error.line. [ $+ [ $calc(%g - 2) ] ] $calc(%g - 2) }
    inc %g
  }
  if (%error) {
    did -a error 1 %error Errors $chr(123)
    while (%t <= $var(%error.line.*,0)) {
      if (%t) && (%t < $calc($line(@error,0) + 1)) { did -a error 1 $str($chr(160),2) Line: $eval($var(%error.line.*,%t),2) } 
      inc %t
    }
    did -a error 1 $chr(125)
  }
  else {
    did -a error 1 No Errors Found In $+(",%file,[,$getpath(%file),],")
  }
  window -c @error
  did -z error 1
}
dialog error {
  title "Parenthesis Error Catcher"
  size -1 -1 177 77
  option dbu
  list 1, 0 13 177 64, size hsbar vsbar
  edit "", 2, 0 3 60 10
  button "Check", 3, 61 2 37 11
}
on *:dialog:error:close:0:{
  unset %error.line.*
}
on *:dialog:error:sclick:3:{
  error $did(2)
}
menu menubar,channel,status {
  Parenthesis Checker: dialog -m error error
}

im trying to find the line the error was on..
this is the code for it:
Code:
    if (%error > 1) && (*{* !iswm $line(@error,%g)) && (*on*{* iswm $line(@error,$calc(%g - 1))) || (*alias*{* iswm $line(@error,$calc(%g - 1))) { set %error.line. [ $+ [ $calc(%g - 2) ] ] $calc(%g - 2) }

any ideas laugh?


new username: tidy_trax