EasyManua.ls Logo

Commodore CBM - Page 418

Commodore CBM
447 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...
Before forcing
an
interrecord gap vou must detect when the cassette buffer
has
written
out a "physical record" or
"block"
of
data to the tape. The buffer holds
191
characters (or
191
bytes). A full buffer
is
a signal
that
a block
of
data was just
written
to the tape since the contents of the buffer are dumped only after it has
reached its capacity.
By
detecting a full buffer.
Vou
can infer
that
a block of data
was just
written
to the tape and
an
interrecord gap is needed.
How
to
Detect
a Full Buffer
Wh
en
writing
data out to a tape.
following
each
PRINT*
statement the
length of each data item
is
calculated and kept in an accumulator.
which
is
then
compared
to
the buffer
limit
(191
characters). When the accumulator equals
191
the
writing
to the tape
is
stopped until
an
interrecord gap
is
written
on
the tape.
Below
is
a sample program:
10
POKE
243.
122:POKE
244.2:0PEN1.l.l
20
FOR
X=l
TO
100
::::0
PRINT#l
..
;.(
40
A=LEN(STR$(X»+l
50
IF
(QT+A»=191
GOSUB
1000
:REM
.IF
EUFFER
FULL
CALL
SUE.
60
QT=QT+A
TO
ADVANCE
TAPE.
?€1
NE)":T
>':
::::1'::1
CLOSE
1
90
Et·m
Line 20 prints a variable. If the variable printed
(in
this case.
X)
is
numeric it
must
be
converted to string form
so
the
LEN
function may be used to determine
X's length.
as
shown in line 40:
40 A=LEN(STR$(X))+1
One
is
added
on
to
the lengths of the strings to include the carriage returns
that
are
written
on the tape following each data item. Line 50 accumulates the
number
of
characters in the previous strings.
(OT).
plus
A.
and compares the total
to
191
(the buffer limit). If the number of characters
written
to the tape
(OT
+
A)
is
greater than or equal to
191
the entire buffer
is
written
to the tape. and it
is
time
to
force
an
interrecord gap by calling the subroutine at 1000. However. if
OT
+A
is
less than
191
(OT
+A
< 191). the buffer
is
not yet full. Line 60 increments
OT
by
A.
and the process keeps repeating until the buffer
is
full. and ail the data
is
written
fram the buffer to the tape. interspersed
with
the interrecord gaps.
Advancing the Cassette Tape
There
are
three necessary steps in the routine to advance the tape:
1.
Turn
on
the cassette tape
motor
(POKE
59411.53).
2.
Use
a
wait
loop to stail program
while
tape
is
advancing.
3.
Turn off the cassette tape
motor
(POKE
59411.61).
405

Table of Contents

Other manuals for Commodore CBM

Related product manuals