24-MAR-2021 Simple Units
|
03-24-2021, 02:17 AM
(This post was last modified: 03-24-2021 06:33 PM by Han.)
Post: #1
|
|||
|
|||
24-MAR-2021 Simple Units
User mode is required. This program basically takes over the [Shift][_] key and provides a super-simple units menu for facilitating unit conversion. When the user types the _ symbol via [Shift][_], a units menu is automatically shown (and if applicable, the last menu used will be displayed). The first menu is the category, and the second menu is the list of units within that category. So if one were to convert 5 kilometers to miles, the keystrokes are:
5 [Shift][_] (select distance) (select km) (press the Sto> menu button on the screen) [Shift][_] (select mile) [Enter] Press [Esc] to traverse back a menu (i.e. from units to category). Escaping out of the category menu will simply place the _ symbol onto the command line (in case you need to type the underscore character inside a string, for example). Pressing [On] will escape all menus (i.e. to avoid pressing [Esc] twice while inside a menu of unit symbols. Adding one's own custom units can be easily done by simply adding to the existing lists named catlist (category) and symlist (unit symbols), which should be fairly obvious to do when looking at the source code (toward the very top). Just make sure to keep the lists ordered properly. To install, simply create a new program called UNITS (or whatever name you want) and copy and paste the code below into your new program (easiest if done via the connectivity kit). Then drag/drop to your calculator. If you already have custom keys set up, then just add this to your existing custom keys program. If you find any typos in the unit symbols, please let me know and I'll update here accordingly. Maybe in the (far?) future I'll focus on creating a custom menu that takes advantage of the large screen so that all categories and unit symbols are visible at once (with keyboard shortcuts) to remove the need to scroll the menu and improve efficiency. Code: #pragma mode( separator(.,;) integer(h32) ) Graph 3D | QPI | SolveSys |
|||
03-24-2021, 02:58 AM
Post: #2
|
|||
|
|||
RE: 23-MAR-2021 Simple Units
(03-24-2021 02:17 AM)Han Wrote: User mode is required. This program basically takes over the [Shift][_] key and provides a super-simple units menu for facilitating unit conversion. When the user types the _ symbol via [Shift][_], a units menu is automatically shown (and if applicable, the last menu used will be displayed). The first menu is the category, and the second menu is the list of units within that category. So if one were to convert 5 kilometers to miles, the keystrokes are: I will check this out later. thanks! |
|||
03-24-2021, 03:48 AM
Post: #3
|
|||
|
|||
RE: 23-MAR-2021 Simple Units
I just tried this out, but I have a few questions. In order to create a unit like Newton Meters, would it require adding "N*m" in the list in the code (actually creating a new group called "Torque" and placing that under that entry)?
Also, does the conversion only work when in Textbook/Algebraic mode? There is no "Sto>" button on screen when in RPN mode (which i am using 99% of the time). |
|||
03-24-2021, 04:04 AM
Post: #4
|
|||
|
|||
RE: 23-MAR-2021 Simple Units
(03-24-2021 03:48 AM)spiff72 Wrote: I just tried this out, but I have a few questions. In order to create a unit like Newton Meters, would it require adding "N*m" in the list in the code (actually creating a new group called "Torque" and placing that under that entry)? Yes, so create a new entry in the catlist variable called "Torque" and add in all your torque units in the symlist variable. (Don't forget to add a comma at the end of the previous entry!) Unfortunately you lose a lot of the efficiency in RPN mode (which to this day seems very rudimentary in my opinion). In RPN mode the keystrokes are a little more drawn out: 5 [Shift][_] (pick units category) (pick unit) [Enter] 1 [Shift][_] (pick target unit) [Enter] [Shift][C] (Tools -> Convert; if Tools was previously selected then it automatically shows this menu) [Enter] So basically you still benefit from the "previous" category being saved when pressing [Shift][_] and don't have to re-navigate through the menus in RPN mode but it is not as convenient as in non-RPN mode. I personally don't use this mode on the Prime (I have other HP calculators I prefer to use for RPN/RPL.) Graph 3D | QPI | SolveSys |
|||
03-24-2021, 04:02 PM
Post: #5
|
|||
|
|||
RE: 23-MAR-2021 Simple Units
(03-24-2021 04:04 AM)Han Wrote:(03-24-2021 03:48 AM)spiff72 Wrote: I just tried this out, but I have a few questions. In order to create a unit like Newton Meters, would it require adding "N*m" in the list in the code (actually creating a new group called "Torque" and placing that under that entry)? I took a shot at adding those elements but I ran into some syntax errors when I tried to use the Sto> softkey to convert. I need to revisit this later. |
|||
03-24-2021, 05:39 PM
Post: #6
|
|||
|
|||
RE: 23-MAR-2021 Simple Units
I still can't get this to work with torque units (Force x Length)...
It works fine to "manually" create units in the Units48 app that I originally posted about, and the syntax it shows there would be: 10_(N*m) 1_(in*lbf) (this can be reversed too and entered as lbf-in, but this is not typical for US units) Using the CONV softkey in Units48 then outputs: 88.507..._(in*lbf) I initially tried setting up the list with a new "Torque" entry, and the line for the contents of that list was: {"N*m","in*lbf","ft*lbf"}, With this method, following your instructions would create the following syntax when using the Sto> button: 10_(N)*m>1_(in)*lbf and then pressing Enter yields a popup message stating: Error: Syntax Error So after seeing how the Units48 program formatted the (N*m) in parenthesis, I edited the line in the code to: {"(N*m)","(in*lbf)","(ft*lbf)"}, I then ended up with the following syntax on the entry line: 10_(N*m)>1_(in*lbf) and then pressing enter yields an error message (not a popup this time) stating: Error: Bad Argument Type So I am not sure what to do in this case. |
|||
03-24-2021, 05:50 PM
Post: #7
|
|||
|
|||
RE: 23-MAR-2021 Simple Units
One more observation:
If I use the same arguments in the CONVERT() function, it converts correctly: CONVERT(10_(N*m),1_(in*lbf)) I get 88.507..._in*lbf It seems like maybe the Sto> shortcut for conversion doesn't work in this application? |
|||
03-24-2021, 06:30 PM
(This post was last modified: 03-24-2021 06:34 PM by Han.)
Post: #8
|
|||
|
|||
RE: 23-MAR-2021 Simple Units
(03-24-2021 05:50 PM)spiff72 Wrote: One more observation: Type it without the 1 in the front so that it looks like: 10_(N*m)▶_(in*lbf) I've adjusted the code to account for non-atomic units. You can simply change the last if statement to: Code: if c2 then return("_("+symlist(c1,c2)+")"); else return("_"); end; so that you don't have to encapsulate all your units in parentheses (should look nicer in the menus, too, without them). I've updated the first post to reflect these changes. Graph 3D | QPI | SolveSys |
|||
03-25-2021, 02:33 AM
Post: #9
|
|||
|
|||
RE: 24-MAR-2021 Simple Units
(03-24-2021 06:30 PM)Han Wrote:(03-24-2021 05:50 PM)spiff72 Wrote: One more observation: Thanks! I just came here to post that I just found the same after doing some more testing here (leaving off the 1). |
|||
03-25-2021, 02:42 AM
Post: #10
|
|||
|
|||
RE: 24-MAR-2021 Simple Units
(03-24-2021 06:30 PM)Han Wrote:(03-24-2021 05:50 PM)spiff72 Wrote: One more observation: One additional question... Is there any reason (or disadvantage) to assigning this program to the template key (the one that would normally be the blue-shift UNITS button? So instead of: KEY KS_Space() use: KEY K_Templ() I think that this would be easier for me to remember (and one less key press to activate it). I am relatively new to the Prime (a few months in, and I came from the HP50g), and I am still getting used to things on this calculator. I REALLY miss being able to assing softkeys to a program! |
|||
03-25-2021, 03:44 AM
Post: #11
|
|||
|
|||
RE: 24-MAR-2021 Simple Units
(03-25-2021 02:42 AM)spiff72 Wrote: KEY KS_Space() You can assign it to any key you wish. I assigned it to KS_Space() since that is where most people would naturally use units (since typing _ suggests they are about to type a unit). Perhaps KS_Templ() might be more natural (unless you never use the templates interface). But again, it's completely up to you to decide. Graph 3D | QPI | SolveSys |
|||
03-25-2021, 01:40 PM
Post: #12
|
|||
|
|||
RE: 24-MAR-2021 Simple Units
(03-25-2021 03:44 AM)Han Wrote:(03-25-2021 02:42 AM)spiff72 Wrote: KEY KS_Space() OK - thanks. I have changed that in my program to try it for a while. I figure that since it only affects the user keyboard it won't really affect normal usage in my case. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)