The prime really doesn't have much to help you program menus.....which I hope they'll fix in a future release. I found a few useful titbits to help get around that shortfall.
Here are 2 very useful utilities to put in your programming utilities. PUTMENU and GETMENU. See here...
https://www.thecalculatorstore.com/Calcu...e-HP-Prime
I'll try to post an example using them when I get a chance...
-Donald
Here is a simple example that I just wrote and works fine....a lot simpler than programming from scratch. This example puts a few menu selections. I've only implemented the EXIT selection.
Code:
EXPORT MENU()
BEGIN
LOCAL men,m,m1,mx,my,s;
// initialize
WHILE MOUSE(1)>=0 DO END;
men:={"","HEX","OCT","DEC","BIN","EXIT"};
PUTMENU(men); // Have to put menu twice...first time here
REPEAT // main loop
REPEAT // read mouse
m:=MOUSE; m1:=m(1);
UNTIL SIZE(m1)>0;
mx:=m1(1); my:=m1(2);
PUTMENU(men); // Have to put menu twice...second time here
s:=GETMENU(mx,my,men);
// This is where you process s for menu selections
UNTIL (s==6);
END; // BEGIN
Hi,
You can also use libMenu, something I made and share here :
http://www.hpmuseum.org/forum/thread-7220.html
video demonstration posted on thread.
it does not work exactly the same as you,
you have to define a function for each of your menu entries.
these functions will be called-back on user action.
it's quite easy to use, and you also have more enhanced versions that can handle enhanced features (toggle menu...)
LibMenu looks nice. I like mine though for simple apps....as it's so simple, and I retain control over everything.....my "lib" is just 2 functions. I should post them here as the link I gave isn't exactly what I'm using....I changed the GETMENU function slightly.
Code:
// DEFINE MENU
EXPORT PUTMENU(mTXT)
BEGIN
DRAWMENU(mTXT(1),mTXT(2),mTXT(3),mTXT(4),mTXT(5),mTXT(6));
END;
// SETS mSEL GLOBAL VIA MENU SELECT
EXPORT GETMENU(mx,my,mTXT)
BEGIN
LOCAL mSEL;
mSEL:=0;
IF my≥220 AND my≤239 THEN
CASE
IF mx≥0 AND mx≤51 AND mTXT(1)>"" THEN
mSEL:=1;
END;
IF mx≥53 AND mx≤104 AND mTXT(2)>"" THEN
mSEL:=2;
END;
IF mx≥106 AND mx≤157 AND mTXT(3)>"" THEN
mSEL:=3;
END;
IF mx≥159 AND mx≤210 AND mTXT(4)>"" THEN
mSEL:=4;
END;
IF mx≥212 AND mx≤263 AND mTXT(5)>"" THEN
mSEL:=5;
END;
IF mx≥265 AND mx≤319 AND mTXT(6)>"" THEN
mSEL:=6;
END;
END; // CASE
END; // IF MENU
RETURN mSEL;
END; // BEGIN
I found that it executes better if the WAIT call is used instead of MOUSE as in this example...
Code:
EXPORT MBase(A,B,C)
BEGIN
LOCAL men,m,m1,mx,my,s;
// initialize
WHILE MOUSE(1)≥0 DO END;
men:={"","HEX","OCT","DEC","BIN","EXIT"};
REPEAT // MAIN LOOP
PUTMENU(men);
REPEAT // WAIT FOR A MOUSE CLICK
m:=WAIT(−1);
UNTIL (m(1)==3 OR m(1)==7);
mx:=m(2); my:=m(3);
s:=GETMENU(mx,my,men);
CASE
IF (s==2) THEN s:=0; PRINT(A); END;
IF (s==3) THEN s:=0; PRINT(B); END;
IF (s==4) THEN s:=0; PRINT(C); END;
DEFAULT
PRINT();
PRINT("");
END;
UNTIL (s==6); // REPEAT...
END; // BEGIN