Post Reply 
HP-42 Program Critique - Kinematic Equations (first program)
06-14-2020, 12:41 AM (This post was last modified: 03-21-2021 07:49 PM by DM48.)
Post: #1
HP-42 Program Critique - Kinematic Equations (first program)
I've been writing small programs trying to get a feel for different areas of Free42/DM42.

Here is my version for the Kinematic equations (three instances). On the menu, the first variable listed is the data you have -> the data you want. Time -> Distance for example.

Don't hold back and let me have it. I welcome any and all suggestions and corrections. My biggest obstacle at the moment is understanding when to use GTO vs XEQ. The difference is GTO goes and stops unless you point it somewhere else to go and XEQ executes and comes back and continues on.

In the early days experimenting with the Menu layout and just have a 1 + option XEQ seemed to fail after four pushes of the soft key. This is why I used GTO here.

Many thanks in advance!

Code:
00 { 137-Byte Prgm }
01▸LBL "KINE"
02 CLMENU
03 "d→t"
04 KEY 1 GTO 01
05 "t→d"
06 KEY 2 GTO 02
07 "t→Vf"
08 KEY 3 GTO 03
09 KEY 9 GTO 09
10 MENU
11 STOP
12▸LBL 01
13 0.5
14 ÷
15 32.17045
16 ÷
17 SQRT
18 CLA
19 ARCL ST X
20 ├" s"
21 AVIEW
22 CLA
23 RTN
24▸LBL 02
25 X↑2
26 0.5
27 ENTER
28 32.17045
29 ×
30 ×
31 CLA
32 ARCL ST X
33 ├"feet"
34 AVIEW
35 CLA
36 RTN
37▸LBL 03
38 32.17045
39 ×
40 5280
41 ÷
42 3600
43 ×
44 CLA
45 ARCL ST X
46 ├" mph"
47 AVIEW
48 CLA
49 RTN
50▸LBL 09
51 EXITALL
52 END

HP48GX user learning the HP42s and DM42.
Find all posts by this user
Quote this message in a reply
06-14-2020, 02:26 PM
Post: #2
RE: Program Critique
You might have been running into issues with the KEY XEQ instructions since your menu doesn't loop back to itself. Typically, after MENU, STOP, you'll want a GTO that jumps back to the same menu. This can either be a LBL directly before the MENU instruction, or all the way before the CLMENU (sometimes it depends on the program and whether it needs to refresh the contents of the menu every time it's displayed).

By doing that, and also leaving out the KEY 9 GTO... (i.e. not moving the program pointer when closing the menu), the user can redisplay the last menu by simply pressing R/S. Of course, there are plenty of times where you DO want to handle the EXIT key and RTN or GTO, particularly if you're building a tree of submenus and you want EXIT to go back up a level.
Visit this user's website Find all posts by this user
Quote this message in a reply
06-14-2020, 06:23 PM
Post: #3
RE: Program Critique
Thank you for the insight. I didn't even think about handling the program pointer when closing the menu. Will have to weight that out. I'm still trying to hold on to my 48G roots and soft menus.

I will play around with the looping back to the same menu and the KEY XEQ call you described.

Thank you.

HP48GX user learning the HP42s and DM42.
Find all posts by this user
Quote this message in a reply
03-18-2021, 12:59 AM (This post was last modified: 03-18-2021 01:00 AM by DM48.)
Post: #4
RE: Program Critique
Updated. Comments welcome.

This program handles a few kinematic equations and sets a Custom menu (Key 4).

Code:

00 { 230-Byte Prgm }
01▸LBL "KINE"
02 CLMENU
03 "d→t"
04 KEY 1 GTO 01
05 "t→d"
06 KEY 2 GTO 02
07 "t→Vf"
08 KEY 3 GTO 03
09 "Vf→t"
10 KEY 4 GTO 04
11 "G"
12 KEY 5 GTO 05
13 KEY 9 GTO 09
14 MENU
15 STOP
16▸LBL 01
17 0.5
18 ÷
19 32.17045
20 ÷
21 SQRT
22 CLA
23 "t = "
24 ARCL ST X
25 ├" s"
26 AVIEW
27 CLA
28 RTN
29▸LBL 02
30 X^2
31 0.5
32 ENTER
33 32.17045
34 ×
35 ×
36 CLA
37 ARCL ST X
38 ├" ft"
39 AVIEW
40 CLA
41 RTN
42▸LBL 03
43 32.17045
44 ×
45 5280
46 ÷
47 3600
48 ×
49 CLA
50 ARCL ST X
51 ├" mph"
52 AVIEW
53 CLA
54 RTN
55▸LBL 04
56 5280
57 ×
58 3600
59 ÷
60 32.17045
61 ÷
62 CLA
63 ARCL ST X
64 ├" s"
65 AVIEW
66 CLA
67 RTN
68▸LBL 05
69 ASSIGN "R↑" TO 01
70 ASSIGN "X<>" TO 02
71 ASSIGN "%CH" TO 03
72 ASSIGN "ABS" TO 04
73 ASSIGN "Root" TO 05
74 ASSIGN "EXITA••" TO 06
75▸LBL 09
76 EXITALL
77 END

HP48GX user learning the HP42s and DM42.
Find all posts by this user
Quote this message in a reply
03-18-2021, 03:17 AM
Post: #5
RE: Program Critique
The "00 { Header }" clarifies this program is intended for the 42S/Free42/DM42, but it's a good idea to include that in the posting Subject. This also makes it easier to locate the thread later when looking for this thread.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
03-18-2021, 11:17 AM
Post: #6
RE: HP-42 Program Critique - Kine
Done and thank you.

HP48GX user learning the HP42s and DM42.
Find all posts by this user
Quote this message in a reply
Post Reply 




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