Here's another example:
IF
X + 0
OR
Y > 0
AND
Z = 1
THEN
GOTO
255
The relational operators =
and
> have the highest precedence, so
BASIC performs them first, one after the next, from left to right. Then
the logical operations are performed. AND has a higher precedence
than OR, so BASIC performs the AND operation before OR.
If the above line looks confusing because you can't remember which
operator is precedent over which, then you can use parentheses to
make the sequence obvious:
IF x = 0
OR
«Y
>
0)
AND
(Z
=
1»
THEN
GOTO
255
Functions
A function
is
a built-in sequence of operations which BASIC performs
on
data. BASIC functions save
you
from having to write a BASIC
routine, and they operate faster than a BASIC routine would.
Examples:
SQR
(A
+
6)
tells BASIC to compute the square root of (A +
6).
MID$
(A$t3t2)
tells BASIC to return a substring of the string A$, starting with the
third character, with a length of
2.
BASIC functions are described
in
more detail
in
Chapter
7.
If
the function returns numeric data, it
is
a numeric function and may
be used
in
a numeric expression. If it returns string data, it is a string
function and may
be
used
in
a string expression.
D-
How to Construct
an
Expression
Understanding how to construct
an
expression will help you put
together powerful statements - instead of using many short ones.
In
this section we will discuss the two kinds of expressions you may
construct:
• Simple
• Complex
as well as how to construct a function.
2-47