I'm writing my first COBOL program in decades. It's not supposed to do anything
important, but it's not a toy. I need a program that chews up CPU in order to
try out ABO (Automatic Binary Optimizer). I started with a REXX and am now
rewriting in COBOL 4.2. It's not doing what I want, which is to read a
sequential file, do some arithmetic, then write out records to a couple of
other sequential files. Very simple, but I'm missing something. When the input
file is empty-no records-the program does 1,100 reads! When the input file has
one record, it does 2,200 reads!! It's not a real loop because the program ends
normally after all the commotion. What's wrong? The REXX is structured almost
identically, and it works fine.
PROCEDURE DIVISION USING iterate .
IF ADDRESS OF iterate = NULL THEN MOVE 1 TO iterate; END-IF
DISPLAY "Iterate" iterate "times" UPON CONSOLE
OPEN OUTPUT testoute
OPEN OUTPUT testouto
PERFORM iterate TIMES
OPEN INPUT testin
MOVE "N" TO testin-eof
PERFORM UNTIL testin-eof = "Y"
display "Reading record" UPON CONSOLE
READ testin INTO in-rec
AT END MOVE "Y" TO testin-eof < < < EOF is not getting set as it
should
END-READ
IF testin-eof = "N" THEN
MOVE 0 TO dig-sum
PERFORM VARYING i1 FROM 1 BY 1 UNTIL i1 = 80
ADD in-digit(i1) TO dig-sum
MOVE dig-sum TO rec-sum
MOVE SPACES TO out-filler
DIVIDE dig-sum BY 2 GIVING quo REMAINDER rem
IF rem = 0 THEN
WRITE outpute-rec FROM out-rec
ELSE
WRITE outputo-rec FROM out-rec
END-IF
END-PERFORM
END-IF
END-PERFORM
CLOSE testin
END-PERFORM
CLOSE testoute
CLOSE testouto
STOP RUN .
END PROGRAM ABOTEST .
.
.
.
J.O.Skip Robinson
Southern California Edison Company
Electric Dragon Team Paddler
SHARE MVS Program Co-Manager
323-715-0595 Mobile
626-302-7535 Office
[email protected]<mailto:[email protected]>
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN