Download Print this page

Radio Shack TRS-80 model III Owner's Manual page 152

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

Advertisement

DISK BASIC
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"»
It
"GLOSSARY/BAS"
110
FIELD
It
16
AS
ND$* 240
AS
MEANINGS
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
field
statement. So, for
example,
the statement:
10
PRINT WD$?
":"
5
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
H
*
1*
"GLOSSARY/BAS"
110
FIELD
1*
IS
AS
ND$, 240
AS
MEANING$
120
LSET WD*="LEFT-JUSTIFY"
130
LSET
MEANING*="T0
PLACE
A
VALUE
IN
A
FIELD FROM LEFT
TO
RIGHT?
IF
THE DATA DOESN'T FILL THE FIELD* BLANKS ARE
ADDED
ON
THE RIGHT
5
IF
THE DATA
IS
TOO LONG
t
THE EXTRA
151

Advertisement

loading