MOUSE returns Invalid Input - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: MOUSE returns Invalid Input (/thread-87.html) |
MOUSE returns Invalid Input - Eddie W. Shore - 12-14-2013 07:30 PM My goal with the program is to eventually have the user touch one of the "four corners", which each touch turning the a certain color on (from upper left hand: red, green, blue, yellow). I am not all the way there yet. I am having trouble getting input with the MOUSE command - keep getting "Invalid Input" error. And I am stuck to finding where my error is. Program I have so far: EXPORT FOURSQUARE() BEGIN LOCAL mx, my, L0; mx=-1; my:=-1; REPEAT RECT(); RECT_P(0,0,318,200); RECT_P(0,201,318,218,0); TEXTOUT_P("EXIT",130,218,3, RGB(255,255,255)); WAIT(-1); L0:=MOUSE(); mx:=B→R(L0(1,1)); my:=B→R(L0(1,2)); // draw boxes here UNTIL my≥201; RETURN "DONE"; END; Map: (0,0) to (158, 100): red box that lights up with a touch (159, 0) to (318,100): blue box that lights up with a touch (0, 101) to (158, 200): yellow box that lights up with a touch (159, 101) to (318, 200): green box that lights up with a touch (0, 200) to (218, 318): black exit box. Touch this region to terminate program. Any help is appreciated. RE: MOUSE returns Invalid Input - Jacob Wall - 12-14-2013 08:12 PM Hi, I have just started playing with PPL myself and very much still learning the basics, however I think the alternative below should work for you? EXPORT FOURSQUARE() BEGIN LOCAL mx, my, L0; mx=-1; my:=-1; REPEAT RECT(); RECT_P(0,0,318,200); RECT_P(0,201,318,218,0); TEXTOUT_P("EXIT",130,218,3,RGB(255,255,255)); L0:=WAIT(-1); IF SIZE(L0)>1 THEN mx:=L0(2); my:=L0(3); // draw boxes here END; UNTIL my≥201; RETURN "DONE"; END; Jacob RE: MOUSE returns Invalid Input - Eddie W. Shore - 12-14-2013 08:51 PM No such luck. RE: MOUSE returns Invalid Input - Han - 12-14-2013 09:16 PM Did you check to see if MOUSE() returned an empty list? The very first instance of MOUSE() may very well return an empty list, in which case L0(1,1) and L0(1,2) would cause errors. Code:
RE: MOUSE returns Invalid Input - Jacob Wall - 12-14-2013 10:29 PM (12-14-2013 08:51 PM)Eddie W. Shore Wrote: No such luck. Maybe I'm misunderstanding what you're trying to do, I thought your goal was to do something similar to what the code below does: Code: EXPORT FOURSQUARE() Jacob RE: MOUSE returns Invalid Input - Damien - 12-14-2013 10:53 PM Hi, everyone, maybe something like that should work... Code:
Regards, Damien. RE: MOUSE returns Invalid Input - cyrille de brébisson - 12-16-2013 08:38 AM hello have a look at this code Code:
cyrille RE: MOUSE returns Invalid Input - Jacob Wall - 12-17-2013 03:58 AM Quote:have a look at this code Some interesting techniques in that code, thanks for sharing! Jacob RE: MOUSE returns Invalid Input - Eddie W. Shore - 12-17-2013 01:49 PM I echo Jacob's comment. Thank you for sharing. RE: MOUSE returns Invalid Input - Snorre - 12-20-2013 04:34 PM There's an example for using MOUSE in a German Wiki: http://wiki.hp-prime.de/index.php?title=Maus#Demonstrationsprogramm |