
Now look at Program B-2.
It accesses the file
"DATA"
that
was created in Program B-1 and displays the name of everyone
hired in 1978.
10 OPEN "I",t1,"OATA"
20 INPUTt1,N$,D$,H$
30 IF RIGHT$ (H$,2).n7S" THEN PRINT N$
40 GOTO 20
RUN
EBENEEZER SCROOGE
SUPER MANN
Input past end in 20
Ok
Program B-2 reads, sequentially, every
item
in
the
file.
When all
the data has been read, line 20 causes an "Input
past end" error.
To avoid getting this error,
insert
line
1S which uses the EOF function to test for end-of-file:
A program that creates a
sequential
file
can
also
write
formatted
data to ~~e disk with the PRINT# USING statement.
For example, the statement
PRINT#1,USING"#ttt.tt,";A,B,e,o
could be used to write numeric data to disk without explicit
delimiters.
The
comma
at
the
end
of the format string
serves to separate the items in the disk file.
The Loe function, when used with a sequential file,
returns
the number of sectors that have been written to or read from
the file since it was OPENed.
A
sector is a 128-byte
block
of data.
B.3.1.1
Adding
~!£
~
Seauential File -
If you have a sequential file residing
on
disk
and
later
want
to
add
more data to the end of it, you cannot simply
open the file in
"0"
mode and start writing data.
As
soon
as
you
open a sequential file in
"0"
mode, you destroy its
current contents.
The following procedure can
be
used
to
add data to an existing file called "~AMES".
Summary of Contents for Basic Interpreter Basic 80
Page 1: ...5IA iC intc tit tcl c t ...
Page 2: ......
Page 6: ... ...
Page 10: ......
Page 26: ......
Page 33: ...2 5 Intentially left blank ...
Page 37: ...BASIC SO COMMANDS AND STATEMENTS 2 9 Intentially left blank ...
Page 112: ......
Page 136: ......
Page 140: ......
Page 160: ......
Page 165: ......
Page 166: ......
Page 174: ......
Page 176: ......
Page 182: ......
Page 184: ......
Page 190: ......