HP Forums

Full Version: Program Critique
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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.
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.
Reference URL's