EasyManua.ls Logo

Commodore Plus 4 - Page 339

Commodore Plus 4
464 pages
Print Icon
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...
The
Disk
Drive
327
Example:
10
0PEin,8,2,"DATAFILE,S,W"
20
IFDSO0THENPRIlTTDS$:CL0SEl:E]SrD
30
F0RI=lT010
40
PRINT''WHAT
ARE'T'TH
VALUES
OF
X
AM)
Y'^:IIIPUTX,Y
50
PRIlTT#l,X;//,//;Y
60
IFDS=OTHENNEXT:ELSEPRIHTDS$:CLOSEl:E]SrD
70
CL0SE1
80
0PEEU,8,2,"DATAFILE"
90
1=1
100
INPUT#1,X,Y
110
PRINT
I"TH
VALUES
ARE",X,Y
120
IFST=OTHENT=I+1:GOTO1OO
130
CL0SE1
Line-by-Line
Explanation
10
Open
a
sequential
file
called
DATAFILE
on
device
8
using
channel
2
for
writing.
20
Check
for
an
error.
If
one
is
found,
print
message
and
stop.
30
I
runs
from
1
to
10.
40
Accept
input
from
the
keyboard
for
the
values
of
X
and
Y.
50
Output
the
values
of
X
and
Y
to
the
data
file
separated
by
a
comma.
A
carriage
return
is
automatically
sent
because
no
semicolon
is
found
at
the
end
of
the
statement.
60
Check
for
an
error.
If
there
is
no
error,
get
next
I.
If
there
is
an
error,
print
message
and
stop.
70 Close
the
data
file
just
created.
80
Now,
open
DATAFILE
for
reading.
Since
the
type
and
mode
are
omit
ted,
they
are
assumed
to
be
sequential
and
read.
90
I
counts
the
records
read.
100
Read
a
set
of
X
and
Y.
110
Print
the
values
read.
120
Check
for
end-of-file.
If
not
found,
add
one
to
I
and
read
next
record.
130
Close
the
file.