|
Joined: May 2003
Posts: 2,265
Hoopy frood
|
OP
Hoopy frood
Joined: May 2003
Posts: 2,265 |
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
|
|
|
|
Joined: Jan 2003
Posts: 249
Fjord artisan
|
Fjord artisan
Joined: Jan 2003
Posts: 249 |
It found 13 more } than { eheh
Looking at the script rapidly I do not see anything wrong.
|
|
|
|
Joined: May 2003
Posts: 2,265
Hoopy frood
|
OP
Hoopy frood
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
|
|
|
|
Joined: Dec 2002
Posts: 29
Ameglian cow
|
Ameglian cow
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
|
|
|
|
Joined: May 2003
Posts: 2,265
Hoopy frood
|
OP
Hoopy frood
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
|
|
|
|
Joined: May 2003
Posts: 2,265
Hoopy frood
|
OP
Hoopy frood
Joined: May 2003
Posts: 2,265 |
the problem was it was evaluating the text, heh. just in case anybody wants it :\
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
|
|
|
|
Joined: Jun 2003
Posts: 67
Babel fish
|
Babel fish
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 }
|
|
|
|
Joined: May 2003
Posts: 2,265
Hoopy frood
|
OP
Hoopy frood
Joined: May 2003
Posts: 2,265 |
i already fixed it, thanks though.
new username: tidy_trax
|
|
|
|
Joined: May 2003
Posts: 2,265
Hoopy frood
|
OP
Hoopy frood
Joined: May 2003
Posts: 2,265 |
now im having another problem 
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:
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  ?
new username: tidy_trax
|
|
|
|
|