Commodore 2001-8 User Manual page 23

Table of Contents

Advertisement

Chapter 4.
BEGINNING BASIC
The combination of instructions to solve a particular problem cannot be taught in a text book. It is a
creative process. Someone who knows how to use the computer uses his intuition or careful planning to
figure out instruction sequences to allow solution of his problem. All that we can cover in this book and
all the PET can be - except when it is provided with pre-programmed softrware - is a tool to use for solving
problems. This book cannot teach you to solve your particular problem. It can, however, teach you how to
use the PET as an instrument.
THE PRINT STATEMENT
A computer can calculate numbers all day but it is of no value unless the computations can be displayed.
We will begin our discussion of BASIC with the PRINT statement for that reason.
When typing text, PRINT can be abbreviated as ? A statement such as this:
PRINT "HELLO"
is an Instruction to the computer telling it to display on the screen all characters between the quotes -- in
this case a word of greeting. On the other hand:
PRINT 1024·S
is an instruction to print the product of 1024 multiplied ·8.
It is useful to note that BASIC allows you to print more than one value at a given time. Rather than having
it write a line, print 'A' and on a second line print 'B', it is possible to write the line:
PRINT 10241
2, 1024
t
3
which will print the square of 1024, a few spaces, and then the cube of 1024. Details of the exact format is
contained in the next section. The point here is that you can print as many values across a series of lines
as you can write down.
Unless the computer has been instructed otherwise by means of CMD command, all print outputs are
directed to the built-in screen. The characters are printed
in
the next available print position on the
screen, under the control of BASIC and
an
editor which
is
keeping track of the screen position. Although
the physical representation on the screen is 25 fines by 40 characters, the printing of up to 80 characters
is accomplished by the screen automatically folding over the 41st character onto the next line. The
computer automatically scrolls the screen up one or two full lines when it reaches the one-thousandth
character on the screen.
The command PRINT has two major forms under the control of BASIC.
(1)
The standard print single
character which allows for printing the field specified after the print statement has ended in the form
print variable.
If
the data
is
presented in this form, the field is printed starting at the current screen
position and followed by
a
carriage return.
(2)
Data presented in the form PRINT
A,
B, then BASIC
automatically tabulates printing 'A' starting at the current screen position then spacing over 10
characters, prints 'B' followed by
a
carriage return. In order to cause BASIC to not send the carriage
return after B,
a ;
(semicolon) is used. PRINT A;B; results
in
the 'A' being printed, then foffowed by no
extra spaces, variable 'B' is printed. The cursor is left at the end of the 'B' field.
If
the variable A
is
more
than seven characters, 'B' will be printed after spacing 20 characters, when using PRINT A,B.
BASIC obeys the foffowing roles for printing characters. When the field to be printed is
a
string, there are
no leading or trailing characters sent. If the field to be printed
is
a number, BASIC first checks its size.
If
the number is fess than .01 or greater than or equal to 999999999.2, BASIC prints it using scientific
notation. For example, .0034 is printed
as
3.4
E-03 and - 1234567890.5
is
printed
as -
1.2345678E
+
Og.
If
the number falls between these values, the most significant
9
digits are printed, plus a decimal point if
19

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pet 2001-8

Table of Contents