Applesoft
BASIC
Programming
59
The
following
comparisons
between
strings
would
all evaluate
as
true.
"ABC"="
ABC"
"ABC
">"ABC"
"BAA"
>
"AAA"
" ALFRED" <
"ALFREDO"
A$ < Z$
where
A$=" ALFRED" and Z$=" ALFREDO"
Note
that
all string constants must be enclosed in
quotation
marks
when
used
as
constants.
Logical Operators
Logical
or
Boolean
operations
are generally used in BASIC
to
compare
the
outcomes
of
two
relational operations. Logical
operations
themselves
return
a
true
or
false value
which
will
be
used
to
determine
program
flow.
The logical operators are
NOT
(logical
complement),
AND
(conjunction),
and
OR
(disjunction).
These are best
explained
with
a
simple
analogy. Suppose
that
Steve and Sherry
were
shopping
in
the
produce
department
of
their
grocery
store.
If
they
decided
to
collectively
purchase an
item
if
either
of
them
individually
wanted
that
item
,
they
would
be
acting
under
the
OR logical
operator.
Now,
suppose
that
Steve and Sherry
decided
that
they
would
only
purchase an
item
if
they
both
wanted
that
item
. They
would
then
be
acting
under
the
AND
logical
operation.
Now,
suppose
that
Sherry
was
angry
with
Steve. If Sherry
decided
not
to
purchase
the
items
that
Steve
wanted
, she
would
be
acting
under
the
NOT
logical
operation
. The
NOT
,
AND,
and
OR logical operators are summarized in
Illustration
3-3.
A logical
operator
evaluates an
input
of
one
or
more
operands
with
true
or
false values. The logical
operator
evaluates these
true
or
false values and
returns
a value
of
true
or
false itself.
An
operand
of
a logical
operator
is
evaluated
as
true
if
it
has
a
non-zero
value.
(Remember
, relational operators
return
a value