EasyManua.ls Logo

Radio Shack TRS-80 Model 100 - Page 66

Radio Shack TRS-80 Model 100
210 pages
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...
Now list the program to confirm that it is:
5
CLEAR
100
10
READ
D$
20
IF
LEFT$(D$,3)
=
DAY$
THEN
GOTO
40
30
GOTO
10
40
L =
LEN(O$)
44
A$
=
STRING$(
(40
-
L)/2,
"*")
48
0$
=
A$
+
D$
+
A$
48
PRINT
D$
50
DATA
SundaY,
Monday,
Tuesday,
Wednesday
80
DATA
Thursday,
Friday,
Saturday
Execute the program
by
entering the RUN command.
If
the current day
is
Thursday,
the following will be output:
****************Thursday****************
If
the current day
is
Friday, then the output will appear
as:
*****************Friday************~~***
In
each case, the word
is
centered in the line and an equal number of asterisks are
printed on both sides to fill the line.
If
the current day
is
Tuesday, which has 7
characters, then
16
asterisks are printed on both sides so that
39
columns are used.
The function
LEN
returns the number
of
characters in a string variable or string
constant. For example if
0$
contains Friday, then the function LEN(O$) returns the
value 6, and LEN("Friday") also returns a
6.
Since
the
value returned by the function LEN
is
an
integer, there
is
no dollar sign ($)
attached
to
the function name. In line 40, the number of characters of the string stored
in
0$
is
a<;signed
to
L.
If
the current day
is
Friday, then L has 6 assigned to
it.
60

Other manuals for Radio Shack TRS-80 Model 100

Related product manuals