cancel
Showing results for 
Search instead for 
Did you mean: 
Jem_1964
New member
5 4 0 0
Message 1 of 9
987
Flag Post

Calling a user key from a hppl program on the hp prime

HP Recommended
Hp prime

Hello,

I am attempting to write a program that uses a user key.  How do I enter user mode programmatically and evaluate a user key as if it were pressed?

Any help will be most appreciated.

Jim

0 Kudos
Tags (1)
8 REPLIES 8
Jem_1964
Author
New member
5 4 0 0
Message 2 of 9
Flag Post
HP Recommended

To elaborate more, the user key can return an uncommented string to the rpn stack so if the string contains the names of variables, multiple stack levels are written to.  Thus if from with in a program, I can execute a key, say k_0, it would be possible to implement swap, dupn, roll, etc and so give more hp 48 style rpn programming.  I have used the 42S, 48SX and 48GX for years and have many programs I would like to port to the prime.  My idea is a bit of a hack, but the functionality would be very useful....

 

0 Kudos
cyrille
Level 6
Level 6
252 251 42 77
Message 3 of 9
Flag Post
HP Recommended

hello,

 

Sorry, unfrotunately you can not "simulate" a key...

You can call the program associated with the redefined key directly, it is nothing more than a PPL function with a special marker...

But you can not simulate a key.

 

RPN was shoehorned in HPPRime to be "good enough" in interactive mode. But prime is fundamentally NOT a RPN machine and what you are trying to do will likely end up causing you a lot of time and effort without working well... Sorry....

I would strongly suggest that you try programming in PPL as it is very powerfull and will be a much better sollution for what you are trying to do.

 

Cyrille

I am an HP Employee
0 Kudos
Jem_1964
Author
New member
5 4 0 0
Message 4 of 9
Flag Post
HP Recommended

Can you please explain how to do what you are saying:

 

You can call the program associated with the redefined key directly, it is nothing more than a PPL function with a special marker...

 

What is the proper syntax to do this?

 

Best regards,

 

Jim

0 Kudos
cyrille
Level 6
Level 6
252 251 42 77
Message 5 of 9
Flag Post
HP Recommended

Hello,

 

Let us say you want to redefine the Tan key...

You create a function in your program this way:

KEY K_Tan()

begin

  return 1;

end;

 

Well, K_Tan IS a PPL function and you can call it from anywhere else in a program!

EXPORT myFunc()

begin

  return K_Tan()+1;

end;

 

Cyrille

I am an HP Employee
0 Kudos
Jem_1964
Author
New member
5 4 0 0
Message 6 of 9
Flag Post
HP Recommended

Thank you Cyrille,

From the key board, I must invoke the user entry mode to make my user key k_0  work.  Are you saying this is not is not necessary from a ppl program or is there syntax to invoke user entry ?  Thank you again for all your help!

Best regards,

Jim

0 Kudos
cyrille
Level 6
Level 6
252 251 42 77
Message 7 of 9
Flag Post
HP Recommended

Hello,

 

You are correct, there is no need to be in user mode to call a function associated to a key...

 

a user key association is nothing more (internally) than a regular function (it can even be exported), with the "KEY" keyword in front and a special name...

 

Cyrille

I am an HP Employee
0 Kudos
Jem_1964
Author
New member
5 4 0 0
Message 8 of 9
Flag Post
HP Recommended

Hi Cyrille,

Can I map the soft key ROT from the touch screen key to a user key?  If so, should I create a single file of exported user keys so that I can call the key programs from any new function?   I wrote a program that assigned a key function to K_0 but when I called it from another program it threw an error.  It occurred to me from your comment about export, that perhaps to make the keys visible to other programs you might need to export the key.  Thanks again for your help!

Best regards,

Jim

0 Kudos
cyrille
Level 6
Level 6
252 251 42 77
Message 9 of 9
Flag Post
HP Recommended

Hello,

 

I do not know if you can "program" rot, I am not the one who implemented RPN and I do not remember, all I know is that it is quite limited...

Ans(n) gives you read access to the nth level, but I am not sure it allows you to change the stack...

 

As a general rule, place all related function in a single program. not in n independent programs...

If you want to call a function from one program to another, you have 2 choices:

1: export the function in the first program.

2: fully qualify the function when you call it as in: program.fnctionName();

As a general rule, you do not want to export functions that are not "user facing".

 

Cyrille

I am an HP Employee
0 Kudos
† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation