mIRC Homepage

on Error Resume next?

Posted By: arctangent

on Error Resume next? - 05/05/05 12:55 AM

hey guys, i need help on recovering from an error. See this code:
Code:
 
/test {
  var %m = $lines(t.txt),%i = 1
  fopen t t.txt
  while (%i <= %m) {
    var %l = $fread(t)
    echo -s %i = %l
    :nxt
    inc %i
  }
  fclose t
  return
  :error
; i assume that d only error would be a 'line too long'
  echo -s line too long: %i
  goto nxt
}
 

i intentionally put a 999-char line in t.txt. i need for the alias to keep going with the loop after printing an error msg

thnx in advance wink
Posted By: MikeChat

Re: on Error Resume next? - 05/05/05 01:53 AM

you can't mix the loop types like that
the goto nxt will never work as that loop has already exited
you dont need to fopen the file
Quote:

/test {
var %m = $lines(t.txt),%i = 1
while (%i <= %m) {
echo -s %i = $read(t.txt,%i)
inc %i
}
}


you should see an error msg if there is one for line too long anyway
Posted By: arctangent

Re: on Error Resume next? - 05/05/05 02:07 AM

uhm.. thnx for the input, but i think u misunderstood me blush my problem is this:

when an error occurs (in this case, a 'line too long..') it HALTS the script. in the case of the alias i posted above, the loop doesnt get to finish /echo'ing the whole file. what i need is to be able to carryout the rest of the loop even if it encounters and error. (something like VBs' On Error Resume Next statement wink)

side note: /fopen & $fread makes things up A WHOLE LOT FASTER than using $read. wink
Posted By: IR_n00b

Re: on Error Resume next? - 05/05/05 02:43 AM

i assume that
/test {
var %m = $lines(t.txt),%i = 1
fopen t t.txt
while (%i <= %m) {
var %l = $fread(t)
echo -s %i = %l
goto finish
:error
echo -s line too long: %i
:finish
inc %i
}
fclose t
return
}
would work smile
Posted By: arctangent

Re: on Error Resume next? - 05/05/05 02:51 AM

sorry man, tried it, but doesnt work smirk
the echo -s Error .. part doesnt even trigger.
Posted By: IR_n00b

Re: on Error Resume next? - 05/05/05 03:59 AM

lets make somthing creative..

/test {
var %m = $lines(t.txt),%i = 1
fopen t t.txt
while (%i <= %m) {
var %l = $fread(t)
echo -s %i = %l
goto finish
:error
echo -s line too long: %i
:finish
inc %i
}
fclose t
return
}

goes to:
/test {
var %m = $lines(t.txt),%i = 1
fopen t t.txt
:loop
while (%i <= %m) {
var %l = $fread(t)
echo -s %i = %l
inc %i
}
goto close
:error
echo -a Error: /var line to long: %1
goto loop
:close
fclose t
return
}
Posted By: arctangent

Re: on Error Resume next? - 05/05/05 04:28 AM

Hey! Great job! ;D Works great! i did have to squeeze in an
inc %i so that the count goes up properly, but damn does it work! ;D thnx a million ;D
© 2020 mIRC Discussion Forums