Radio Shack TRS-80 Model 100 Basic Manual page 71

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

Advertisement

right instead of the left of the string. Of course, the MID$ function could have been
used instead. Using MID$, line 65 would appear as:
65 SS$
=
MID$(TIME$t7t2)
It is usually easier to use LEFf$ or RIGHT$ instead of MID$ if the characters are the
leftmost or rightmost of the string.
Experiment #5 What's the date?
The string function DATE$ returns the date in the form
mm/ddlyy
For example, if the present date is October 23, 1983, then the command:
PRINT DATE$
will display
10/23/83
Note:
The date must be initialized prior to using the DATE$ function. Once entered,
the date will be automatically updated. If you have not already initialized the date,
you may do so by entering the following command:
DATE$
=
"mm/dd/yy"
where mm is the number of the current month (e.g. 03 for March), dd is the day, and
yy the year. For example, if today is December 25, 1983, enter
DATE$
=
"12/25/83"
Delete the previous program from memory with the NEW command. The following
program will print the date in the usual form, (i.e., the name of the month, the day
and the year.) For example:
DECEMBER 25t 1983
Type the following program:
10 MM$
=
LEFT$(DATE$t 2)
20 MM
=
VAL< MM$)
30 READ MM$
110
CT
=
CT
+
1
50 IF CT
<
MM THEN GOTO 30
80 DD$
=
MID$(DATE$,
ll,
2)
70 YY$
=
RIGHT$(DATE$, 2)
80 PRI NT M M $; " "; DD$; ", 19"; YY$
90 DATA JANUARY, FEBRUARY, MARCHt APRIL
100 DATA MAYt JUNEt JULYt AUGUSTt SEPTEMBER
110 DATA OCTOBERt NOVEMBERt DECEMBER
Refer to Figure 5-2 for the flowchart of this program.
Execute the program. The output will be today's date in the usual format: month, day,
and year.
65

Advertisement

Table of Contents
loading

Table of Contents