HP Forums

Full Version: User defined touch-button menu (Softkeys)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi,

Got a HP Prime last week after using a 48GX for 25 years. One of the things I miss on the Prime is the opportunity to add a customised menu (like the CST on the 48). Now, after some days of search it almost seems to me the Prime does not support this (essential) feature. I know that the "physical" keys can be customised. However, I do not want to do that (I need those functions).

Is there indeed no workaround yet?

Yes, I have used the "search"-function and I know this question pops up a lot. But since it seems that it has been a while since this issue had been addressed, I thought I might try again.


Arch
Did you find & read this MoHPC thread when searching for a solution?
I see you are a new member so welcome to the Museum of HP Calculators!
I also did not like using user defined keys on the Prime. I found that using user tabs is time consuming and difficult. I guessing that you just want to push a key and have the calculator type a function like SIN() into the command line in textbook mode. (I don't know how you would do this in RPN mode) These are some of the work arounds I used for textbook mode.

You can create a "User Defined Function", where you would define a function using the "Define" key. Enter the function name such as "sin_h". Then enter the function, such as "SINH(X)", the hyperbolic sine. Then press OK. The function name must be different than any of the pre-existing functions. That is why I used "sin_h" instead of "sinh". To use the function, you position the cursor on the command line where you want insert "sin_h()". Press the toolbox key. Press the User tab. Scroll down to "User Functions". Tap it or right arrow it. Then tap "sin_h". The calculator will insert "sin_h()" into the command line. Then type in a number inside the parenthesis and your done. There is a lot of navigating to get to the function, but it's better than nothing. Read the manual (in the calculator help) to learn how to edit or delete your user function. It is difficult.

[Image: User-Functions1.png] [9/17/19 Replaced Tinypic image]

If you know how to program the prime, you can create your own program with a lot of user functions that would work like the previous example. An example is shown below.

Code:
MyFunctions()
BEGIN
END;

LOCAL x1;

EXPORT cos_h(x1)
BEGIN
  RETURN COSH(x1);
END;

EXPORT acos_h(x1)
BEGIN
  RETURN ACOSH(x1);
END;

You access these function using the toolbox key and user tab, in this case "MyFunctions" and "cosh_h".

[Image: My-Functions1.png] [9/17/19 Replaced Tinypic image]
Thanks for your answers! Smile


(06-20-2019 06:09 PM)Carsen Wrote: [ -> ]Did you find & read this MoHPC thread when searching for a solution?
I see you are a new member so welcome to the Museum of HP Calculators!

@Carsen
Yes, I found that thread. However, I got massive Syntax Error when I tried the code (copied and pasted it). Still trying to figure out what went wrong. Besides, I understood it to work only in CAS mode.

(06-20-2019 09:17 PM)Gene222 Wrote: [ -> ]...I guessing that you just want to push a key and have the calculator type a function like SIN() into the command line in textbook mode…

@Gene222
Yes, you guessed right, that is exactly what I am looking for (in RPN mode). I tried already the workaround you suggested using a function and calling it via the Toolbox menu. At least four clicks until you get what you want (or three if you can call the last used function using <shift> <paste> <enter>). Hm… I won't give up yet.

Arch
(06-21-2019 07:07 AM)Arch Wrote: [ -> ]Yes, I found that thread. However, I got massive Syntax Error when I tried the code (copied and pasted it). Still trying to figure out what went wrong. Besides, I understood it to work only in CAS mode.

Yeah. That happened to me when I tried that program. An example of the WAIT(-1) user tab program can be found at this post.
https://www.hpmuseum.org/forum/thread-12...#pid115217
The problem with user tabs is that they only work when a program is running.

If you want to save keystrokes, key assignments are probably the best method. Eddie Shore had a one button program that used a choose box to type in a function or program, or something like that, but I can't find that program.
(06-21-2019 04:31 PM)Gene222 Wrote: [ -> ]If you want to save keystrokes, key assignments are probably the best method. Eddie Shore had a one button program that used a choose box to type in a function or program, or something like that, but I can't find that program.

I found Eddie Shore's program. It's in the Prime software library under "User Key: Custom Menu". This program uses a key assignment, but it only uses one key assignment. You can access a function, such as COSH() in two key strokes. A modified version of Eddie Shore's program is below. It work's great in textbook mode. I'm not sure if this needs to be modified to run in RPN mode. [added] The SIN function does not work the same as pressing the SIN key in RPN mode. I don't use RPN on the Prime, so I don't know if this is normal. I think I am doing something wrong in the program.

[Image: User-Tabs1.png] [9/17/19 replaced image]

[9/17/19] Note, the following code is incomplete, because it does not close when pressing the Esc key. See post 12 for the final program code.
PHP Code:
// Function Menu
// This program was based on hpmuseum.org / hp prime software library / User Key: Custom Menu,11/3/17 by Eddie Shore

// This program uses a key assigment, where this program is assigned to the Vars key.
// To access this program, the User mode must be permanently toggled on by pressing
// [Shift] [User] [Shift] [User]
// To toggle off the user mode, press [Shift] [User]
// Run the program by pressing the Vars key in user mode.
// A choose box appears with a list of functions.
// Select a function.
// That function will be typed into the command line.

KEY K_Vars()
BEGIN
  LOCAL ch_num
,ch_items,func_list;
  
// choose items
  
ch_items:={"SIN","ASIN","COSH","ACOSH"};
  
// function list
  
func_list:={"SIN()","ASIN()","COSH()","ACOSH()"};
  
CHOOSE(ch_num,"Functions Menu",ch_items);
  RETURN 
func_list(ch_num);
END
@Gene222

Thanks for the code. Trying it right no…>syntax error< Sad

LOCAL ch_num,ch_items(<-seems tob e at this point),func_list;

…no idea what I am doing wrong. I get that a lot with c/p code.
…ok, found the problem. Stupid really. One of the first things I did, I chose "," as decimal mark. And it seems that caused a lot of confusion with the program code. After I changed it to "." The syntax error was gone. Stupid really since I suspected that already and changed it and nothing happened. Seems you must change it, turn the Prime off and on again for the Prime to recognise the change.
I can't get this program to work properly in RPN mode. Currently, using the program in the previous post (in RPN mode), to take the sin of 45 degrees you have to press: 45 [Enter] [Vars] SIN [Enter]. This key sequence puts 45 in the first stack register. The program then takes the 45 and changes it to 0.7071.

I tried to program the first [Enter] using RETURN(30); as shown in the program below. The program puts 45 in the first stack register, but then stops execution, which is what one would expect from the RETURN command. I don't know how to make the program continue execution.

RPN code that does not work
PHP Code:
KEY K_Vars()
BEGIN
  LOCAL ch_num
,ch_items,func_list;
  
// choose items
  
ch_items:={"SIN","ASIN","COSH","ACOSH"};
  
// function list
  
func_list:={"SIN()","ASIN()","COSH()","ACOSH()"};
  RETURN(
30);
  
CHOOSE(ch_num,"Functions Menu",ch_items);
  RETURN(
func_list(ch_num));
END
(06-23-2019 05:10 AM)Gene222 Wrote: [ -> ]I can't get this program to work properly in RPN mode. Currently, using the program in the previous post (in RPN mode), to take the sin of 45 degrees you have to press: 45 [Enter] [Vars] SIN [Enter]. This key sequence puts 45 in the first stack register. The program then takes the 45 and changes it to 0.7071.

I tried to program the first [Enter] using RETURN(30); as shown in the program below. The program puts 45 in the first stack register, but then stops execution, which is what one would expect from the RETURN command. I don't know how to make the program continue execution.

RPN code that does not work
PHP Code:
KEY K_Vars()
BEGIN
  LOCAL ch_num
,ch_items,func_list;
  
// choose items
  
ch_items:={"SIN","ASIN","COSH","ACOSH"};
  
// function list
  
func_list:={"SIN()","ASIN()","COSH()","ACOSH()"};
  RETURN(
30);
  
CHOOSE(ch_num,"Functions Menu",ch_items);
  RETURN(
func_list(ch_num));
END
(06-23-2019 12:03 PM)Stevetuc Wrote: [ -> ]
(06-23-2019 05:10 AM)Gene222 Wrote: [ -> ]I can't get this program to work properly in RPN mode. Currently, using the program in the previous post (in RPN mode), to take the sin of 45 degrees you have to press: 45 [Enter] [Vars] SIN [Enter]. This key sequence puts 45 in the first stack register. The program then takes the 45 and changes it to 0.7071.

I tried to program the first [Enter] using RETURN(30); as shown in the program below. The program puts 45 in the first stack register, but then stops execution, which is what one would expect from the RETURN command. I don't know how to make the program continue execution.

RPN code that does not work
PHP Code:
KEY K_Vars()
BEGIN
  LOCAL ch_num
,ch_items,func_list;
  
// choose items
  
ch_items:={"SIN","ASIN","COSH","ACOSH"};
  
// function list
  
func_list:={"SIN()","ASIN()","COSH()","ACOSH()"};
  RETURN(
30);
  
CHOOSE(ch_num,"Functions Menu",ch_items);
  RETURN(
func_list(ch_num));
END

If you remove the RETURN(30) then for your example
press: 45[Vars] SIN [Enter].
45sin() will appear on command line and then the result on pressing the [Enter] key
(06-22-2019 08:55 PM)Arch Wrote: [ -> ]After I changed it to "." The syntax error was gone. Stupid really since I suspected that already and changed it and nothing happened. Seems you must change it, turn the Prime off and on again for the Prime to recognise the change.

Something like that happened to me when I was writing the program. The Prime would not recognize the revised program. Recompiling the revised program did not help. I had to toggle the User mode off then toggle it back on to recognize the revised program. Other times, the Prime would recognize the new program.

(06-23-2019 12:14 PM)Stevetuc Wrote: [ -> ]If you remove the RETURN(30) then for your example
press: 45[Vars] SIN [Enter].
45sin() will appear on command line and then the result on pressing the [Enter] key

So, that is how the program is supposed works in RPN mode. Thanks.

[revised 6/24/19] Here's the program that will exit when pressing the Esc key. Pressing the Esc key will returns you back to where you were in the command line. It does not exit the command line, which is good when typing in a long equation on the command line. If you press the Vars key twice, it will open two functions menus. The two function menus can be exited by pressing the Esc key twice. So, it is important that the program can be closed by the Esc key.[/i]

[9/17/19] This is the final code of the program for this thread.
PHP Code:
KEY K_Vars()
BEGIN
  LOCAL ch_num
,ch_items,func_list;
  
// choose items
  
ch_items:={"SIN","ASIN","COSH","ACOSH"};
  
// function list
  
func_list:={"SIN()","ASIN()","COSH()","ACOSH()"};
  
CHOOSE(ch_num,"Functions (Esc to exit)",ch_items);
  IF 
ch_num==0 THEN  //Was Esc key pressed?
    
RETURN("");
  ELSE
    RETURN(
func_list(ch_num));
  
END;
END
(06-23-2019 09:14 PM)Gene222 Wrote: [ -> ]
PHP Code:
KEY K_Vars()
BEGIN
  LOCAL ch_num
,ch_items,func_list;
  
// choose items
  
ch_items:={"SIN","ASIN","COSH","ACOSH"};
  
// function list
  
func_list:={"SIN()","ASIN()","COSH()","ACOSH()"};
  
CHOOSE(ch_num,"Functions (Esc to exit)",ch_items);
  IF 
ch_num==0 THEN  //Was Esc key pressed?
    
RETURN("");
  ELSE
    RETURN(
func_list(ch_num));
  
END;
END

I tried this code. Got no error during checking. However, I can't execute it! ...weird...
The program works when I use it. I am using the latest version of the Prime (2018 10 16). There are a couple of spaces after the last end, but that should not make any difference.

There should only be one version of this program on the Prime. Otherwise you would have two programs that are assigned to the [Vars] key.

The User mode needs to be toggled on.

No compiler errors, but does not run... If you forgot to use the ":" in the ch_items or func_list equations, the program won't run. Did you type in this program by hand? Attached is the program that can be installed on the Prime using the Prime connectivity kit.

[added] Or, you can try to find the error yourself using the debugger on the Prime and step through the program.
@Gene222

Copied & pasted your code, didn't work. Same with the ZIP I transferred using the connectivity kit.

When I press "check" I get "No errors in the program", but if I choose "run" I get an exclamation mark "!". If I try to start the program by typing in the name, I get a "x Error: Syntax Error".

(Build: 2.1.14181 (2018 10 16)
(06-26-2019 05:24 AM)Arch Wrote: [ -> ]When I press "check" I get "No errors in the program", but if I choose "run" I get an exclamation mark "!". If I try to start the program by typing in the name, I get a "x Error: Syntax Error".

(Build: 2.1.14181 (2018 10 16)

I get the "X Error: Syntax Error" when my calculator is in RPN Entry mode and the calculator is in CAS mode. I heard that RPN Entry mode does not work in CAS mode.

Try running the program in RPN entry mode in the Home screen. The RPN entry mode key press sequence is 45 [Vars] SIN [Enter], where the command line shows 45SIN() before you press [Enter] as indicated in Stevetuc post.

I know you already know this, but don't run the program from the program catalog. Run the program using the [Vars] key in User mode. Were you able to get the very first version of the program to work on your calculator?

Also try running the program in textbook entry mode in both Home and CAS. The textbook entry mode key press sequence is [Vars] SIN 45 [Enter], where the command line shows SIN(45) before you press [Enter].

It sounds like you did this, but make sure you have deleted all previous copies of the program. If you copied and pasted the program using the connectivity kit you would have had to create a program. Rename the program. And, paste in the program. The program name only appears in the Calculator Window Pane on the connectivity kit or the program catalog on the HP Prime calculator. The program name is not KEY K_Vars(). Maybe you have create a new name of the program you forgot about.
@Gene222

It works! Smile

Thanks Big Grin
Still, I don't understand why HP doesn't allow customised menus. There are 6 not used softkeys in standard RPM mode. I mean, it seems the whole community is begging for it, judged by the number of threads and posts in various forums, newsgroups, etc. At the moment these 6 not used touch-buttons are such a waste of space. I really don't get it.

In case anybody of HP company is reading this: could you please allow us to have user defined touch-buttons??!! Big Grin
@Gene222

Hi,

I tried your code once more.


PHP Code:
EXPORT i_SB()
BEGIN
LOCAL a
,b,z,answeri_Wert;
LOCAL event,loop_1,loop_2,loop_3,loop_3_count;
//initialize continuous loop counter variables
loop_1:=1;
loop_2:=1;
loop_3:=1;
WHILE 
loop_1==DO
  
a:=0;  //clear variables
  
b:=0;
  
z:=0;
  WHILE 
loop_2==DO
    
INPUT({a,b,z});
    
i_Wert:=(1/(2*π))*(ATAN((a*b)/(z*(a^2+b^2+z^2)))+(a*b*z)/((a^2+b^2+z^2))*(1/(a^2+z^2)+1/(b^2+z^2)));
    
answer:=i_Wert;
    
loop_3_count:=0;   //initialize loop 3 cycle counter
    
WHILE loop_3==DO //loop 3
      
loop_3_count:=loop_3_count+1;
      
//if there are no tap or key events after 3 WAIT(-1) cycles (3 minutes), exit program
      
IF loop_3_count==4 THEN
        
//exit program
        
BREAK(3);  //exit loops 3, 2, and 1
      
END;
      
//draw G0 screen
      
RECT();
      
TEXTOUT_P("i-Wert nach Steinbrenner",10,15);
      
TEXTOUT_P("a = "+a,10,45);
      
TEXTOUT_P("b = "+b,10,60);
      
TEXTOUT_P("z = "+z,10,75);
      
TEXTOUT_P("i-Wert = "+i_Wert,10,105);
      
//TEXTOUT_P("Loop 3 WAIT(-1) counter = "+loop_3_count,10,135);
      
DRAWMENU("""""""exit""clear""↩");
      
//pause up to 60 seconds to get a screen tap or key press and store the tap or key data into "event"
      
event:=WAIT(-1);  
      
//key press handling procedues
      
IF TYPE(event)==0 THEN     //Is the variable "event" a real number?
        
IF event==4 THEN         //Was the "Esc" key pressed?
          //exit the program by going to end of loop 1
          
BREAK(3);              //exit loop 3, loop 2, loop 1
        
END;
      
END;
      
//mouse tap handling procedures
      
IF TYPE(event)==6 THEN     //Is the variable "event" a list.
        
IF event(1)==3 THEN      //Is the MOUSE event type a mouse click (i.e. screen tap)?
          
IF event(3) > 219 THEN //Was the y coordinate tap within the row of user tabs?
            
IF event(2≥ 0 AND event(2≤ 51 THEN     //tab 1  Is the x coordinate within tab 1?
              //no action                            
            
END;
            IF 
event(2≥ 53 AND event(2≤ 104 THEN   //tab 2
              //no action
            
END;
            IF 
event(2≥ 106 AND event(2≤ 157 THEN  //tab 3
              //no action          
            
END;
            IF 
event(2≥ 159 AND event(2≤ 210 THEN  //tab 4 "exit"
              //go to end of loop 1
              
BREAK(3);          //exit loops 3, 2, and 1
            
END;
            IF 
event(2≥ 212 AND event(2≤ 263 THEN  //tab 5 "clear"
              //go to end of loop 2, and then goes to the beginning of loop 1
              
BREAK(2);          //exit loops 3, and 2
            
END;
            IF 
event(2≥ 265 AND event(2≤ 319 THEN  //tab 6 "↩"
              //go to end of loop 3, and then goes to the beginning of loop 2
              
BREAK(1);          //exit loop 3
            
END;
          
END;
        
END;
      
END//if TYPE(event)==6
    
END//loop 3
  
END//loop 2
END//loop 1
RETURN answer;  //returns the answer to the home screen
END//main program 

Modified it a tiny bit. Just two questions:

1. The program returns only the last result to the stack when you exit it. I want to calculate several times and use each result for further calculations in RPN. Is there a way that all the previous results are returned to the stack for further use in RPN?
2. While the code works fine on the virtual calculator, I got problems on the real one. The following actions will result in a shutdown of the calculator ("Your calculator has a problem and will be rebooted in 3 seconds"):
a. hitting <enter> several times after a calculation
b. pressing exit after a calculation

Do you have any suggestions?

Thanks
Arch
(06-30-2019 09:06 AM)Arch Wrote: [ -> ]Just two questions:

1. The program returns only the last result to the stack when you exit it. I want to calculate several times and use each result for further calculations in RPN. Is there a way that all the previous results are returned to the stack for further use in RPN?
2. While the code works fine on the virtual calculator, I got problems on the real one. The following actions will result in a shutdown of the calculator ("Your calculator has a problem and will be rebooted in 3 seconds"):
a. hitting <enter> several times after a calculation
b. pressing exit after a calculation

1. I don't use RPN on the Prime. So, I don't know how to take answers from the program and put them on the stack. My last RPN calculator was the HP-42 something. The one that had a two line display. I skipped the 48-50 series.

2. Your code works fine on my physical calculator. I have the early version of the Prime. I don't know the model number, but it's the one that has the light orange letters on the keys. I can't duplicate the "will be rebooted in 3 seconds" error. However, when "hitting <enter> several times after a calculation", I will get a division by zero error message. This is because the first press of the [Enter] key restarts the program. The program then clears or zeros the variables and displays the input screen. The second press of the [Enter] key is like pressing the OK tab on the input screen with no inputs. So you are running the program with inputs of a=0, b=0, and z=0. This causes a division by zero error message.

That WAIT(-1) code is just a beginner's example of how the WAIT(-1) works. There are plenty of other ways to program the WAIT(-1). They are just hard to find and are often difficult to understand.

3. How you use and program the HP Prime is entirely up to you. But if I were writing that program, I would not use "User Tabs" or "program tabs", particularly if I just got the Prime. They are just too difficult to program.
Pages: 1 2
Reference URL's