hp-support-head-portlet

Actions
Loading...

HP Customer Support

hp-contact-secondary-navigation-portlet

Actions
Loading...

hp-share-print-widget-portlet

Actions
Loading...

hp-concentra-wrapper-portlet

Actions
Loading...

HP 39g, 39G+, 40g and 40gs Calculators - Programming

Description
An HP 39g/40g program contains a sequence of numbers, mathematical expressions, and commands that execute automatically to perform a task. These items are each separated by a colon. Commands that take multiple arguments have those arguments separated by a semicolon.
Inside a program, branching structures can be used to control the execution flow. Creating building-block programs enables structured programming to be used. Each building-block program stands alone and can be called from other programs.
 note:
Program names containing spaces must be typed in quotes in order to run the program.
Calculator symbol key
The procedures in this document use the following text to represent symbol keys:
Key
Description
Text Representation
colored key; shift key
SHIFT
Move cursor left
cursor-left
Move cursor right
cursor-right
Move cursor up
cursor-up
Move cursor down
cursor-down
Backspace/clear
backspace
Example of a program
The following example of a program is divided into three main tasks. Each is an individual program. Within each program, the task can be simple or it can be divided further into other programs that perform smaller tasks.
RUN GETVALLUE: RUN CALCULATE: RUN "SHOW ANSWER":
Program catalog
The program catalog is where programs are created, edited, deleted, sent, received, or run. To open the PROGRAM CATALOG press SHIFT, then PROGRAM. The program catalog displays a list of program names. If no programs have been created, the only name that will be seen is EDITLINE. The EDITLINE contains the last expression that was entered from the edit line in HOME, or the last data that was entered in an input form. (In the HOME menu, if ENTER is pressed without entering any data, the HP 39g/40g runs the contents of the EDITLINE).
Program catalog keys
The following table contains a list of the PROGRAM CATALOG keys for the calculator.
Key
Description
EDIT
Opens the highlighted program for editing
NEW
Prompts for a new program name, then opens an empty program
SEND
Transmits the highlighted program to another HP 39g/40g or from a disk drive
RUN
Runs the highlighted program
SHIFT, then cursor-up or down
Moves to the beginning or end of the PROGRAM CATALOG
DEL
Deletes the highlighted program
SHIFT, then CLEAR
Deletes all programs in the PROGRAM CATALOG
Creating and editing programs
This section discusses creating and editing programs for the Calculator.
Creating a new program
To create a new program:
  1. Press SHIFT, then PROGRAM to open the PROGRAM CATALOG.
  2. Press NEW (the calculator will ask for a name).
  3. Type the program name, then press OK
  4. Enter the program. When done, start any other activity. The work is saved automatically.
     note:
    A program name can contain special characters, such as a space. However, if special characters are used, and the program is ran by typing in HOME, the program name must be enclosed in double quotes (" "). Do not use the quotation mark symbol within the program name.
Entering commands
While gaining a familiarity with the commands, the easiest way to enter commands is to use the commands menu from the PROGRAM EDITOR. Commands can also be typed in using alpha characters. To enter a command:
  1. From the PROGRAM EDITOR, press SHIFT, then CMDS to open the PROGRAM COMMANDS menu.
  2. On the left, use the cursor-up or cursor-down keys to highlight a command category, then press cursor-right to access the desired command.
  3. Press OK to paste the command into the PROGRAM EDITOR.
Editing program
To edit a program:
  1. Press SHIFT, then PROGRAM to open the PROGRAM CATALOG.
  2. Use the cursor keys to highlight the program that is to be edited and press EDIT (the calcualtor opens the PROGRAM EDITOR. The name of the program will appear in the title bar on the display).
Editing keys
The following table contains a list of the editing keys used by calculator.
Key
Description
STO+cursor-right
Inserts the STO+cursor-right character at the editing point
SPACE
Enters a space into the text
PAGE+cursor-up
Displays previous page of the program
PAGE+cursor-down
Displays next page of the program
cursor-up or cursor-down
Moves up or down one line
cursor-left or cursor-right
Moves right or left one character
A...Z
ALPHA-lock for letter entry. Press SHIFT+A...Z to lock lower case
BKSP
Backspaces cursor and deletes character
DEL
Deletes current character
ENTER
Starts a new line
SHIFT, then CLEAR
Erases the entire program
VARS and MATH
Menus for entering variable names, contents of variables, math functions, and program constants
SHIFT, then CMDS
Menus for entering program commands
SHIFT, then CHARS
Displays all characters. To type one, highlight it and press OK. To enter several characters in a row, use the ECHO menu key while in the CHARS menu
Using programs
The following section discusses using programs.
Running a program
From HOME, type run and then the program name or from the PROGRAM CATALOG, highlight the desired program and press run.
 note:
Regardless of where the program is started, all programs run in HOME. What is seen will differ slightly depending on where the program is started. If the program is started from HOME, the calculator will display the contents of ANS (HOME variable containing the last result), when the program has finished. If the program is started from the PROGRAM CATALOG, the calculator will return to the PROGRAM CATALOG when the program ends.
Debugging a program
If a program is ran that contains errors, the program will stop and an error message will be given. To debug a program:
  1. Choose YES to edit the program (the insert cursor will appear in the program at the point where the error occurred).
  2. Edit the program to fix the error.
  3. Restart the program.
  4. Repeat the process until all the errors are found and corrected.
Stopping a program
The execution of a program can be stopped at any time by pressing CANCEL (the ON key).
 note:
The key may have to be pressed a couple of times to stop the program from running.
Working with programs
The following section discusses working with programs on the calculator.
Copying a program
To copy a program:
  1. Press SHIFT, then PROGRAM to open the PROGRAM CATALOG.
  2. Press NEW
  3. Type a new file name, then press OK (the PROGRAM EDITOR will open with a new program).
  4. Press VARS to open the VARIABLE menu.
  5. Press 7 to quickly scroll to PROGRAM.
  6. Press the cursor-right key and then highlight the program that is to be copied.
  7. Press VALUE, then press OK (the contents of the highlighted program are copied into the current program at the cursor location).
     note:
    If a programming routine is used often, save the routine under a different name, then use the above method to copy it into a program.
Transmitting a program
Similar to APLETS, matrices, lists, and notes; programs can be sent to and received from other compatible calculators (39g and 40g are inter compatible, 39g+ and 40gs are compatible). To transmit a program to or from another calculator:
  1. After aligning the calculator's infrared ports, open the PROGRAM CATALOGS on both calculators.
  2. Highlight the program to send, then press SEND on the sending calculator and RECV on the receiving calculator.
     note:
    Programs can also be sent to and received from a remote storage device (APLET disk drive or computer). This takes place via a cable connection and requires an APLET disk drive or specialized software running on a PC (such as a connectivity kit).
Deleting a program
Any program can be deleted except EDITLINE. To delete a program:
  1. Press SHIFT, then PROGRAM to open the PROGRAM CATALOG.
  2. Highlight a program to delete, then press DEL
Deleting all programs
To delete all programs:
  1. In the PROGRAM CATALOG, press SHIFT, then CLEAR
  2. Press YES
Delete the contents of a program
The contents of a program can be cleared without deleting the program name. To delete the contents of a program:
  1. Press SHIFT, then PROGRAM to open the PROGRAM CATALOG.
  2. Highlight a program and press EDIT
  3. Press SHIFT, CLEAR, then YES (the contents of the program are deleted, but the program name remains).

hp-feedback-input-portlet

Actions
Loading...

hp-online-communities-portlet

Actions
Loading...

Ask the community!


Support Forum

Support Forum

Join the conversation! Find Solutions, ask questions, and share advice with other HP product owners. Visit now


hp-feedback-banner-portlet

Actions
Loading...

hp-country-locator-portlet

Actions
Loading...
Country: Flag United States

hp-detect-load-my-device-portlet

Actions
Loading...