Download Print this page

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

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

Advertisement

Sample
Program
1310 At
=
"WILLIAM WILSON"
1320 GET
1
<+l
1330
IF
N$
=
A$
THEN PRINT "FOUND
IN
RECORD" LOC(l): 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-File
Record
Number
lor(nmexp)
nmexpsp
'^mmim
:
mwmexfi=
1,2,.. ..is.
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
F0RI%=1
TO
L0F(1)
40
GET
1
,11
50
PRINT
A$
60
NEXT
In
line
30,
lof(d
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