EasyManua.ls Logo

Commodore 1570 - Page 51

Commodore 1570
132 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
ADDING TO A SEQUENTIAL FILE
The APPEND command allows you
to
reopen
an
existing sequential
file
and add
more information to the end
of
it.
In
place
of
the
"type"
and "direction" parameters
in
your OPEN statement, substitute
",A"
for Append. This will reopen your file, and
position the disk head at the end
of
the existing data
in
your file, ready
to
add
to
it.
FORMAT FOR THE APPEND OPTION
BASIC 7.0:
APPEND#file#,
"file name"[,Ddrive#l [,Udevice#l
BASIC 2.0: OPEN
file
#,device #,channel
#,"drive
#:file name,A"
where everything
is
as
on the previous page except for the ending
"A"
replacing
the
"type"
and
"direction"
parameters.
EXAMPLE:
If you are writing a grading program,
it
would be convenient
to
simply tack on each
student's new grades to
the
end
of
their existing grade files. To add data to the
"JOHN
PAUL JONES" file, type:
BASIC 7 .0: APPEND#
1,
"0:JOHN PAUL JONES" ,D0,U8
BASIC 2.0: OPEN 1,8,3, "0:JOHN PAUL JONES,A"
In this case, the Disk Operating System (DOS) will allocate at least one more sector
(block) to the
file
the first time you append
to
it, even if you only add one character
of
information. You may also notice that using the COLLECT or VALIDATE command
didn't correct the
file
size. If the wasted space becomes a problem, you can easily correct
it
by copying the
file
to
the same diskette or a different one, and scratching the original
file. Here's a sequence
of
commands that will copy such files
to
the original diskette under
the original name:
RENAME
"JOHN
PAUL JONES" TO
"TEMP"
COPY
"TEMP"
TO
"JOHN
PAUL JONES"
SCRATCH
"TEMP"
WRITING FILE DATA: USING
PRINT#
After a sequential
file
has
been opened
to
write (with a type and direction
of
" ,S,
W'
'),
we
use the
PRINT#
command to send data
to
it
for storage on diskette. If you
are familiar with BASIC's PRINT statement, you will find PRINT# works exactly the
same way, except that the list
of
items following the command word
is
sent
to
a particular
file, instead
of
automatically appearing
on
the screen. Even the formatting options such as
punctuation work
in
much the same way
as
in
PRINT statements. This means you have
to
be
sure the items sent make sense
to
the particular
file
and device used.
43

Related product manuals