Commodore 2001-8 User Manual page 26

Table of Contents

Advertisement

will be discussed later on. The string is limited to the 80 characters of the input buffer. There is a specific
set 'of functions th'at allow the construction of strings up to 255 characters (see later text).
INTEGERS
As we have indicated, an integer is simply a whole number. Floating point variables are stored in BASIC
with five bytes; one for the exponent and four for the mantissa, which gives an accuracy of 9 digits. In
many cases, variables can be expressed in much simpler numbers. In order to allow the user most
memory efficiency, particularly in the case of arrays which can take significant amounts of memory, the
PET has implemented the concept of storing certain numbers as two-byte integer values. Any integer
value between minus 32,767 to plus 32,767 may be stored in the form of a two-byte number with the
highest bit of the number containing the Sign.
USE OF PROGRAM AND DIRECT STATEMENTS
Throughout the text, until now, we have been using the program technique which allowed us to get the
PETto respond directly to the print statement. In this case, BASIC is obeying the command we are giving
it directly, as we type it from the keyboard and hit carriage return. This is so-called direct mode. In this
mode, we can use the PET as a super calculator. For Instance, if we want the PET to add two numbers and
divide the result by a third, we can ask it the question ?(2
+
8)/5. If you have typed that on the PET, you
should get the answer of 2 followed by a READY. The PET will obey any statement given it from the
keyboard, except when it is in the process of executing a BASIC program. In addition to using it as a
super calculator and for teaching with the PET, the direct mode is quite useful for debugging of
computer programs. Variables can be assigned intermediate values and then small sections of the
program can be executed with GOTO statements to assess why any particular piece of code is not
working correctly. Break points can be put in programs and current status of variables checked with print
commands, again in direct mode, without having to modify your main program. However, except for
debugging or in the case of using the PET as a super calculator, in order to get the computer to act as a
true computing element, one has to write or load a BASIC program. The difference between execution tn
direct mode and a program is that several statements can be grouped together in logical order and then
BASIC will execute all of the statements before asking the user for control.
Suppose we want BASIC to print our HI THERE message vertically as opposed to horizontally. We can
easily accomplish this in a program but not very easily in a direct statement. Rules for program entry are
very simple. Any statement you want to be treated by BASIC as a program statement must be preceded
by a line number. A line number may be any number from 0 to 63,999.
A good habit to develop when typing in lines of a program is to use increnments of 10 or 100. Instead of
1,2,3, etc., use 10, 20, 30. This will give you space later to add lines and make corrections in your
program. All you need to remember is that BASIC interprets each line number in order.
To print HI THERE, vertically, each line of our program will type one letter of the message. we are going
to start with line 10 and make each line a multiple of 10.
10?"H"
20?"1"
3O?"T"
40?"H"
50?"E"
60?"R"
70?"E"
Whether you are typing in a program or giving direct commands like RUN, you have got to hit RETURN to
tell the PET to take a look at what you have typed and act accordingly. The lines ten through seventy
22

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pet 2001-8

Table of Contents