HP Forums
Prime userkeys with embedded escape characters? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Prime userkeys with embedded escape characters? (/thread-16302.html)



Prime userkeys with embedded escape characters? - Stevetuc - 02-10-2021 01:05 PM

There is a very interesting thread in the general forum about setting up HP-71B userkeys with embedded escape characters such as chr$(8) to perform a non-destructive backspace

HP-71B Custom Key Definitions to save lots of keystrokes

I wondered if the same could be achieved on the Prime? It's possible to configure a userkey on the prime to return a string to the command line, but embedded escape characters seem just to print as a rectangle.

HP Prime escape sequences

Code:
KEY K_4()
BEGIN
  RETURN "TEST"+CHAR(8);
 //RETURN "TEST\X08"; //alturnative
END;

There is also a program in the Prime software library called
CSTMENU
This allows user defined softkeys to return a string, but embedded escape sequences have same result as described above.
Any thoughts?

[attachment=9085]


RE: Prime userkeys with embedded escape characters? - Wes Loewer - 02-10-2021 06:35 PM

I have longed for the the ability for assigned keys to be able to automatically run without the need to press Enter afterwards while in RPN mode. For example, say I have a program called ASIN2 that I want to run when Shift-Sin is pressed. I could use this:

Code:
KEY KS_Sin()
BEGIN
 RETURN "ASIN2";
END;

In RPN, I'd like to be able to execute the ASIN2 program by just pressing Shift-Sin as you would have with other RPN/RPL calculators. Instead, you have to press Shift-Sin followed by Enter.

This could be fixed by allowing something like this:
Code:
 RETURN "ASIN2\n";

This would be exceedingly useful. If anyone knows how to accomplish this, please let me know.


RE: Prime userkeys with embedded escape characters? - ramon_ea1gth - 02-10-2021 08:18 PM

Yes, I agree with these points. Apparently the user key functions are only allowed to return a string, but appending a "\n" or "\r" has no effect. It would be useful something that outputs a string and executes an ENTER afterwards so I could add further functionality to CSTMENU.


RE: Prime userkeys with embedded escape characters? - Didier Lachieze - 02-11-2021 06:38 AM

Quoted from Cyrille here:

Quote: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).

For your ASIN2 program you can use :
Code:
KEY KS_Sin()
BEGIN
 RETURN (STRING(ASIN2(Ans(1)))+" ");
END;

This will return the result of ASIN2 followed by a space to the command line, so you can directly type another number without the two being concatenated.


RE: Prime userkeys with embedded escape characters? - Wes Loewer - 02-11-2021 01:17 PM

(02-11-2021 06:38 AM)Didier Lachieze Wrote:  For your ASIN2 program you can use :
Code:
KEY KS_Sin()
BEGIN
 RETURN (STRING(ASIN2(Ans(1)))+" ");
END;

This will return the result of ASIN2 followed by a space to the command line, so you can directly type another number without the two being concatenated.

You still have to press Enter afterwards to push the result onto the stack, but it's a step in the right direction.


RE: Prime userkeys with embedded escape characters? - Didier Lachieze - 02-11-2021 01:31 PM

(02-11-2021 01:17 PM)Wes Loewer Wrote:  You still have to press Enter afterwards to push the result onto the stack, but it's a step in the right direction.

Yes but you don't always need to, for example if you want to calculate 2*ASIN2(PI/4) you can just type in User mode:
PI 4 / Shift SIN 2 *

Also one of the limitations is that this user key assignment is applying the ASIN2 function to the value in the stack level 1, so if you want to calculate ASIN(0.5) you need to press ENTER after typing 0.5 to put it on the stack.
So not a perfect solution... but the best I was able to find.


RE: Prime userkeys with embedded escape characters? - Stevetuc - 02-12-2021 10:22 AM

(02-11-2021 06:38 AM)Didier Lachieze Wrote:  Quoted from Cyrille here:

Quote: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).

The escape sequences are entered as strings
https://tiplanet.org/hpwiki/index.php?title=HP_Prime/Commands/Guides/All_About_Strings
so their use should be consistent with Cyrilles explanation. Seems like a bug that they don't work. Unlikely to be addressed anytime soon though.