[HP-Prime] Picking elements from a List in a program



I'm currently learning about the MOUSE() command used to detect where a finger is touching the screen.

It returns a list of lists with following structure:


where x and y are the coordinates of the points where the touchscreen is hit. At least this is what I understood...

I tried to use the SUB() command to extract x and y (separately or as a list {x,y}), but did not get better result than


i.e. a list of list of the first term of the list returned by MOUSE().

I was thinking that


would return x coordinate of the touch point, but it does not.

I did not find any other command dealing with lists that could do the job.

Did I miss something, am I doing something wrong (probably !)

Help much appreciated.

Kind regards.


I'd recommend storing the return from mouse into a local variable. The reason why is that it is an EXACT snapshot of the instant that command is evaluated. Thus you have the potential to check the state, then in the few ms between when you check it and begin to try and evaluate the state may have changed.

Then you can use direct indexing myvar(1,1) and so on to access the specific pieces directly.

Note you can also do MOUSE(1) or MOUSE(2) which returns -1 if nothing is there, or else the list.



Thanks Tim for your advice.

In fact, even if I did not mention it in my post, I already tried this solution (storing the value in a variable. Even tested local or exported variable).

What do you mean, please, by "direct addressing"? Which instruction does this?


case 1:


SUB(myvar,1,2) --> {1,2} as expected

case 2:

myvar:={{1,2,3,4},{5,6,7,8}} --> list of lists, as MOUSE() returns

SUB(myvar,1,1) --> {1,2,3,4} as expected

SUB(SUB(myvar,1,1)),1,1) --> {{1,2,3,4}} (not the the double brackets) where {1} would be expected

[edit 2:]

Got it!

(direct addressing)

Edited: 14 Nov 2013, 5:54 p.m.


I mean you can try myvar(2,3) => 7 with myvar:={{1,2,3,4},{5,6,7,8}}

friendly :o)

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sending little images to the Prime (...and Program name bug?) Erwin Ried 19 7,332 12-10-2013, 05:35 PM
Last Post: Erwin Ried
  Problem with debug HP prime program, somebody help me? Carlos CM (Mexico) 6 3,332 12-05-2013, 03:07 PM
Last Post: Carlos CM (Mexico)
  Milestones:List of IEEE Milestones -> HP-35 AlbertTocarLoseggs 4 2,115 11-27-2013, 08:52 AM
Last Post: Massimo Gnerucci (Italy)
  HP PRIME: APP program code DISAPPEARS !! Joseph Ec 0 1,204 11-25-2013, 11:35 AM
Last Post: Joseph Ec
  Prime: Placing more than 1 item on the RPN stack in a single program? John Colvin 4 2,250 11-19-2013, 08:59 AM
Last Post: Miguel Toro
  Prime: Program size limited to 64K? Erwin Ried 4 2,029 11-17-2013, 11:42 PM
Last Post: Joseph Ec
  HP-Prime : Extracting elements from a list in RPN Miguel Toro 0 1,608 11-15-2013, 06:44 PM
Last Post: Miguel Toro
  HP Prime: Recommendation for future RPN Program Mode BruceTTT 3 2,148 11-13-2013, 10:03 PM
Last Post: BruceTTT
  HP Prime: run a program in another program Davi Ribeiro de Oliveira 6 2,699 11-11-2013, 08:28 PM
Last Post: Davi Ribeiro de Oliveira
  Hp PRIME - how to send a list to the connectivity Kit giancarlo 1 1,326 11-10-2013, 11:50 AM
Last Post: Tim Wessman

Forum Jump: