Commodore PET User Manual page 271

Table of Contents

Advertisement

The INPUT# command at line 60 reads one number at a time. The PET
knows where the numbers are separated because carriage returns were
written between each number input to the tape. The FOR. .. NEXT loop (or a
similar command su ch as GOTO) is necessary because a single INPUT# com-
mand stops reading when a carriage return is encountered. Without a loop or
GOTO command to return to the INPUT# statement. only one number wou Id be
read. The PET reads both the number and the carriage return and sends them to
memory so that the carriage return will be printed on the screen.
After the data is read. the file must be closed before ending the program.
90 PRINT" •• CLOSING DATA FILE •• ":CLOSE1
100 Et"D
Program
Tape
Screen
PRINT N
<CR>
2
<CR>
3
<CR>
4
<CR>
5
<CR>
6
<CR>
7
<CR>
8
<CR>
9
<CR>
10
<CR>
A complete listing of NUM.PRINT# is printed below. followed by a sample
run of the program. The only file manipulation commands in this program are at
lines 40, 60, and 90: OPEN, INPUT# , and CLOSE.
NUM.INPUT#
10 PR 1 NT":'Jto. READ NUt-1ER 1 C DATA FILE •• ": F'F.: 1NT
2€1 PRUlT" •• t'10UNT TAPE.; F'RESS <RETURN>
~.JHEN
REAIi'r"': F'RINT
3€1 GET A$: IF A$="" THEN 313
413 F'RINT" •• OF'ENING IIATA FILE •• ":OPEN
1,1.-13,"NUt1BERS":F'F~It-n
50 FOR 1=1 TO 10
613 INF'UT#
LN
71::1 PRIt-JT N
813 NE>::T 1
913 F'RHlT" •• CLOSING IiATA FILE •• ": CLOSEl
11313 ENIi
258

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cbm

Table of Contents