Sample Program 2
Next
is
the sample program MAIL.GET#2. to read MAIL and print the data
on
the screen divided into records. Below
is
a program listing of MAIL.GET#2.
MAIL,GET#2
10
PRINT":-»+++++++++++++++++++++++++"
20
PRINT"+
+"
3(1
PRINT"+
READ
t'lAIL
FILE
W/ GET#
+"
40
PRINT"+
+"
5e
PRINT"+.++++++++++++++++++++++++":PRINT:PRINT
65
PRINT"++
PRESS
(RETUR,..[>
l"HEt,~
TAPE
IS
LOADED
++":
PRINT:
70
GET
A:t:
IF
A:t=""
THEN
7e
8e
PRINT"++
OPENING MAIL
FILE
++":
PRHH:
OPEN
1,1,0
e
..
"t'lAIL"
ge
PRINT:
PRHH":-»+
MAIL
FILE
++":
PRmT:
1ee
IF
ST=64
THEN
9999
11(1
GET#l
"
>:::t
12e
IF
X:t=CHR:t(13)
THEN
F=F+l
13e
PRINT
X:t.:
14e
IF
F>=5
THEN
GOSUB
16e
150
GOTO
1ee
16(1
PR
H~T
:
170
R=R+1
18e
IF
R:>2
THEN
PRINT
"PRESS
"'r
'
"
FOR
NE:x:T
SET
OF
RECOFi:DS"
.;
: INPUT
A:t
185
IF
A:t="'r'"
THEN
F:=(1
190
F=0:PRINT:RETURN
9999
PRINT"~+
END
OF MAIL
FILE--PROGRAM
TERMINATED++":
CLOSE1:
END
Type in MAIL.GET#2 and SAVE and
VERIFY
it
on a cassette tape. LIST the
program.
The first ten lines (10 through 100) of MAIL,GET#2 are identical to the first
ten lines of MAIL,GET#1, This part of the program informs the user of the pro-
gram's functions and procedures. and opens the MAIL data file in preparation for
reading the data,
The
real
difference between MAIL.GET#2 and MAIL.GET#1
is
at line 120. If
X$=CHR$(13), instead of changing the value of X$ from a carriage return to FULL
GRID
•.
variable F- a carriage return counter -
is
incremented by
one,
When
MAIL,PRINT# wrote to the data file, a carriage return marked the end of each of
the five fields in each record. By keeping track of the number of carriage returns.
MAIL.GET#2 counts the number of fields
read
to know when
an
entire record
has
been
read,
This can only
be
done by programming a conditional statement
into
the
read
program where GET#is used instead of INPUT#.
line
140 conditionally
calls a subroutine if the specified condition
is
true,
269