novice programming questions

Post here to share useful tips and tricks, to ask questions about using your DM42 or to report software-related problems
Post Reply
WLVA
Posts: 7
Joined: Sat Jul 11, 2020 5:05 pm

novice programming questions

Post by WLVA »

I am learning the capabilities of the DM42 by methodically reading the HP-42S manual as well as online forums. Because my PDF version of the manual isn't searchable, I have novice questions and observations.

(1) [GTO] . and general meaning of the deciimal point
From p.111 of the manual, I see that [GTO] . has several reserved meanings. I could brute-force memorize these, but what would be a better way to understand them? In particular, why is the decimal point there at all? Is the appearance of the decimal point related to how [GTO] . . opens a new program space? In general, the appearance of the decimal point here just surprises me.

(2) comment delimiter syntax
In another online forum, someone posted code that seems to use "--" as a comment delimiter. In general, what are acceptable ways to set off comments? (Because HP programs are dense to me, I

(3) start-of-line syntax
In that same code, which I am attempting to understand before I install it, the lines sometimes begin with a space and sometimes with a ">". Is the presence or absence of a character at the start of a line import.

(4) query about best way to learn
I decided to write a very simple program of my own, because sometimes I just want a visually clean display, with X, Y, Z, T, and L set to zero. I can achieve that by clearing the stack and then performing a quick operation like addition (four button pushes). I wrote a program that I installed in the Custom menu that does this (accessing it takes three button pushes -- a whopping 25% savings of time!). My first version of this program left me in the Custom menu, which annoyed me (back to four button pushes). But the Operation Index of the HP-42S manual allowed me to find the command EXITALL, which is exactly what I needed. I'm beginning to appreciate the appendices at the end of the HP-42S manual.

I do wish the documentation were available as a physical codex (for less than the $100 on eBay -- that's just for the manual, not even a calculator!) or as a searchable PDF. There is a wealth of information avaialble in the HP-42S manual, HP-42S programming examples book, HP-41C books, Alternative HP-42S/Free42 Manual, DM42 manual, and online -- it's just difficult to access all of this information.

Am I on the right path to learn how to program the DM42? -- that is, by reading the HP-42S manual methodically in order, examing code in online forums, and playing around at times for my own purposes?
Thomas Okken
Posts: 790
Joined: Tue May 02, 2017 5:48 pm
Location: United States
Contact:

Re: novice programming questions

Post by Thomas Okken »

WLVA wrote:
Sun Sep 13, 2020 4:37 pm
(1) [GTO] . and general meaning of the deciimal point
From p.111 of the manual, I see that [GTO] . has several reserved meanings. I could brute-force memorize these, but what would be a better way to understand them? In particular, why is the decimal point there at all? Is the appearance of the decimal point related to how [GTO] . . opens a new program space? In general, the appearance of the decimal point here just surprises me.
This has its origin in some early programmable HP calculators. I remember it from the HP-19C/29C and the 67/97. In those models, GTO nn means "go to label nn", and GTO . nn means "go to line number nn".

Since jumps to a line number aren't programmable, GTO . works in PRGM mode as well as RUN mode, and this distinction was then applied to GTO "FOO" / GTO . "FOO" in the HP-41C, so you can use GTO . "FOO" to go to label "FOO" while in PRGM mode, without having to switch to RUN mode and back. These GTO variants, like GTO nn and GTO . nn, were passed on from the HP-41C/41CV/41CX to the 42S later on.

GTO . . was always a bit of an odd case, since it's not just a GTO but also adds an END in order to create a new empty program at the end of program memory, in case the last program wasn't empty already. The GTO aspect can be justified by the fact that GTO . . takes you to the final program, which has the final END, i.e. the .END., which also has two dots in its name.
WLVA wrote:
Sun Sep 13, 2020 4:37 pm
(2) comment delimiter syntax
In another online forum, someone posted code that seems to use "--" as a comment delimiter. In general, what are acceptable ways to set off comments? (Because HP programs are dense to me, I
Strictly speaking, there is no comment delimiter syntax. A comment is simply whatever text is on a line after the end of the instruction. This is usually unambiguous, but you do need to be a bit careful with ALPHA strings; for example, in the case of

Code: Select all

 42 |-"X"   add "X"
it isn't clear whether the string being appended is X or X" add "X.
As long as you avoid the use of double quotes in comments following lines containing ALPHA strings or ALPHA arguments, you'll be fine.
WLVA wrote:
Sun Sep 13, 2020 4:37 pm
(3) start-of-line syntax
In that same code, which I am attempting to understand before I install it, the lines sometimes begin with a space and sometimes with a ">". Is the presence or absence of a character at the start of a line import.
In program listings, HP calculators print some non-blank character before LBL instructions, in order to make them stand out. The HP-97 and 19C print an asterisk, for example. The HP-42S prints a solid black triangle, and in program listings, this is often simulated by putting a > character in that position.
WLVA wrote:
Sun Sep 13, 2020 4:37 pm
(4) query about best way to learn
I agree that it would be nice if all the available documentation were organized a bit better, but the good news is that the HP-42S isn't as complex as the HP-48/49/50 series calculators, and it is possible to get to the point where you can use them effectively without needing the manuals all the time. Until you get there, the HP-42S manual really is your friend, and so is this forum and the one at the Museum of HP Calculators, https://www.hpmuseum.org/forum/.
dlachieze
Posts: 257
Joined: Thu May 04, 2017 12:20 pm
Location: France

Re: novice programming questions

Post by dlachieze »

WLVA wrote:
Sun Sep 13, 2020 4:37 pm
I do wish the documentation were available as a physical codex
If you don't have already have one you may consider getting an original HP 42S Quick Reference Guide from the author of the HP 42S Owner's Manual. It's reasonably priced.
It also inspired the DM42 on-calc help.
DM42: 00425 - DM41X: β00066
WLVA
Posts: 7
Joined: Sat Jul 11, 2020 5:05 pm

Re: novice programming questions

Post by WLVA »

Thank you, Thomas Okken and dlachieze, for the information, resources, and encouragement.

My son asked me on Saturday what work I was doing and I replied that I wasn't working, I was learning how to use my calculator better. He gave me a quick doubtful side glance, but I hope in my spontaneous answer he again observed the value in learning for learning's sake. (Then again, later in the day he shared what he was doing on Minecraft, which holds no interest for me although I recognize its own educational potential.)
cdmackay
Posts: 161
Joined: Fri Oct 05, 2018 8:33 pm
Location: Cambridge, UK
Contact:

Re: novice programming questions

Post by cdmackay »

WLVA wrote:
Sun Sep 13, 2020 4:37 pm
I am learning the capabilities of the DM42 by methodically reading the HP-42S manual as well as online forums. Because my PDF version of the manual isn't searchable, I have novice questions and observations.
Some PDF tools are able to make a PDF searchable. I seem to have done that with mine, so DM me if you would like a copy.
Cambridge, UK
41CL/DM41X 12/15C/16C DM15/16 71B 17B/BII/bII+ 28S 42S/DM42 32SII 48GX 50g 35s 30b/WP34S Prime G2
& Casios, Rockwell 18R :)
Post Reply