mIRC Home    About    Download    Register    News    Help

Print Thread
#203210 09/08/08 06:09 AM
Joined: Aug 2006
Posts: 183
T
Thrull Offline OP
Vogon poet
OP Offline
Vogon poet
T
Joined: Aug 2006
Posts: 183
Code:
Alias TestError {
  :error
  if $error != $null { echo -a An Error has occured: $error | halt }
  if X
  echo -a Script never gets this far.
}


Either the script isn't going to :error when an error occurs, and/or $error isn't being filled properly.


Yar
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
If you mean that "if X" doesn't cause mirc to jump to :error, this is because the former is placed after the error label. This is most probably by design (one reason for this is that if you example didn't have /halt, it would go into an infinite loop if :error worked like you're suggesting).


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Aug 2006
Posts: 183
T
Thrull Offline OP
Vogon poet
OP Offline
Vogon poet
T
Joined: Aug 2006
Posts: 183
Code:
Alias TestError {
  if X
  :error
  if $error != $null { echo -a An Error has occured: $error | halt }
  echo -a Script never gets this far.
}


The above does indeed work as qwerty explained. Let me paste something from the help file which is what led to my confusion.

Quote:
Error handling

Script errors can be caught by adding an :error goto point to your script. When an error occurs, the script will jump to :error and continue running. $error returns the error message.


I had assumed this worked like a normal /goto statement would. If this is indeed intended behavior, perhaps the help file could be updated to explain it? The help file currently makes it sound like it will jump either back or forward, not just forward.

Thanks for explaining that, qwerty.


Yar

Link Copied to Clipboard