As we have stated before,
an
expression is actually data. This is
because once BASIC performs
all
the operations, it returns one data
item.
An
expression may be string or numeric. It may be composed
of:
• Constants
• Variables
• Operators
• Functions
Expressions may
be
either simple or complex:
A
simple expression consists of a single term: a constant, variable
or function. If it
is
a numeric term, it may be preceded by
an
optional
+ or - sign, or by the logical operator NOT.
For example:
+A 3.3 - 5 SQR(8)
are all simple numeric expressions, since they only consist of one
numeric term.
A$ STRING$ (20,A$) "WORD"
"M"
are all simple string expressions, since they only consist of one string
term.
Here's how a
simple expression
is
formed:
"..........
NOT
'--./
CONSTANT
VARIABLE
FUNCTION
A complex expression consists of two or more terms (simple
expressions) combined by operators. For example:
A-1
X+3.2 - Y 1= 1 A AND B ABS(B) +LOG(2)
are all examples of complex numeric expressions. (Notice that you
can use the relational expression
(1
=
1)
and the logical expression (A
AND
B)
as
a complex numeric expression since both actually return
numeric data.)
A$
+ B$
"Z" +
Z$
STRING$(10, "A") +
"M"
are all examples of complex string expressions.
2-48