it erases data that windows saved in the mouse buffer. If _mouseinput is in a slow loop then a higher percentage of the data will be erased.
If windows goes to the trouble of storing the mouse data then why erase it?
Quick question: How much information is too much information?
Do you need to know where your mouse cursor is every minute? Every second? Every millisecond? Every nanosecond? Every 1/1000000000000000000000000000000000000th of a second?
Fractions are an infinite thing, and you have to decide how small you need something. A cake cut into fourths is tasty; a cake cut into millionths is just powder.
By setting a _LIMIT in your program, you’re saying, “I only need interactions with a user LIMIT times per second.” With _LIMIT 10 in your main loop, you’re only running the loop 10 times per second, and who gives a hoot about what’s going on between those decaseconds?
So what if the user pressed the button 397 times in 1/10th of a second?!! Your program is only going to make one cycle in that 1/10th of a second, so all you react to is one singular press; the rest you toss into the garbage. To do otherwise, your program would have to run 397 cycles to process each of those button events, which at a limit of 10 per second means it would take 39.7 seconds to process one burst of the user’s awesome button clicking skills!!
And WTH wants that type of program???
Here's a quick example of what I'm talking about:
DIM ArrayX(100000) AS INTEGER, ArrayY(100000) AS INTEGER
DO
count = 0
WHILE _MOUSEINPUT
count = count + 1
ArrayX(count) = _MOUSEX
ArrayY(count) = _MOUSEY
WEND
PRINT count; "position events in 1/5th second"
_DISPLAY
_LIMIT 5
LOOP UNTIL _MOUSEBUTTON(1)
At the best, this little program is only going to run 5 loops per second, since I set the limit to 5. Scroll the mouse across the screen and see how many movement events you've triggered in each 1/5th of a second. I think my best would be about 130, or so, on my system -- which means if I read and processed each and every one of them, I'd need 26 seconds to process every 1/5th second of user input!
The user would move their mouse across the screen a few dozen times, click the button twice, and then get to go home and enjoy a whole day off from work just because my program is now going to take the rest of their evening to track EACH AND EVERY fragment of a pixel which their mouse moved in that time!
Here, a second illustration of what I'm talking about:
SCREEN _NEWIMAGE(1024, 720, 32)
DIM ArrayX(100000) AS INTEGER, ArrayY(100000) AS INTEGER
FOR fivepasses = 1 TO 5
DO
count = 0
WHILE _MOUSEINPUT
count = count + 1
ArrayX(count) = _MOUSEX
ArrayY(count) = _MOUSEY
WEND
_DELAY .2
LOOP UNTIL count <> 0
PRINT "In 1/5th of a second, your mouse was at:"
FOR i = 1 TO count
PRINT "("; ArrayX(i); ","; ArrayY(i); ")";
NEXT
NEXT
As you can see, you're generating many more results than what you can reasonably expect to deal with. You don't need to know where the mouse was every 1/1000th of a second, when your program is only going to be cycling every 1/5th of a second. Clear the mouse buffer and deal with where the mouse is at, WHEN your loop cycles through, and toss out all the other garbage that happened in the past.