EasyManua.ls Logo

Texas Instruments TI-99/4A - Page 147

Texas Instruments TI-99/4A
204 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
Loading...
INPUT
Using INPUT with RELATIVE Files
(See
"OPEN"
for a description
of
RELATIVE
file· organization.)
You
may
read
RELATIVE
files
either
sequentially or randomly.
Thc
computet-
scts
up
an
internal
counter
to
point
to
which
record
should be
processed
next.
The
first
record
in a file is record
O.
Thus,
the
counter
begins
at
zero
and
is
incremented
by +1 after
each
access
to
the
file.
eithel-
to
read
01-
to
wr-ite
u
I-ecord.
In
the
example
on
the
right.
the
statements
direct
the
computer
to
read
the
file
sequentially.
The
internal
counter
can
be
changed
by
using the REC clause.
The
numeric'expression following the
keyword
REC
will be
evaluated
to
designate
a specific
record
number
on the file. When
the
computer
performs
an
INPUT
statement
with a
REC
clause. it
reads
the specified
record
from the
designated
file
and
places
it
in
the
110
buffer.
The
REC
clause
can
appear
only
in
statements
referencing
RELATIVE
files.
The
example
on
the
right illustrates
accessing
a
RELATIVE
file randomly. using the
REC
clause.
Be
sure
to use the
REC
clause
if
you
read
and
write
records
on
the
samc
file within a
program
Sincc
the
same
internal
counter
is
incremented
when
records
are
either
read
or
written for the
same
file, you
may
skip
some
records
and
write
over
others
if
REC
is not
used,
as
shown
in
the
example
all the
ri~ht.
If
the
internal
counter
points to a
record
beyond the limits
of
the file
when
the
computer
tries to
access
the file.
the
program
will
tf'rminrltf'
with
;'In
TNPT
IT
ERROR.
User's
Reference
Guide
Examples:
>NEW
>100
OPEN
#4:NAME$,RELATIVE,I
NTERNAL,INPUT,FIXED
64
>110
INPUT
~4:A,B,C$,~$,X
program
Lines
>200
CLOSE
~4
>210
END
>NEW
>100
OPEN
#6:NAME$,RELATIVE,I
NTERNAL,UP~ATE,FIXED
72
>110
INPUT
K
>120
INPUT
#6,REC
K:A,B,C$,D$
program
Lines
>170
PRINT #6,REC
K:A,B,C$,D$
program
Lines
>300
CLOSE
116
>310
END
>NEW
>100
OPEN
#3:NAME$,RELATIVE,I
NTERNAL,UPDATE,FIXED
>110
FOR
1=1
TO
10
>120
INPUT
Y3:A$,B$,C$,X,Y
program
Lines
>23U
P~INl
113:A$,8$,C$,X,Y
>240
NEXT
I
>250
CLOSE
#3
>260
EN~
>RUN
--LINE
120-Reads
records
0,2,4,6,8
••.
--LINE
130-Writes
records
1,3,5,7,9
•.•
IT
·127

Other manuals for Texas Instruments TI-99/4A

Related product manuals