|
Alfred Wong's Programming Showcase
|
|
|
Source
*Print labels separated by 3 lines in the following format.
*Name
*Address
*City State Zip
identification division.
program-id. Assignment.
author. Alfred Wong.
environment division.
input-output section.
file-control.
select input-file assign "address.txt"
organization is line sequential.
select print-rec assign "label.prn"
organization is line sequential.
data division.
file section.
fd input-file record contains 59 characters.
01 input-rec.
05 i-zip-code pic x(5).
05 i-state pic xx.
05 i-city pic x(13).
05 i-address pic x(17).
05 i-name pic x(22).
fd print-rec.
01 label-rec.
05 o-name pic x(22).
05 o-line2 redefines o-name.
10 o-address pic x(17).
10 o-space1 pic x(5).
05 o-line3 redefines o-name.
10 o-city pic x(13).
10 o-space2 pic x.
10 o-state pic x(2).
10 o-space3 pic x.
10 o-zip-code pic x(5).
working-storage section.
01 eof-sw pic x(3) value "no".
procedure division.
open input input-file, output print-rec.
read input-file, at end move "yes" to eof-sw.
perform main-processing thru main-processing-exit
until eof-sw = "yes".
close input-file print-rec.
stop run.
main-processing.
move i-name to o-name.
write label-rec before advancing 1 line.
move i-address to o-address.
move spaces to o-space1.
write label-rec before advancing 1 line.
*Print 3 blank lines between each label.
move i-city to o-city.
move space to o-space2.
move i-state to o-state.
move space to o-space3.
move i-zip-code to o-zip-code.
write label-rec before advancing 4 lines.
read input-file at end move "yes" to eof-sw.
main-processing-exit.
Output
Mr. P. S. College
197th & Halsted
Chicago Hts. IL 60411
Mike Kreevich
35th & Shields
Chicago IL 60616
Cornelius McGillicuddy
Connie Mack Stad.
Philadelphia PA 00000
John Doe
1234 Anywhere
Your City ZZ 99999
C. L. Hartnett
1060 W. Addison
Chicago IL 60613
Arecibo Ionospheric
Observatory
Arecibo PR 00612