From
Basic
to
SuperBAS1C
In
this case
w=1
is
a condition or logical expression which
is
either true or false
If
it
•
is
true then a subroutine starting at line
300
would be executed. This subroutine may
deal with
kite
flying but you cannot
tell
from the above
line.
A careful programmer would
write:
40
IF
w=l
THEN
GOSUB
300
:
REM
fly_ki
te
to
make
it
more readable. But the SuperBASIC statement
is
readable
as
it
stands. The
identifier
windy
is
interpreted
as
true or false though
it
is
actually a floating point
van
able.
A value
of
1 or
any
non-zero value
is
taken
as
true.
Zero
is
taken
as
false.
Thus the
single word,
windy, has the same effect
as
a condition of logical expression.
The other word,
fly_kite,
IS
a procedure.
It
does a job similar
to,
but rather better than,
GOSUB
300.
The following program
Will
convey the idea of logical variables and the simplest type
of named procedure.
100
INPUT wi
ndy
110
IF
windy
THEN
fly
kite
120
IF
NOT
windy
THEN-tidy
shed
130
DEFine
PROCedure
fly
kite
140
PRINT
"See
it
in
the
air."
150
END
DEFine
160
DEFine
PROCedure
tidy
shed
170
PRINT
"Sort
out
rubbish."
180
END
DEFine
INPUT
OUTPUT
a
Sort
out
rubbish.
1
See
it
in
the
air
2
See
it
intheair
-2
See
it
in
the
air
You
can see that only zero
is
taken as meaning
false.
You
would not normally write
procedures
with
only one action statement but
the
program
illustrates
the idea and syntax
in
a very simple context. More
is
said about procedures later
in
this chapter.
LET
STATEMENTS
In
SuperBASIC LET
is
optional but we use
it
in
thiS
manual so that there
will
be less
chance
of
confusion caused
by
the two possible uses of
=.
The meanings of =
in:
LET
count
= 3
and
in
IF
count
= 3
THEN
EXIT
are different and the LET helps
to
emphasise
this.
However,
if there are two or a
few
LET statements dOing some simple job such
as
setting initial values,
an
exception may
be made.
For
example:
100
LET
fi
rst
= a
110
LET
second
= a
120
LET
t h i
rd
= a
may be re-written
as:
100
LET
first
=
0:
second
=
0:
third
= a
without loss of clarity or
style.
It
is
also consistent
With
the general concept of
allOWing
short forms of other constructions where they are used
in
simple
ways.
The colon:
is
a valid statement terminator and may
be
used with other statements besides
LET.
12/84
•
•
•