mIRC Homepage
haltdef on error. - 11/03/13 02:33 PM
I trying to remove file, but on error i want to echo the error to active window, and hide it from the status window. befor i could use this code.

(path\to\file is set up right, the file is used by mirc, thats why i get the error)
Code:
alias test {
.remove $qt(path\to\file)) :error if (* /remove: unable to remove isin$error) { haltdef | echo -a File could not be deleted. }
}


But now when i trying to use it again it show in the status window:

* /remove: unable to remove 'path\to\file'

What do i miss here?
Re: haltdef on error. - 11/03/13 02:49 PM
You are missing the /reseterror command
Re: haltdef on error. - 11/03/13 03:13 PM
Did not help, i get nothing from $error, it should display a error message, but it display nothing. Any options in mirc that need to be enabled? ;-- edit I noticed somthing strange, if i using a command that dont exist, then it dont display a error message, can you halt the display of the errors somhow? I dont have a alias called "error" so that should not be the the problem. Will try to update from 7.27 to 7.29 and see if that helps. ;-- Edit 1 more time. Testing in a clean mirc, no scripts loaded, there it using the :error, but haltdef would not halt the error message in status window. And now im 100% shure nothing i did doint somthing funny. Re: haltdef on error. - 11/03/13 08:54 PM I should have elaborated a bit sorry. When you use :error, it jumps to that point when a scripting error occurs; but calling a non existing command while connected to a server will send that command to the server, obviously.From that point, it's not a scripting error, you will eventually get a raw 421 reply from the server "/thecommand unknown command". /haltdef has nothing to do with it either, /haltdef let you halt the default behavior mirc will use in a certain situation, /haltdef is only useful inside an event using the ^ prefix, you should use /halt otherwise. /reseterror lets you recover from an error, if you don't use it, the scripting engine will try to find another :error goto point by going backward in the chain call (if alias1 call alias2 and you catch an error in alias2 without using /reseterror, it will jump to an eventual :error in alias1), if no :error is found, it behaves as usual, halting with an error displayed. Use /reseterror if you want to hide the error message. Re: haltdef on error. - 12/03/13 10:18 AM Hmm, now i got it to hide the error msg, but it always return it. Even when it was able to delete the file, so still a no go. Any more ideas? Code: alias testing { .remove$qt($+($logdir,test,.log))
:error
reseterror
echo -a File could not be deleted.
}


The file test.log will be removed, and if i userstand it right the :error will only be used if a error occur? $error return nothing. Re: haltdef on error. - 12/03/13 04:37 PM Found out what the problem are, i have a alias for echo, if i remove that alias he code working. But what do echo have to do with a$error ?
Code:
echo {
if ($left($1,2) == -q) { !.echo -q $2- | return } !echo$utfdecode($1-) }  Made this since i want to be able to use å-ä-ö in mirc. Re: haltdef on error. - 12/03/13 05:36 PM Originally Posted By: sparta if i userstand it right the :error will only be used if a error occur?$error return nothing.
Not exactly, ":error" is just a goto label (mIRC jumps to it automatically if there is an error) but like any goto label, if the script doesn't /return before it reaches that point, whatever follows will still be executed.

For example, this will echo the error line even though there is obviously no error
Code:
alias sparta1 {
noop
:error
echo -ag Error: [sparta1]
reseterror
}
This time because we check that there is an error, it won't.
Code:
alias sparta2 {
noop
:error
if ($error) { echo -ag Error: [sparta2] reseterror } } The /reseterror command must come after you check for$error.
Re: haltdef on error. - 12/03/13 08:58 PM
But how come the echo alias i use halt the error? If i have it i will not get the error, if i remove my alias i get the error. And then im able to halt the default message. Cant understand what that have to do with anything. Tested with my alias, and the \$error return nothing, removing my echo alias and it display as it should. And i dont alter the echo that much, only make it possible to use å-ä-ö, and i need that since i echo away messages to a @window, and i dont want to make a totaly new echo and rename it, so is it possible to get it to work?

Thnx for the explanation by the way