You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: COBOL Programming Course #2 - Learning COBOL/COBOL Programming Course #2 - Learning COBOL.md
+26-24Lines changed: 26 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1091,7 +1091,7 @@ There are many ways we can load a table. The first one involves loading the tabl
1091
1091
To load a table dynamically, we need to use the PERFORM statement with either subscripting or indexing. When doing this, we need to make sure that the data does not exceed the space allocated for the table. We will discuss file handling and the use of PERFORM clause in a later chapter. For example,
1092
1092
1093
1093
```COBOL
1094
-
PROCEDURE DIVISION
1094
+
PROCEDURE DIVISION.
1095
1095
...
1096
1096
PERFORM READ-FILE.
1097
1097
PERFORM VARYING SUB FROM 1 BY 1 UNTIL END-OF-FILE
@@ -1177,7 +1177,7 @@ We must ensure that the ODO object correctly specifies the number of occurrences
1177
1177
The following example shows how we can use an OCCURS DEPENDING ON clause:
1178
1178
1179
1179
```COBOL
1180
-
WORKING-STORAGE SECTION
1180
+
WORKING-STORAGE SECTION.
1181
1181
01 MAIN-AREA.
1182
1182
03 REC-1.
1183
1183
05 FIELD-1 PIC 9.
@@ -1763,8 +1763,8 @@ The code we have built so far is still not optimal, the repetition of the perfor
1763
1763
MOVE 'THE NUMBER IS: ' TO MSG-HEADER OF PRINT-REC.
1764
1764
1765
1765
PERFORM VARYING COUNTER FROM 01 BY 1 UNTIL COUNTER EQUAL 11
1766
-
MOVE COUNTER TO MSG-TO-WRITE
1767
-
WRITE PRINT-REC
1766
+
MOVE COUNTER TO MSG-TO-WRITE
1767
+
WRITE PRINT-REC
1768
1768
END-PERFORM.
1769
1769
1770
1770
CLOSE PRINT-LINE.
@@ -1899,8 +1899,8 @@ There is no requirement about the order that paragraphs should appear within a C
1899
1899
2000-READ-NEXT-RECORD.
1900
1900
PERFORM 4000-READ-RECORD
1901
1901
PERFORM UNTIL LASTREC = 'Y'
1902
-
PERFORM 5000-WRITE-RECORD
1903
-
PERFORM 4000-READ-RECORD
1902
+
PERFORM 5000-WRITE-RECORD
1903
+
PERFORM 4000-READ-RECORD
1904
1904
END-PERFORM.
1905
1905
*
1906
1906
3000-CLOSE-STOP.
@@ -1910,7 +1910,7 @@ There is no requirement about the order that paragraphs should appear within a C
1910
1910
*
1911
1911
4000-READ-RECORD.
1912
1912
READ ACCT-REC
1913
-
AT END MOVE 'Y' TO LASTREC
1913
+
AT END MOVE 'Y' TO LASTREC
1914
1914
END-READ.
1915
1915
*
1916
1916
5000-WRITE-RECORD.
@@ -1935,8 +1935,8 @@ There is no requirement about the order that paragraphs should appear within a C
1935
1935
2000-READ-NEXT-RECORD.
1936
1936
PERFORM 4000-READ-RECORD
1937
1937
PERFORM UNTIL LASTREC = 'Y'
1938
-
PERFORM 5000-WRITE-RECORD
1939
-
PERFORM 4000-READ-RECORD
1938
+
PERFORM 5000-WRITE-RECORD
1939
+
PERFORM 4000-READ-RECORD
1940
1940
END-PERFORM.
1941
1941
2000-READ-NEXT-RECORD-END.
1942
1942
```
@@ -1953,8 +1953,8 @@ Perhaps the simplest way of repeating a perform statement is to use the TIMES ke
1953
1953
1954
1954
```COBOL
1955
1955
PERFORM 10 TIMES
1956
-
MOVE FIELD-A TO FIELD-B
1957
-
WRITE RECORD
1956
+
MOVE FIELD-A TO FIELD-B
1957
+
WRITE RECORD
1958
1958
END-PERFORM.
1959
1959
```
1960
1960
*Example 10. TIMES*
@@ -2000,9 +2000,9 @@ Adding the UNTIL keyword to a perform sentence allows you to iterate over a grou
2000
2000
```COBOL
2001
2001
MOVE 0 TO COUNTER.
2002
2002
PERFORM UNTIL COUNTER = 10
2003
-
ADD 1 TO COUNTER GIVING COUNTER
2004
-
MOVE COUNTER TO MSG-TO-WRITE
2005
-
WRITE PRINT-REC
2003
+
ADD 1 TO COUNTER GIVING COUNTER
2004
+
MOVE COUNTER TO MSG-TO-WRITE
2005
+
WRITE PRINT-REC
2006
2006
END-PERFORM.
2007
2007
```
2008
2008
*Example 13. PERFORM UNTIL*
@@ -2024,9 +2024,9 @@ In this case, the Boolean condition is evaluated before the loop is executed. H
2024
2024
2025
2025
```COBOL
2026
2026
PERFORM WITH TEST AFTER UNTIL COUNTER = 10
2027
-
ADD 1 TO COUNTER GIVING COUNTER
2028
-
MOVE COUNTER TO MSG-TO-WRITE
2029
-
WRITE PRINT-REC
2027
+
ADD 1 TO COUNTER GIVING COUNTER
2028
+
MOVE COUNTER TO MSG-TO-WRITE
2029
+
WRITE PRINT-REC
2030
2030
END-PERFORM.
2031
2031
```
2032
2032
*Example 15. PERFORM WITH TEST AFTER UNTIL*
@@ -2490,7 +2490,7 @@ Observe in Example 1. 'The State is not Texas' is written as a result of the fi
2490
2490
2491
2491
2492
2492
```COBOL
2493
-
WORKING-STORAGE.
2493
+
WORKING-STORAGE SECTION.
2494
2494
01 USA-STATE PIC X(2) VALUE SPACES.
2495
2495
88 STATE VALUE 'TX'.
2496
2496
....
@@ -2521,7 +2521,7 @@ Other level number data-names require the condition expression to include a Bool
2521
2521
2522
2522
2523
2523
```COBOL
2524
-
WORKING-STORAGE.
2524
+
WORKING-STORAGE SECTION.
2525
2525
01 USA-STATE.
2526
2526
05 STATE PIC X(2) VALUE SPACES.
2527
2527
....
@@ -2610,7 +2610,7 @@ A PERFORM with UNTIL phrase is a conditional expression. In the UNTIL phrase fo
2610
2610
2611
2611
2612
2612
```COBOL
2613
-
WORKING-STORAGE.
2613
+
WORKING-STORAGE SECTION.
2614
2614
01 FACIAL-EXP PIC X(11) VALUE SPACES.
2615
2615
88 HAPPY VALUE 'HAPPY'.
2616
2616
....
@@ -2628,7 +2628,7 @@ END-PERFORM.
2628
2628
It is also possible to use PERFORM statement without the use of an 88-level conditional name, observe Example 6.
2629
2629
2630
2630
```COBOL
2631
-
WORKING-STORAGE.
2631
+
WORKING-STORAGE SECTION.
2632
2632
01 FACIAL-EXP PIC X(11) VALUE SPACES.
2633
2633
....
2634
2634
....
@@ -2647,7 +2647,7 @@ END-PERFORM.
2647
2647
The SEARCH statement searches a table for an element that satisfies the specified condition and adjusts the associated index to indicate that element. Tables, effectively an array of values, are created with an OCCURS clause applied to WORK-STORAGE data names. A WHEN clause is utilized in SEARCH statements to verify if the element searched for satisfies the specified condition. Assuming FACIAL-EXP has many possible values, then SEARCH WHEN is an alternative conditional expression, observe Example 7.
2648
2648
2649
2649
```COBOL
2650
-
WORKING-STORAGE.
2650
+
WORKING-STORAGE SECTION.
2651
2651
01 FACIAL-EXP-TABLE REDEFINES FACIAL-EXP-LIST.
2652
2652
05 FACIAL-EXP PIC X(11) OCCURS n TIMES INDEXED BY INX-A.
2653
2653
88 HAPPY VALUE "HAPPY".
@@ -2657,7 +2657,7 @@ PROCEDURE DIVISION.
2657
2657
....
2658
2658
....
2659
2659
SEARCH FACIAL-EXP
2660
-
WHEN HAPPY(INX-A) DISPLAY 'I am glad you are happy'
2660
+
WHEN HAPPY(INX-A) DISPLAY 'I am glad you are happy'
2661
2661
END-SEARCH
2662
2662
```
2663
2663
*Example 7. SEARCH WHEN statement*
@@ -3294,7 +3294,9 @@ Example 6 shows a usage of the COBOL function UPPER-CASE where a string or alpha
3294
3294
```COBOL
3295
3295
MOVE FUNCTION UPPER-CASE("This is shouting!") TO SOME-FIELD
0 commit comments