mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline OP
Hoopy frood
OP Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
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).

Joined: Dec 2002
Posts: 580
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
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-)
}


NaquadaBomb
www.mirc-dll.com
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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.


Gone.
Joined: Dec 2002
Posts: 580
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
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...


NaquadaBomb
www.mirc-dll.com
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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.


Gone.
Joined: Dec 2002
Posts: 580
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
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


NaquadaBomb
www.mirc-dll.com
Joined: Dec 2002
Posts: 580
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
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.


NaquadaBomb
www.mirc-dll.com
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline OP
Hoopy frood
OP Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
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.

Joined: Dec 2002
Posts: 580
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
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.


NaquadaBomb
www.mirc-dll.com
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline OP
Hoopy frood
OP Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
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

Joined: Dec 2002
Posts: 580
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
No Problem laugh


NaquadaBomb
www.mirc-dll.com
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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.


Gone.
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline OP
Hoopy frood
OP Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
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

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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.


Gone.
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
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!)

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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.


Gone.
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline OP
Hoopy frood
OP Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
I have an alias here where it never goes to the label so I'd still like this to be implemented properly.


Link Copied to Clipboard