Debian Codegraph @

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

raw
1 *> { dg-do run }
2 *> { dg-output-file "group2/INSPECT_ISO_Example_3.out" }
3
4 Identification Division.
5 Program-Id. Clouseau.
6 Data Division.
7 Working-Storage Section.
8 01 inputs.
9 05 row occurs 10 times indexed by counter.
10 10 star PIC X.
11 10 input PIC X(20).
12 10 count PIC 99 occurs 3 times.
13 10 output PIC X(20).
14 77 len PIC 9(8).
15
16 Procedure Division.
17 Move ' BBEABDABABBCABE 030002BBEXYZXYXYZCABV' to row(1).
18 Move ' ADDDDC 000004AZZZZC' to row(3).
19 Move ' ADDDDA 000005AZZZZZ' to row(5).
20 Move ' CDDDDC 000000CDDDDC' to row(7).
21 Move ' BDBBBDB 000300BDWWWDB' to row(9).
22
23 Display ' INPUT C0 C1 C2 OUTPUT'
24 Display ' -------------------- -- -- -- --------------------'
25 Perform Example-3 with test after
26 varying counter from 1 by 2 until counter = 9.
27
28 Goback.
29
30 Inspection Section.
31 Example-3.
32 Move row(counter) to row(counter + 1)
33 Move input(counter) to output(counter)
34 Move Zero to count(counter 1)
35 Move Zero to count(counter 2)
36 Move Zero to count(counter 3)
37
38 Move function length( function trim(input(counter)) ) to len.
39 INSPECT OUTPUT(COUNTER)(1:len) TALLYING
40 COUNT(counter 1) FOR ALL "AB" BEFORE "BC"
41 COUNT(counter 2) FOR LEADING "B" AFTER "D"
42 COUNT(counter 3) FOR CHARACTERS AFTER "A" BEFORE "C";
43 INSPECT OUTPUT(COUNTER)(1:len) REPLACING
44 ALL "AB" BY "XY" BEFORE "BC"
45 LEADING "B" BY "W" AFTER "D"
46 FIRST "E" BY "V" AFTER "D"
47 CHARACTERS BY "Z" AFTER "A" BEFORE "C"
48
49 If row(counter) = row(counter + 1) then
50 Move '*' to star(counter + 1)
51 Else
52 Move '!' to star(counter + 1).
53
54 Display star(counter) ' '
55 input(counter) ' '
56 count(counter 1) ' '
57 count(counter 2) ' '
58 count(counter 3) ' '
59 function trim(output(counter))
60 Display star(1 + counter) ' '
61 input(1 + counter) ' '
62 count(1 + counter 1) ' '
63 count(1 + counter 2) ' '
64 count(1 + counter 3) ' '
65 function trim(output(1 + counter))
66 continue.
67 end program Clouseau.
68