© 2025 Torsten Manz mail_logo.gif 20x14

Programs

PRGM mode

Writing Programs

To write a program on the HP-15C, you must switch to PRGM mode by pressing g P/R. In the Simulator you can also press F9 on the keyboard or click on P/R. The display format will change and the word "PRGM" will appear in the lower right corner of the display:

prgm_step_000.gif 310x70

You can now start typing commands, just as you would do in Run mode. The HP-15C will record the keys as you type, but will not execute any commands. HP-15C programs are more like macros than like true programs.

All programs in this documentation use the decimal comma style, where the comma acts as the decimal separator and the period as the thousands separator.

Each program begins with a label. Valid labels are the letters "A" to "E", the numbers "0" to "9" and ".0" to ".9". As an example, we will write a program that starts with label "A". Click f LBL A or key in F8 Q. This is the first program step and it is displayed like this:

prgm_step_001.gif 310x70

Each key on the HP-15C is identified by a two-digit code that corresponds to its position on the keypad. The first digit indicates the row (starting from one) and the second digit indicates the column (where 0 means 10). For example, LBL is on the first key in the second row and has the key code "21". Digit keys, however, differ from that rule; the digit itself identifies them.

The key codes for a three-key sequence are separated by a thousands separator. The codes in a two-key sequence are separated by blanks. There are also four-key sequences, like STO + . 5 which adds the contents of the X-register to register 15. Those sequences are displayed like this

prgm_step_021.gif 310x70

To complete the program, enter the following key sequence:

2 × 9 . 8 ÷ √x̅ g RTN

This little program computes the time it takes for an object to fall from a given height to the ground in the earth's gravity field. The gravitational acceleration is approximately 9.8 m/s2.

In PRGM mode, you can display the program popup menu by right-clicking the display. You can find a complete description of this popup menu in the Pop-up Menu section.

prgm_mnemonics_col.gif 164x204

To run a program you must switch to Run mode. Click g P/R, or press F9, again.

In PRGM mode, you can paste text from the system clipboard into the simulator by using CtrlV or B2 when it is in Program File Format.
The Mnemonic Converter generates that format.

Running a Program

To run a program click the GSB key followed by the program label. So GSB A will run the program that begins with LBL A. While a program is running, the display flashes "running":

prgm_step_run.gif 310x70

On the Simulator, programs with an alpha label can also be run by clicking on the gold labels A through E, if the 'Access "f" and "g" functions directly' option is enabled in the preferences. Programs with numeric labels can only be run using the GSB key. In addition, the Simulator provides several shortcuts for running programs. A complete list can be found in the Program (Run mode) section of the "Keyboard" chapter.

Any keystroke or any mouse click on a simulator key interrupts a running program. Mouse clicks outside of the keyboard area do not interrupt a program. For example, you can move the simulator window around the screen while a program is running without interrupting it.

The GTO key cannot be used to run a program. If the simualator is in Run mode, GTO A will only position the program pointer on the step with label "A", but will not run the program. To run the program now, click R/S or press F5.

◀ PRGM Mode ▲ Top

Program Documentation

With the Simulator, you can add documentation to your programs, a feature not available on the real HP-15C. The documentation has no effect on the program itself. Documented programs are fully compatible with the real HP-15C.

The Description Dialogue

To document a program, press F12 or select "Program description…" from the ON popup menu to open the Program Description dialogue box. The dialogue has the following elements:

Changes to the documentation are indicated by a * in the title bar of the window.

The elements in the dialogue box, i.e. labels, data storage registers and flags, are displayed in

Documentation Life Cycle

When you start documenting a program, the documentation is only in the simulator memory. To include it in the program, you must save the program file. This also applies to changes to the documentation: You must always save the program manually. When you open a documented program file, the documentation is copied into the simulator memory. Any existing documentation will be overwritten.

If you delete a label or flag or if you no longer use a data storage register, its description will not be deleted until you close the Simulator or save the program file. In these cases, the documentation is purged, i.e. descriptions that are no longer used are deleted and not saved.

If you reuse a previously deleted element before closing the Simulator or saving the program, the previous description of that element will be re-used in the program description.

◀ Documentation ▲ Top

Program Files

Saving and Opening Programs

The current program is always part of the memory file and is therefore automatically saved each time the memory is saved. In addition, programs can also be saved separately: Pressing CtrlS opens the operating system's Save File dialogue box. The default file name for new programs is "New.15c" or the first 40 characters of the "Program title", if available. The Simulator supports the file extensions ".15c" and ".txt"; the default is ".15c".

To open a program file press CtrlO. The standard operating system dialogue box for opening files opens. When a program is loaded, all currently loaded programs are deleted. If the new program is larger than the available memory, the display will show   ERROR  4  and the program will not be loaded. It is not possible to merge programs during loading. For information on how to do this manually, see the next section on file format.

The Simulator remembers the last directory used to read or write a program file. This directory is used as the start directory the next time a dialogue box is opened.

Program File Format

Simulator program files are simple text files. The following figure shows the program file for the small program used in the previous sections:

HP-15C Simulator program

   # --------------------------------------------
   # HP-15C Simulator program
   # Created with version 3.0.00
   # --------------------------------------------

      000 {             }
      001 {    42 21 11 } f LBL A
      002 {           2 } 2
      003 {          20 } ×
      004 {           9 } 9
      005 {          48 } .
      006 {           8 } 8
      007 {          10 } ÷
      008 {          11 } √x̅
      009 {       43 32 } g RTN

   # --------------------------------------------
          

As on the real HP-15C, step "000" is always empty.

Each line in a program file must be of one of the following types:

Program files are encoded in UTF-16 (LE) by default to preserve all special characters used in mnemonics. You can change the encoding to the system default encoding (see Files), but then mnemonics with special characters may not be stored correctly. Key sequences are not affected as key codes contain only digits.

When reading a file, only the key sequences are used. Line numbers and mnemonics are stored for documentation purposes only.

When writing a program file, the Simulator uses the file format described above. As the files are simple text files, you can edit them with any text editor that supports UTF-16 (LE). When editing the files, you only need to address the key sequences.
For example, you can increase the accuracy of the acceleration due to gravity in the program example from 9.8 m/s2 to 9.81 m/s2. To do this, simply insert a new program step with the key code for the number 1 after the line "006":

HP-15C Simulator program

      ...
      003 {          20 } ×  
      004 {           9 } 9
      005 {          48 } .
      006 {           8 } 8
                    { 1 }
      007 {          10 } ÷
      ...
        

Neither the line number nor the mnemonic need be specified. The program steps are automatically renumbered when the file is read. When program is written back with the Simulator, the full file format is used. Missing information, such as the mnemonics, will be added by the Simulator.

Omitting all optional information gives us to the simplest form of the example program file.

Simplified file format

   {42 21 11}  
   {2}
   {20}
   {9}
   {48}
   {8}
   {10}
   {11}
   {43 32}
         

HTML Export

The program code together with the documentation can be exported to an HTML file. HTML exports cannot be reloaded into the Simulator! They are for documentation purposes only.

To export a program to HTML, open the Save Program dialogue box and select "HTML Files (*.htm, *.html)" as the file type. The HTML files are UTF-8 encoded.

macOS:
Some versions of Tcl/Tk do not display the standard Save dialogue box with the file type list box activated. In this case, open the dialogue either via "File | Export program to HTML…" or via the shortcut E. In both cases, the default file type is set to "HTML Files (*.htm, *.html)". You can always force the file type by manually setting the file extension ".htm" manually to force an HTML export.

If any of the following are empty, you will be asked if you still want to save the file anyway:

The warning message can be disabled in the Preferences dialogue box.

When you press CtrlF1 or ShiftF1 on the Simulator, it will search for an HTML file with the same name as the program file and with the extension ".htm" or ".html" in the same directory from which the program was loaded. If a program help file is found, it will be opened in the help file browser.

All the programs in the Program Examples package come with an HTML help file.

◀ Program Files ▲ Top

Menus ▶