Back when I was in college I had to take two of the offered programming languages to complete my degree. Given the options, I decided to make one of them COBOL. COBOL is a high-level programming language, which means that the code that the programmer puts into the computer looks a whole lot like words and sentences rather than symbols and abbreviations that might be difficult to understand. The goal being that the programs should be easy to read, easy to write, and easy to fix.
COBOL was developed all the way back in 1960 in part by a lady named Grace Hopper who, if she were alive today, would be celebrating her 100th birthday.
In honor of her centennial, I’ve decided to pull out some of my old programming homework to share with the world. This code came from an actual program that I wrote. Since I’m fairly certain that the teacher that gave me this assignment still uses this same problem/assignment, I probably shouldn’t post the whole thing. Plagiarism, you know.
B100-PROCESS-EMPLOYEE-RECORDS *************************************************************** * THE FUNCTION OF THIS MODULE IS TO PERFORM THE NECESSARY * * CALCULATIONS FOR THE REPORT, CONTROL PRINTING OF REPORT * * DETAIL LINES, AND READ THE NEXT RECORD * *************************************************************** ADD 1 TO NO-RECORDS-READ-WRK. IF EMF-EMPLOYEE-PAY-TYPE-03 IS EQUAL TO "N" THEN ADD 1 TO NO-HOURLY-EMPS-PRINTED-WRK ELSE IF EMF-EMPLOYEE-PAY-TYPE IS EQUAL TO "S" THEN ADD 1 TO NO-SALARIED-EMPS-PRINTED-WRK. MOVE "DETAIL-1" TO DETAIL-LINE-REPORT-INDICATOR. PERFORM U100-PRINT-DETAIL-LINES. MOVE "EMP" TO DISK-INPUT-CONTROL-INDICATOR. PERFORM U300-INPUT-DISK-RECORDS. /
Yep, that code up there has some flaws, but it gets the job done. Briefly:
ADD 1 TO NO-RECORDS-READ-WRK.
Increments a counter.
IF EMF-EMPLOYEE-PAY-TYPE-03 IS EQUAL TO "N" THEN ADD 1 TO NO-HOURLY-EMPS-PRINTED-WRK ELSE IF EMF-EMPLOYEE-PAY-TYPE IS EQUAL TO "S" THEN ADD 1 TO NO-SALARIED-EMPS-PRINTED-WRK.
Looks at the record currently in memory. Increments one of two counters based on the value of EMF-EMPLOYEE-PAY-TYPE-03. Why “N” is used for hourly employees and “S” for salaried, I’ll never know. I also forgot to put in what happens if something other than “N” or “S” is in there. Whoops.
MOVE "DETAIL-1" TO DETAIL-LINE-REPORT-INDICATOR. PERFORM U100-PRINT-DETAIL-LINES.
Makes U100-PRINT-DETAIL-LINES print one detail line.
MOVE "EMP" TO DISK-INPUT-CONTROL-INDICATOR. PERFORM U300-INPUT-DISK-RECORDS.
Reads the next employee’s record from the file.
/
Stops the module.
Aaah, you can just smell the geekery!