Post Reply 
Graphic cursor problem
01-12-2021, 12:13 PM (This post was last modified: 01-12-2021 12:17 PM by C.Ret.)
Post: #4
RE: Graphic cursor problem
(01-09-2021 09:20 PM)cahlucas Wrote:  [...] Based on the code, what could possibly be wrong or what needs to be inserted in order for the program to work in the end? Sincerely, Karel.

I am not sure, but I see a potential problem in the way index is initialized. To ease my explanation, I copy your code simplifying the tests which appear to be correct.

Code:

 ...
   index:= 0   ; //    <---------------------   There to set the  value of index to indicate a "user touch out of any expected zone "
    CASE
      IF   "cx in touchzone_x1" THEN
        CASE
          IF "cy in touchzone_y1" THEN index:=1; END;
          IF "cy in Touchzone_y2" THEN index:=3; END;
        END;
      END;
      IF "cx in Touchzone_x2" THEN
        CASE
          IF "cy in Touchzone_y1" THEN index:=2; END;
          IF "cy in Touchzone_y2" THEN index:=4; END;
        END;
      END;
    END;
 ...

The variable index is correctly set only when the user touch’s in one of the four Touch-Zone as expected, respectively 1 2 3 or 4 depending of the zone.

But, what happen to index when the user miss any of the four zones ? I can not see where the variable index is set to a specific value (I may propose set to 0) to indicate a wrong touch !

And, more important, in the last portion of the code, no test is made to verify that index is correctly set and one of the four Touch Zone was actually touched :

Code:

    IF cursor:=1 AND  index<>0 THEN    // <--------------- "index don't indicate any missed touch zone"
      dx:=mcrd(index,1); dy:=mcrd(index,2); 
      INVERT_P(G0,dx-4,dy+2,dx+11,dy+17);
    END;
    . . .

I hope this observation help a bit...
Debugging on the HP Prime is sometime really hard, a source of stress and time consuming... (I just spend two hours realizing that the incorrect behavior of my CAS function was due to a capitalized local variable name, the calculator was using the global variable same value each time what ever were the specific samples I introduce ... How fool are we on ours doggy horses ?? )

Best Regards.
C.Ret
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Graphic cursor problem - cahlucas - 01-09-2021, 09:20 PM
RE: Graphic cursor problem - Han - 01-10-2021, 09:45 PM
RE: Graphic cursor problem - cahlucas - 01-12-2021, 05:39 AM
RE: Graphic cursor problem - Han - 01-13-2021, 02:27 AM
RE: Graphic cursor problem - C.Ret - 01-12-2021 12:13 PM
RE: Graphic cursor problem - cahlucas - 01-13-2021, 05:52 AM



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