Radio Shack TRS-80 Trsdos & Disk Basic Reference Manual page 142

Micro computer system
Hide thumbs Also See for TRS-80:
Table of Contents

Advertisement

DISK BASIC
The
following
sequence of
lines
reads
numeric
data
from
DATA/TXT
into the array
A(
).
When
the
last
data character
in
the
file
is
read,
the
EOF
test
in line
30
"passes", so the
program
branches out of
the
disk access loop,
preventing an
INPUT PAST
END
error
from
occurring.
Also note
that the variable
I
contains the
number
of
elements input
into array
A(
).
5
DIM
fi<166)
'ASSUMING THIS
IS R
SAFE VALUE
16 OPEN
"IM,
"DflTfl/TXT"
29 I%=0
30
IF
EQF<1> THEN 70
40 INPUT#l,fl<IX)
50
I5S=I5i+l
60 GOTO 30
70 REM PROGRAM CONTINUES HERE AFTER DISK INPUT
LOF
(get end-of-file
record
number)
LOF
(nmexp)
where
nmexp
specifies a
random
access
buffer
nmexp=l,2,
...
,15
This function
tells
you
the
number
of the
last,
i.e.,
highest
numbered,
record
in a
file.
It
is
useful for
both
sequential
and
random
access.
For
example, during
random
access to a pre-existing
file,
you
often
need
a
way
to
know when
you've
read the
last
valid
record.
LOF
provides
a
way.
Examples:
10 OPEN
"RV1,
"UNKNOWN/TXT"
20 FIELD 1,255 AS A$
30 F0RIK=1 TO L0F<1)
40 GET
1,
IV.
50 PRINT A*
60 NEXT
In
line
30,
LOF(l)
specifies
the highest record
number
to
be
accessed.
Note:
If
you
attempt
to
GET
record
numbers beyond
the
end-of-file
record,
BASIC
simply
fills
the buffer
with hexadecimal
zeroes,
and
no
error
is
generated.
When
you want
to
add
to
the
end of
a
file,
LOF
tells
you
where
to
start
adding:
100 IK=L0F<1)+1 'HIGHEST EXISTING RECORD
110 PUT
1,
17.
'ADD
NEXT RECORD
7-56

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents