mIRC Home    About    Download    Register    News    Help

Print Thread
#242442 14/07/13 01:28 AM
Joined: Jun 2013
Posts: 14
M
MarkyO Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Jun 2013
Posts: 14
I'm a little confused as to how :error operates and the help file isn't very specific.

How are :error's properly placed in your script?

Say you have multiple script files loaded. Each of them have multiple ON and alias events within them.

Do you place :error's within every ON event or alias? So that the :error catches the error that happens per event?

Or is it just once within each script and it's actually a sortof global goto call. Whenever there's an error it searches for the :error within the script?

MarkyO #242454 17/07/13 02:13 AM
Joined: Jun 2013
Posts: 14
M
MarkyO Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Jun 2013
Posts: 14
Anyone?

Anyone at all?

MarkyO #242455 17/07/13 03:39 AM
Joined: Mar 2004
Posts: 526
Fjord artisan
Offline
Fjord artisan
Joined: Mar 2004
Posts: 526
from help:

The on ERROR event triggers when an IRC Server sends an ERROR message, this usually occurs on a disconnection.

so its traps SERVER errors, not script errors, but the event must be coded in any script that wants to use it, it is NOT global if loaded in one script.


Help others! It makes the world a better place, Makes you feel good, and makes you Healthy!
HorseC #242457 17/07/13 06:49 AM
Joined: Jun 2013
Posts: 14
M
MarkyO Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Jun 2013
Posts: 14
This isn't the ON ERROR event.

It's using the :error goto for error handling.

MarkyO #242460 17/07/13 02:48 PM
Joined: Jun 2003
Posts: 81
T
TRT Offline
Babel fish
Offline
Babel fish
T
Joined: Jun 2003
Posts: 81
Originally Posted By: MarkyO
Do you place :error's within every ON event or alias? So that the :error catches the error that happens per event?


This.

MarkyO #242463 17/07/13 03:42 PM
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
You use :error to catch an error, once :error is reached after an error occured, you either use /reseterror to recover from the 'error state' and continue with the processing of the script, or you don't, and you use /return to propagate the error back to the previous function. That's the two use there are, if you don't use /reseterror and you don't use /return to propagate the error back, mIRC stays in an error state and, even though it seems it can keep going with processing the script, it won't do it properly, and this is exepected.
Here are the different possibilities:

1) Recovering
Code:
alias A {
B
echo -a A finished
}
alias B {
echo -a %variable
:error
 if ($error) {
  echo -a An error occured: $v1
  reseterror
 }
 echo -a B finished
}



2) Recovering from the previous function
Code:
alias A {
B
:error
if ($error) { 
  echo -a An error occured: $v1
  reseterror
 }
 echo -a A finished
}
alias B {
echo -a %variable
echo -a B finished
}


3) Recovering from the previous function with the actual function being 'aware' an error occured
Code:
alias A {
B
:error
if ($error) { 
  echo -a An error occured: $v1
  reseterror
}
echo -a A finished
}
alias B {
echo -a %variable
:error
if ($error) return
echo -a B finished
}
}


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard