Sharp MZ-80B Basic Manual page 14

Personal computer double precision disc
Hide thumbs Also See for MZ-80B:
Table of Contents

Advertisement

6
As a simple example of sequ ential access file control, let ' s discu ss the recording of names and
addresses o f persons' homes in a sequ ential access file. Ou r file, an address list in this example, mu st be
made in the following form .
Name
Address
Name
Address
Name
Address
The reason the above rectangles are not the same length is that data recorded with the sequ ential
access method is not fixed in length. In a random access file, as we will later mention, all data is given
a fixed length o f 3 2 bytes. When all data is handled in the blocks as in this example, or when most of
the d ata (addresses in this example) is too long to be recorded in 3 2 bytes or is not fixed in length, the
sequ ential access file may be more su itable.
Shown below is a program which c a u ses the system to behave as follows: su bstitu te string variables
alternately with names and addresses with the INPUT statement, record a combination of names and
addresses one by one to make "ADDRESS LIST" with 50 combinations in all, then read stored data
ou t of the file (list) and display it on the CRT screen in grou ps of 10 items.
(Writing)
100 WOPEN #3 , "ADDRESS LIST" . . . . . . . . .
1 10 FOR P = 1 TO 50
1 20 INPUT "NAME=" ; NA$
1 30 INPUT "ADDRESS= " ; AD$
1 40 PRINT #3 , NA $ , AD $
1 50 NEXT P
1 60 CLOSE #3
file name
"ADDRESS LIST"
=
Dif ines the name of a sequ ential access file and
opens it with logical nu mber assigned.
In the program, the WOPEN statement defines the
name of the sequ ential access fi le as "ADDRESS
LIST" and assigns logical nu mber 3 to it.
This statement, when it follows the WOPEN state­
ment, generates a series of sequ ential access records.
When the PRINT # statement is execu ted, the
specified data record is added to a series of sequ en­
tial access records. The sequ ential access file is not
generated at this stage of program .
Writes a series of records generated by PRINT #
statements in a file. A sequ ential access file (BSD)
is generated when this statement is generated.

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents