Lesson # 10 Data Files - 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 #18 Data Files
In this Lesson you will learn how to read and write data files to cassette and RAM.
Data files allow you to store information for future reference. Some common examples
include:
• A list of customer names and addresses
• A
list of items in inventory
• Sales data
• A
list of students and their grades
• A
list of hourly data readings such as temperature, pressure, humidity, wind
velocity, wind direction and pollution index, etc.
You can save data files in either RAM or on cassette. The easiest and most convenient
way to save a data file is in RAM. A RAM data file has the advantage of quick access
and does not require attaching an external device. The disadvantage of a RAM data
file, however, is that it uses up available memory space.
Cassette files are external to the Computer and do not use up valuable RAM space.
When storing a large data file, it is more practical to use cassette tape. For example, a
mailing list of 1000 names and addresses would require around 80K bytes of memory.
This exceeds the maximum memory capacity of your Computer, so a RAM data file is
out of the question. However, a list of this size could fit easily on a cassette file.
Experiment #1 Writing a data file to RAM
The program below allows you to create a RAM file where various names may be
kept.
Clear memory using the NEW command and enter the following program:
100 CLS
110 OPEN "RAM:NAMES" FOR OUTPUT AS 1
120 INPUT "NAME"; N$
130 IF N$
= ""
GoTo 200
1a0
PRINT #1, N$
150 N$
= ""
:
GoTo 120
200 STOP
Execute this program and type the name John Smith when prompted, as shown below:
NAME? John SMith
The program will prompt you again to enter another name, and repeatedly do so until
(!RIEID is pressed with no name preceding it. Enter the names as shown below:
NAME? Peter Wolf
NAME? Aloysius T. Cornpone
NAME? JiM Shoe
NAME? Steele Masnet
NAME? Ray D. o'Shack
NAME?
123

Advertisement

Table of Contents
loading

Table of Contents