Post Reply 
New member, simple question
10-11-2020, 06:06 PM (This post was last modified: 10-11-2020 06:27 PM by spiff72.)
Post: #1
New member, simple question
Hello all,

New member here, current HP50g user who just ordered an HP Prime off eBay. I have been playing with the HP Prime windows app, and I have.a question about programming a simple inch to mm conversion that I had created on my HP50g.

I had created a small RPN program that I stored as 'inmm' so I could type in a value in inches and then tap the inmm soft key to output a value in mm. My program was:
<<25.4 * >>

Is there a way to do this on the Prime so I can have the same functionality as I had with the HP50g?

I know that there are user defined functions, but can these be assigned to a soft key? Or is there another way to do this?

Thanks!

EDIT: Corrected my "program" to change / to *
Find all posts by this user
Quote this message in a reply
10-11-2020, 09:09 PM (This post was last modified: 10-11-2020 09:21 PM by pinkman.)
Post: #2
RE: New member, simple question
Hi, there are many ways to do this, but you may consider the Prime as an Algebraic calc instead of a RPN/RPL one. The soft keys don’t behave like on the RPL HP’s calc, you can’t create custom menus with them, and there is no real “VAR” (directory) equivalent.

Here is my proposal:
Code:

EXPORT Inmm(A)
BEGIN
 RETURN CONVERT(A*1_in, 1_mm);
END;

KEY K_Minus()
BEGIN
 RETURN "Inmm()";
END;

Explanations:
EXPORT Inmm [...] defines a function.
Inmm is your function, it takes a value as an argument and returns the inches to mm conversion, using the built-in CONVERT function. Thus you can see how units can be used.

KEY K_Minus [...] assigns the function to the minus (-) key.

Usage:
1) Textbook or Algebraic mode:
Shift Help -> User mode
[-] -> the command line now shows Inmm()
10 -> the command line now shows Inmm(10)
Enter
Here you are.

2) RPN mode
10
Enter
Shift Help -> User mode
[-] -> the command line now shows Inmm()
Enter
Here you are again

In both cases instead of using a user defined key you can call your function by typing its name or by using the Catalog (Suitcase) key.

Regards,
Thibault

Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co
Find all posts by this user
Quote this message in a reply
10-11-2020, 09:18 PM (This post was last modified: 10-11-2020 09:18 PM by pinkman.)
Post: #3
RE: New member, simple question
Another way would be to use the “Define” key (Shift Xtθn) this way:
Name: Inmm
Function: CONVERT(X*1_(in),1_(mm))

(Let X checked)

You can call it the same way than above (user defined key), or using the Catalog (Suitcase) key.

I don’t really like user defined functions with the “Define” key for my everyday tools, because deleting them is so easy that I reserve the use of this key for transient functions. Using programmed functions is more persistent.

Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co
Find all posts by this user
Quote this message in a reply
10-11-2020, 09:23 PM
Post: #4
RE: New member, simple question
Thanks for the response! I am trying this now...

How/where do you set up that program? I just tried:
Shift - Program, and copied and pasted your code there. Checked no errors.

However, when I try to use it, when I press shift-Help (user), I just get the negative symbol?
Find all posts by this user
Quote this message in a reply
10-11-2020, 09:55 PM
Post: #5
RE: New member, simple question
(10-11-2020 09:09 PM)pinkman Wrote:  Hi, there are many ways to do this, but you may consider the Prime as an Algebraic calc instead of a RPN/RPL one. The soft keys don’t behave like on the RPL HP’s calc, you can’t create custom menus with them, and there is no real “VAR” (directory) equivalent.

Here is my proposal:
Code:

EXPORT Inmm(A)
BEGIN
 RETURN CONVERT(A*1_in, 1_mm);
END;

KEY K_Minus()
BEGIN
 RETURN "Inmm()";
END;

Explanations:
EXPORT Inmm [...] defines a function.
Inmm is your function, it takes a value as an argument and returns the inches to mm conversion, using the built-in CONVERT function. Thus you can see how units can be used.

KEY K_Minus [...] assigns the function to the minus (-) key.

Usage:
1) Textbook or Algebraic mode:
Shift Help -> User mode
[-] -> the command line now shows Inmm()
10 -> the command line now shows Inmm(10)
Enter
Here you are.

2) RPN mode
10
Enter
Shift Help -> User mode
[-] -> the command line now shows Inmm()
Enter
Here you are again

In both cases instead of using a user defined key you can call your function by typing its name or by using the Catalog (Suitcase) key.

Regards,
Thibault

This may end up being a double post, but I tried this method and I couldn't get it to work with the "+/-". I ended up watching this video:
https://www.youtube.com/watch?v=0FiD48pTGqY

And then I realized that you weren't using the +/- key, but were using the actual "-" key.

So I ended up setting up a similar conversion (the MmIn conversion) to another key. It works well in RPN mode, where I can enter the value first, and then press Shift-Help and the key i assigned and it converts the number that was on the bottom of the stack. However, when I try in algebraic mode, I have to arrow left into the parenthesis before i type the value after pressing Shift-Home-(assigned key). Am I missing something - or is there a way for the program to have the cursor placed between the parenthesis to avoid the arrow left?
Find all posts by this user
Quote this message in a reply
10-12-2020, 10:18 PM
Post: #6
RE: New member, simple question
Yes this is the behavior of the algebraic mode (can’t explain why), but in Textbook mode the cursor is moved inside the parenthesis.

Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co
Find all posts by this user
Quote this message in a reply
10-12-2020, 10:55 PM
Post: #7
RE: New member, simple question
(10-12-2020 10:18 PM)pinkman Wrote:  Yes this is the behavior of the algebraic mode (can’t explain why), but in Textbook mode the cursor is moved inside the parenthesis.

Good to know - thanks!
Find all posts by this user
Quote this message in a reply
Post Reply 




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