Here are ten things I learned about COBOL. (1) Programs have four "division"s: IDENTIFICATION DIVISION. AUTHOR. WM MITCHELL. ENVIRONMENT DIVISION. SOURCE-COMPUTER. IBM-360. DATA DIVISION. ... PROCEDURE DIVISION. ... (2) Here's a description of the format of payroll records (probably punched cards) that might appear in the DATA DIVISION. FD PAYROLL-FILE. 01 PAYROLL-RECORD. 05 I-PAYROLL-NUMBER PIC X(5). 05 I-NAME PIC X(20). 05 I-HOURS-WORKED PIC 99V9 05 FILLER PIC XXX 05 I-PAYRATE PIC 99V999. 05 I-DEPENDENTS PIC 99. 05 FILLER PIC X(42). Each time a record is read from PAYROLL-FILE, the data from the various pieces of that record is read into the six variables (I-PAYROLL-NUMBER, etc.). "FILLER" fields are ignored; no data is moved. (3) Here's how to read a record from PAYROLL-FILE: READ PAYROLL-FILE AT END MOVE 'Y' TO W-OUT-OF-CARDS-FLAG. Note the assigment of 'Y' to W-OUT-OF-CARDS-FLAG when end-of-file is reached. (4) 'PIC X(5)', a shorthand for 'PICTURE XXXXX', specifies a five-character field with no constraints on the data. (5) 'PIC 99V9' specifies three digits of input with a decimal point ASSUMED between the second and third digits. Thus, '123' would be interpreted as 12.3. Similarly, the 'PIC 99V999' for I-PAYRATE means that '52812' would be interpreted as 52.812. (Remember that when COBOL was created, memory was many millions of times more expensive than today. A PIC like 99V9 vs. 99.9 reduces memory usage by 25%!) (6) Here's an example of a PROCEDURE DIVSION with two paragraphs, with line numbers added: 1 PROCEDURE DIVISION: 2 FINAL-TOTAL-PROCESSING. 3 PERFORM ACCOUNT-TOTAL-PROCESSING. 4 MOVE FINAL-TOTAL TO FINAL-TOTAL-OUT. 5 PERFORM LINE-OUT. 6 7 ACCOUNT-TOTAL-PROCESSING. 8 MOVE PREVIOUS-ACCOUNT-NUMBER TO ACCOUNT-NUMBER-OUT. 9 MOVE ACCOUNT-TOTAL TO ACCOUNT-TOTAL-OUT 10 PERFORM LINE-OUT 11 MOVE ACCOUNT-NUMBER TO PREVIOUS-ACCOUNT-NUMBER 12 MOVE ZERO TO ACCOUNT-TOTAL. The paragraphs are a bit like functions/procedures, but they have no parameters. Note that lines 3, 5, and 10 perform other paragraphs. At line 12, "MOVE ZERO ..." is used to zero ACCOUNT-TOTAL. The variables ACCOUNT-NUMBER-OUT, ACCOUNT-TOTAL-OUT, and FINAL-TOTAL-OUT are fields in an FD (file description) for an output file. (7) Here's code that executes the code in one of two "paragraphs" based on the value of HOURS-WORKED: IF I-HOURS-WORKED IS GREATER THAN 40 PERFORM OVERTIME-ROUTINE. ELSE PERFORM NORMAL-ROUTINE. Note that variable names can contain hyphens, and "IS GREATER THAN 40" is English. (8) Here's an example of opening two files: OPEN INPUT BALANCE-FORWARD-FILE. OPEN OUTPUT INVENTORY-LISTING. (9) Some examples of math: ADD X, Y, Z, GIVING SUM ADD 1 TO ITEM-COUNT ADD A, B TO C, D (adds A+B to both C and D) MULTIPLY 4 BY A (10) EXAMINE can count and/or replace occurrences of characters. If SAMPLE is '0016047', then EXAMINE SAMPLE TALLYING LEAD '0' REPLACING BY '*' will change SAMPLE to '**16047' and put 2 in the "register" TALLY. If SAMPLE is 'PT890NQ9' EXAMINE SAMPLE TALLYING UNTIL FIRST 'Q' would put 6 in TALLY. INSPECT is similiar to EXAMINE, but more powerful. Example: INSPECT SAMPLE TALLYING INDEX-4 FOR LEADING SPACES REPLACiNG ALL '.' BY ',', FIRST 'Q' BY 'P'. (11) PERFORM, MOVE, EXAMINE are "verbs", but IF ..., ADD ..., and MULTIPLY ... are considered to be "statements". (12) Here's an example of getting a quote into a variable MOVE 'THOMAS M. O' QUOTE 'REILLY' to FULL-NAME. Yes, that's twelve things, not ten--I got carried away! Maybe you'll get carried away, too! Sources: A Simplified Guide to Structured COBOL Programming by Daniel D. McCracken Standard COBOL, 2nd edition, Mike Murach