Text preview for : 22687-90009_LearningTSB.pdf part of HP 22687-90009 LearningTSB HP 2000TSB 22687-90009_LearningTSB.pdf



Back to : 22687-90009_LearningTSB.p | Home

HEWLETT if PACKARD
preface
BASIC means two things. First, BASIC means the Hewlett-Packard version of the BASIC program-
ming language. And second, BASIC is the operating system provided with your computer (actually one
of several timeshare systems offered by Hewlett-Packard.)



When you are using BASIC the programming language, you construct a set of instructions (called
statements) which are to be performed by the computer when your program is run. Statements can be
simple instructions such as PRINT ((BLA-BLA" or involved instructions containing formulas and
other intricacies. A program generally consists of many statements which tell the computer to perform
a specific job. When a program is run, the statements are performed in the exact sequence that you
number them.



When you are talking directly to the BASIC operating system, you issue commands which are carried
out immediately by the computer. Commands tell the operating system to run a program, create a file,
or some such task, and are generally brief, consisting of one or two words. Commands are never
included in a program.



To master BASIC then, all you need to do is understand the various statements and commands
available to you. This manual defines the most commonly used BASIC statements and commands, and
will enable you to write simple, effective programs on any HP Timeshare BASIC system*. The
complete set of BASIC statements and commands available to you is explained in the reference
manual appropriate to your HP system. The latest HP Timeshare BASIC system is described in the
HP 2000lACCESS BASIC Reference Manual (22687-90001).




*Learning Timeshare BASIC is not applicable to the Hewlett-Packard Timeshared BASIC/2000, Level
E, System.
content
Page

the terminal ................................................................................ 1
how to turn the terminal on and off ....................................................... 2
how to establish a connection ............................................................. 2
how to complete an entry ................................................................. 2
how to correct mistakes .................................................................. 2
how to break in ............................................................................ 3
logging on and off ............. '............................................................. 4
a program .................................................................................. 6
tricks of the trade .......................................................................... 8
operators .................................................................................. 10
input ..................................................................................... 11
the LET statement ...................................................................... 11
the INPUT statement ................................................................... 13
the READ statement .................................................................... 17
a sense of direction ........................................................................ 20
scientific notation .......................................................................... 24
output .................................................................................... 26
a short note ............................................................................ 29
other tricks ............................................................................... 30
more about operators ...................................................................... 32
your own library .......................................................................... 35
SAVE .................................................................................. 35
PURGE ................................................................................ 36
DELETE ............................................................................... 36
CATALOG .............................................................................. 36
files ....................................................................................... 37
strings and things ......................................................................... 39
functions .................................................................................. 42
an array is ................................................................................ 45
subroutines ................................................................................ 47
express yourself ........................................................................... 49
the answers ............................................. " ................................ 52
calling the computer ....................................................................... 54
how to use a data set ................................................................... 55
how to use a coupler/modem ............................................................. 56




ii
the terminal
Before you get under way, be sure you have familiarized yourself with your terminal. The terminal is
the device through which you talk to the computer and by which the computer speaks with you. Your
terminal may be either a printing device (rather like a typewriter) or a video display screen device
(sort of a cross between a typewriter and a television).




A printing device looks like this.




A video display screen terminal
looks like this ..




Either type of terminal may be used with BASIC, provided you know how to do the following
operations:

1. How to turn the terminal on and off.

2. How to establish a connection between the terminal and the computer.

3. How to enter data and complete an entry.

4. How to correct mistakes, for example - erasing lines and backspacing over incorrect answers.

5. How to ~1>reak in" or override terminal activity in an emergency.

6. Where to find help when all else fails.


1
HOW TO TURN THE TERMINAL ON AND OFF
Look for the switch on the keyboard, on the side casing, at the back, or even on the bottom of the
terminal. Turn it to ON, or if there are options, turn the switch to the position called LINE. Be sure to
turn the switch to OFF when you have finished using the terminal.




HOW TO ESTABLISH A CONNECTION
Once the terminal is on, press the keys marked RETURN and LINE FEED. If the terminal is
connected directly, the computer will say PLEASE LOG ON. If the terminal is not connected, the
computer will say nothing at all and you must phone the computer to establish the connection.
Procedures for calling a computer are included at the end of this manual.




HOW TO COMPLETE AN ENTRY
Every line of data you type must be terminated by the RETURN key. This key signals the computer
that you have finished a line of input. The computer can respond by advancing the terminal to the next
line permitting you to continue with your input, or even by asking you a new question. Remember - a
line of input may consist of only one word or character. You must still press the RETURN key to
indicate that you are fmished. A line or character may be erased only before the RETURN key is
pressed. So be sure you like what you typed before you press the RETURN key and send it to the
computer.




HOW TO CORRECT MISTAKES
If you realize that you've made a typing error and have not yet finished typing the line of data
containing the error, you can erase the line by holding down the CONTROL key and the X key at the
same time. The line is thus effectively ~~erased" and the terminal advances to a clean line so that you
may try typing the data again.




~
THI SIS F\ ........
TH I SIS "fH E DA T A
------"""\< CONTROL/X prints a backward slash (\ ), erases the line,
and advances the terminal.


2
A single character in a line can also be erased. Press the CONTROL key and the H key simultaneously
to erase the last character you typed. Then type the character you really wanted in the fIrst place. If
you erred for more than just one character, hold down the CONTROL key and press the H key together
for each character to be erased.

nn SIS THE DATT V ControllH prints an.- or _ and erases the last character.



Notice: The character keys used for correction may differ according to terminal. Experiment with
your terminal until you are sure that you know how to erase lines and/or characters.



HOW TO BREAK IN

The BREAK key lets you stop a runnirig (or runaway) program. This is an emergency button that lets
you regain control of the terminal by interrupting a program when necessary. Of course, interrupting
a program destroys what it was accomplishing, and you have to restart it by typing RUN. And it does
start again, from the beginning.



LINE FEED KEY - RETURN KEY



' " r::\
\V~ CD-CD V CD- 0 CD ()\ n
3 ~ 4 0 7 8 ~~U ~0-
f.\ - '-V

8