DISK BASIC
Sequential
Line
Input:
An
Example
Using
the line-oriented input,
you
can
write
programs
that edit
other
basic
program
files:
renumber
them, change lprints
to
prints,
etc.
—
as
long
as
these
"target"
programs
are stored
in
ascii format.
The
following
program
counts
the
number
of
lines in
any
ascii
—
format basic
disk
file
with
the
extension
/txt.
10
CLEAR 300
20
INPUT'WHAT
IS
THE NAME
OF THE
PROGRAM"; PROG*
30
IF
INSTR(PROG*»"/TXT")=0
THEN
110
'require /TXT extension
40
0PEN"I
H
t
1
t
PROG*
50
H.
=
60
IF
EOF(l) THEN
30
70 n,= n,+
l:
LINE INPUT#I
t
TEMP*
80
GOTO
G0
30
PRINT PROG*"
IS"
11
"LINES LONG*"
100
CLOSE: GOTO 20
110
PRINT "FILESPEC MUST INCLUDE THE EXTENSION
'/TXT'"
120
GOTO
20
For basic programs
stored
in ascii,
each
program
line
ends with
a carriage
return character
not
preceded by
a
line
feed.
So
the
line input
in line
70
automatically reads
one
entire line
at
a time,
into the
variable
temp$.
Variable
i%
actually
does
the counting.
To
try
out
the
program,
first
save
any basic program
using
the
a
(ascii)
option
(See save).
Use
the
extension
/txt.
149