Tandy TRS-80 Owner Manual & Programming Manual page 36

Color computer disk system
Hide thumbs Also See for TRS-80:
Table of Contents

Advertisement

ONE
THING
AT A TIME
By
adding
line
105
to
the
program,
the
Computer
checks
to
see
if
you've
reached
the
End
before
inputting
the next check.
If
you
have,
line
130
clo-
ses
communication
to
the
file.
DETAILS...
So
far,
"CHECKS/DAT"
has been easy
to
handle,
but not very
useful.
You would
probably
like to
add
more
details:
CHECKS
PAYABLE
TO
AMOUNT
EXPENSE
DR.
HORN
45.78
MEDICAL
SAFEWAY
22.50
FOOD
FIRST
CHRISTIAN
20.00
CONTRIB.
OFFICE
SUPPLY
13.67
BUSINESS
Change
lines
25
and
115,
and add some
lines
by
typing:
25
WRITE
ttl
t
^5.
78
27
WRITE
#1
t
"MEDICAL"
110
INPUT
#1
t
ft$i
Ct
115
PRINT At
t
B
>
Ct
LIST
the
program. This
is
the
way
it
should
look
now:
#1
>
"CHECKS/DAT"
"DR.
HORN"
#1
.
"CHECKS/DAT
1
=
-1
THEN
130
10
OPEN
"0"
t
20
WRITE
*1
>
25
WRITE
«1
,
a5.
78
27
WRITE
«1
t
"MEDICAL"
30
CLOSE
«1
100
OPEN
"I"
»
105
IF
E0F(1)
110
INPUT
#1
,
A$i Bt C$
115
PRINT
A$
>
Bi
Ct
120
GOTO
105
130
CLOSE
*1
Now
RUN
it.
A GOOD
TIGHT
PROGRAM
What
if
you need
to
store
a
whole
list
of
checks?
Continue
to
plod
along with
this
program,
and
it'll
soon be unbearable.
Here,
we
have
a tight
program which
asks
you
to
INPUT
all
your
data, stores
it
on
disk,
and
reads
it
back
into
memory. Erase
memory
and
type:
5
CLS
10
OPEN
"O"
*
*1
i
"CHECKS/DAT"
20
INPUT "CHECK PAYABLE
TO
:"i
A$
30
IF
At
=
""
THEN
80
40
INPUT "AMOUNT
:
*"!
B
50
INPUT "EXPENSE
:"
i
C$
GO
WRITE
«li
At
t
B
t
C$
70
GOTO
20
80
CLOSE
*1
80 CLS
100
PRINT "YOUR CHECKS ARE STORED
ON DISK"
110
INPUT "PRESS <ENTER>
TO
READ THEM"!
At
120
OPEN
"I"
t
alt
"CHECKS/DAT"
130
IF
E0F(
1
)
=
-1
THEN
170
140
INPUT *li
At
i
Bt
Ct
150
PRINT a$;
b;
Ct
1G0
GOTO
130
170
CLOSE
»1
RUN
it.
Input
any
checks.
When
you
want
to quit,
simply
press
(ENTER
)
in
answer
to
the check pay-
able
to
:
prompt. For example:
(ENTER)
CHECK PAYABLE
TO
:?
GOODY BANK
(INTER)
AMOUNT
:$?
230.97
EXPENSE
CHECK
CAR
(ENTER)
PAYABLE
TO
:?
(ENTER)
YOUR CHECKS ARE STORED
ON
DISK
PRESS (ENTER)
TO
READ THEM?
(ENTER)
GOODY
BANK
230.87
CAR
PROGRAMMING
EXERCISE
#5.1
Write a
program
which
will
print
only those checks
which were
for
JAR
expenses.
The
answers
to
all
the
"Programming
Exercises"
are
in
Appendix
A.
CHAPTER CHECKPOINT
1.
What
is
a buffer
#1?
2.
Why
must you
OPEN
a disk Hie?
3.
Why
must you
CLOSE
it?
4.
What
is
the difference
between a
file
OPEN
for
input
and
output?
28

Advertisement

Table of Contents
loading

Table of Contents