COBOL in array operation

xiaoxiao2021-03-06  13

The following is an example of an array: 01 Record-x. 03 Month Occurs 12 Times. 05 name pic x (12). 07 Comment Pic X (20). 07 Temp-Hi Pic S999. 07 Temp-LO Pic S999. 77 CURRENT-DAY PIC 99. Call representation is as follows: Month (5): Group items containing Name and Days tables. Name of Month (5): Basic alphanumeric item, length 12 characters long. Name (5) (1: 3) The first 3 characters of the 5th item described above. Temp-Hi (1,31) Basic digital items, length of 3 characters. The previous parameter is the location in the Month array, and the latter parameter is in the location of the DAYS array. Equivalent to Month [1] .days [31] .TEMP-HI. Comment of Record-x (5, Current-Day) (11) The last 10 characters of the CURRENT-DAY of the basic alphanumeric item for the fifth month.

03 TEXT PIC XXX OCCURS 1 to 12 Times Depending on ix. Defines a growing array. The defined length is 12, actually in IX, if IX is 10, the length of the text is 30.

Index Index Name Index index names can be used as variables for Perform statements, used for SET and SEARCH statements and used as subscripts. 03 TEXT PIC XXX OCCURS 7 Times Indexed by Index 05 A PIC XXX 05 B PIC XXX Perform Varying Index from 1 by 1 Until Index> 7 Display A (Index), B (INDEX) end-perform. Note and no index name comparison : 77 INDEX PIC 99 03 TEXT PIC XXX OCCURS 7 TIMES 05 A PIC XXX 05 B PIC XXX Perform Varying Index from 1 by 1 Until INDEX> 7 Display A (Index), B (INDEX) end-perform.

Keyword Key keyword has ascending (ascending, from low to high) and descending (descending, from high to low). 03 TEXT PIC XXX OCCURS 7 TIMES Ascending Key IS A, B. 05 A PIC XXX. 05 B PIC XXX. The elements in the text are sorted by A ascending order, and the same elements are sorted in B ascending. The function of the keyword is to define the sort of the SEARCH statement with all the phrases.

Table initialization can be initialized separately by one data item or initialized together. 03 TEXT PIC XXX OCCURS 7 TIMES VALUES SPACCURS 7 TIMES VALUES SPACE. 05 A PIC XXX. Together to the space together. 03 TEXT PIC XXX OCCURS 7 TIMES. 05 A Pic XXX VALUES SPACE. 05 B PIC XXX VALUES SPACE. Separate initialization. Set Save or restore the index value. Set a to B. Increment the index or decreases an integer value. Set a up / down by n.

Search Search A [Varying B] at End C {When Condition D} ... End-Search A is a table with indexed by phrase. Each step is turned in the value of the Condition, performs D, and the Search statement is terminated for true. In order to fake, the index value is incremented, and at the maximum index is executed, the At end c, the Search statement terminates. If the index value is the largest, the WHEN statement is not executed, and the AT End statement is executed directly. Varying Specifies index B, omitting the index set in A. The following example looks for the next month of the month with the next month. 01 MONTH-DATA. 03 MONTH-INFO. 05 PIC X (10) Values ​​"January". 05 Pic X (3) VALUES "JAN". 05 PIC 99 VALUES 31. 05 Pic X (10) Values ​​"february". 05 Pic X (3) VALUES "Feb". 05 PIC 99 VALUES 28. ... (省略) 03 Month Redefines Month-Info Occurs 12 Times Indexed by Month-Index. 05 Name Pic X (10). 05 Abbrev Pic X (3). 05 Days Pic 99. 77 Current-Month Pic 99. 77 Next-31-Day-Month PIC 99.

转载请注明原文地址:https://www.9cbs.com/read-49558.html

New Post(0)