Download Print this page

Radio Shack TRS-80 Owner's Manual page 169

Mini-disk operation disk operating system disk basic programming language
Hide thumbs Also See for TRS-80:

Advertisement

DISK BASIC
Ik,-,-:
J
mmmmm®
m
The
buffer
is
a waiting area
for the data.
Before
writing data
to
a
file,
you must
place
it
in the
buffer
assigned
to
the
file.
After reading data
from
a
file,
you
must
retrieve
it
from
the
buffer.
As
you can
see
from
the
sample put and get
statements above, data
is
passed
to
and
from
the
disk
in
records.
The
size
of
each
record
is
determined
by an
Open
statement.
Storing
Data
In
a Buffer
You
must
place the
entire
record
into the buffer
before putting
its
contents
into
the disk
file.
This
is
accomplished by
1)
dividing the buffer
up
into
fields
and
naming
them,
then
2)
placing
the string or
numeric
data
into the
fields.
For example, suppose
we
want
to store
a glossary
on
disk.
Each
record
will
consist
of
a
word
followed
by
its
definition.
We
start
with:
100
0PEN"R"»
1>
"GLOSSARY/BAB"
110
FIELD
1,
IB
AS
WD$t 240
AS
MEANING*
Line 100 opens
a
file
named
glossary/bas
(creates
it
if
it
doesn't already
exist);
and
gives buffer
1
direct
access
to
the
file.
Line 110
defines
two
fields
onto
buffer
1:
wd$
consists
of
the
first
16 bytes
of
the buffer;
meanings
consists
of
the
last
240
bytes.
wd$
and
meanings
are
now
field-names
What
makes
field
names
different?
Most
string
variables point
to
an
area
in
memory
called the
string
space.
This
is
where
the
value of
the
string
is
stored.
Field
names, on
the
other
hand,
point
to
the buffer area
assigned
in
the
held
statement.
So,
for
example,
the statement:
10
PRINT WD*5
":"
i
MEANING*
displays the contents
of
the
two
buffer
fields
defined above.
These
values
are
meaningless
unless
we
first
place data
in
the buffer, lset,
rset
and
get
can
all
be used
to
accomplish
this
function.
We'll
start
with
lset and
rset,
which
are
used
in
preparation
for
disk
output.
Our
first
entry
is
the
word
"left-justify"
followed
by
its
definition.
100
0PEN"R"»
"GLOSSARY/BAS"
110
FIELD
IS
AS
WD*, 240
AS
MEANING*
120
LSET
WD*="LEFT-JUSTIFY"
130
LSET
MEANING*="T0
PLACE
A
VALUE
IN
A
FIELD FROM LEFT
TO
RIGHT1
IF
THE DATA
DOESN'T FILL
THE
FIELD, BLANKS
ARE
ADDED
ON THE
RIGHT?
IF
THE DATA
IS
TOO LONG, THE EXTRA
151

Advertisement

loading

This manual is also suitable for:

Model iii