Debian Codegraph @

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

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