HP30b 36Programming automating tasks
HP30b 36Programming automating tasks
The HP 30b Business Professional calculator includes a programming capability designed to help automate repetitive
calculations and extend the usefulness of the built-in function set of the calculator. The capability includes the creation of
up to 10 separate programs using up to 290 bytes of memory among them.
Programs record keystrokes, with each keystroke using one byte of memory, although some commands use more than
one byte. In addition, many program-only functions are provided for conditional tests, “gotos”, looping, displaying
intermediate results and even calling other programs as subroutines.
This learning module will show how to automate repetitive calculations to save time as well as how to bring functions out
of menus and onto the keyboard. Other learning modules will show how to enter and edit programs, loop and call
subroutines as well as showing several example programs to help get you started.
When a program is displayed, a number will be shown below it indicating how many bytes are used. If the program name
is shown in reverse video, then the program has been assigned to a key and can be executed by pressing the
appropriate key combination, even when in calculation mode, as shown
in the image at right. When viewing a program in the program catalog,
pressing :xI will delete the presently displayed program
and return to the calculation environment. To delete all programs, press
:x>>II while in calculation mode.
At different places within a program, you can insert a Label (LBL) command. A label defines a location to which program
control may be transferred. The HP 30b can handle up to 100 labels within the entire program memory. These labels are
a two-digit numeric value from 00 to 99. No label can be used more than once, which makes each label a “global” label
and defined only once within the global program memory space. If you attempt to enter a label that has already been
used, a message saying “Exists!” will be briefly displayed.
Example 1: Suppose you needed to compute the area under the normal distribution curve for a number of standardized
z-score values. The normal distribution probability function is labeled LTND located in the math menu as shown below.
To automate this type of function found in a menu, make a list of the exact keys pressed to access the function manually.
These key presses will be entered in the program. In this case, once the standardized z-score is in the display, you
would press :s<<II. The final I (a final = works just as well) is necessary to have the
HP 30b execute the function instead of just previewing the potential answer.
Note: To enter a < (or > or { or O) function in a program, it is necessary to press :, hold it down and
press the appropriate key (such as < ) before releasing the : key. This will be shown in the program listings as
:+ <.
To enter this series of key presses into a program, you would press the following keys.
To exit program edit mode, press : . This returns the HP 30b to the program catalog and now displays Prgm 0,
showing the program’s 3 digit checksum of 243 and that the program uses 7 bytes of program memory.
One way to run this program is from the program catalog. With Prgm 0 shown in the display, you can enter a z-score for
which you want to have the cumulative probability computed and press ==. This will run the program and return
the result. For example, press 1==. The program runs and displays the result below. Note that running the
program in this way exits the program catalog.
To run the program again, you can re-enter the program catalog, key in another z-score and rerun the program.
However, this is also rather keystroke intensive.
Fortunately, you have the ability to assign a program to a key. Once assigned to a key, pressing the key will
automatically run the program. Suppose you wanted to assign this program to the :f key position. To make this
assignment, re-enter the program catalog by pressing : .
Note: If you assign this program to the :f key position, the random number function is ONLY available if you clear
the program key assignment or if you press: + 1 (shift-hold 1) while in the calculation environment (since the
random number function is the shifted function of the 1 key). If the shift-hold f position (: + 1 ) has ALSO been
assigned to a program, the original functionality of the key position will be unavailable until one of the key assignments
has been cleared. To clear an assignment, press { when program step 0 is displayed.
The program catalog is displayed showing program 0. Press I to begin editing the program. Now press >. This
takes the program listing to step 0, as shown below.
The HP 30b will automatically assign a program to the key represented by the step entered at step 0. With step 0 shown,
press :f to assign this program to that key position on the keyboard. Note that the program step location did not
advance when the program assignment was entered – it stayed on step 0, as shown below.
Now press <O to exit the program editing environment. To run the program, key in a z-score and press :f.
For example, to compute the area under the normal distribution curve for the z-scores of 1, 0 and 0.5, you can now
press:
1:f then 0:f and then 0.5:f. You have now extended the HP 30b keyboard by
placing the normal distribution probability function on the keyboard at the location :f. This saves a large number
of key presses and is actually very easy to do.
Example 2: The HP 30b has the three basic trigonometry functions, sine, cosine and tangent on the keyboard. The
inverse trigonometry functions are in the Math menu, however, as shown below. If you need to use the inverse
trigonometry functions often, you can assign these functions to the “shift hold” positions of the three trigonometry
functions that are on the keyboard. You can visualize this by looking at the HP 30b keyboard. Every key except the shift
key itself has two functions: the function printed on the top of the key and the blue function written on the front slope of
the key. Each of these two locations can be “assigned” as the starting key for a program. In addition, you can define
assignments of programs to the shift and hold key position as well. In this example, we will assign the inverse sine
function to the shift-hold 7 key. To access that function, you would press : and while holding it down, press 7.
To automate this type of function found in a menu, make a list of the exact keys pressed to access the function
manually. These key presses will be entered in the program. To perform an inverse sine, you would press
:sI<I. The final I (a final = works just as well) is necessary to have the HP 30b execute
the function instead of just previewing the potential answer.
To enter this series of key presses into a program, you would press the following keys.
To exit program edit mode, press : . This returns the HP 30b to the program catalog and now displays Prgm 1.
The number of bytes used by Prgm 1 is shown below it in the display. The automation program uses 6 bytes of memory
and has a checksum of 047.
To assign this program to the :+ 7 key position, enter the program catalog by pressing : . Press > to
view step 0 of this program where the key assignment will be entered. To assign this program to the :+ 7 key
position, press :+ 7. The display should appear as shown below. SH7 stands for “shift-hold 7” which is the shift-
hold sine function position.
Press <O to exit the program edit mode and return to calculation mode. Assuming the calculator is in the degrees
angle mode, calculate the sine of a 25 degree angle by pressing 25:p. The display should appear as
shown below.
To find the angle again by executing the inverse sine function, press : + 7. The display should appear as shown
below.
Note that in this example, an assignment was made to a key position that already had a shift-hold function assigned to it
by the HP 30b itself: the CALL programming environment function. In the calculation environment, the inverse sine
program assignment will be executed. If you press this shift-hold key position while editing a program, the CALL function
will be entered into the program, since that assignment is active in program mode.
Example 3: Change the previous program so that step 1 contains the MSG “INV SIN” so that the program will show
those characters as a title in the program catalog listing. Remember that to move the character position to a numeric digit
as a letter in a message, press the corresponding numeric key. To move to an =, press =. Pressing . moves to the
? character. Pressing } moves the character position to a space. The arithmetic operators move the character position
to the corresponding operator character. Press I to select the displayed character and prepare to enter another
character. Press O to select the displayed character and terminate character entry. A maximum of 8 characters may
be entered as a message.
To modify the program, do the following.
Although this takes some key presses to input, some users will find this ability to give a title to a program very useful, as
the function of the program will be much more evident from “INV SIN” being displayed in the program catalog than the
generic “Prgm 2”. The title is displayed in “reverse video” because this program is assigned to a key from example 2.
Note that inserting the MSG to give this program a title used an additional 9 bytes of memory (15 – 6 from the previous
example). Remember that if you make a mistake while entering a MSG, you can press { at any time before you press
O and the character at the end of the message will be deleted. Note that the MSG command is perhaps most useful to
enter a string of characters in a program to display a prompt to the user before the program stops for input. This
prompting message can help the user know what values to enter before resuming program execution. The use of the
MSG command here to give a title to a program in the program catalog is simply another use of this function.