Radio Shack TRS-80 Model 100 Basic Manual page 66

Basic language lab
Hide thumbs Also See for TRS-80 Model 100:
Table of Contents

Advertisement

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

Advertisement

Table of Contents
loading

Table of Contents