Introduction to the System

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.

Notations Used in this Manual

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].

Significance of Letter-case

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.

Program Control

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:

The Status Indicators

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.

System Status Indicators
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.

Run Light Indications
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.

Is There a BASIC Program in Memory?

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.

Controlling Program Status

To pause or stop a program before its normal completion, continue operation, or abort an I/O statement, use the following keys:

Pausing and Stopping Programs
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.

Determining Current System Devices and Binaries

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.

System Defaults
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 if disabled.
  • UX: if enabled without escape character.
  • UX:&\ if enabled with &\ as the escape character.
  • UX:' if enabled with ' as the escape character.
  • DOS: if enabled for MS-DOS style 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

Using the Keyboard

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:

Performing Calculations at the Keyboard

You can use BASIC as a calculator to evaluate numeric expressions using the following arithmetic operators:

Arithmetic Operators\for Keyboard Calculations
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."

Typing and Executing Commands

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:
   17 Mar 1991       10:27:32
You can set the time and date using SET TIMEDATE.
   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.
Softkey Keycap Labels
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]

Softkey Labels

If you are using the ITF keyboard and the KBD binary is loaded, the following softkey labels are displayed at the bottom of the screen when you first turn on your computer or boot BASIC: User 1 Caps Idle [EDIT][CONTINUE][RUN][SCRATCH] [LOAD][LOADBIN][LISTBIN][RESTORE] When you press a softkey, it produces a commonly used command, which is indicated by the key label. Some softkeys act simply as typing aids. For example, if you press {{EDIT}} ([f1]), the command EDIT appears on the command line. BASIC will go into EDIT mode when you then press [Return]. Other softkeys immediately execute the command. For example, if you press {{RUN}} ([f3]), the program currently in memory will be run -- you don't have to press [Return]. BASIC automatically defines what each softkey does, and what its key label is. However, you can redefine any softkey to execute commands specific to your needs. For further information refer to "Redefining Softkeys" later in this chapter.
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.

On the ITF keyboard, if the softkey labels are not displayed, press [Menu] to display them. Press [Menu] again to turn them off. You can also turn the softkey labels on with either of the following commands:

      KEY LABELS ON [Return]        requires CRTX binary

      CONTROL CRT,12;2 [Return]     no binary required

Selecting a Menu

The set of eight softkey labels at the bottom of the screen is a ==softkey menu==. The softkeys ([f1] through [f8]) have four independent sets of definitions for the ITF keyboard. Select the menu that you want as follows: Press [System] to display the System softkey menu: System Caps Idle
 [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).

Redefining Softkeys

This section describes how to create your own set of softkey definitions; it also shows how to store these definitions in a file so you can reload them at a later time. To redefine softkeys, make sure the KBD binary is currently loaded. If you do not understand how to verify or load the KBD binary, see the LIST BIN and LOAD BIN entries in the &langref;. As an alternative to the following procedures, you can also write a program that defines the softkeys, using the SET KEY statement. See the "Communicating with the Operator" chapter of HP BASIC 6.2 Advanced Programming Techniques for details.

Memory Available for Softkey Definitions

BASIC uses about 3072 bytes of memory to store the softkey definitions. Since there is a small amount of overhead required for each key, there are only about 3000 bytes available for keystrokes. The maximum number of characters you can put into each definition is 256 characters. However, if you produce a 256-character softkey definition--on a system with a high-resolution display-- and then try to edit it on a system with a medium-resolution display, you will only be able to get 160 characters into the modified softkey definition. An additional restriction: attempting to use a softkey definition that contains more characters than will fit into the keyboard input line will result in lost characters.

Examples of Redefining Softkeys

Use the EDIT KEY command to redefine softkeys with your own softkey definitions. For programming purposes, softkeys are numbered 1 through 24. USER 1 keys are numbered 1-8, USER 2 keys are numbered 9-16, and USER 3 keys are numbered 17-24. These examples use the ITF keyboard. If you have an HP 98203 keyboard, there will be slight differences (such as using [k0] instead of [f1]). Don't worry about losing the original softkey definitions. You can get them back by executing LOAD KEY, or by rebooting. Example 1 This example defines a softkey that produces My very own keystrokes.
  1. Enter the edit softkey mode for the desired softkey:
    • Press [User] until the softkey-menu indicator displays User 1.
    • Press {{EDIT}} ([f1]), then press [f1] again. [f1] is the key you are going to define. Press [Return].

      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
      

  2. Press [Shift]-[Clear line] to clear the key's current definition.
  3. Type the desired characters on the keyboard input line.
         My very own keystrokes
    
Enter or cancel the softkey redefinition: If you entered the new definition, verify that the key works as desired. Press [Shift]-[Clear line] to clear the line for the next example. Example 2 This example redefines a softkey to do the following:
  1. Here is another way to enter the edit-softkey mode. Since you redefined [f1] in the previous example, you'll have to enter the edit softkey mode by typing:
    EDIT KEY 2 [Return]
    
Press [Shift]-[Clear line] Enter the following keystrokes:
[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.

Improving Softkey Labels

You may want to improve specific labels to fit in the label area on the display. The following example shows how to improve the [f2] label for the LIST command used in the previous example. Example 3
  1. Type:
    
    EDIT KEY 2 [Return].
    
To clear the current softkey definition, press [Shift]-[Clear line]. Type the following line (enter 12 spaces after LIST.)
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.

Listing the Current Softkey Definitions

You can list all current softkey definitions by executing one of the following statements:

      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
Since most printers cannot print the inverse-video {{k}} in softkey definitions, LIST KEY substitutes the letters System key: for this character. For example:

Key 2:            

System key: #      [Clear line] key
LIST               

System key: E      [Return] key

Storing and Loading Softkey Definitions

STORE KEY stores all of the current softkey definitions in a file. Use LOAD KEY to restore the default definitions or to load your own definitions back into the computer. The following examples show how to store and load softkey files and apply only to the currently specified mass storage volume.

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

Clearing the Computer

When you turn on the power and boot BASIC, computer memory is cleared and various system elements are assigned default values. Turning power off, then back on again is one way to clear the computer. However, an easier and faster way is to use SCRATCH commands. Several forms of this command allow a choice of clearing actions. The following paragraphs give general descriptions of the choices; for complete descriptions see "Reset Tables" in the "Useful Tables" chapter of the &langref;.
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.