mIRC Home    About    Download    Register    News    Help

Print Thread
#232717 17/06/11 05:40 AM
Joined: Apr 2010
Posts: 969
F
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
While coding[isn't that where ppl realize they don't have what they need?] I realized there wasn't a decent way to test if the buffer of a window has changed, be it due to user's /echoing, an error in a script, etc

So I suggest one of two ways:
Code:
on *:BUFFERCHANGE:window:{ 
  $target == window whom's buffer has changed
}
and/or
Code:
/window -Z name
  Resets $window().CBuffer to $false

$Window().CBuffer
   returns $True/False if the buffer of the specified window has changed since the last /window -Z


I am SReject
My Stuff
Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2006
Posts: 183
T
Vogon poet
Offline
Vogon poet
T
Joined: Aug 2006
Posts: 183
You just use $line(Window,0) to get the number of lines. Set that to a variable, then set a timer to check and see if that number has changed.

While I admit it might be handy to have, the other thread mentioned shows some pretty good reasons not to do such a thing.

Edit: Actually, the above won't work if you're at the buffer limit. You could still set the last line to a variable (with a timestamp if need be) and then set up a timer that compares it to the last line in the buffer. Slightly more complex, but it gets the job done.

Last edited by Thrull; 18/06/11 06:25 AM.

Yar
Joined: Apr 2010
Posts: 969
F
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
For the most part something like that works, but what happens if a channell is getting flooded, a timer goes haywire, the user is //echo testing something, all with a full buffer? There's really no way to detect that.

I'm not asking for a unique identifier for each line[though that would be GRAND!], just a WAY to tell if the buffer changed. Seriously, there are so many ways to change the buffer [not even including when data is received from an IRC server] that to be able to track as much as possible of the buffer changing commands/events would take quite the bit of coding. And still echoed errors and such still wouldn't be able to be caught....


I am SReject
My Stuff
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
@Thrull: If you read that thread a bit more, you'll see reasons why your examples aren't going to work well. You already edited to point out why total lines isn't going to work. You also can't check the last lines because it's very possible to have two lines (or more) be the same. There are some examples of how to get accuracy up to around 99.9% or so (checking top, bottom, and at least one middle line... more increases accuracy) and for most things, that really is enough.

@FroggieDaFrog: It doesn't take that much code to check multiple lines for changes and it's very accurate. The chances of it not being correct are extremely low. You can even avoid such a line check and just save the buffer and check it's hash. Of course, that's more CPU intensive and depending how often your check it, it may not be worth it. But it requires very little code to do.

In any case, this should be very easy to add and would be worth adding. mIRC already knows when there are changes, so providing an event for them shouldn't be hard. It probably needs to be limited in scope, though... as mentioned, you don't want it to override on text or anything else.


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2010
Posts: 969
F
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
I thought about it some more, and the problem isn't detecting if the buffer changes, it's really detecting when a line is deleted from the front of the buffer to make room for a line at the end, so something like: on *:BufferDelete:window:{ } would suffice.


I am SReject
My Stuff
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
That won't work if you're not at full buffer, though. Unless you want to count lines and do that, which seems like extra work for no reason.


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2006
Posts: 183
T
Vogon poet
Offline
Vogon poet
T
Joined: Aug 2006
Posts: 183
Quote:
@Thrull: If you read that thread a bit more, you'll see reasons why your examples aren't going to work well. You already edited to point out why total lines isn't going to work. You also can't check the last lines because it's very possible to have two lines (or more) be the same. There are some examples of how to get accuracy up to around 99.9% or so (checking top, bottom, and at least one middle line... more increases accuracy) and for most things, that really is enough.


On the average channel, doing a bit of mid section checking should get you up far beyond 99.9%. But point taken, it won't be 100% and that can matter.


Yar

Link Copied to Clipboard