EasyManua.ls Logo

Commodore Plus 4 - Page 177

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...
Using
the
String
Functions
168
When
you
use
the
other
comparison
operators
to
compare
text
strings,
the
computer
reads
the
strings
character
by
character-,
checking
for
which
string's
current
character
is
greater
or
less
based
on
the
character's
character
code
number
(CHR$
value).
A
has
the
lowest
value,
Z
the
highest,
so
characters
are
checked
for
standard
alphabetical
order,
although
the
comparison
is
actually
done
by
numeric
values
for
each
letter
of
the
alphabet.
Shifted
characters
are
always
greater
than
unshifted
characters.
See
the
CHR$
value
list
in
Appendix
C.
When
numbers
in
text
strings
are
compared,
the
computer
treats
them
as
a
character
(CHR$)
code
number.
All
numbers
have
lower
character
codes
than
any
letter,
so
9
is
less
than
A.
Examples
of
Text
String
Comparisons
10
INPUT
T
SO
A$
=
"BIT"
+
STRICT)
30
PRINT
"A$
=";
A$
RUN
?
2
A$
=
BIT
2
NEW
10
D0:INPTJT
K$
20
PRINT
"G0":L00P
WHILE
K$
<>
"STOP"
NEW
10
INPUT
X$
20
IP
LEFT$(X$,1)
<
"L"
THEN
G0SUB
100:
ELSE
PRINT
"PAST
RANGE"
RUN
?
MIDDLE
PAST
RANGE
Makes
A$
equal
to
the
string
"BIT"
plus
the
value
of
T
converted
to
a
string
value
by
the
STR$
function.
Compares
the
value
input
for
K$
to
the
string
"STOP".
The
loop
con
tinues
while
K$
is
not
equal
to
"STOP".
Checks
the
first
charac
ter
of
X$,
input
in
line
10.
If
the
character
is
less
than
L
(A-K),
the
pro
gram
branches
to
a
sub
routine.
Otherwise
the
PAST
RANGE
is
printed.
Using
the
String
Functions
BASIC
Version
3.5
contains
14
functions
that
operate
using
text
strings:
ASC
returns
the
character
(CHR$)
code
of
the
first
character
in
the
string.
CHR$
returns
the
character
string
represented
by
its
character
code.

Other manuals for Commodore Plus 4

Related product manuals