Presentation is loading. Please wait.

Presentation is loading. Please wait.

Screen I/O ACCEPT DISPLAY Relevant to the Fujitsu Compiler.

Similar presentations


Presentation on theme: "Screen I/O ACCEPT DISPLAY Relevant to the Fujitsu Compiler."— Presentation transcript:

1 Screen I/O ACCEPT DISPLAY Relevant to the Fujitsu Compiler

2 Ch 11- Tables Introduction to tables OCCURS clause Processing a table
Not permitted at the 01 level Use parenthesis to get the actual data Processing a table Brute force Does not take advantage of the table structure PERFORM…VARYING Repeated execution of statements Initializes a variable and tests a condition repeatedly

3 Figure 11.1 The Table Concept
01 ANNUAL-SALES-DATA JAN-SALES PIC 9(6) FEB-SALES PIC 9(6) MAR-SALES PIC 9(6) APR-SALES PIC 9(6) MAY-SALES PIC 9(6) JUN-SALES PIC 9(6) JUL-SALES PIC 9(6) AUG-SALES PIC 9(6) SEP-SALES PIC 9(6) OCT-SALES PIC 9(6) NOV-SALES PIC 9(6) DEC-SALES PIC 9(6). (a) Brute Force 01 ANNUAL-SALES-DATA SALES OCCURS 12 TIMES PIC 9(6). (b) OCCURS Clause ANNUAL-SALES-DATA SALES (1) SALES (2) SALES (12) (c) Storage Schematic

4 Figure 11.2 PERFORM VARYING (with TEST BEFORE)
Initialize identifier-1 to FROM value Evaluate condition=1 Perform procedure-1 or imperative- statement Increment identifier-1 with BY value TRUE FALSE

5 Figure 11.3 Processing a Table
MOVE ZERO TO ANNUAL-TOTAL. PERFORM INCREMENT-ANNUAL-TOTAL VARYING SALES-SUB FROM 1 BY 1 UNTIL SALES-SUB > INCREMENT-ANNUAL-TOTAL. ADD SALES (SALES-SUB) TO ANNUAL-TOTAL. (a) Performing a Paragraph MOVE ZERO TO ANNUAL-TOTAL. PERFORM VARYING SALES-SUB FROM 1 BY 1 UNTIL SALES-SUB > 12 ADD SALES (SALES-SUB) TO ANNUAL-TOTAL END-PERFORM. (b) In-line Perform

6 Example Occurs clause At group level At elementary level Problems with
If using occurs clause then use parenthesis Compilation errors Execution errors Does not check if data exists in a subscript

7 Figure 11.4 OCCURS Clause at the Group Level
05 SALARY-DATA OCCURS 3 TIMES. 10 SALARY PIC 9(6)V SAL-DATE PIC 9(4). (a) COBOL Statements SALARY-DATA (1) SALARY (1) SAL-DATE (1) SALARY-DATA (2) SALARY (2) SAL-DATE (2) SALARY-DATA (3) SALARY (3) SAL-DATE (3) (b) Storage Schematic

8 Figure 11.5 OCCURS Clause at the Elementary Level
05 SALARY-DATA SALARY OCCURS 3 TIMES PIC 9(6)V SAL-DATE OCCURS 3 TIMES PIC 9(4). (a) COBOL Statements SALARY (2) SAL-DATE (2) SALARY-DATA SALARY (1) SAL-DATE (1) SAL-DATE (3) SALARY (3) (b) Storage Schematic

9 Figure 11.6 Relative Subscripting
CURRENT SALARY EFFECTIVE DATE PERCENT INCREASE $46, / % $40, / % $36, / % $32, /90 (a) Salary History PERFORM VARYING SUB FROM 1 BY 1 UNTIL SUB > 3 OR SALARY (SUB + 1) = COMPUTE PCT-SALARY-INC (SUB) = 100 * ((SALARY (SUB) - SALARY (SUB+1)) / SALARY (SUB + 1) END-COMPUTE END-PERFORM (b) Computation of Percent Salary Increase

10 Relative subscripts Using the subscript to refer to different fields.
OCCURS DEPENDING ON Saves room when reserving space in memory

11 Figure 11.7 Variable-length Records
FD STUDENT-TRANSCRIPT-FILE RECORD CONTAINS 42 TO 1131 CHARACTERS DATA RECORD IS STUDENT-RECORD. 01 STUDETN-RECORD ST-NAME PIC X(30) ST-MAJOR PIC X(10) ST-COURSES-COMPLETED PIC 99. 05 ST-COURSE-INFO OCCURS 0 TO 99 TIMES DEPENDING ON ST-COURSES-COMPLETED ST-COURSE-NUMBER PIC 9(6) ST-GRADE PIC X ST-COURSE-DATE PIC 9(4).

12 Student transcript program
Specifications Hierarchy chart Pseudocode Completed program

13 Indexes versus subscripts
Occurrence Initialization (MOVE) Incrementing (ADD) Arithmetic permitted in COBOL-85 Use in PERFORM statements

14 Indexes Displacement Initialization (SET) Incrementing (SET)
Arithmetic permitted Use in PERFORM statements

15 How many times will PARAGRAPH-A be executed?
PERFORM PARAGRAPH-A VARING SUBSCRIPT FROM 1 BY 1 UNTIL SUBSCRIPT > 5 WITH TEST BEFORE UNTIL SUBSCRIPT = 5

16 Are these valid entries of the occurs clause
TABLE-ENTRY OCCURS 4 TIMES. TABLE-ENTRY OCCURS 4. TABLE-ENTRY OCCUES 3 TO 30 TIMES DEPENDING ON NUMBER-OF-TRANS. TABLE-ENTRY OCCURS 5 TIMES SUBSCRIPTED BY TABLE-SUBSCRIPT.

17 How many storage positions are allocated for each of the following and show a schematic of storage assignment. 01 STATE-TABLE. 05 STATE-NAME OCCURS 50 TIMES PIC X(15). 05 STATE-POP OCCURS 50 TIMES PIC 9(8).

18 How many storage positions are allocated for each of the following and show a schematic of storage assignment. 01 STATE-TABLE. 05 NAME-POP OCCURS 50 TIMES. 10 STATE-NAME PIC X(15). 10 STATE-POP PIC 9(8).

19 Write the record statement that will define a table that contains:
1. Student-Name 2. Up to 20 Courses with the following: 3. Course-Number 4. Course-Grade 5. Course-Credits Using the occurs clause

20 Write the code to determine the largest and smallest population
Write the code to determine the largest and smallest population. Move the values to BIGGEST and SMALLEST and the names to BIG-STATE & SMALL-STATE. Assume a variable SUBSCRIPT exists. 01 POPULATION-TABLE. 05 POPULATION-AND-NAME OCCURS 50 TIMES. 10 POP PIC 9(8). 10 STATE PIC X(15).


Download ppt "Screen I/O ACCEPT DISPLAY Relevant to the Fujitsu Compiler."

Similar presentations


Ads by Google