Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Playing with the mouse
#1
I am running this program to play with the mouse, just playing with things to understand it before trying to imbed it into something else.


Code: (Select All)
$NOPREFIX

CONST FALSE = 0, TRUE = NOT FALSE

TYPE MouseType
    EndX AS INTEGER
    EndY AS INTEGER
    StartX AS INTEGER
    StartY AS INTEGER
    LButDown AS INTEGER
    RButDown AS INTEGER
    OldLBut AS INTEGER
    OldRBut AS INTEGER
END TYPE

SCREEN NEWIMAGE(1280, 720, 32)

DIM AS MouseType Mouse
DIM AS INTEGER highlight(500000)
DIM AS BIT Active

Mouse.OldLBut = --1
Active = FALSE

LINE (500, 200)-(600, 300), RGB(0, 0, 255), BF
DO
    'LIMIT 120
    DO WHILE MOUSEINPUT
    LOOP

    Mouse.StartX = MOUSEX
    Mouse.StartY = MOUSEY
    Mouse.LButDown = MOUSEBUTTON(1)

    IF Mouse.StartX >= 500 AND Mouse.StartX <= 600 AND Mouse.StartY >= 200 AND Mouse.StartY <= 300 AND NOT Active THEN
        GET (500, 200)-(600, 300), highlight()
        PUT (500, 200), highlight(), PRESET
        Active = TRUE
    ELSEIF Active EQV Mouse.StartX < 500 OR Mouse.StartX > 600 OR Mouse.StartY < 200 OR Mouse.StartY > 300 THEN
        GET (500, 200)-(600, 300), highlight()
        PUT (500, 200), highlight(), PRESET
        Active = FALSE
    END IF

    IF Mouse.LButDown AND NOT Mouse.OldLBut THEN
        LOCATE 1, 1
        PRINT Mouse.StartX, Mouse.StartY, Mouse.LButDown
    END IF

    Mouse.OldLBut = Mouse.LButDown

LOOP UNTIL INKEY$ = CHR$(27)



and it is working as expected with a box highlighting and not but I don't understand why this if statement needs EQV:

Code: (Select All)
    ELSEIF Active EQV Mouse.StartX < 500 OR Mouse.StartX > 600 OR Mouse.StartY < 200 OR Mouse.StartY > 300 THEN
        GET (500, 200)-(600, 300), highlight()
        PUT (500, 200), highlight(), PRESET
        Active = FALSE
    END IF
 
than the one I was trying to work with at first:


Code: (Select All)
    ELSEIF Active AND Mouse.StartX < 500 OR Mouse.StartX > 600 OR Mouse.StartY < 200 OR Mouse.StartY > 300 THEN
        GET (500, 200)-(600, 300), highlight()
        PUT (500, 200), highlight(), PRESET
        Active = FALSE
    END IF

My belief that If (false and True or True or True or True) should return a false with false and true.... condition. 


Never used EQV before but the table on the wiki implies both should return false. Maybe someone can educate me where my logic has gone wrong? Many thanks  Shy
Reply


Messages In This Thread
Playing with the mouse - by NasaCow - 12-11-2022, 07:59 AM
RE: Playing with the mouse - by Pete - 12-11-2022, 02:47 PM
RE: Playing with the mouse - by NasaCow - 12-11-2022, 03:03 PM
RE: Playing with the mouse - by SMcNeill - 12-11-2022, 02:51 PM
RE: Playing with the mouse - by TempodiBasic - 12-11-2022, 03:10 PM
RE: Playing with the mouse - by Pete - 12-11-2022, 04:50 PM
RE: Playing with the mouse - by mnrvovrfc - 12-11-2022, 06:36 PM
RE: Playing with the mouse - by Pete - 12-11-2022, 06:39 PM
RE: Playing with the mouse - by TempodiBasic - 12-11-2022, 05:39 PM
RE: Playing with the mouse - by SMcNeill - 12-11-2022, 08:21 PM
RE: Playing with the mouse - by NasaCow - 12-12-2022, 09:38 AM
RE: Playing with the mouse - by TempodiBasic - 12-11-2022, 06:24 PM
RE: Playing with the mouse - by Pete - 12-12-2022, 12:22 AM
RE: Playing with the mouse - by TempodiBasic - 12-13-2022, 02:45 PM



Users browsing this thread: 4 Guest(s)