Chapter 51 Disk Files - Radio Shack TRS-80 Model 4 Owner's Manual

Hide thumbs Also See for TRS-80 Model 4:
Table of Contents

Advertisement

Chapter 5/ Disk Files
You may want to store data on your disk for future use. To do this,
you need to store the data in a "disk file." A disk file is an organized
collection of related data. It may contain a mailing list, a personnel
record, or almost any kind of information. This is the largest block of
information on disk that you can address with a single command.
To transfer data from a BASIC program to a disk file, and vice-versa,
the data must first go through a "buffer". This is an area in memory
where data is accumulated for further processing.
With BASIC, you can create and access two types of disk files. The
difference between these two types is that each is created in a
different "mode." The mode you choose determines what kind of
access you will have to the file: sequential access or direct access.
Sequential-Access Files
With a sequential-access file, you can only access data in the same
order it was stored: sequentially. To read from or write to a particular
section in the file, you must first read through all the contents in the
file until you get to the desired section.
Data is stored in a sequential file as ASCII characters. Therefore, it is
ideal for storing free-form data without wasting space between data
items. However, it is limited in flexibility and speed.
The statements and functions used with sequential files are:
OPEN
PRINT#
PRINT# USING
WRITE#
INPUT#
LINE INPUT#
EOF
LOC
CLOSE
These statements and functions are discussed in more detail in
Chapters 6 and 7.
Creating a Sequential-Access File
1. To create the file, OPEN it in
"a"
(output) mode and assign it a
buffer number (from 1 to 15).
Example
OPEN "0"
1
11
"LIST/EMP"
opens a sequential output file named L1ST/EMP and gives buffer 1
access to this file.
2. To input data from the keyboard into one or more program
variables, use either INPUT or LINE INPUT. (The difference
between these two statements is that each recognizes a different
set of "delimiters". Delimiters are characters that define where a
data item begins or ends).
2-51

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Trs-80 model 4p

Table of Contents