Lesson #5 Day, Time And Date - Radio Shack TRS-80 Model 100 Basic Manual

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

Advertisement

Lesson #5 Day, Time and Date
Your Model 100 has a number of string functions which allow you to manipulate
string constants and string variables in various ways.
In
this lesson you will learn how to use some special string functions that "return"
the day, time and date. Also, other string functions will be used to extract information
from string constants and string variables and to output character data.
Experiment #1 What Day is it?
DAY$ is a string function which returns the day of the week. If you type:
PRINT DAY$
wrnID
you will see that the first three letters of the present day are displayed. For example, if
today happens to be Thursday, the Computer will display
Thu
Note: You must initialize the day sometime prior to using the DAY$ function. Once
initialized, the day will be automatically updated.
If you have not already initialized the day, this can be done by entering the following
command:
DAY$
=
"xxx"
where
"xxx"
are the first three letters of the current day. For example, if today is
Monday, enter
DAY$
=
II
M ON"
CEBIEID
While the DAY$ function returns the first three letters of the day of the week, it is
often desirable to print the full name of the day (e.g. Thursday, not Thu).
The following program, which we'll call DAY, accomplishes this. Refer to Figure 5-1
for a flowchart of the program.
Clear working memory with the NEW command and type the following program in
from the keyboard.
10 READ 0$
20 IF LEFT$(D$,3)- DAY$ GO TO 40
30 GOTO 10
40 PRINT "TODAY IS "; 0$
50 DATA Sunday, Monday, Tuesday, Wednesday
60 DATA Thursday, Friday, Saturday
Execute this program.
The program will output the day of the week. Here is an example of the output:
TODAY IS Thursday
57

Advertisement

Table of Contents
loading

Table of Contents