A
ll
and more about Sharp PC-1500
at
http://www.PC-1500.info
F.
A Closer Look
At
Some Old Friends
Now
that
we
know
how
to
enter
, run, and
edit
pro9rams,
we
shall
expan
d
our
vocabul
ary
of
useful statem
ents
and commands. Let's
bc,g
in
by
examining some
old
friends:
the
NEW
command,
the
LET
statement,
and the PR I
NT
statement.
F .
1.
The
NEW
Command
As
\Ye
saw
in
our p
revi
ous
p
rogrammin
g exampl
es,
the
NE\iV
command
del
et.es
all
program
l
ines
currently in memory.
We
will use
the
NEW
command
(in PROgram mode)
before
each sample
pro
gram
to
i
ns.
ur
e
that
the
on
ly instructions in SHARP's memory arc
the
instructions
of
our
current
program. Although
it
is possible {and
often
desirable)
to
have several programs in memory
simultaneously,
we
will postpone
the
use
of
this feature
to
avoid
con
fusion.
In
PROgram mode, issue
the
NEW
command
. What effect
do
the
Up
and Down Arrow keys
have now?
F.2. The LET
Statement
Don't
be
ala·rmed if you
don't
recognize
the
LET
statement
as
an
"o
ld
friend";
I sneaked
this
one in on you. Actually, the LET stateme
nt
is nothing
but
the Assignment statement in disguise.
{If you don't recognize the Assignment statement either, please re-read the
sectio
n
on
vnr
iablcs,
in Chapter 2,
ir
runed
iately! ).
In
the
early
days
of
BASIC eve
ry
stat
ement began with a " k
eyword"
{like
PR
INT, INPUT,
etc
.)
which indicated
what
th
e instruction did. LET was
the
keyword which ide
nt
ified
the
fact
that
a
value was
to
be
sto
red
into
a variable. Today,
it
is generally agreed
that
the
wo
rd LET
is
not
really
needed.
As
a
r.
esult, the k
eywo
rd LET
is
optional in PC·1500 BASIC. Thus, a st
atement
which
stores
the
number
7 into a variable
Scan
be
written
in either
of
the following ways:
s = 7
or=1
L
LET S = 7
The
one
excep
tion, the place where
LE
T
must
be u
se
d,
is
an
assignment
which
occ
urs
as
part
of
an
IF
staterrnent. Although we have
not
yet
d iscuss
ed
the
IF
st
at
ement,
th
is should
be
possible
to
exp
lain (cros$
your
fingers).
Using
the
IF
stat
em
en
t
you
can write
an
instruct
i
on
like the following:
.!£.
expression THEN
stat
emen
t
If
the
statement
following
the
T
HEN
is
an
Assignment
statement,
the keyword LET
must
be
used. This
wou
ld result in a
statement
with
the
form:
_!£_expression T
HEN
LET variable·name =
exp
ression
NOTE :
Omitting
the
LET in this case
would
produce
an
ERROR
19
(or
other
error message).
F.3.
The
PRINT
Statement
For
mo
st
of
the
pr
ograms
you
write,
the
instructions will
fo
llow a basic
pattern
{no
pun
intended). There will
be
instructions
to
read in r
aw
data,
instructions
to
process the
data,
and
instructions
to
print
or
display
th
e results. This pattern has been referred to as the Input,
Processing,
Output
cycle.
The
PRINT
sta
t
ement
is
th
e main
state
ment
used
to
produce
output.
It
is
no
t surprising,
therefore,
that
the PRINT statement has several
diff
erent
variations.
The
general form
at
of
the
l'RINT
statement
is
the
wo
rd PRINT followed!
by
an
item
or
a li
st
of
ite
ms
to
be printed. These
i
nc
lude character strings, expressions. or names
of
var
iables whose values
"·1ill
be printed. Each
item
in
a
list
is
separated
by a
comma
or a
sem
i.:olon.
29
Do
not sale this PDF
!!!