Input/Output Statements
32
Input
statements are used to
read
data
into
the
program
and
output
statements
are
used to
print
or
punch
the
results of calculations.
Consider
the
following
mathematical
problem
and
assume
that
I,
J,
K,
L,
and
M
are
variable quantities
punched
into a file of
cards,
with
N
equal
to
48.
If
you
write
the
source statement
N = 48
the
processor sets aside
an
area
in
storage
(in
the
object
program)
called N,
and
sets
up
the
necessary instructions to place
the
quantity
48
in
that
area
at
object
time.
The
variables may
be
punched
into
the
cards as shown below .
:::,;..1.::
..:~;.
L:-:
;-'
--
;
~
"!
"'I
..
'
K
L
M
II
J
0000
0010
0000
0100
0000
000000000000000000000000000000000000000000000000000000000000
, ?
~
•
5618
9101112
1314151
17
18
19
~(j
~DaMn~"Mn~nnn~n~u~.~~Q~«~~o~~~nuu~~~u~~oo~~~~~~u~wm~nnM~."
••
~
1111
1111
1111 1111
1111
111111111111111111111111111111111111111111111111111111111111
2122
2221
2221
222
2 22 22
222222222222222222'-22222222222222222222222222222222222222222
3333
3
333
3333
3333
333
3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
J 3 3 3 33
J3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
HI4
4144
4444
444.
4444
4 4 4 4 4
44
4 4 4 4 4 4 4 4 4 44 4 4 4 4 4
~
~
4 4 4 4 4 4 4 4
44
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
:
:55
5555
5555 5555
5555
55555555"~5555555~555555555555555555555555555555555555555555
6G66
6666
6666
6666 6666
6666666666666666666666~G5666E6666666666666666666666666666666
*
~
7777
7777 7777
7777
7771
777777777777777777777177777777777777777777777777777
777777777
8888
8 8 8 8
8888
8888 8888
J 8 8 & 8
88
B 8
888
8 8 8 8 8 a 8 8 8 6 E 8 8 8 8 8
888
8 8
888
B 8
888
8 8 8 8
888
8 8 8
888
8 8 8 8 8 8
99 9 9
9999
9999
9999 9999
99:l~9999999999999999999S9S99999999SS9999999999999q9999999999
1234
5 S 1 e
9101112
!3
1~ ,~
:6
"
I~
, j
20
11
22
2J
2'
~5
:r.
v
Z6
J9
3\.
',:
;'
33
14
35 3b 31
J8
39
40
41
41
4J
44
45 46
41
48
'9
so
51 52
5J
54
5S
56
5:
sa
59
60
61
62
GJ
&4
65 66 67
68
69
0
/l
;~
IJ
14
15
16 11
78
19
8il
Remember
that
the
data
cards
are
not
available while
the
source
program
is
being
compiled. Therefore,
in
this example,
an
input
statement
would
be
included
in
the
source
program
to tell
the
processor
that
the
object
program
will
read
the
input
data
from cards
(that
there
will
be
five
data
fields in
the
sequence of
K,
L,
M,
I,
and
J).
The
input
statement
also contains
the
statement
number
of
another
type
of statement called
FORMAT.
In
this example,
the
FORMAT
statement, referenced
by
the
input
statement, tells
the
processor
that
each
field
named
in
the
list is four col-
umns long
and
that
the
quantities
are
in
fixed
point
mode. Thus, as
the
object
program is executed, each
data
card
is
read
by
the
program
and
the
quantity
fields
are
placed
into
the
storage locations
named
K,
L,
M,
I,
and
J.
When
processing is
completed for
the
set of values
in
one card,
the
values for
the
next
card
are
read
into
the
same storage locations
and
processing for
the
new
set of values is per-
formed.
Thus,
an
input
or
output
statement,
each
with
its corresponding
FORMAT
state-
ment
specifies
the
number
and
sequence of
the
data
input
or
output
fields,
the
length of
the
data
fields,
and
whether
they
are
in
fixed or floating
point
mode.
NOTE:
FORMAT
statements
are
described
in
a
later
section entitled
SPECIFICATION
STATEMENTS.