Debian Codegraph @

gcc/testsuite/cobol.dg/group2/INSPECT_ISO_Example_2.cob

raw
1 *> { dg-do run }
2 *> { dg-output-file "group2/INSPECT_ISO_Example_2.out" }
3
4 Identification Division.
5 Program-Id. Clouseau.
6 Data Division.
7 Working-Storage Section.
8 01 rows pic 99 value 2.
9 01 counts pic 99 value 2.
10
11 01 rowlim pic 99.
12 01 ncount pic 99.
13
14 01 inputs.
15 05 row occurs 4 times indexed by counter.
16 10 star PIC X.
17 10 input PIC X(20).
18 10 count PIC 99 occurs 2 times.
19 10 output PIC X(20).
20 77 len PIC 9(8).
21 Procedure Division.
22 *> Odd-numbered rows are "read only" and contain the inputs and expected
23 *> outputs.
24 *> Even-numbered rows are modified by the INSPECT statements and contain
25 *> the observed outputs
26 Move ' BBB 0300ZZZ' to row(1).
27 Move ' ABA 0300ZZZ' to row(3).
28
29 compute rowlim = 2*rows - 1
30
31 Display ' INPUT C0 C1 OUTPUT'
32 Display ' -------------------- -- -- ----------------'
33 Perform Example-1 with test after
34 varying counter from 1 by 2 until counter >= rowlim.
35
36 Goback.
37
38 Inspection Section.
39 Example-1.
40 Move row(counter) to row(counter + 1)
41
42 perform varying ncount from 1 by 1 until ncount > counts
43 Move Zero to count(counter + 1 ncount)
44 end-perform
45
46 Move function length( function trim(input(counter)) ) to len.
47 MOVE INPUT(COUNTER) TO OUTPUT(COUNTER + 1)
48 INSPECT INPUT(COUNTER)(1:len) TALLYING
49 COUNT(counter + 1 1) FOR CHARACTERS
50 COUNT(counter + 1 2) FOR ALL "A";
51 INSPECT OUTPUT(COUNTER + 1)(1:len) REPLACING
52 CHARACTERS BY "Z"
53 ALL "A" BY "X"
54
55 If row(counter) = row(counter + 1) then
56 Move '*' to star(counter + 1)
57 Else
58 Move '!' to star(counter + 1).
59
60 Display star(counter) ' '
61 input(counter) ' ' with no advancing
62 perform varying ncount from 1 by 1 until ncount > counts
63 Display count(counter ncount) ' ' with no advancing
64 end-perform
65 display function trim(output(counter))
66
67 Display star(1 + counter) ' '
68 input(1 + counter) ' ' with no advancing
69 perform varying ncount from 1 by 1 until ncount > counts
70 Display count(1 + counter ncount) ' ' with no advancing
71 end-perform
72 display function trim(output(1 + counter))
73 continue.
74 end program Clouseau.
75