In addition to the complete set of manuals provided with HP BASIC, HP E2160A BASIC Plus is available from Hewlett-Packard for convenient on-line HELP.
This chapter explains simple BASIC operations such as interpreting the display, typing commands, using printers, and using and redefining softkeys.
The following table describes some of the notations (conventions) used in this manual.
If You See... | It Means... |
---|---|
COMPUTER FONT | something typed by you or the computer. |
italic font | replace the italic word with your own entry. (Replace file_name with a file name, such as Myfile). |
[Break] | an actual keycap on the keyboard. |
{{Set Tab}} or {{k}} | a softkey label as shown on your CRT, or an inverse-video character. |
All references to keycaps in the text apply to ITF keyboards. However, tables are provided in the chapter on "Keyboard Information" as a convenient resource for users of model HP 98203 keyboards. For example, [Return] is used in this manual. If you have a keyboard other than the ITF keyboard the keycap may be labeled [Enter] instead of [Return].
Letter-case is important in BASIC. Keywords consist of all capital letters (for example, "BEEP"). Identifiers such as variable names, line labels, or subprogram names consist of an initial capital letter followed by lower-case letters or numbers. However, if you type all capital or all lower-case letters, the BASIC editor is usually "smart" enough to recognize what you mean from the context. For example, if you type "beep", and press [Return], BASIC will execute the BEEP command. Don't type "Beep," or BASIC won't know whether you meant it to be a command or a variable name.
Let's look at an example using the program editor.
If you type: | The editor enters: | Because: |
---|---|---|
let abc=1 | LET Abc=1 | LET is a keyword and Abc is a variable name. |
print "hello" | PRINT "hello" | PRINT is a keyword |
BEGIN: beep | Begin: BEEP | Begin is a line label and BEEP is a keyword. |
The resulting program lines will look like this:
10 LET Abc=1
20 PRINT "hello"
30 Begin: BEEP
Note that literal strings ("hello") must be typed exactly as desired.
When BASIC is booted, it clears memory and assigns various default values. This condition is the power-on state. For a complete list of power-on defaults, see "Useful Tables" in the &langref;.
If your computer has been used since power-on, it may be in an unknown state. For instance, there may be an unwanted program in memory, or the default printer may specify a device you don't want. This section explains how to:
You can determine BASIC's current status by looking at the lower right-hand corner of the screen. BASIC uses this area to display information about whether a program is currently running, what softkey menu is currently active, and other information.
Indicator | Description | Keyboard\Control |
---|---|---|
Softkey Menu Indicator (ITF Keyboards only) | The following labels are used depending on which menu is selected: System, User 1, User 2, User 3. | Select menu with [System], [User], or [Shift]-[Menu]. |
Caps Lock Indicator (ITF Keyboards only) | Indicates the keyboard's caps mode status. | Toggle caps mode using [Caps]. |
Program Status Indicator (ITF Keyboards only) | Indicates the run light status. | See following tables for run light indicator meanings and how to control system/program status. |
Softkey Labels | Label the keyboard function keys' operations. | Turn on and off with KEY LABELS ON and OFF or [Menu]. |
Run Light | Graphic indicator of the system or program status. | See following tables for run light indicator meanings and how to control system/program status. |
The character in the lower right corner is called the run light. The following table shows the various run light indications and their meanings.
Status\Indicator1 | Run Light | System State |
---|---|---|
Idle | (blank) | Program stopped; can execute commands; CONTINUE not allowed. |
Running | {{ }} | Program running; can execute commands; CONTINUE not allowed. |
Paused | _ | Program paused; can execute commands; CONTINUE is allowed. |
Transfer | IO | Program paused, but an overlapped TRANSFER (I/O) operation is still in progress; can also execute commands. |
Input? | ? | BASIC program waiting for input from keyboard; cannot execute commands. |
Command | * | System executing command entered from keyboard; can enter 1 more command, but it will not be executed until after the current command is completed. |
1Note that these indicators are displayed only if softkey labels are currently on. Use [Menu] or the KEY LABELS ON statement, to turn these labels on.
To see if a BASIC program is in memory, use the LIST command to print the program lines. For example:
PRINTER IS CRT [Return] Tell BASIC to print to the CRT display.
LIST [Return]
Typical results:
10 PRINT "Short program."
20 END
Available memory = 5629926
If you don't want to wait for the entire program to list, you can stop it by pressing [Break]. If there is no program in memory, LIST prints the amount of available memory.
To pause or stop a program before its normal completion, continue operation, or abort an I/O statement, use the following keys:
ITF\Keyboard | Effect |
---|---|
[Stop] (Pause) | Pauses a program after it finishes the current line and any I/O in progress. Useful for pausing a program that is executing an INPUT statement, leaves internal information intact. You can resume program execution with {{Continue}} (or the CONT command). |
[f2] {{Continue}} | {{Continue}} (or the CONT command) after Pause causes program to resume in a normal manner from where it was paused. |
[Break] (Clr I/O) | Cancels any I/O operation in progress (ENTER or TRANSFER) and pauses the program. The program counter returns to the beginning of the canceled I/O statement, so {{Continue}} resumes execution beginning with that same statement. |
[Shift]-[Stop] (Stop) | Stops the program at the end of the current line, returning the program to the main context. Does not affect interfaces, CRT, program memory, variables, tabs, or the {{Recall}} ([f8]) buffer. {{Continue}} is not allowed after Stop. |
[Reset] ([Shift]- [Break]) | The most drastic and complete way to stop a program. The program stops immediately, cancels I/O operations, closes open files, and resets all interface cards. However, the printout area of the CRT, program or variable memory, tabs, and the {{Recall}} buffer are not affected. {{Continue}} is not allowed after [Reset]. |
ITF keyboard definitions are easy to remember if you use the BASIC keyboard overlay and keep softkey labels turned on.
You can determine the current state of several system defaults by using the statements in the following table. See the &langref; for a complete list of the system defaults, or for more information about SYSTEM$, LOAD BIN, and LIST BIN.
Method | Explanation | Default |
---|---|---|
SYSTEM$("PRINTER IS") | Returns the current system printer's select code (destination for PRINT operations). | PRINTER IS CRT
|
SYSTEM$("PRINTALL IS") | Returns the current printall printer's select code (destination for system messages when PRINTALL ON is active). | PRINTALL IS CRT
|
SYSTEM$("DUMP DEVICE IS") | Returns the current dump device's select code (destination of DUMP ALPHA and DUMP GRAPHICS). | DUMP DEVICE IS 701
|
SYSTEM$("MSI") | Returns the default mass storage device used when one is not explicitly specified. | device from which BASIC booted
|
SYSTEM$("AVAILABLE MEMORY") | Returns the amount of memory available for programs and data. | (not applicable)
|
SYSTEM$("VERSION:BASIC") | Returns the BASIC revision number. | (not applicable)
|
SYSTEM$("VERSION:bin") | Returns the revision number of bin (if loaded); for example: SYSTEM$( VERSION:EDIT ) | (not applicable)
|
SYSTEM$("WILDCARDS") | Returns the current status of WILDCARDS:
|
OFF
|
LIST BIN | Lists all binaries currently in memory. (For more information, see the Configuring Language Extensions and Drivers chapter in Installing and Maintaining HP BASIC/WS 6.2.) | CRTA and CRTB |
The following section briefly describes using an ITF keyboard with BASIC. For detailed information on using an ITF keyboard, an HP 98203B/C, or an HP 98203A keyboard, refer to chapter 8, "Keyboard Information."
ITF Keyboard (with BASIC Keyboard Overlay)
Use the keyboard to perform the following BASIC tasks:
You can use BASIC as a calculator to evaluate numeric expressions using the following arithmetic operators:
Operator | Operation | Example | Results |
---|---|---|---|
- | subtraction | 2-4 [Return] | -2 |
= | addition | 5.23=2.8-2 [Return] | 6.03 |
/ | division | 5=3/2-1 [Return] | 5.5 |
* | multiplication | 3*3-1 [Return] | 8 |
^ | exponentiation | 3^2*2-2 [Return] | 16 |
SIN, COS, etc. | functions | SQRT(25)/5 [Return] | 1 |
(...) | grouping | SQRT(125/5)=(2*3)/4 [Return] | 6.5 |
For example:
99/9 Characters you type appear here. Press [Return]
11 System response appears here.
For a complete explanation of all math operations, see the HP BASIC 6.2 Programming Guide, "Numeric Computation."
You can type and execute commands from the keyboard at all times except:
At all other times, you can type commands and press [Return] to present them to the system for execution. The system parses the command and takes the appropriate action.
Type and execute the following command (characters will appear on the keyboard input line near the bottom of the display):
SYSTEM$("AVAILABLE MEMORY") [Return]
Typical results:
123456 number of unused bytes of memory >
The following functions allow you to check the setting of the system clock (the CLOCK binary must already be loaded):
DATE$(TIMEDATE), TIME$(TIMEDATE) [Return]
Typical results:You can set the time and date using SET TIMEDATE.17 Mar 1991 10:27:32
SET TIMEDATE DATE("17 Mar 1991")=TIME("10:30:00") [Return]
Using Softkeys \(Requires KBD Binary)
All of the keyboards available for Series 200/300 computers have softkeys. However, the keycap labels differ slightly.
Keyboard | Keycap Labels |
---|---|
ITF | [f1] [f2] [f3] [f4] [f5] [f6] [f7] [f8] |
HP 98203A/B/C | [k0] [k1] [k2] [k3] [k4] [k5] [k6] [k7] [k8] [k9] |
NOTE |
---|
There is an exception to the normal operation of a softkey. The softkey will execute the command indicated by its key label, except when that softkey has been defined by a running program to produce an interrupt. Refer to "Program Structure and Flow" in the HP BASIC 6.2 Programming Guide for information on ON KEY interrupts. |
KEY LABELS ON [Return] requires CRTX binary
CONTROL CRT,12;2 [Return] no binary required
[STEP][CONTINUE][RUN][PRINTALL] [CLRTAB][ ][ ][RECALL]
(The System menu is the default menu at system power-up, or after a SCRATCH
A, when the KBD binary is not present.)
Press [User] to return to the User 1 softkey menu.
(The User 1 menu is the default menu when the KBD binary is loaded.)
Press [Shift]-[Menu] to display the User 2 softkey
menu.
Softkeys [f4] through [f8] are only defined if the PDEV and
EDIT binaries are loaded at the time that the default definitions of these
keys are set up (when SCRATCH A, LOAD KEY, or LOAD BIN "KBD" are executed).
Press [Shift]-[Menu] again to display the User
3 softkey menu.
Pressing [Shift]-[Menu] cycles through the User menus (from
1 to 2 to 3 to 1, and so on).
If you are using an unmodified version of BASIC, your display should look similar to this:
{{k}}#EDIT Displayed on the keyboard input line
Editing key 1 Displayed on the system message line
My very own keystrokes
EDIT KEY 2 [Return]
[CTRL]-[Shift]-[Clear line] LIST [CTRL]-[Return]
The notation [CTRL]-[Return] means to hold down the[CTRL] key then press [Return]. The [CTRL] key tells
BASIC not to execute that key's function, but to enter that key in the softkey
definition. The display will show an inverse-video k (shown here as {{k}}),
followed by another character. For example, [CTRL]-[Return]
produces {{k}}E.
To enter the softkey's definition and exit softkey editing mode, press
[Return] To cancel the redefinition and retain the existing definition,
press [Shift]-[Stop] (Stop).
If you entered the definition above, you can execute the LIST command by
pressing [f2]. You don't need to press [Return] because you
already included it in the softkey definition.
EDIT KEY 2 [Return].
LIST [CTRL]-[Shift]-[Clear line] [CTRL]-[Return]
Press [Return] to save.
Press [f2] to see how the new definition works. Notice that LIST is
momentarily displayed, then cleared and executed.
Since most printers cannot print the inverse-video {{k}} in softkey definitions, LIST KEY substitutes the letters System key: for this character. For example:
LIST KEY lists on the default printer (usually CRT)
LIST KEY #PRT lists on printer, if available
LIST KEY #701 lists on device at 701, if available
Key 2:
System key: # [Clear line] key
LIST
System key: E [Return] key
STORE KEY "MyKeys" To store definitions in new file called MyKeys
RE-STORE KEY "MyKeys" To replace definitions in an existing file of MyKeys
LOAD KEY "MyKeys" To load definitions stored in file called MyKeys
LOAD KEY To restore default softkey definitions
SCRATCH R SCRATCH RECALL | Clears the {{Recall}} ([f8]) key's buffer. |
SCRATCH KEY | Clears softkey definition(s). See the descriptions of softkeys in preceding sections of this chapter for further information. |
SCRATCH C SCRATCH COM | Clears all variables from the computer's memory, including COM. However, the current program and softkey definitions are left intact. |
SCRATCH | Clears all program lines currently in the computer's memory. It also clears all variables which are not in COM. See the "Subprograms" chapter of &progd; for a description of COM. |
SCRATCH A SCRATCH ALL | Clears most everything from the computer's memory, restoring the system to its power-on state. The only exceptions are the {{Recall}} ([f8]) key's buffer, the real-time clock, and the currently loaded binaries. |
SCRATCH B SCRATCH BIN | Removes all of the current binaries in memory (except the driver of the currently active CRT display), and re-executes all of the steps in a power-up operation (except loading and running the autostart program). See the "Language Extensions, Drivers, and Configuration" chapter of Installing and Maintaining HP BASIC/WS 6.2 for details. |