mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2003
Posts: 9
A
Acid_X Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: May 2003
Posts: 9
I recently found out that /close does not trigger the on close event... Just a little bug, but it does make some problems for scripters out there.

Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Quote:

on 1:CLOSE:?:/echo -s you just closed $target query window
This triggers when you close a query window.
on 1:CLOSE:=:/notice $me $nick just left the discussion!
This triggers when a dcc chat session ends, or when you close your chat window manually.


Yup, it seems that /close doesn't fall under the "you closed the window" category.. >:\


-KingTomato
Joined: Dec 2002
Posts: 1,541
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Dec 2002
Posts: 1,541
if I remember correctly, the following would not work with the /close command either:

on me:*:close:=:/echo $me just closed a window

I know most people dont use this type of code, but hey, I agree with the poster that it should be triggering it


Those who fail history are doomed to repeat it
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
It's not a bug. Events aren't meant to be triggered by scripts/commands. If you want to do something when you use /close, well, just put the necessary commands right after /close. In case you want to monitor users typing /close or something, you could use on INPUT. I know, this is far from perfect, but having /close trigger an event is not the way to go: imo it is very important that commands cannot trigger events (except signals), I hope it stays this way.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Apr 2003
Posts: 210
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Apr 2003
Posts: 210
Well, it wouldn't really be the /close command triggering the event, it would be the window closing that triggers it. The fact that somebody typed /close is incidental, the event is the window closing.

Just like when you type /exit and have an ON EXIT event. There are other commands (maybe lots) that can directly, or indirectly trigger events.

I don't think adding a switch to /close for this would hurt anyone, nor would it harm mIRC scripting in general, imho.

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Well, it wouldn't really be the /close command triggering the event, it would be the window closing that triggers it.

But the window closing in general shouldn't be an event; only the window being closed by the user should. For example, I have a lot of aliases that open a hidden window, load stuff in it, do something and then close the window (for example, sorting). Would you like an on CLOSE somewhere in another script to trigger for that too? I wouldn't. Calling /close isn't always the same thing as clicking on the X button.

I think that a scripter must always know that when he uses a certain command, only the things that he wishes to be done by that command will be done. Triggering an event by a command would destroy that sense of control and would make things unpredictable in many cases (imagine a command in that event calling another command, which in turn triggers another event etc).

A similar case is that of /window @blah and on OPEN. A custom window opening is certainly no less an 'event' than a custom window closing, the on OPEN doesn't trigger though. And this isn't a bug since the help file notes: "The OPEN event does not trigger for custom windows". The reason is that a @window can only be opened by a /command and since we (presumably) don't want commands triggering events, the on OPEN has specifically been made not to trigger.

Making commands trigger an event (directly or indirectly) isn't useless, but in most cases, it creates more problems than it solves imo. /exit could be considered one of the few exceptions, because it cannot be used repeatedly or be of any use for a specific scripting task. It can only be used once (usually at the end of a script) and has almost the same purpose as the X button. More important, closing mirc without other scripts knowing (so they can save their settings etc) is 'fatal'; so fatal, that the rule "a command cannot trigger a script" must be violated.

I just found out that /window -a also triggers the on ACTIVE event. I don't fully agree with that either, but I can imagine why this makes more sense than /close triggering on CLOSE.


I don't think adding a switch to /close for this would hurt anyone, nor would it harm mIRC scripting in general, imho.

It wouldn't hurt but it wouldn't be of much use either. I'm guessing that most of the times scripters feel the need for such an event because they want to monitor open windows (to update their custom switchbar for example): if a user types /close, they want to know about it so the switchbar is updated. I doubt that any user would include that switch when they type /close from the command line, thinking that this could be useful for some of the scripts they run.

Neither way (triggering or not triggering on CLOSE) is perfect, but considering the way mirc works in general, I prefer the second (current) way. If the first way is ever implemented, there should at least be a switch that would make /close work like it used to (ie not triggering the event).


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Dec 2002
Posts: 580
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
Try...

on ^1:CLOSE:?:/echo -s you just closed $target query window

-or-

on 1:CLOSE:*:/echo -s you just closed $target query window

If you choose that last and it works, deal with $target to figure out what kind of window is being closed...

I have had problems with the close event, so I do think it is a bug (and it doesn't seem to effect custom windows), but right now my close events are working fine, and because of one or both of the previous reasons listed.


NaquadaBomb
www.mirc-dll.com
Joined: May 2003
Posts: 9
A
Acid_X Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: May 2003
Posts: 9
Yeah.. But to make the world an easier place, /close should trigger on close. I tend to use /close -m alot when closing query windows, and it causes errors in my script.. Haha.


Link Copied to Clipboard