EasyManua.ls Logo

Commodore Plus 4 - Page 63

Commodore Plus 4
464 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
BASIC
Version
3.5
Commands,
Functions,
and System
Variables
81
Parameters:
true-false
condition
THEN
clause
:
ELSE
clause
1.
The
conditions
in
the
IF
command
can
use
comparison
operators
(=,
<,
>,
<>,
<=,
or
>=)
to
compare
values.
The
values
can
be
any
of
the
following:
Numbers
or
text
strings
Any
type
of
variable
Variables
on
both
sides
of
the
comparison
operator
Mathematical
formulas
2.
The
THEN
clause
contains
commands
that
are
executed
only
when
the
IF
command
condition(s)
is
(are)
true.
The
THEN
clause,
which
is
always
a
required
part
of
the
IF
command,
can
contain
any
legal
commands.
(If
the
THEN
clause
contains
more
than
one
command,
they
must
be
separated
by
colons.)
The
THEN
clause
must
be
typed
on
the
same
line
as
IF
with
no
punctuation
separating
it
from
the
keyword
THEN.
If
the
THEN
clause
is
a
GOTO,
the
keyword
GOTO
can
be
omitted.
Example:
50
IF
X$
=
"HALT"
THEN
END
The
program
ends
when
X$
does
equal
HALT.
The
THEN
clause
is
not executed
otherwise.
3.
The
ELSE
clause
contains
a
command
that
is
executed
only
when
the
IF
condition(s)
is
(are)
false.
The
ELSE
clause
can
contain
any
legal
command.
If
the
ELSE
clause
is
a
GOTO,
the
keyword
GOTO
can
be
omitted.
The
ELSE
clause
is
always
optional,
but
the
THEN
clause
is
always
required,
so
an IF
command
cannot
have
an
ELSE
clause
but
no
THEN
clause.
ELSE
must
be
separated
from
the
THEN
clause
by
a
colon.
ELSE
is
a
clause,
not
an
independent
command;
type
THEN
and
ELSE
clauses
on
the
same
lines
as
the
IF
command.
Note:
IF
commands
can
be
"nested,"
but
their
ELSE
commands
will
not
be.
When
an IF
condition
is
found
to
be
false,
the
next
ELSE
clause
on
the
line
is
always
executed.
Examples:
30
IF
A
=
B
THEM"
PRINT
"EQUALITY":
ELSE
GOTO
100
40
IF
A
=
0
THEN
IF
B
=
0
THEN
PRINT
"BOTH
0":ELSE
PRINT
"ONE
NONZERO"
When
A
equals
B,
the
THEN
clause
executes
and
the
ELSE
clause
does
not.
When
the
condi
tion
is
false,
the
THEN
clause
does
not
execute,
and
the
ELSE
clause
does.
Prints
BOTH
0
if
A
and
B
are
zero.
Prints
ONE
NONZERO
if
either
is
not
zero.

Other manuals for Commodore Plus 4

Related product manuals