-
×InformationNeed Windows 11 help?Check documents on compatibility, FAQs, upgrade information and available fixes.
Windows 11 Support Center. -
-
×InformationNeed Windows 11 help?Check documents on compatibility, FAQs, upgrade information and available fixes.
Windows 11 Support Center. -
- HP Community
- Archived Topics
- Tablets and Mobile Devices Archive
- Can a user key definition only return a string?

Create an account on the HP Community to personalize your profile and ask a question

03-05-2017 04:44 AM
The Prime's manual (2nd ed., pages 571ff) teaches us that we can reassign keys in the user keyboard. The only example, however, is one where the corresponding "program" returns a string.
I, however, would like to execute my own program when a certain user key is pressed and I thought this will work:
EXPORT Next(N) BEGIN IF odd(N) THEN RETURN 3*N+1; ELSE RETURN N/2; END; END; KEY K_Xttn(M) BEGIN Next(M); END;
However, back in the Home screen (I'm in UPN mode most of the time) when I put a number on the stack and then press Shift-Help (User) xttn-Key I just get an X in the input line. 😒
So is there no way I can repeatedly execute my program by just pressing one key in the user keyboard (in persistent user mode)? This was something I very often did on my HP48 back then ... I, too, loved that I could press the top row keys for that and saw on the display what they did. Unfortunately, the Prime's menu keys on the display are just six all black rounded filled ractangles and totally useless. Or can I fill those with functionality?
03-05-2017 11:16 PM
Hello,
if a user key returns a string, that string is handled as a text which is entered in the calculator.
if a user key returns a number, it is assume that this is a key code, which is executed instead of the original key.
all else is ignored and the original key is executed.
If you want no further actions taken than your program, return the number of a useless key (such as 41 for shift if I am not mistaken).
Cyrille
03-06-2017 04:25 AM
Thanks, Cyrille.
However, returning some integer that's not a keycode is not an option here because my program returns the result of a calculation and I want this to be on the stack – so that I can press the User-key again to take the result as input to my program.
So what was no problem on an HP48 is not possible on the Prime, right? 😒
It would be SO cool if the useless, empty black key labels on the screen could be assigned to functions/programs like it was possible with the HP28/48/49/50 series ...
Best,
Stefan.
03-07-2017 08:58 AM - edited 03-07-2017 11:25 AM
It is not such a bad idea to let a user key return a string, because when the string is the name of a program, and we press Enter next, the program is executed!
So by pressing 1 key we will not get things done, but by pressing a key, and Enter next, we will.
Then our program is:
EXPORT Next(N) BEGIN IF odd(N) THEN RETURN 3*N+1; ELSE RETURN N/2; END; END; KEY K_Xttn() BEGIN RETURN "Next"; END;
03-07-2017 10:45 AM
We can also write a program which allows us to tap an arbitrary key in order to achieve the same thing.
For this purpose we use the PRINT command and insert it into an endless loop.
To end the loop and the program press Shift – On.
Before starting the program assign a value to N.
NEXT(); //declaration of programs MYPROG(); EXPORT NEXT() BEGIN PRINT(); //clears the screen REPEAT //start of loop PRINT(N); WAIT; //waits for pressing key PRINT(); //clears the screen N:=MYPROG(N); UNTIL 0; END; MYPROG(N) BEGIN IF odd(N) THEN RETURN 3*N+1; ELSE RETURN N/2; END; END;
