EasyManua.ls Logo

Commodore Plus 4 - Page 180

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...
168
Some
Programming
Techniques
40
IP
FE>0
THEN
Ft(X)=LEFT$(L$(X),FE-1):
L$(X)=RIGHT$(L$(X),LEN(Lf(X))-FE)
50
PRINT
"LAST
NAME:
";L$(X);:
IF
LEN(F$(X))>0
THEN
PRINT
"
FIRST
NAME:
";Ff
(X);
60
PRINT:NEXT
LEN
can
be used
to
figure
a
parameter
in
a
LEFTS,
RIGHTS,
or
MID$
function.
For
example,
in
the
following
program,
the
starting
position
in
the
MIDS
function
in
line
30
uses
the
LENgth
of
S$:
10
INPUT
"MONTH/DAY/YEAR";
S$
30
PRINT"THIS
IS
DAY
";MID$(S$,LEN(S$)-4,2);"
OF
MONTH
";
LEFT$(S$,2)
RUN
MONTH/DAY/YEAR?
12/25/84
THIS
IS
DAY
25
OF
MONTH
12
You
can
also
use
the
string
functions
to
search
input
for
characters
that are
not
acceptable
for
your
application.
For
example,
suppose
an
error
will
occur
in
your
program
if
information
being
input
contains
numbers.
You
can
use
the
string
functions
to
search
each
piece
of
input
for
a
number.
10
INPUT
"FULL
NAME";
S$
20
FOR
1=48
TO
57
30
Y
=
INSTR(S#,CHR$(I))
40
IF
Y>0
THEN
PRINT
"ILLEGAL
INPUT;
CHARACTER"
;Y;
"IS
A
NUMBER"
50
NEXT
The
INSTR
(IN
STRing)
function
finds
the
starting
position
of
a
string
embedded
within
another
string.
INSTR
searches
a
text
string
from
left
to
right
and
returns
a
number
that
tells
you
the
character
position
of
the
first
character
in
the
sought
string.
Like
the
LEN
function,
INSTR
is
a
numeric
function,
which
means
it
returns
a
number,
not a
text
string.
Also
like
LEN,
INSTR
works
only
on
a
text
string
expression,
not
on
a
number.
Converting
Strings
and
Numeric
Values:
STRl
and
VAL
The
STRS
function
converts
numeric
values
into text
strings.
You
would
use
this
conversion
when
you
want
to
use
a
string
function
to
search
the
number.
There
are
no
numeric
functions
comparable
to
LEFTS,
RIGHTS,
MIDS,
and
LEN.
So

Other manuals for Commodore Plus 4

Related product manuals