Debian Codegraph @

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

raw
1 *> { dg-do run }
2 *> { dg-output-file "group2/INSPECT_ISO_Example_6.out" }
3
4 Identification Division.
5 Program-Id. Clouseau.
6 Data Division.
7 Working-Storage Section.
8 01 rows pic 99 value 1.
9
10 01 rowlim pic 99.
11 01 ncount pic 99.
12
13 01 inputs.
14 05 row occurs 6 times indexed by counter.
15 10 star PIC X.
16 10 input PIC X(20).
17 10 output PIC X(20).
18 77 len PIC 9(8).
19 Procedure Division.
20 *> Odd-numbered rows are "read only" and contain the inputs and expected
21 *> outputs.
22 *> Even-numbered rows are modified by the INSPECT statements and contain
23 *> the observed outputs
24 Move ' AC"AEBDFBCD#AB"D AC"XEYXFYZX#AB"D' to row(1).
25
26 compute rowlim = 2*rows - 1
27
28 Display ' INPUT OUTPUT'
29 Display ' -------------------- ----------------'
30 Perform Example-1 with test after
31 varying counter from 1 by 2 until counter >= rowlim.
32
33 Goback.
34
35 Inspection Section.
36 Example-1.
37 Move row(counter) to row(counter + 1)
38
39 Move function length( function trim(input(counter)) ) to len.
40 MOVE INPUT(COUNTER) TO OUTPUT(COUNTER + 1)
41 INSPECT OUTPUT(COUNTER + 1)(1:len) CONVERTING
42 "ABCD" TO "XYZX" AFTER QUOTE BEFORE "#".
43
44 If row(counter) = row(counter + 1) then
45 Move '*' to star(counter + 1)
46 Else
47 Move '!' to star(counter + 1).
48
49 Display star(counter) ' '
50 input(counter) ' ' with no advancing
51 display function trim(output(counter))
52
53 Display star(1 + counter) ' '
54 input(1 + counter) ' ' with no advancing
55 display function trim(output(1 + counter))
56 continue.
57 end program Clouseau.
58