Download Print this page

Radio Shack TRS-80 Owner's Manual page 160

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

Advertisement

Sample
Program
1310 A$
=
"WILLIAM WILSON"
1320 GET
1
j
X:
X=K+1
1330
IF
N$
=
A$
THEN PRINT "FOUND
IN
RECORD" LOC(i): CLOSE:
END
1340 GOTO 1320
This
is
a portion
of a program.
Elsewhere
the
file
has
been opened and
fielded.
n$
is
a
field
variable.
If
n$ matches a$
the
record
number
in
which
it
was
found
is
printed.
LOF
Get End-Of-Fie Record
Number
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.
lof
is
valid as
soon
as a
previously created
file is
opened.
If
a
file is
extended,
lof
is
not
valid
until
a
get
is
executed.
Examples:
10
OPEN
"R"
,1
("UNKNOWN/TXT"
20
FIELD
1
(255 AS A$
30
F0RIX=1
TO
L0F(1)
40
GET
1
>I1
50
PRINT
A$
60
NEXT
In
line
30, LOF(i)
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
zeros,
and no
error
is
generated.
142

Advertisement

loading

This manual is also suitable for:

Model iii