Post Reply 
MOUSE command problem (FW 2.1.14730)
08-07-2023, 03:02 PM
Post: #1
MOUSE command problem (FW 2.1.14730)
I tried to read the touch screen status in a loop. It's important that it's not a blocking function (like WAIT) because other tasks are executed in the meantime. I used the MOUSE() command, but it behaves oddly.

First, I'll provide an example of a program that works, but doesn't quite meet my expectations:
Code:

EXPORT MOUSE1()
BEGIN
 local m,n;
 PRINT();
 REPEAT
  m:=MOUSE(0)*1;
  n:=MOUSE(1)*1;
  PRINT("X:" + m + "; Y:" + n);
 UNTIL 0;
END;

Above, the coordinate retrieval is done by calling MOUSE() twice, which is not very neat, and with very fast movements, it can lead to returning the x coordinate from one point and the y from another, combining them into a single mismatched point on the screen that might not have been touched at all.

A better solution would be to retrieve the MOUSE() result into a variable once and then operate on its components:
Code:

EXPORT MOUSE2()
BEGIN
 local m,n;
 PRINT();
 REPEAT
  m:=MOUSE();
  n:=m(1)*1;
  PRINT("X:" + n(1) + "; Y:" + n(2));
 UNTIL 0;
END;

Unfortunately, such a solution doesn't work. Despite the infinite loop, the program stops after several iterations of the loop and it doesn't even report an error. Moreover, MOUSE2 can only be run from the 'Program Catalog', but from the command line in 'Home', it returns "Error: Invalid input".

Is this a bug?

Regards
Piotr Kowalewski
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
MOUSE command problem (FW 2.1.14730) - komame - 08-07-2023 03:02 PM



User(s) browsing this thread: 1 Guest(s)