mIRC Home    About    Download    Register    News    Help

Print Thread
#240973 11/03/13 02:33 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
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?


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Jul 2006
Posts: 3,944
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,944
You are missing the /reseterror command


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #240976 11/03/13 03:13 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
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.

Last edited by sparta; 11/03/13 03:51 PM.

if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Jul 2006
Posts: 3,944
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,944
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.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #240992 12/03/13 10:18 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
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.


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
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.


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Oct 2012
Posts: 164
D
Vogon poet
Offline
Vogon poet
D
Joined: Oct 2012
Posts: 164
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. wink
Code:
alias sparta2 {
  noop
  :error
  if ($error) {
    echo -ag Error: [sparta2]
    reseterror
  }
}
The /reseterror command must come after you check for $error.

Deega #240998 12/03/13 08:58 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
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 smile


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }

Link Copied to Clipboard