Skip to content

Commit 3e931b4

Browse files
committed
Fix grammatical issues and typos
Signed-off-by: Hartanto Ario Widjaya <[email protected]>
1 parent dda72f6 commit 3e931b4

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

COBOL Programming Course #1 - Getting Started/COBOL Programming Course #1 - Getting Started.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,7 +1903,7 @@ Notice that this line tells you to focus on the GROSS-PAY picture clause in orde
19031903

19041904
\newpage
19051905

1906-
# Tables handling
1906+
# Table handling
19071907

19081908
This section introduces the concept of tables, which are a collection of data items that have the same description. The subordinate items are called table elements. A table is the COBOL equivalent of arrays.
19091909

@@ -1920,7 +1920,7 @@ To code a table, we need to give the table a group name and define a subordinate
19201920
10 ELEMENT2 PIC 9(2).
19211921
```
19221922

1923-
In the example above, TABLE-NAME is the name of the group item. The table also contain a subordinate item called SUBORDINATE-NAME which we are repeating n times. Each of the SUBORDINATE-ITEM have 2 elementary items, ELEMENT1 and ELEMENT2. In this case, we called SUBORDINATE-NAME as the table element definition (since it includes the OCCURS clause). Note that the OCCURS clause cannot be used in a level-01 description.
1923+
In the example above, TABLE-NAME is the name of the group item. The table also contains a subordinate item called SUBORDINATE-NAME which we are repeating n times. Each SUBORDINATE-ITEM has 2 elementary items, ELEMENT1 and ELEMENT2. In this case, we called SUBORDINATE-NAME as the table element definition (since it includes the OCCURS clause). Note that the OCCURS clause cannot be used in a level-01 description.
19241924

19251925
Alternatively, we can also make simpler tables:
19261926

@@ -1929,9 +1929,9 @@ Alternatively, we can also make simpler tables:
19291929
05 SUBORDINATE OCCURS n TIMES PIC X(10).
19301930
```
19311931

1932-
In this case, TABLE-NAME contains n SUBORDINATE item, each can contain up to 10 alphanumeric characters.
1932+
In this case, TABLE-NAME contains n SUBORDINATE items, each can contain up to 10 alphanumeric characters.
19331933

1934-
We can also nest multiple OCCURS elements to create table of additional dimensions, up to a limit of seven dimensions. Note the example below:
1934+
We can also nest multiple OCCURS elements to create a table of additional dimensions, up to a limit of seven dimensions. Note the example below:
19351935

19361936
```
19371937
01 PROGRAM-DETAILS.
@@ -1944,11 +1944,11 @@ We can also nest multiple OCCURS elements to create table of additional dimensio
19441944
15 ASSIGMMENT-WEIGHTAGE PIC 9(03).
19451945
```
19461946

1947-
Here, we are defining a degree program which have 10 course and each course will have 8 assignments. What if we don't know beforehand how many times will a table element occurs? To solve that, we can use variable-length table, using the OCCURS DEPENDING ON (ODO) clause which we will be going into more details on a later section.
1947+
Here, we are defining a degree program which has 10 courses and each course will have 8 assignments. What if we don't know how many times will a table element will occur? To solve that, we can use variable-length table, using the OCCURS DEPENDING ON (ODO) clause which we will be going into more details on a later section.
19481948

19491949
## Referring to an item in a table
19501950

1951-
While a table element have a collective name, the individual items within does not have a unique name. To refer to an item, we can either use subscript, index, or a combination of both.
1951+
While a table element has a collective name, the individual items within do not have a unique name. To refer to an item, we can either use subscript, index, or a combination of both.
19521952

19531953
### Subscripting
19541954

@@ -1973,7 +1973,7 @@ Alternatively, we can create an index using the INDEXED BY phrase of the OCCURS
19731973

19741974
Here, INX-A is an index name. The compiler will calculate the value in the index as the occurence number minus 1 multiplied by the length of the table element. So, for example, for the second occurence of TABLE-ELEMENT, the binary value contained in INX-A is (2-1) * 3, or 3.
19751975

1976-
If you happen to have another table with the same number of table elements of the same length, you can use an index name as a reference for both table.
1976+
If you happen to have another table with the same number of table elements of the same length, you can use an index name as a reference for both tables.
19771977

19781978
We can also define an index data item using the USAGE IS INDEX clause. These index data items can be used with any table. For example,
19791979

@@ -2002,7 +2002,7 @@ Since we are comparing physical displacements, we cannot use index data items as
20022002

20032003
## Loading a table with data
20042004

2005-
There are many ways we can load a table. The first one involves loading the table dynamically, from a screen, file or databases. We can also use the REDEFINES clause on hard-coded field values along with an OCCURS clause. The third way is using the INITIALIZE statement, and lastly, we can also use the VALUE clause when defining the table.
2005+
There are many ways we can load a table. The first one involves loading the table dynamically, from a screen, file or database. We can also use the REDEFINES clause on hard-coded field values along with an OCCURS clause. The third way is using the INITIALIZE statement, and lastly, we can also use the VALUE clause when defining the table.
20062006

20072007
### Loading a table dynamically
20082008

@@ -2041,7 +2041,7 @@ Here, we are taking hard-coded values of spelled out numbers from 1 to 5 and loa
20412041

20422042
### INITIALIZE a table
20432043

2044-
We can also use the INITIALIZE statement to load data into a table. The table will be processed as a group item and each elementary data items within are recognized and processed. For example, assume that we have the following table:
2044+
We can also use the INITIALIZE statement to load data into a table. The table will be processed as a group item and each elementary data item within it will be recognized and processed. For example, assume that we have the following table:
20452045

20462046
```
20472047
01 TABLE-ONE.
@@ -2052,14 +2052,14 @@ We can also use the INITIALIZE statement to load data into a table. The table wi
20522052

20532053
Here we have a table that contains 10 elements, each with their own NUMBER-CODE (with a value of 10) and ITEM-ID (with a value of "R3").
20542054

2055-
We can move the value 3 to each of the elementary numeric data item and the value "X" into each of the elementary alphanumeric data items in the table:
2055+
We can move the value 3 to each of the elementary numeric data items and the value "X" into each of the elementary alphanumeric data items in the table:
20562056

20572057
```
20582058
INITIALIZE TABLE-ONE REPLACING NUMERIC DATA BY 3.
20592059
INITIALIZE TABLE-ONE REPLACING ALPHANUMERIC DATA BY "X".
20602060
```
20612061

2062-
After running the two INITIALIZE statement, NUMBER-CODE will contain the value of 3, while ITEM-ID will contain the value of "X ".
2062+
After running the two INITIALIZE statements, NUMBER-CODE will contain the value of 3, while ITEM-ID will contain the value of "X ".
20632063

20642064
### Assigning values using VALUE clause
20652065

@@ -2074,7 +2074,7 @@ In the above example, the alphanumeric group data item TABLE-TWO uses a VALUE cl
20742074

20752075
## Variable-length tables
20762076

2077-
If we do not know before runtime how many times will a table element occurs, we can define a variable-length table using the OCCURS DEPENDING ON (ODO) clause.
2077+
If we do not know before runtime how many times a table element will occur, we can define a variable-length table using the OCCURS DEPENDING ON (ODO) clause.
20782078

20792079
```
20802080
X OCCURS 1 TO 10 TIMES DEPENDING ON Y
@@ -2131,9 +2131,9 @@ A binary search can be more efficient than a serial search, however it requires
21312131

21322132
### Serial search
21332133

2134-
We can do a serial search by using the SEARCH statement. The search will begins at the current index setting and will continue until the condition in the WHEN phrase are fulfilled. To modify the index setting, we can use the SET statement If there are multiple condition in the WHEN phrase, the search will ends when the one of the conditions is satisfied and the index will remain pointing to the element that satisfied the condition.
2134+
We can do a serial search by using the SEARCH statement. The search will begin at the current index setting and will continue until the condition in the WHEN phrase is fulfilled. To modify the index setting, we can use the SET statement. If there are multiple conditions in the WHEN phrase, the search will end when the one of the conditions is satisfied and the index will remain pointing to the element that satisfied the condition.
21352135

2136-
For example, assume that we have a list of name:
2136+
For example, assume that we have a list of names:
21372137

21382138
```
21392139
77 PEOPLE-SEARCH-DATA PIC X(20).
@@ -2150,17 +2150,17 @@ PROCEDURE-DIVISION.
21502150
DISPLAY "Found".
21512151
```
21522152

2153-
The code above will search the list of name from an index of 1. If it found the content of PEOPLE-SEARCH-DATA, it will DISPLAY "Found", otherwise, it will DISPLAY "Not found".
2153+
The code above will search the list of names from an index of 1. If it found the content of PEOPLE-SEARCH-DATA, it will DISPLAY "Found", otherwise, it will DISPLAY "Not found".
21542154

2155-
For a more complex use case, we can also use nested SEARCH statement. We will need to delimit each nested SEARCH statement with END-SEARCH.
2155+
For a more complex use case, we can also use nested SEARCH statements. We will need to delimit each nested SEARCH statements with END-SEARCH.
21562156

21572157
### Binary search
21582158

21592159
To do a binary search, we can use a SEARCH ALL statement. We do not need to set the index, but it will use the one associated in the OCCURS clause. To use the SEARCH ALL statement, the table must specify the ASCENDING or DESCENDING KEY phrases of the OCCURS clause, or both, and it must be ordered on the specified key.
21602160

21612161
Using the WHEN phrase, you can test any key that is named in the ASCENDING or DESCENDING KEY phrases. The test must be an equal-to condition, and the WHEN phrase must specify either a key or a condition-name associated with the key.
21622162

2163-
For example, assume that we have a list of name sorted in an ascending order:
2163+
For example, assume that we have a list of names sorted in an ascending order:
21642164

21652165
```
21662166
77 PEOPLE-SEARCH-DATA PIC X(20).
@@ -2177,7 +2177,7 @@ PROCEDURE-DIVISION.
21772177
DISPLAY "Found".
21782178
```
21792179

2180-
The code above will search the alphabetically-sorted list of state name. If it found the content of PEOPLE-SEARCH-DATA, it will DISPLAY "Found", otherwise, it will DISPLAY "Not found".
2180+
The code above will search the alphabetically-sorted list of names. If it found the content of PEOPLE-SEARCH-DATA, it will DISPLAY "Found", otherwise, it will DISPLAY "Not found".
21812181

21822182
## Lab
21832183

0 commit comments

Comments
 (0)