mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2013
Posts: 81
I
Iire Offline OP
Babel fish
OP Offline
Babel fish
I
Joined: Aug 2013
Posts: 81
This may well be seen as a very minor and somewhat insignificant feature request, but I figured I'd suggest it anyway... grin

Would it be possible to alter the behavior of the :error label such that:
  1. it can be considered valid to use { } / braces with it to open a new scope, and
  2. the script engine would simply ignore the command (or (potentially unconditional) { }-enclosed block of commands) that immediately follow(s) it?


(In other words, to be able to do something like:
Code
alias testerror {
  !echo -ga $1-
  :error {
    ; maybe a bit... "hacky", but allows the value of $error
    ; to be seen by the user before /reseterror clears it...
    !reseterror $input( $error , doh , Error: )
    !return 
  }
}
...without the script engine executing the error handling bits when no error actually occurs?)

The reason I ask is because it seems a bit redundant to have to explicitly check if $error contains a value every time the :error label is used, since that label is, itself, intended to mark the branch the engine should take if a scripting error does occur. Of course, the value of $error could still be checked if need be (say, to perform different error handling routines depending on the type of error), but for basic error handling, I feel like it shouldn't be necessary to do so.

I realize that there is a risk that this change could potentially break scripts, and so I'd understand if it couldn't be implemented because of that... at the same time, however, I would also wonder how or why someone would be (mis)using :error in a way that implementing this would cause an issue in the first place.

(On a related side-note, since this change would require that a copy of the value of $error be manually created before /reseterror is called if one wishes to make use of its previously stored message, perhaps an identifier like $lerror could be added to handle this automatically as well..?)

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
I think it's difficult to argue for it as a requirement, because this would not offer you something you can't already do easily, and even for multiple error handling I don't see it helping. But I like the idea.
Specifically, $error is already behaving the way you want so your suggestion
Code
alias testerror {
  !echo -ga $1-
  :error {
    ; maybe a bit... "hacky", but allows the value of $error
    ; to be seen by the user before /reseterror clears it...
    !reseterror $input( $error , doh , Error: )
    !return 
  }
}
is equivalent to what you can already do currently:
Code
alias testerror {
  !echo -ga $1-
  :error
  if ($error) {
    !reseterror $input( $error , doh , Error: )
    !return 
  }
}
Saving only one line of code for each :error statement (and a check for $error but it would eventually happen later in that { } part and isn't annoying to do, pretty standard stuff in fact))which is usually one per routine, is that really worth it confused


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

Link Copied to Clipboard