Post Reply 
Prime userkeys with embedded escape characters?
02-10-2021, 01:05 PM (This post was last modified: 02-10-2021 01:06 PM by Stevetuc.)
Post: #1
Prime userkeys with embedded escape characters?
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?

   
Find all posts by this user
Quote this message in a reply
02-10-2021, 06:35 PM (This post was last modified: 02-11-2021 12:53 PM by Wes Loewer.)
Post: #2
RE: Prime userkeys with embedded escape characters?
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.
Find all posts by this user
Quote this message in a reply
02-10-2021, 08:18 PM
Post: #3
RE: Prime userkeys with embedded escape characters?
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.

Ramón
Valladolid, Spain
TI-50, Casio fx-180P, HP48GX, HP50g, HP Prime G2
Visit this user's website Find all posts by this user
Quote this message in a reply
02-11-2021, 06:38 AM
Post: #4
RE: Prime userkeys with embedded escape characters?
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.
Find all posts by this user
Quote this message in a reply
02-11-2021, 01:17 PM
Post: #5
RE: Prime userkeys with embedded escape characters?
(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.
Find all posts by this user
Quote this message in a reply
02-11-2021, 01:31 PM
Post: #6
RE: Prime userkeys with embedded escape characters?
(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.
Find all posts by this user
Quote this message in a reply
02-12-2021, 10:22 AM
Post: #7
RE: Prime userkeys with embedded escape characters?
(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?ti...ut_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.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)