mIRC Home    About    Download    Register    News    Help

Print Thread
#223512 27/07/10 07:19 AM
Joined: Feb 2006
Posts: 546
J
jaytea Offline OP
Fjord artisan
OP Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
Code:
on *:text:*:?:{ echo -a $wid }


gives the Status Window's WID instead of $window($nick).wid

just a quick report, i didn't test this on other events


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
jaytea #223521 27/07/10 09:43 AM
Joined: Dec 2002
Posts: 5,420
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,420
This is by design, almost all events use the server window as the base window, so if a script needs to target a window related to particular event it will need to do so based on the parameters for that event.

Khaled #250619 24/01/15 12:00 PM
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Are you sure this is intended behavior, Khaled? It seems like the behavior you're referencing is $cid (connection id) instead of $wid (window id).

I think most users expect On Text $wid to reference the channel or query or dqwindow that the text event happened in. There can be multiple query windows of the same name, so it would be impossible to pin point which of the multiple query windows the Text was sent to, otherwise. Same with On Chat and several DCC chat windows opened to the same target ... which $wid?


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Khaled #265829 02/08/19 09:46 PM
Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
Hello,

While this design is definitely not desirable for scripters, it's failing with on open, where in combination with this report, it makes it impossible to tell where the message comes from (as Raccoon pointed out)

In most cases, the language is capable of letting us do what we want in events with windows, as in, we simply don't need to know the window id of the window that triggered the events.

However, sometimes we need that value, if you recommend to use the parameter of the event to target a window, with an event such as on *:open:*:!,=:{ or simply on *:open:*:*:{, how do you tell if it's a dcc chat or fserv?

For all practical purpose, it would be nice to have $eventwid, to get the wid of the window that triggered the event, and maybe $eventtype or similar which would return '#', '?', '=', '!', '@', depending on the window associated with the event.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #265830 02/08/19 10:37 PM
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Because DCC CHAT and SERV windows are both named =samenickname, and it's possible to have multiple DCC CHAT windows open to the same nick, "/echo =$nick message" isn't guaranteed to echo to the correct window, instead showing in whichever of the =samenickname windows was opened first. And $window(=$nick).wid would also return the wrong number, and if you have 2 dcc chat windows open to someone, or a dcc-chat and dcc-fserve, then //echo -a $window($active).wid shows the same number in both editboxes.

With something like $eventwid or $wid.event the correct window could be targeted like "/echo @ $+ $window(@ $+ $eventwid).wid message"

It would also be nice to have $window(@number).name to find out the window name associated with a .wid

The syntax shown for /help ON OPEN is confusing because it combines the syntax for ON OPEN with unrelated syntax for ON CLOSE. This makes it looks like ON OPEN requires the matchtext field, the same way it requires the windowtype field, and makes it seem as if it's possible for @custom to trigger ON OPEN. From the examples using ON OPEN without matchtext, it's not obvious that the matchtext field is optional for query windows, and can be present for other window types only if the event handler isn't a 1-liner:

Code
on *:OPEN:*:*:{ echo test $scriptline $event }


/help says * is a valid windowtype for ON OPEN, but the above event handler tries to execute an alias named :{ generating a server error, for all window types except for query. If the echo is moved down to its own row, then there's no error generated. and it does execute the echo correctly after generating the server error.

It's possible to have an alias named :{ to prevent this, but you'd need to give it an unmatched end-brace to prevent the Ctrl+H warning, like:

Code
alias :{ echo -s test }


Link Copied to Clipboard