HP Forums
User defined key going to straight to a program - 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: User defined key going to straight to a program (/thread-16964.html)



User defined key going to straight to a program - matalog - 05-17-2021 08:58 PM

I tired this, to remove the need to press enter, after a key assigning program, returning a program name as a function:
Code:
KEY K_Sin()
BEGIN
 Input(A,"Number","Number: ",0,0);
 Return A;
END;

But it doesn't work as expected. Depending on the number entered in the input box, the program will return different things, I once (with 78 input) got it to return a square symbol with circle inside, and got it to return Sin() (with 238 or something close input. Both times, I had User Input activated, and my program ran upon clicking Sin() key. Inputting 83 will bring up the Lists menu, and 84 will return curly brackets.

What I am describing is in textbook entry mode.

Were user keys assignments not designed to work like this, is it considered a bug?

Is there a correct way to run a user program with a single button press (not followed by Enter), that will allow the Returned number to go on the calculator stack?


RE: User defined key going to straight to a program - matalog - 05-18-2021 08:39 PM

So, I worked out that exactly is happening here, maybe you all knew already.

The input number is being treated like an instruction to a Key, like Getkey numbers, but extended to Shift keys (51+Input) or Alpha Keys (51+51+Input), Shift+Alpha Keys (51+51+51+Input), so, if you input 134 in this program, then the outcome will be a Q, 185 will be q on screen.

There is a very small chance that something useful could ever come of this, but it is there :-).


RE: User defined key going to straight to a program - matalog - 05-18-2021 09:45 PM

I suppose It may be obvious, when you consider that the whole program was defined in the first line as KEY K_Sin(), effectively making it a Key reading program, not a function or procedure, but then KEY, as a command is not defined anywhere in any of the lists that I have looked at, it was merely mentioned in page 616 of the 2017 version of the Manual that I read.

Maybe it is not defined, because it is not usable anywhere else in a program?

Any advice on the subject would be appreciated.


RE: User defined key going to straight to a program - Tim Wessman - 05-19-2021 05:12 AM

(05-18-2021 08:39 PM)matalog Wrote:  There is a very small chance that something useful could ever come of this, but it is there :-).

It was to let a basic user redefine keys into a new location... Smile


RE: User defined key going to straight to a program - matalog - 05-19-2021 12:48 PM

(05-19-2021 05:12 AM)Tim Wessman Wrote:  
(05-18-2021 08:39 PM)matalog Wrote:  There is a very small chance that something useful could ever come of this, but it is there :-).

It was to let a basic user redefine keys into a new location... Smile

But not to redifine a key to a program, it seems a strange choice. I mean, if there was some ambiguity, give the user both.

Maybe it will come in a later update of firmware.