mIRC Homepage
Posted By: hixxy Break command halted addition - 01/12/05 03:15 AM
I think it would be great if all resources created in an alias you break out of are freed when you break out of it using the pause/break key (file handles, com objects, etc).
Posted By: NaquadaServ Re: Break command halted addition - 01/12/05 07:44 PM
You can already do that...
Code:
alias testerr {
  set %~blah1 123
  echo -a $gettok(ONLY ONE ARGUMENT)
  goto end
  :error
  unset %~blah1 
  .signal -n ERROR $+($script, $chr(160), $scriptline, $chr(160), $error, $chr(160), $1-)
  :end
}
on *:signal:ERROR:{
  echo -a $+($chr(3), $color(notify), * $2-)
}
Posted By: FiberOPtics Re: Break command halted addition - 01/12/05 07:45 PM
That's not what he asked for.

He's asking for mIRC to automatically free resources that were created in the alias, and for them to be freed by mIRC itsself when the script is interrupted by ctrl+break.
Posted By: NaquadaServ Re: Break command halted addition - 01/12/05 07:53 PM
Go use BASIC than, as that is just plain lazy... I wouldn't want the additional overhead in the script interperter in order for mIRC to remember where everything was initially set. Programmers need to clean-up after themselves...
Posted By: FiberOPtics Re: Break command halted addition - 01/12/05 07:55 PM
Whether you think it's lazy or not doesn't concern me, I'm not commenting on the feature suggestion, I'm simply informing you that what you gave him is not what he's asking for, so there's no point in posting that code.

PS: How about showing some courtesy by giving me some feedback regarding your request here... I spent well over 2 hours coming up with that, the least you could do is reply.
Posted By: NaquadaServ Re: Break command halted addition - 01/12/05 08:03 PM
Minus the Automatic, it is what he asked for. I supplied the code as an alternative.

Did someone wake-up on the wrong side of the bed today???
gezz
Posted By: NaquadaServ Re: Break command halted addition - 01/12/05 08:06 PM
Quote:

PS: How about showing some courtesy by giving me some feedback regarding your request here... I spent well over 2 hours coming up with that, the least you could do is reply.


Thanks, works great. There is no need to get all pissed off about it though.
Posted By: hixxy Re: Break command halted addition - 02/12/05 04:10 AM
Quote:
Go use BASIC than, as that is just plain lazy...


No it isn't. Infinite loops are not uncommon in the early stages of scripts I write, so I'd rather have mIRC cleanup objects for me than have to spend about a minute cleaning up objects so I can retest my new code, that way I can get the actual code done rather than waste time freeing resources.

Quote:
I wouldn't want the additional overhead in the script interperter in order for mIRC to remember where everything was initially set.


See below.

Quote:
Programmers need to clean-up after themselves...


Agreed. It's a shame that we can't in mIRC though as there's no way you can check if a command has been halted by the break key unless you periodically check the status window for such messages.

I'm not bothered whether the cleanup is done by mIRC or a script, I just want a way to free resources used when the break key is hit, so an event being called with the alias/event as a parameter when the break key is hit would be an alternative method I'd be happy with.
Posted By: NaquadaServ Re: Break command halted addition - 02/12/05 05:20 AM
Quote:

Agreed. It's a shame that we can't in mIRC though as there's no way you can check...

I'm not bothered whether the cleanup is done by mIRC or a script, I just want a way to free resources used when the break key is hit, ...

Have you tried using :error, that is exactly why it's there... After ctrl-break, mIRC goes to the :error line of whatever particular alias, signal, or event that ctrl-break occured in... What better place to clean up the mess that a ctrl-break does than in the alias, signal, or event that it happened in. This "goto :error" thing also propogates backwards allowing everything to get cleaned up... What could be simpler. See Error Handling in /help Aliases. Now that I understand how to use it, I have no problems with mIRC's error handling.
Posted By: hixxy Re: Break command halted addition - 02/12/05 05:38 AM
Ah I see.
I didn't realise that mIRC went to the :error label when the break key was hit since it's not an error per se. Thanks smile
Posted By: NaquadaServ Re: Break command halted addition - 02/12/05 05:47 AM
No Problem laugh
Posted By: FiberOPtics Re: Break command halted addition - 25/12/05 04:56 PM
Actually, mIRC doesn't always jump to the error label when doing a ctr+break, it very often does, but sometimes it doesn't, in other words, it isn't a 100% proof solution for now.
Posted By: hixxy Re: Break command halted addition - 25/12/05 07:26 PM
Hmm that's weird. Do you mean you could call the exact same code 10 times and only 9/10 it would go to the error label? Or, do you mean that you could call 10 different scripts and only 9/10 would work with error handling? The figures are just examples.

If you mean the second could you post an example please smile
Posted By: FiberOPtics Re: Break command halted addition - 25/12/05 08:10 PM
No, I mean I made a small test alias that is something like:

Code:
alias testloop {
  while (1) ! 
  return
  :error
  echo -a reached error
}


Just tried it again, most of the time it works just fine, though on small occasions it doesn't jump to the error label. Note that I am talking about ctrl+break not always making mIRC jump to the error label. If it is a case of a scripting error, then it jumps to it 100% of the time. Note that I use random intervals before holding ctrl+break, sometimes I wait 2 seconds, sometimes 5 etc.

EDIT: Here's a little screenshot:

In occassions where mIRC catches the ctrl+break, it first echo's "reached error" then shows the message: * Break: command halted (line 2, personal.mrc), in other cases it doesn't show the line number and script file, as you can see. It's funny, when I decided to make the screenshot, it reached it less than when I was testing before, as you can see quite a few weren't catched.

EDIT2: This is on mIRC 6.16.
Posted By: DaveC Re: Break command halted addition - 25/12/05 09:54 PM
Its not to do with the amount of time ctrl-break is down for by any chance?

Maybe its been caught every time, but then the error code is being broken out of, and due to it being in the error trap its not showing a line number?
(just saying a possability, cant test right now myself im using my pda to write messages, i love xmas presents!)
Posted By: FiberOPtics Re: Break command halted addition - 25/12/05 10:29 PM
Nah, the amount of time of holding ctrl+break doesn't seem to be a factor. I've held it down long/short times, and its behaviour remains random, sometimes it catches it, sometimes it doesn't.
Posted By: hixxy Re: Break command halted addition - 08/02/06 07:23 PM
I have an alias here where it never goes to the label so I'd still like this to be implemented properly.
© mIRC Discussion Forums