EasyManuals Logo

Tandy 1000 Basic Reference Manual

Default Icon
411 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #212 background imageLoading...
Page #212 background image
Chapter
10
I
BASIC
Keywords
LOF
Function
LOF
(
buffer)
Returns the length of the file in bytes.
Buffer
is
the number assigned to the file when you opened it.
Example
Y
=
LOF(5)
assigns the length of the file in bytes to variable
Y
Sample Programs
During direct access to an existing file, you often need a way to
know when you have read the last valid record.
LOF
provides a
way:
1540 OPEN
"R",
1,
"unknown.txt",
128
1550 FIELD 1, 128 AS
A$
1560 RCNUM%
=
1 'START AT BEGINNING OF FILE
1570 RCSIZ%
=
128 'SET RECORD SIZE
1580 IF RCNUM%
*
RCSIZ%
>
LOF(1) GOTO 1640
1590 'CHECK FOR END OF FILE
1600 GET 1, RCNUMX 'RECORD NUM. TO BE ACCESSED
1610 PRINT
AS
1620 RCNUM%
=
RCNUM%
+
1 'INCREMENT RECORD NUM
1630 GOTO 1580
1640 CLOSE
If you attempt to
GET
record numbers beyond the end-of-file,
BASIC gives you an error.
These lines use
LOF
to determine where to start adding when
you want to add to the end of
a
file:
1700 RCNUM%
=
(LOFC1)
/
RCSIZ%)
+
1
1720 'HIGHEST EXISTING RECORD
1720 PUT 1, RCNUM% 'ADD NEXT RECORD
210

Table of Contents

Other manuals for Tandy 1000

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Tandy 1000 and is the answer not in the manual?

Tandy 1000 Specifications

General IconGeneral
ProcessorIntel 8088
Processor Speed4.77 MHz
RAM128 KB (expandable to 640 KB)
Operating SystemMS-DOS 2.11
ManufacturerTandy Corporation
Release Year1984
StorageSingle or double 5.25" floppy disk drive (360 KB), optional hard drive
SoundTandy 3-voice sound
PortsParallel, Serial
GraphicsCGA (Color Graphics Adapter)
Graphics Modes320x200, 640x200

Related product manuals