New member, simple question - 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: New member, simple question (/thread-15715.html) New member, simple question - spiff72 - 10-11-2020 06:06 PM 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 * RE: New member, simple question - pinkman - 10-11-2020 09:09 PM 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 RE: New member, simple question - pinkman - 10-11-2020 09:18 PM 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. RE: New member, simple question - spiff72 - 10-11-2020 09:23 PM 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? RE: New member, simple question - spiff72 - 10-11-2020 09:55 PM (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? RE: New member, simple question - pinkman - 10-12-2020 10:18 PM Yes this is the behavior of the algebraic mode (can’t explain why), but in Textbook mode the cursor is moved inside the parenthesis. RE: New member, simple question - spiff72 - 10-12-2020 10:55 PM (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!