Debian Codegraph @

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

raw
1 *> { dg-do run }
2 *> { dg-output-file "group2/INSPECT_ISO_Example_4.out" }
3
4 Identification Division.
5 Program-Id. Clouseau.
6 Data Division.
7 Working-Storage Section.
8 01 rows pic 99 value 1.
9 01 counts pic 99 value 1.
10
11 01 rowlim pic 99.
12 01 ncount pic 99.
13
14 01 inputs.
15 05 row occurs 2 times indexed by counter.
16 10 star PIC X.
17 10 input PIC X(20).
18 10 count PIC 99 occurs 1 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 ' ABABABABC 01ABABXYABC' to row(1).
27
28 compute rowlim = 2*rows - 1
29
30 Display ' INPUT C0 C1 OUTPUT'
31 Display ' -------------------- -- -- ----------------'
32 Perform Example-1 with test after
33 varying counter from 1 by 2 until counter >= rowlim.
34
35 Goback.
36
37 Inspection Section.
38 Example-1.
39 Move row(counter) to row(counter + 1)
40
41 perform varying ncount from 1 by 1 until ncount > counts
42 Move Zero to count(counter + 1 ncount)
43 end-perform
44
45 Move function length( function trim(input(counter)) ) to len.
46 MOVE INPUT(COUNTER) TO OUTPUT(COUNTER + 1)
47 INSPECT INPUT(COUNTER)(1:len) TALLYING
48 COUNT(counter + 1 1) FOR ALL "AB" AFTER "BA" BEFORE "BC";
49 INSPECT OUTPUT(COUNTER + 1)(1:len) REPLACING
50 ALL "AB" BY "XY" AFTER "BA" BEFORE "BC"
51 If row(counter) = row(counter + 1) then
52 Move '*' to star(counter + 1)
53 Else
54 Move '!' to star(counter + 1).
55
56 Display star(counter) ' '
57 input(counter) ' ' with no advancing
58 perform varying ncount from 1 by 1 until ncount > counts
59 Display count(counter ncount) ' ' with no advancing
60 end-perform
61 display function trim(output(counter))
62
63 Display star(1 + counter) ' '
64 input(1 + counter) ' ' with no advancing
65 perform varying ncount from 1 by 1 until ncount > counts
66 Display count(1 + counter ncount) ' ' with no advancing
67 end-perform
68 display function trim(output(1 + counter))
69 continue.
70 end program Clouseau.
71