So reading inside the loop doesn't give you the state

by Clippy (Login burger2227)
R

I found that reading INSIDE of the loop can miss events. In fact, no clicks are read inside of them if you read them after the loop!



DO
DO WHILE _MOUSEINPUT
loop& = loop& + 1
IF _MOUSEBUTTON(1) THEN PRINT "Read"; loop&; 'never reads
LOOP
IF _MOUSEBUTTON(1) THEN 'current button state
PRINT "DOWN"; loop&;
ELSE PRINT " UP "; loop&;
END IF
Readmouse
LOOP

SUB Readmouse
STATIC loops&
DO WHILE _MOUSEINPUT
IF _MOUSEBUTTON(1) THEN PRINT "down1"; loops& ELSE PRINT "up1"; loops& 'never reads
loops& = loops& + 1
LOOP
IF _MOUSEBUTTON(1) THEN PRINT "down2"; loops& ELSE PRINT "up2"; loops& 'current state
END SUB

There is STILL the possibility that something is missed. This is indicated when a loop count doesn't change.

COMMENT out the reads AFTER the loops and see what happens when reading INSIDE of the loop ONLY... WOW!

Ted



    
This message has been edited by burger2227 on Jan 29, 2011 1:08 PM
This message has been edited by burger2227 on Jan 29, 2011 12:41 PM
This message has been edited by burger2227 on Jan 29, 2011 12:31 PM

Posted on Jan 29, 2011, 12:23 PM

Respond to this message   

Return to Index