Beginning SmartBASIC I
by ?
From: ADAM S ALIVE
DECEMBER 1987
Beginning with this issue, we will be studying how to program in
SmartBASIC. For many of you, this series should help you to understand
the fundamentals to Basic programming. We will start with the very
basics, and work up in our study with each succeeding issue.
Before we start., 'boot' (or load) SmartBASIC. To do this, insert your
SmartBASIC data pack and pull A computer reset. When a black screen
appears., and you see a 'blinking, cursor, we are ready to begin.
Using the Adam's keyboard., type the following and press <RETURN> after
each line:
]NEW
]100 PRINT " HERE IS AN EXAMPLE"
] 110 PRINT "OF A PROGRAM IN"
] 120 PRINT "SMARTBASIC."
There is our first SmartBASIC program. Remember to press <RETURN> after
each line. Each time you entered a line, and pressed the return key,
ADAM responded with a right square bracket. The right square bracket (1)
is ADAM's signal to us that the computer is ready for our next
instruction. Unlike some other computers, ADAM will tell you. when you
make a mistake in entering an instruction. When this occurs, you can
either enter the line again, or move the cursor with the arrow keys)
under the entire line., making the changes where needed, and then
pressing return. This procedure will save you much needed. time when you
need to edit a program line.
The first thing we did with our program was to prepare ADAM for a new
program. New erases any SmartBASIC program in the ADAM's memory.
Naturally, you should never type NEW unless you really mean it. The old
program is NOT recoverable. So, use the command NEW with great caution.
Our program consists of three statements. Each statement is labeled with
a line number. The ADAM will accept line numbers up to 65535.
After the second 1, we typed:
100 PRINT "HERE IS AN EXAMPLE"
and pressed the RETURN key. The ADAM responded by showing a blank line
and then another right bracket. We then typed the next two lines in the
same manner. Each of these three statements is an example of the PRINT
statement, When a program is RUN, each PRINT statement is an instruction
to the computer that something is to be printed out to the screen of the
TV monitor and/or on the paper of a printer.
]RUN HERE IS AN EXAMPLE OF A PROGRAM IN SMARTBASIC.
Next, we typed RUN and pressed the RETURN key. In this case, as with the
NEW instruction, we did not give a line number to the instruction. The
presence of a line number label means that the current line is to be
stored for later use by ADAM. The absence of a line number label means
that ADAM will immediately process whatever is on the line as an
instruction. The RUN instruction may also be followed by a line number
that names a line in the program where the run should begin. For
example, to get our little program to display "SMARTBASIC", simply enter
run 120 (and press return).
As with all other computers, the ADAM is really not very smart. A
computer can only follow the instructions given it. Thus the old saying,
"Garbage in, garbage out". This means that a computer can only respond
to the information it has been given.
Note the difference between the letter "oh" and the digit zero. The ADAM
uses an oval with a slash through it for the digit zero and an open oval
for the letter "oh". You might type "oha", zeros, and eights so that you
can study them on your monitor. You will find the zero key between the
"9" and "-" in the top row of keys, while the "oh" is in the second row
from the top between the "I" and "P" keys.
We call the process of carrying out the instructions of program
statements execution
Thus, when we type RUN, we are telling the computer to "execute" the
program.
To look at our entire program in memory, we must use the command LIST.
]LIST
100 PRINT "HERE IS AN EXAMPLE"
110 PRINT "OF A PROGRAM IN"
120 PRINT "SMARTBASIC"
The instructions NEW, RUN, and LIST are commonly called commands because
they are used to command the computer to manipulate the program as an
entity rather than perform a program instruction.
What happens when we make typing errors? That depends upon the error. If
we type LOST instead of LIST., SmartBASIC will display the following
message:
? SYNTAX ERROR
No harm has been done; merely correct the request and proceed. If we
type:
100 PRIMT a
instead of:
100 PRINT a
ADAM will display an error message such as:
SYNTAX ERROR IN 100
The line 100 will thus not be accepted. We will have to retype the
correct command line.
We can look at a single statement by using the LIST command.
LIST 110
will display only line 110 of our program, if it exists. LIST 100-200
will display all of the lines in our program from 100 to 200, inclusive.
Now -retype the line and re-execute the program. If we type
100 PRINT b
instead of
100 PRINT a
we have a different kind of error. which the computer will never find
for us. The value of b will be displayed where we expected to see the
value of a. It is very important to evaluate our results for
correctness.
SUMMARY
A computer language is a defined set of instructions that have specific
meaning to the computer. In SmartBASIC, each instruction of a program
must begin with a line number. The PRINT statement is used to display a
message on the computer screen.
The NEW command prepares BASIC for a new program. LIST displays your
program on the screen. LIST 100 displays the line 100, while LIST
100-200 lists all the lines from 100 to 200.
MORE NEXT MONTH....
Back to
Top
|