Download Print this page

VTech PreComputer 2000 Manual page 43

Advertisement

IF ... THEN ... ELSE
In general terms, the IF ..
.
THEN ... statement is used for CONDITIONAL BRANCH-
ING.
It uses the general form "IF (condition) THEN (action
clause)".
A condition
is made up of an expression
,
a relation and an expression.
Any BASIC expression, either numeric or string, may be
used,
but both
expressions must be the same type.
Relations or comparisons used in the IF ... THEN statement are the following:
Equal to
<
= Less than or equal to
< >
Not equal to
>
= Greater than or equal to
<
Less than
>
Greater than
Examples of how you can use conditionals
:
IF .... THEN A=B
IF .... THEN GOTO
IF
..
..
THEN GOSUB
IF ..
..
THEN PRINT
IF
..
.. THEN INPUT
Example:
I
30 IF X >25 THEN 60
Here if the condition X >25 is true, the computer is told to jump to line 60 (Note:the
GOTO is optional after THEN).
If the condition
is
not true, that is, if X is not greater than 25 then the computer
simply carries on with the normal line number order in the program
.
Notice that
it is not necessary to use the ELSE part of the command here as this is optional.
42

Advertisement

loading
Need help?

Need help?

Do you have a question about the PreComputer 2000 and is the answer not in the manual?