Source

pygments-main / tests / examplefiles / example.cob

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
       IDENTIFICATION DIVISION.
       PROGRAM-ID. OCic.
      *****************************************************************
      ** This program provides a Textual User Interface (TUI) to the **
      ** process of compiling and (optionally) executing an OpenCOBOL**
      ** program.                                                    **
      **                                                             **
      ** This programs execution syntax is as follows:               **
      **                                                             **
      ** ocic <program-path-and-filename> [ <switch>... ]            **
      **                                                             **
      ** Once executed, a display screen will be presented showing   **
      ** the compilation options that will be used.  The user will   **
      ** have the opportunity to change options, specify new ones    **
      ** and specify any program execution arguments to be used if   **
      ** you select the "Execute" option.  When you press the Enter  **
      ** key the program will be compiled.                           **
      **                                                             **
      ** The SCREEN SECTION contains an image of the screen.         **
      **                                                             **
      ** The "010-Parse-Args" section in the PROCEDURE DIVISION has  **
      ** documentation on switches and their function.               **
      *****************************************************************
      **                                                             **
      ** AUTHOR:       GARY L. CUTLER                                **
      **               CutlerGL@gmail.com                            **
      **               Copyright (C) 2009-2010, Gary L. Cutler, GPL  **
      **                                                             **
      ** DATE-WRITTEN: June 14, 2009                                 **
      **                                                             **
      *****************************************************************
      ** Note: Depending on which extended DISPLAY handler you're    **
      **       using (PDCurses, Curses, ...), you may need to un-    **
      **       comment any source lines tagged with "SCROLL" in cols **
      **       1-6 in order to have error messages scroll properly   **
      **       in the OCic shell window.                             **
      *****************************************************************
      **  DATE  CHANGE DESCRIPTION                                   **
      ** ====== ==================================================== **
      ** GC0609 Don't display compiler messages file if compilation  **
      **        Is successful.  Also don't display messages if the   **
      **        output file is busy (just put a message on the       **
      **        screen, leave the OC screen up & let the user fix    **
      **        the problem & resubmit.                              **
      ** GC0709 When 'EXECUTE' is selected, a 'FILE BUSY' error will **
      **        still cause the (old) executable to be launched.     **
      **        Also, the 'EXTRA SWITCHES' field is being ignored.   **
      **        Changed the title bar to lowlighted reverse video &  **
      **        the message area to highlighted reverse-video.       **
      ** GC0809 Add a SPACE in from of command-line args when        **
      **        executing users program.  Add a SPACE after the      **
      **        -ftraceall switch when building cobc command.        **
      ** GC0909 Convert to work on Cygwin/Linux as well as MinGW     **
      ** GC0310 Virtualized the key codes for S-F1 thru S-F7 as they **
      **        differ depending upon whether PDCurses or NCurses is **
      **        being used.                                          **
      ** GC0410 Introduced the cross-reference and source listing    **
      **        features.  Also fixed a bug in @EXTRA switch proces- **
      **        sing where garbage will result if more than the      **
      **        @EXTRA switch is specified.                          **
      *****************************************************************
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           FUNCTION ALL INTRINSIC.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT Bat-File             ASSIGN TO Bat-File-Name
                                       ORGANIZATION IS LINE SEQUENTIAL.

           SELECT Cobc-Output          ASSIGN TO Cobc-Output-File
                                       ORGANIZATION IS LINE SEQUENTIAL.

           SELECT Source-Code          ASSIGN TO File-Name
                                       ORGANIZATION IS LINE SEQUENTIAL
                                       FILE STATUS IS FSM-Status.
       DATA DIVISION.
       FILE SECTION.
       FD  Bat-File.
       01  Bat-File-Rec                PIC X(2048).

       FD  Cobc-Output.
       01  Cobc-Output-Rec             PIC X(256).

       FD  Source-Code.
       01  Source-Code-Record          PIC X(80).

       WORKING-STORAGE SECTION.
       COPY screenio.

       01  Bat-File-Name               PIC X(256).

GC0909 01  Cmd                         PIC X(512).

       01  Cobc-Cmd                    PIC X(256).

       01  Cobc-Output-File            PIC X(256).

       01  Command-Line-Args           PIC X(256).

       01  Config-File                 PIC X(12).

GC0310 01  Config-Keys.
GC0310     05 CK-S-F1                  PIC 9(4).
GC0310     05 CK-S-F2                  PIC 9(4).
GC0310     05 CK-S-F3                  PIC 9(4).
GC0310     05 CK-S-F4                  PIC 9(4).
GC0310     05 CK-S-F5                  PIC 9(4).
GC0310     05 CK-S-F6                  PIC 9(4).
GC0310     05 CK-S-F7                  PIC 9(4).

GC0909 01  Dir-Char                    PIC X(1).

       01  Dummy                       PIC X(1).

       01  Env-TEMP                    PIC X(256).

       01  File-Name.
           05 FN-Char                  OCCURS 256 TIMES PIC X(1).

       01  File-Status-Message.
           05 FILLER                   PIC X(13) VALUE 'Status Code: '.
           05 FSM-Status               PIC 9(2).
           05 FILLER                   PIC X(11) VALUE ', Meaning: '.
           05 FSM-Msg                  PIC X(25).

       01  Flags.
           05 F-Compilation-Succeeded  PIC X(1).
              88 88-Compile-OK         VALUE 'Y'.
GC0909        88 88-Compile-OK-Warn    VALUE 'W'.
              88 88-Compile-Failed     VALUE 'N'.
GC0609     05 F-Complete               PIC X(1).
GC0609        88 88-Complete           VALUE 'Y'.
GC0609        88 88-Not-Complete       VALUE 'N'.
GC0809     05 F-IDENT-DIVISION         PIC X(1).
GC0809        88 88-1st-Prog-Complete  VALUE 'Y'.
GC0809        88 88-More-To-1st-Prog   VALUE 'N'.
           05 F-LINKAGE-SECTION        PIC X(1).
              88 88-Compile-As-Subpgm  VALUE 'Y'.
              88 88-Compile-As-Mainpgm VALUE 'N'.
           05 F-No-Switch-Changes      PIC X(1).
              88 88-No-Switch-Changes  VALUE 'Y'.
              88 88-Switch-Changes     VALUE 'N'.
GC0709     05 F-Output-File-Busy       PIC X(1).
GC0709        88 88-Output-File-Busy   VALUE 'Y'.
GC0709        88 88-Output-File-Avail  VALUE 'N'.
GC0809     05 F-Source-Record-Type     PIC X(1).
GC0809        88 88-Source-Rec-Linkage VALUE 'L'.
GC0809        88 88-Source-Rec-Ident   VALUE 'I'.
GC0809        88 88-Source-Rec-IgnoCOB-COLOR-RED VALUE ' '.
           05 F-Switch-Error           PIC X(1).
              88 88-Switch-Is-Bad      VALUE 'Y'.
              88 88-Switch-Is-Good     VALUE 'N'.

GC0909 01  Horizontal-Line             PIC X(80).
GC0909
       01  I                           USAGE BINARY-LONG.

       01  J                           USAGE BINARY-LONG.

GC0909 01  MS                          USAGE BINARY-LONG.

GC0909 01  ML                          USAGE BINARY-LONG.

       01  OC-Compiled                 PIC XXXX/XX/XXBXX/XX.

GC0909 01  OS-Type                     USAGE BINARY-LONG.
GC0909     88 OS-Unknown               VALUE 0.
GC0909     88 OS-Windows               VALUE 1.
GC0909     88 OS-Cygwin                VALUE 2.
GC0909     88 OS-UNIX                  VALUE 3.

GC0909 01  OS-Type-Literal             PIC X(7).

       01  Output-Message              PIC X(80).

       01  Path-Delimiter              PIC X(1).

       01  Prog-Folder                 PIC X(256).

       01  Prog-Extension              PIC X(30).

       01  Prog-File-Name              PIC X(40).

       01  Prog-Name                   PIC X(31).

       78  Selection-Char              VALUE '>'.

       01  Switch-Display.
           05 SD-Switch-And-Value      PIC X(19).
           05 FILLER                   PIC X(1).
           05 SD-Description           PIC X(60).

       01  Switch-Keyword              PIC X(12).
GC0410     88 Switch-Is-CONFIG     VALUE '@CONFIG', '@C'.
GC0410     88 Switch-Is-DEBUG      VALUE '@DEBUG', '@D'.
GC0410     88 Switch-Is-DLL        VALUE '@DLL'.
GC0410     88 Switch-Is-EXECUTE    VALUE '@EXECUTE', '@E'.
GC0410     88 Switch-Is-EXTRA      VALUE '@EXTRA', '@EX'.
GC0410     88 Switch-Is-NOTRUNC    VALUE '@NOTRUNC', '@N'.
GC0410     88 Switch-Is-TRACE      VALUE '@TRACE', '@T'.
GC0410     88 Switch-Is-SOURCE     VALUE '@SOURCE', '@S'.
GC0410     88 Switch-Is-XREF       VALUE '@XREF', '@X'.

       01  Switch-Keyword-And-Value    PIC X(256).

       01  Switch-Value.
           05 SV-1                     PIC X(1).
           05 FILLER                   PIC X(255).
       01  Switch-Value-Alt            REDEFINES Switch-Value
                                       PIC X(256).
           88 Valid-Config-Filename
              VALUE 'BS2000', 'COBOL85', 'COBOL2002', 'DEFAULT',
                    'IBM',    'MF',      'MVS'.

       01  Switches.
           05 S-ARGS                   PIC X(75) VALUE SPACES.
           05 S-CfgS.
              10 S-Cfg-BS2000          PIC X(1)  VALUE ' '.
              10 S-Cfg-COBOL85         PIC X(1)  VALUE ' '.
              10 S-Cfg-COBOL2002       PIC X(1)  VALUE ' '.
              10 S-Cfg-DEFAULT         PIC X(1)  VALUE Selection-Char.
              10 S-Cfg-IBM             PIC X(1)  VALUE ' '.
              10 S-Cfg-MF              PIC X(1)  VALUE ' '.
              10 S-Cfg-MVS             PIC X(1)  VALUE ' '.
           05 S-EXTRA                  PIC X(75) VALUE SPACES.
           05 S-Yes-No-Switches.
              10 S-DEBUG               PIC X(1)  VALUE 'N'.
              10 S-DLL                 PIC X(1)  VALUE 'N'.
GC0410        10 S-XREF                PIC X(1)  VALUE 'N'.
GC0410        10 S-SOURCE              PIC X(1)  VALUE 'N'.
              10 S-EXECUTE             PIC X(1)  VALUE 'N'.
              10 S-NOTRUNC             PIC X(1)  VALUE 'Y'.
              10 S-SUBROUTINE          PIC X(1)  VALUE 'A'.
              10 S-TRACE               PIC X(1)  VALUE 'N'.
              10 S-TRACEALL            PIC X(1)  VALUE 'N'.

       01  Tally                       USAGE BINARY-LONG.

         SCREEN SECTION.
      *>
      *> Here is the layout of the OCic screen.
      *>
      *> Note that this program can utilize the traditional PC line-drawing characters,
      *> if they are available.
      *>
      *> If this program is run on Windows, it must run with codepage 437 activated to
      *> display the line-drawing characters.  With a native Windows build or a
      *> Windows/MinGW build, one could use the command "chcp 437" to set that codepage
      *> for display within a Windows console window (that should be the default, though).
      *> With a Windows/Cygwin build, set the environment variable CYGWIN to a value of
      *> "codepage:oem" (this cannot be done from within the program though - you will
      *> have to use the "Computer/Advanced System Settings/Environment Variables" (Vista or
      *> Windows 7) function to define the variable.  XP Users: use "My Computer/Properties/
      *> Advanced/Environment Variables".
      *>
      *> To use OCic without the line-drawing characters, comment-out the first set of
      *> 78 "LD" items and uncomment the second.
      *>
      *> The following sample screen layout shows how the screen looks with line-drawing
      *> characters disabled.
      *>
      *>===================================================================================
      *> OCic (2010/04/02 11:36) - OpenCOBOL V1.1 Interactive Compilation        Windows 01
      *> +-----------------------------------------------------------------------------+ 02
      *> | Program:  OCic                                            F-Key: Select Opt | 03
      *> | Folder:   E:\OpenCOBOL\Samples                            Enter: Compile    | 04
      *> | Filename: OCic.cbl                                        Esc:   Quit       | 05
      *> +-----------------------------------------------------------------------------+ 06
      *>   On/Off Switches:                                          Configuration:      07
      *> +---------------------------------------------------------+-------------------+ 08
      *> | F1   Compile debug lines    F8   Produce source listing | S-F1   BS2000     | 09
      *> | F2   Always make DLLs       F9   Produce xref listing   | S-F2   COBOL85    | 10
      *> | F3   Pgm is a SUBROUTINE                                | S-F3   COBOL2002  | 11
      *> | F4   Execute if compile OK                              | S-F4 > Default    | 12
      *> | F5 > No COMP/BINARY trunc                               | S-F5   IBM        | 13
      *> | F6   Trace procedures                                   | S-F6   MicroFocus | 14
      *> | F7   Trace proc + stmnts                                | S-F7   MVS        | 15
      *> +---------------------------------------------------------+-------------------+ 16
      *>   Additional "cobc" Switches (if any):                                          17
      *> +-----------------------------------------------------------------------------+ 18
      *> | -O2________________________________________________________________________ | 19
      *> +-----------------------------------------------------------------------------+ 20
      *>   Program Execution Arguments (if any):                                         21
      *> +-----------------------------------------------------------------------------+ 22
      *> | ___________________________________________________________________________ | 23
      *> +-----------------------------------------------------------------------------+ 24
      *> OCic Copyright (C) 2009-2010, Gary L. Cutler, GPL                               25
      *>===================================================================================
      *>12345678901234567890123456789012345678901234567890123456789012345678901234567890
      *>         1         2         3         4         5         6         7         8
      *>
      *> USE THESE CHARS FOR LINE-DRAWING IF YOU HAVE ACCESS TO PC-DOS CODEPAGE 437:
      *>
       78 LD-UL-Corner                 VALUE X"DA".
       78 LD-LL-Corner                 VALUE X"C0".
       78 LD-UR-Corner                 VALUE X"BF".
       78 LD-LR-Corner                 VALUE X"D9".
       78 LD-Upper-T                   VALUE X"C2".
       78 LD-Lower-T                   VALUE X"C1".
       78 LD-Horiz-Line                VALUE X"C4".
       78 LD-Vert-Line                 VALUE X"B3".
      *>
      *> USE THESE CHARS FOR LINE-DRAWING IF YOU DO NOT HAVE ACCESS TO PC-DOS CODEPAGE 437:
      *>
      *> 78 LD-UL-Corner                          VALUE '+'.
      *> 78 LD-LL-Corner                          VALUE '+'.
      *> 78 LD-UR-Corner                          VALUE '+'.
      *> 78 LD-LR-Corner                          VALUE '+'.
      *> 78 LD-Upper-T                            VALUE '+'.
      *> 78 LD-Lower-T                            VALUE '+'.
      *> 78 LD-Horiz-Line                         VALUE '-'.
      *> 78 LD-Vert-Line                          VALUE '|'.
      *>
       01 Blank-Screen LINE 1 COLUMN 1 BLANK SCREEN.

       01 Switches-Screen BACKGROUND-COLOR COB-COLOR-BLACK
                          FOREGROUND-COLOR COB-COLOR-WHITE AUTO.
      *>
      *> GENERAL SCREEN FRAMEWORK
      *>
          03 BACKGROUND-COLOR COB-COLOR-BLACK
             FOREGROUND-COLOR COB-COLOR-BLUE  HIGHLIGHT.
             05 LINE 02 COL 02           VALUE LD-UL-Corner.
             05                PIC X(77) FROM  Horizontal-Line.
             05         COL 80           VALUE LD-UR-Corner.

             05 LINE 03 COL 02           VALUE LD-Vert-Line.
             05         COL 80           VALUE LD-Vert-Line.

             05 LINE 04 COL 02           VALUE LD-Vert-Line.
             05         COL 80           VALUE LD-Vert-Line.

             05 LINE 05 COL 02           VALUE LD-Vert-Line.
             05         COL 80           VALUE LD-Vert-Line.

             05 LINE 06 COL 02           VALUE LD-LL-Corner.
             05                PIC X(77) FROM  Horizontal-Line.
             05         COL 80           VALUE LD-LR-Corner.

             05 LINE 08 COL 02           VALUE LD-UL-Corner.
             05                PIC X(57) FROM  Horizontal-Line.
             05         COL 60           VALUE LD-Upper-T.
             05                PIC X(19) FROM  Horizontal-Line.
             05         COL 80           VALUE LD-UR-Corner.

             05 LINE 09 COL 02           VALUE LD-Vert-Line.
             05         COL 60           VALUE LD-Vert-Line.
             05         COL 80           VALUE LD-Vert-Line.

             05 LINE 10 COL 02           VALUE LD-Vert-Line.
             05         COL 60           VALUE LD-Vert-Line.
             05         COL 80           VALUE LD-Vert-Line.

             05 LINE 11 COL 02           VALUE LD-Vert-Line.
             05         COL 60           VALUE LD-Vert-Line.
             05         COL 80           VALUE LD-Vert-Line.

             05 LINE 12 COL 02           VALUE LD-Vert-Line.
             05         COL 60           VALUE LD-Vert-Line.
             05         COL 80           VALUE LD-Vert-Line.

             05 LINE 13 COL 02           VALUE LD-Vert-Line.
             05         COL 60           VALUE LD-Vert-Line.
             05         COL 80           VALUE LD-Vert-Line.

             05 LINE 14 COL 02           VALUE LD-Vert-Line.
             05         COL 60           VALUE LD-Vert-Line.
             05         COL 80           VALUE LD-Vert-Line.

             05 LINE 15 COL 02           VALUE LD-Vert-Line.
             05         COL 60           VALUE LD-Vert-Line.
             05         COL 80           VALUE LD-Vert-Line.

             05 LINE 16 COL 02           VALUE LD-LL-Corner.
             05                PIC X(57) FROM  Horizontal-Line.
             05         COL 60           VALUE LD-Lower-T.
             05                PIC X(19) FROM  Horizontal-Line.
             05         COL 80           VALUE LD-LR-Corner.

             05 LINE 18 COL 02           VALUE LD-UL-Corner.
             05                PIC X(77) FROM  Horizontal-Line.
             05         COL 80           VALUE LD-UR-Corner.

             05 LINE 19 COL 02           VALUE LD-Vert-Line.
             05         COL 80           VALUE LD-Vert-Line.

             05 LINE 20 COL 02           VALUE LD-LL-Corner.
             05                PIC X(77) FROM  Horizontal-Line.
             05         COL 80           VALUE LD-LR-Corner.

             05 LINE 22 COL 02           VALUE LD-UL-Corner.
             05                PIC X(77) FROM  Horizontal-Line.
             05         COL 80           VALUE LD-UR-Corner.

             05 LINE 23 COL 02           VALUE LD-Vert-Line.
             05         COL 80           VALUE LD-Vert-Line.

             05 LINE 24 COL 02           VALUE LD-LL-Corner.
             05                PIC X(77) FROM  Horizontal-Line.
             05         COL 80           VALUE LD-LR-Corner.
      *>
      *> TOP AND BOTTOM LINES
      *>
          03 BACKGROUND-COLOR COB-COLOR-BLUE  BLINK
             FOREGROUND-COLOR COB-COLOR-WHITE HIGHLIGHT.
GC0410       05 LINE 01 COL 01 VALUE ' OCic ('.
GC0410       05                PIC X(16) FROM OC-Compiled.
GC0410       05                VALUE ') OpenCOBOL V1.1 06FEB2009 ' &
GC0410                               'Interactive Compilation         '.
GC0410       05 LINE 25 COL 01 PIC X(81) FROM Output-Message.
      *>
      *> LABELS
      *>
          03 BACKGROUND-COLOR COB-COLOR-BLACK
             FOREGROUND-COLOR COB-COLOR-CYAN  HIGHLIGHT.
             05 LINE 07 COL 04 VALUE 'On/Off Switches:'.
             05         COL 62 VALUE 'Configuration:'.
             05 LINE 17 COL 04 VALUE 'Additional "cobc" Switches (if any
      -                              '):'.
             05 LINE 21 COL 04 VALUE 'Program Execution Arguments (if an
      -                              'y):'.
      *>
      *> TOP SECTION BACKGROUND
      *>
          03 BACKGROUND-COLOR COB-COLOR-BLACK
             FOREGROUND-COLOR COB-COLOR-CYAN LOWLIGHT.
             05 LINE 03 COL 04 VALUE 'Program:  '.
             05 LINE 04 COL 04 VALUE 'Folder:   '.
             05 LINE 05 COL 04 VALUE 'Filename: '.

             05 LINE 03 COL 62 VALUE 'F-Key: Select Opt'.
             05 LINE 04 COL 62 VALUE 'Enter: Compile   '.
             05 LINE 05 COL 62 VALUE 'Esc:   Quit      '.
      *>
      *> TOP SECTION PROGRAM INFO
      *>
          03 BACKGROUND-COLOR COB-COLOR-BLACK
             FOREGROUND-COLOR COB-COLOR-WHITE HIGHLIGHT.
             05 LINE 03 COL 14 PIC X(47) FROM Prog-Name.
             05 LINE 04 COL 14 PIC X(47) FROM Prog-Folder.
             05 LINE 05 COL 14 PIC X(47) FROM Prog-File-Name.
      *>
      *> MIDDLE LEFT SECTION F-KEYS
      *>
          03 BACKGROUND-COLOR COB-COLOR-BLACK
             FOREGROUND-COLOR COB-COLOR-WHITE HIGHLIGHT.
             05 LINE 09 COL 04 VALUE 'F1'.
             05 LINE 10 COL 04 VALUE 'F2'.
             05 LINE 11 COL 04 VALUE 'F3'.
             05 LINE 12 COL 04 VALUE 'F4'.
             05 LINE 13 COL 04 VALUE 'F5'.
             05 LINE 14 COL 04 VALUE 'F6'.
             05 LINE 15 COL 04 VALUE 'F7'.
             05 LINE 09 COL 32 VALUE 'F8'.
             05 LINE 10 COL 32 VALUE 'F9'.
      *>
      *> MIDDLE LEFT SECTION SWITCHES
      *>
          03 BACKGROUND-COLOR COB-COLOR-BLACK
             FOREGROUND-COLOR COB-COLOR-RED   HIGHLIGHT.
             05 LINE 09 COL 07 PIC X(1) FROM S-DEBUG.
             05 LINE 10 COL 07 PIC X(1) FROM S-DLL.
             05 LINE 11 COL 07 PIC X(1) FROM S-SUBROUTINE.
             05 LINE 12 COL 07 PIC X(1) FROM S-EXECUTE.
             05 LINE 13 COL 07 PIC X(1) FROM S-NOTRUNC.
             05 LINE 14 COL 07 PIC X(1) FROM S-TRACE.
             05 LINE 15 COL 07 PIC X(1) FROM S-TRACEALL.
             05 LINE 09 COL 35 PIC X(1) FROM S-SOURCE.
             05 LINE 10 COL 35 PIC X(1) FROM S-XREF.
      *>
      *> MIDDLE LEFT SECTION BACKGROUND
      *>
          03 BACKGROUND-COLOR COB-COLOR-BLACK
             FOREGROUND-COLOR COB-COLOR-CYAN  LOWLIGHT.
             05 LINE 09 COL 09 VALUE 'Compile debug lines   '.
             05 LINE 10 COL 09 VALUE 'Always make DLLs      '.
             05 LINE 11 COL 09 VALUE 'Pgm is a SUBROUTINE   '.
             05 LINE 12 COL 09 VALUE 'Execute if compile OK '.
             05 LINE 13 COL 09 VALUE 'No COMP/BINARY trunc  '.
             05 LINE 14 COL 09 VALUE 'Trace procedures      '.
             05 LINE 15 COL 09 VALUE 'Trace proc + stmnts   '.
             05 LINE 09 COL 37 VALUE 'Produce source listing'.
             05 LINE 10 COL 37 VALUE 'Produce xref listing  '.
      *>
      *> MIDDLE RIGHT SECTION F-KEYS
      *>
          03 BACKGROUND-COLOR COB-COLOR-BLACK
             FOREGROUND-COLOR COB-COLOR-WHITE HIGHLIGHT.
             05 LINE 09 COL 62 VALUE 'S-F1'.
             05 LINE 10 COL 62 VALUE 'S-F2'.
             05 LINE 11 COL 62 VALUE 'S-F3'.
             05 LINE 12 COL 62 VALUE 'S-F4'.
             05 LINE 13 COL 62 VALUE 'S-F5'.
             05 LINE 14 COL 62 VALUE 'S-F6'.
             05 LINE 15 COL 62 VALUE 'S-F7'.
      *>
      *> MIDDLE RIGHT SECTION SWITCHES
      *>
          03 BACKGROUND-COLOR COB-COLOR-BLACK
             FOREGROUND-COLOR COB-COLOR-RED HIGHLIGHT.
             05 LINE 09 COL 67 PIC X(1) FROM S-Cfg-BS2000.
             05 LINE 10 COL 67 PIC X(1) FROM S-Cfg-COBOL85.
             05 LINE 11 COL 67 PIC X(1) FROM S-Cfg-COBOL2002.
             05 LINE 12 COL 67 PIC X(1) FROM S-Cfg-DEFAULT.
             05 LINE 13 COL 67 PIC X(1) FROM S-Cfg-IBM.
             05 LINE 14 COL 67 PIC X(1) FROM S-Cfg-MF.
             05 LINE 15 COL 67 PIC X(1) FROM S-Cfg-MVS.
      *>
      *> MIDDLE RIGHT SECTION BACKGROUND
      *>
          03 BACKGROUND-COLOR COB-COLOR-BLACK
             FOREGROUND-COLOR COB-COLOR-CYAN LOWLIGHT.
             05 LINE 09 COL 69 VALUE 'BS2000    '.
             05 LINE 10 COL 69 VALUE 'COBOL85   '.
             05 LINE 11 COL 69 VALUE 'COBOL2002 '.
             05 LINE 12 COL 69 VALUE 'Default   '.
             05 LINE 13 COL 69 VALUE 'IBM       '.
             05 LINE 14 COL 69 VALUE 'MicroFocus'.
             05 LINE 15 COL 69 VALUE 'MVS       '.
      *>
      *> FREE-FORM OPTIONS FIELDS
      *>
          03 BACKGROUND-COLOR COB-COLOR-BLACK
             FOREGROUND-COLOR COB-COLOR-WHITE HIGHLIGHT.
             05 LINE 19 COL 04 PIC X(75) USING S-EXTRA.
             05 LINE 23 COL 04 PIC X(75) USING S-ARGS.
      /
       PROCEDURE DIVISION.
      *****************************************************************
      ** Legend to procedure names:                                  **
      **                                                             **
      ** 00x-xxx   All MAIN driver procedures                        **
      ** 0xx-xxx   All GLOBAL UTILITY procedures                     **
      ** 1xx-xxx   All INITIALIZATION procedures                     **
      ** 2xx-xxx   All CORE PROCESSING procedures                    **
      ** 9xx-xxx   All TERMINATION procedures                        **
      *****************************************************************
       DECLARATIVES.
       000-File-Error SECTION.
           USE AFTER STANDARD ERROR PROCEDURE ON Source-Code.
       000-Handle-Error.
           COPY FileStat-Msgs
               REPLACING STATUS BY FSM-Status
                         MSG    BY FSM-Msg.
           MOVE SPACES TO Output-Message
           IF FSM-Status = 35
               DISPLAY
                   'File not found: "'
                   TRIM(File-Name,TRAILING)
                   '"'
               END-DISPLAY
           ELSE
               DISPLAY
                   'Error accessing file: "'
                   TRIM(File-Name,TRAILING)
                   '"'
               END-DISPLAY
           END-IF
           GOBACK
           .
       END DECLARATIVES.
      /
       000-Main SECTION.

           PERFORM 100-Initialization
GC0609     SET 88-Not-Complete TO TRUE
GC0609     PERFORM UNTIL 88-Complete
GC0609         PERFORM 200-Let-User-Set-Switches
GC0609         PERFORM 210-Run-Compiler
GC0410         IF (88-Compile-OK OR 88-Compile-OK-Warn)
GC0410         AND (S-XREF NOT = SPACE OR S-SOURCE NOT = SPACE)
GC0410             PERFORM 220-Make-Listing
GC0410         END-IF
GC0709         IF  (S-EXECUTE NOT = SPACES)
GC0709         AND (88-Output-File-Avail)
GC0609             PERFORM 230-Run-Program
GC0609         END-IF
GC0609     END-PERFORM
           .

       009-Done.
           PERFORM 900-Terminate
           .
      * -- Control will NOT return
      /
       010-Parse-Args SECTION.
      *****************************************************************
      ** Process a sequence of KEYWORD=VALUE items.  These are items **
      ** specified on the command-line to provide the initial        **
      ** options shown selected on the screen.  When integrating     **
      ** OCic into an edirot or framework, include these switches on **
      ** the ocic.exe command the editor/framework executes.  Any    **
      ** underlined choice is the default value for that switch.     **
      **                                                             **
      ** @CONFIG=BS2000|COBOL85|COBOL2002|DEFAULT|IBM|MF|MVS         **
      **                                  =======                    **
      ** This switch specifies the default cobc compiler configura-  **
      ** tion file to be used                                        **
      **                                                             **
      ** @DEBUG=YES|NO                                               **
      **            ==                                               **
      ** This switch specifies whether (YES) or not (NO) debugging   **
      ** lines (those with a "D" in column 7) will be compiled.      **
      **                                                             **
      ** @DLL=YES|NO                                                 **
      **          ==                                                 **
      ** Use this switch to force ALL compiled programs to be built  **
      ** as DLLs ("@DLL=YES").  When main programs are built as DLLs **
      ** they must be executed using the cobcrun utility.  When      **
      ** "@DLL=NO" is in effect, main programs are generated as      **
      ** actual "exe" files and only subprograms will be generated   **
      ** as DLLs.                                                    **
      **                                                             **
      ** @EXECUTE=YES|NO                                             **
      **              ==                                             **
      ** This switch specifies whether ("@EXECUTE=YES") or not       **
      ** ("@EXECUTE=NO") the program will be executed after it is    **
      ** successfully compiled.                                      **
      **                                                             **
      ** @EXTRA=extra cobc argument(s)                               **
      **                                                             **
      ** This switch allows you to specify additional cobc arguments **
      ** that aren't managed by the other OC switches.  If used,     **
      ** this must be the last switch specified on the command line, **
      ** as everything that follows the "=" will be placed on the    **
      ** cobc command generated by OC.                               **
      **                                                             **
      ** @NOTRUNC=YES|NO                                             **
      **          ===                                                **
      ** This switch specifies whether (YES) or not (NO) the sup-    **
      ** pression of binary field truncation will occur.  If a PIC   **
      ** 99 COMP field (one byte of storage), for example, is given  **
      ** the value 123, it may have its value truncated to 23 when   **
      ** DISPLAYed.  Regardless of the NOTRUNC setting, internally   **
      ** the full precision of the field (allowing a maximum value   **
      ** of 255) will be preserved.  Even though truncation - if it  **
      ** does occur - would appear to have a minimal disruption on   **
      ** program operation, it has a significant effect on program   **
      ** run-time speed.                                             **
      **                                                             **
      ** @TRACE=YES|NO|ALL                                           **
      **            ==                                               **
      ** This switch controls whether or not code will be added to   **
      ** the object program to produce execution-time logic traces.  **
      ** A specification of "@TRACE=NO" means no such code will be   **
      ** produced.  By specifying "@TRACE=YES", code will be genera- **
      ** ted to display procedure names as they are entered.  A      **
      ** "@TRACE=ALL" specification will generate not only procedure **
      ** traces (as "@TRACE=YES" would) but also statement-level     **
      ** traces too!  All trace output is written to STDERR, so      **
      ** adding a "2>file" to the execution of the program will pipe **
      ** the trace output to a file.  You may find it valuable to    **
      ** add your own DISPLAY statements to the debugging output via **
      ** "DISPLAY xx UPON SYSERR"  The SYSERR device corresponds to  **
      ** the Windows or UNIX STDERR device and will therefore honor  **
      ** any "2>file" placed at the end of your program's execution. **
      ** Add a "D" in column 7 and you can control the generation or **
      ** ignoring of these DISPLAY statements via the "@DEBUG"       **
      ** switch.                                                     **
      **                                                             **
GC0410** @SOURCE=YES|NO                                              **
GC0410**           ==                                                **
GC0410** Use this switch to produce a source listing of the program, **
GC0410** PROVIDED it compiles without errors.                        **
      **                                                             **
GC0410** @XREF=YES|NO                                                **
GC0410**           ==                                                **
GC0410** Use this switch to produce a cross-reference listing of the **
GC0410** program, PROVIDED it compiles without errors.               **
      *****************************************************************

       011-Init.
           MOVE 1 TO I
           .

       012-Extract-Kwd-And-Value.
           PERFORM UNTIL I NOT < LENGTH(Command-Line-Args)
               MOVE I TO J
               UNSTRING Command-Line-Args
                   DELIMITED BY ALL SPACES
                   INTO Switch-Keyword-And-Value
                   WITH POINTER I
               END-UNSTRING
               IF Switch-Keyword-And-Value NOT = SPACES
                   UNSTRING Switch-Keyword-And-Value
                       DELIMITED BY '='
                       INTO Switch-Keyword, Switch-Value
                   END-UNSTRING
                   PERFORM 030-Process-Keyword
               END-IF
           END-PERFORM
           .

       019-Done.
           EXIT.

      *****************************************************************
      ** Since this program uses the SCREEN SECTION, it cannot do    **
      ** conventional console DISPLAY operations.  This routine      **
      ** (which, I admit, is like using an H-bomb to hunt rabbits)   **
      ** will submit an "ECHO" command to the system to simulate a   **
      ** DISPLAY.                                                    **
      *****************************************************************
       021-Build-And-Issue-Command.
           DISPLAY
               Output-Message
           END-DISPLAY
           .

       029-Done.
           EXIT.
      /
       030-Process-Keyword SECTION.
      *****************************************************************
      ** Process a single KEYWORD=VALUE item.                        **
      *****************************************************************

       031-Init.
           MOVE UPPER-CASE(Switch-Keyword) TO Switch-Keyword
           SET 88-Switch-Is-Good TO TRUE
           .

       032-Process.
           EVALUATE TRUE
               WHEN Switch-Is-EXTRA
GC0410             MOVE J TO I
                   UNSTRING Command-Line-Args DELIMITED BY '='
                       INTO Dummy, S-EXTRA
GC0410                 WITH POINTER I
GC0410             END-UNSTRING
                   MOVE LENGTH(Command-Line-Args) TO I
               WHEN Switch-Is-CONFIG
                   MOVE 'CONFIG' TO Switch-Keyword
                   MOVE UPPER-CASE(Switch-Value)
                     TO Switch-Value
                   EVALUATE Switch-Value
                       WHEN 'BS2000'
                           MOVE SPACES TO S-CfgS
                           MOVE Selection-Char    TO S-Cfg-BS2000
                       WHEN 'COBOL85'
                           MOVE SPACES TO S-CfgS
                           MOVE Selection-Char    TO S-Cfg-COBOL85
                       WHEN 'COBOL2002'
                           MOVE SPACES TO S-CfgS
                           MOVE Selection-Char    TO S-Cfg-COBOL2002
                       WHEN 'DEFAULT'
                           MOVE SPACES TO S-CfgS
                           MOVE Selection-Char    TO S-Cfg-DEFAULT
                       WHEN 'IBM'
                           MOVE SPACES TO S-CfgS
                           MOVE Selection-Char    TO S-Cfg-IBM
                       WHEN 'MF'
                           MOVE SPACES TO S-CfgS
                           MOVE Selection-Char    TO S-Cfg-MF
                       WHEN 'MVS'
                           MOVE SPACES TO S-CfgS
                           MOVE Selection-Char    TO S-Cfg-MVS
                       WHEN OTHER
                           MOVE 'An invalid /CONFIG switch value ' &
                                'was specified on the command line ' &
                                '- ignored'
                             TO Output-Message
                   END-EVALUATE
               WHEN Switch-Is-DEBUG
                   MOVE 'DEBUG' TO Switch-Keyword
                   MOVE UPPER-CASE(Switch-Value)
                     TO Switch-Value
                   PERFORM 040-Process-Yes-No-Value
                   IF 88-Switch-Is-Good
                       MOVE SV-1 TO S-DEBUG
                   END-IF
GC0410         WHEN Switch-Is-DLL
GC0410             MOVE 'DLL' TO Switch-Keyword
GC0410             MOVE UPPER-CASE(Switch-Value)
GC0410               TO Switch-Value
GC0410             PERFORM 040-Process-Yes-No-Value
GC0410             IF 88-Switch-Is-Good
GC0410                 MOVE SV-1 TO S-DLL
GC0410             END-IF
               WHEN Switch-Is-EXECUTE
                   MOVE 'EXECUTE' TO Switch-Keyword
                   MOVE UPPER-CASE(Switch-Value)
                     TO Switch-Value
                   PERFORM 040-Process-Yes-No-Value
                   IF 88-Switch-Is-Good
                       MOVE SV-1 TO S-EXECUTE
                   END-IF
               WHEN Switch-Is-NOTRUNC
                   MOVE 'NOTRUNC' TO Switch-Keyword
                   MOVE UPPER-CASE(Switch-Value)
                     TO Switch-Value
                   PERFORM 040-Process-Yes-No-Value
                   IF 88-Switch-Is-Good
                       MOVE SV-1 TO S-NOTRUNC
                   END-IF
GC0410         WHEN Switch-Is-SOURCE
GC0410             MOVE 'SOURCE' TO Switch-Keyword
GC0410             MOVE UPPER-CASE(Switch-Value)
GC0410               TO Switch-Value
GC0410             PERFORM 050-Process-Yes-No-All
GC0410             IF 88-Switch-Is-Good
GC0410                 MOVE SV-1 TO S-SOURCE
GC0410             END-IF
               WHEN Switch-Is-TRACE
                   MOVE 'TRACE' TO Switch-Keyword
                   MOVE UPPER-CASE(Switch-Value)
                     TO Switch-Value
                   PERFORM 050-Process-Yes-No-All
                   IF 88-Switch-Is-Good
                       MOVE SV-1 TO S-TRACE
                   END-IF
GC0410         WHEN Switch-Is-XREF
GC0410             MOVE 'XREF' TO Switch-Keyword
GC0410             MOVE UPPER-CASE(Switch-Value)
GC0410               TO Switch-Value
GC0410             PERFORM 050-Process-Yes-No-All
GC0410             IF 88-Switch-Is-Good
GC0410                 MOVE SV-1 TO S-XREF
GC0410             END-IF
               WHEN OTHER
                   MOVE SPACES TO Output-Message
                   STRING '"'
                          TRIM(Switch-Keyword)
                          '" is not a valid switch ' &
                                         '- ignored'
                          DELIMITED SIZE
                          INTO Output-Message
                   END-STRING
                   SET 88-Switch-Is-Bad TO TRUE
           END-EVALUATE
           .

       039-Done.
           EXIT.
      /
       040-Process-Yes-No-Value SECTION.
      *****************************************************************
      ** Process a switch value of YES or NO                         **
      *****************************************************************

       042-Process.
           EVALUATE SV-1
               WHEN 'Y'
                   MOVE 'YES' TO Switch-Value
               WHEN 'N'
                   MOVE 'NO'  To Switch-Value
               WHEN OTHER
                   MOVE SPACES TO Output-Message
                   STRING '*ERROR: "' TRIM(Switch-Value)
                           '" is not a valid value for the "'
                           TRIM(Switch-Keyword) '" switch'
                           DELIMITED SPACES
                           INTO Output-Message
                   END-STRING
                   SET 88-Switch-Is-Bad TO TRUE
           END-EVALUATE
           .

       049-Done.
           EXIT.
      /
       050-Process-Yes-No-All SECTION.
      *****************************************************************
      ** Process a switch value of YES, NO or ALL                    **
      *****************************************************************

       052-Process.
           IF SV-1 = 'A'
               MOVE 'ALL' TO Switch-Value
           ELSE
               PERFORM 040-Process-Yes-No-Value
           END-IF
           .

       059-Done.
           EXIT.
      /
       060-Process-Yes-No-Auto SECTION.
      *****************************************************************
      ** Process a switch value of YES, NO or AUTO                   **
      *****************************************************************

       061-Init.
           IF SV-1 = 'A'
               PERFORM 070-Find-LINKAGE-SECTION
               IF 88-Compile-As-Subpgm
                   MOVE 'Y' TO Switch-Value
               ELSE
                   MOVE 'N' TO Switch-Value
               END-IF
           ELSE
               PERFORM 040-Process-Yes-No-Value
           END-IF
           .
      /
       070-Find-LINKAGE-SECTION SECTION.
      *****************************************************************
      ** Determine if the program being compiled is a MAIN program   **
      *****************************************************************

       071-Init.
           OPEN INPUT Source-Code
           SET 88-Compile-As-Mainpgm TO TRUE
           SET 88-More-To-1st-Prog   TO TRUE
           PERFORM UNTIL 88-1st-Prog-Complete
               READ Source-Code AT END
                   CLOSE Source-Code
                   EXIT SECTION
               END-READ
               CALL 'CHECKSOURCE' USING Source-Code-Record
                                       F-Source-Record-Type
               END-CALL
               IF 88-Source-Rec-Ident
                   SET 88-1st-Prog-Complete TO TRUE
               END-IF
           END-PERFORM
           .

       072-Process-Source.
           SET 88-Source-Rec-IgnoCOB-COLOR-RED TO TRUE
           PERFORM UNTIL 88-Source-Rec-Linkage
                      OR 88-Source-Rec-Ident
               READ Source-Code AT END
                   CLOSE Source-Code
                   EXIT SECTION
               END-READ
               CALL 'CHECKSOURCE' USING Source-Code-Record
                                       F-Source-Record-Type
               END-CALL
           END-PERFORM
           CLOSE Source-Code
           IF 88-Source-Rec-Linkage
               SET 88-Compile-As-Subpgm TO TRUE
           END-IF
           .

       079-Done.
           EXIT.
      /
       100-Initialization SECTION.
      *****************************************************************
      ** Perform all program-wide initialization operations          **
      *****************************************************************


GC0909 101-Determine-OS-Type.
GC0909     CALL 'GETOSTYPE'
GC0909     END-CALL
GC0909     MOVE RETURN-CODE TO OS-Type
GC0909     EVALUATE TRUE
GC0909         WHEN OS-Unknown
GC0909             MOVE '\'         TO Dir-Char
GC0909             MOVE 'Unknown'   TO OS-Type-Literal
GC0310             MOVE COB-SCR-F11 TO CK-S-F1
GC0310             MOVE COB-SCR-F12 TO CK-S-F2
GC0310             MOVE COB-SCR-F13 TO CK-S-F3
GC0310             MOVE COB-SCR-F14 TO CK-S-F4
GC0310             MOVE COB-SCR-F15 TO CK-S-F5
GC0310             MOVE COB-SCR-F16 TO CK-S-F6
GC0310             MOVE COB-SCR-F17 TO CK-S-F7
GC0909         WHEN OS-Windows
GC0909             MOVE '\'         TO Dir-Char
GC0909             MOVE 'Windows'   TO OS-Type-Literal
GC0310             MOVE COB-SCR-F13 TO CK-S-F1
GC0310             MOVE COB-SCR-F14 TO CK-S-F2
GC0310             MOVE COB-SCR-F15 TO CK-S-F3
GC0310             MOVE COB-SCR-F16 TO CK-S-F4
GC0310             MOVE COB-SCR-F17 TO CK-S-F5
GC0310             MOVE COB-SCR-F18 TO CK-S-F6
GC0310             MOVE COB-SCR-F19 TO CK-S-F7
GC0909         WHEN OS-Cygwin
GC0909             MOVE '/'         TO Dir-Char
GC0410             MOVE 'Cygwin'    TO OS-Type-Literal
GC0310             MOVE COB-SCR-F11 TO CK-S-F1
GC0310             MOVE COB-SCR-F12 TO CK-S-F2
GC0310             MOVE COB-SCR-F13 TO CK-S-F3
GC0310             MOVE COB-SCR-F14 TO CK-S-F4
GC0310             MOVE COB-SCR-F15 TO CK-S-F5
GC0310             MOVE COB-SCR-F16 TO CK-S-F6
GC0310             MOVE COB-SCR-F17 TO CK-S-F7
GC0909         WHEN OS-UNIX
GC0909             MOVE '/'         TO Dir-Char
GC0410             MOVE 'UNIX   '   TO OS-Type-Literal
GC0310             MOVE COB-SCR-F11 TO CK-S-F1
GC0310             MOVE COB-SCR-F12 TO CK-S-F2
GC0310             MOVE COB-SCR-F13 TO CK-S-F3
GC0310             MOVE COB-SCR-F14 TO CK-S-F4
GC0310             MOVE COB-SCR-F15 TO CK-S-F5
GC0310             MOVE COB-SCR-F16 TO CK-S-F6
GC0310             MOVE COB-SCR-F17 TO CK-S-F7
GC0909     END-EVALUATE
GC0909     .

       102-Set-Environment-Vars.
           SET ENVIRONMENT 'COB_SCREEN_EXCEPTIONS' TO 'Y'
           SET ENVIRONMENT 'COB_SCREEN_ESC'        TO 'Y'
           .

       103-Generate-Cobc-Output-Fn.
           ACCEPT Env-TEMP
               FROM ENVIRONMENT "TEMP"
           END-ACCEPT
           MOVE SPACES TO Cobc-Output-File
           STRING TRIM(Env-TEMP,TRAILING)
GC0909            Dir-Char
GC0909            'OC-Messages.TXT'
                  DELIMITED SIZE
                  INTO Cobc-Output-File
           END-STRING
           .

       104-Generate-Banner-Line-Info.
           MOVE WHEN-COMPILED (1:12) TO OC-Compiled
           INSPECT OC-Compiled
               REPLACING ALL '/' BY ':'
               AFTER INITIAL SPACE
           .

       105-Establish-Switch-Settings.
           ACCEPT Command-Line-Args
               FROM COMMAND-LINE
           END-ACCEPT
           MOVE TRIM(Command-Line-Args, Leading)
             TO Command-Line-Args
           MOVE 0 TO Tally
GC0410     INSPECT Command-Line-Args TALLYING Tally FOR ALL '@'
           IF Tally = 0
               MOVE Command-Line-Args TO File-Name
               MOVE SPACES            TO Command-Line-Args
           ELSE
GC0410         UNSTRING Command-Line-Args DELIMITED BY '@'
                   INTO File-Name, Dummy
               END-UNSTRING
               INSPECT Command-Line-Args
GC0410             REPLACING FIRST '@' BY LOW-VALUES
               UNSTRING Command-Line-Args
                   DELIMITED BY LOW-VALUES
                   INTO Dummy, Cmd
               END-UNSTRING
               MOVE SPACES TO Command-Line-Args
GC0410         STRING '@' Cmd DELIMITED SIZE
                   INTO Command-Line-Args
               END-STRING
           END-IF
           IF File-Name = SPACES
               DISPLAY
                   'No program filename was specified'
               END-DISPLAY
               PERFORM 900-Terminate
           END-IF
           PERFORM 010-Parse-Args
           IF S-SUBROUTINE = 'A'
               MOVE 'S' TO Switch-Keyword
               MOVE 'A' TO Switch-Value
               PERFORM 070-Find-LINKAGE-SECTION
               IF 88-Compile-As-Subpgm
                   MOVE 'Y' TO S-SUBROUTINE
               ELSE
                   MOVE 'N' TO S-SUBROUTINE
               END-IF
           END-IF
           INSPECT S-Yes-No-Switches REPLACING ALL 'Y' BY Selection-Char
           INSPECT S-Yes-No-Switches REPLACING ALL 'N' BY ' '
           .

       106-Determine-Folder-Path.
           Move 256 TO I
GC0909     IF OS-Cygwin AND File-Name (2:1) = ':'
GC0909         MOVE '\' TO Dir-Char
GC0909     END-IF
           PERFORM UNTIL I = 0 OR FN-Char (I) = Dir-Char
               SUBTRACT 1 FROM I
           END-PERFORM
           IF I = 0
               MOVE SPACES    TO Prog-Folder
               MOVE File-Name TO Prog-File-Name
           ELSE
               MOVE '*' TO FN-Char (I)
               UNSTRING File-Name DELIMITED BY '*'
                   INTO Prog-Folder
                        Prog-File-Name
               END-UNSTRING
               MOVE Dir-Char TO FN-Char (I)
           END-IF
           UNSTRING Prog-File-Name DELIMITED BY '.'
               INTO Prog-Name, Prog-Extension
           END-UNSTRING
           IF Prog-Folder = SPACES
               ACCEPT Prog-Folder
                   FROM ENVIRONMENT 'CD'
               END-ACCEPT
GC0909     ELSE
GC0909         CALL "CBL_CHANGE_DIR"
GC0909             USING TRIM(Prog-Folder,TRAILING)
GC0909         END-CALL
           END-IF
GC0909     IF OS-Cygwin AND File-Name (2:1) = ':'
GC0909         MOVE '/' TO Dir-Char
GC0909     END-IF
           .

GC0909 107-Other.
GC0909     MOVE ALL LD-Horiz-Line TO Horizontal-Line.
GC0410     MOVE CONCATENATE(' OCic for ',
GC0410                      TRIM(OS-Type-Literal,Trailing),
GC0410                      ' Copyright (C) 2009-2010, Gary L. Cutler,',
GC0410                      ' GPL')
GC0410       TO Output-Message.
GC0909     .
GC0909
       109-Done.
           EXIT.
      /
       200-Let-User-Set-Switches SECTION.
      *****************************************************************
      ** Show the user the current switch settings and allow them to **
      ** be changed.                                                 **
      *****************************************************************

       201-Init.
           SET 88-Switch-Changes TO TRUE
           .

       202-Show-And-Change-Switches.
           PERFORM UNTIL 88-No-Switch-Changes
               ACCEPT
                   Switches-Screen
               END-ACCEPT
               IF COB-CRT-STATUS > 0
                   EVALUATE COB-CRT-STATUS
                       WHEN COB-SCR-F1
                           IF S-DEBUG = SPACE
                               MOVE Selection-Char TO S-DEBUG
                           ELSE
                               MOVE ' ' TO S-DEBUG
                           END-IF
                       WHEN COB-SCR-F2
                           IF S-DLL = SPACE
                               MOVE Selection-Char TO S-DLL
                           ELSE
                               MOVE ' ' TO S-DLL
                           END-IF
                       WHEN COB-SCR-F3
                           IF S-SUBROUTINE = SPACE
                               MOVE Selection-Char TO S-SUBROUTINE
                               MOVE ' ' TO S-EXECUTE
                           ELSE
                               MOVE ' ' TO S-SUBROUTINE
                           END-IF
                       WHEN COB-SCR-F4
                           IF  S-EXECUTE = SPACE
                           AND S-SUBROUTINE = SPACE
                               MOVE Selection-Char TO S-EXECUTE
                           ELSE
                               MOVE ' ' TO S-EXECUTE
                           END-IF
                       WHEN COB-SCR-F5
                           IF  S-NOTRUNC = SPACE
                               MOVE Selection-Char TO S-NOTRUNC
                           ELSE
                               MOVE ' ' TO S-NOTRUNC
                           END-IF
                       WHEN COB-SCR-F6
                           IF  S-TRACE = SPACE
                               MOVE Selection-Char TO S-TRACE
                               MOVE ' ' TO S-TRACEALL
                           ELSE
                               MOVE ' ' TO S-TRACE
                           END-IF
                       WHEN COB-SCR-F7
                           IF  S-TRACEALL = SPACE
                               MOVE Selection-Char TO S-TRACEALL
                               MOVE ' ' TO S-TRACE
                           ELSE
                               MOVE ' ' TO S-TRACEALL
                           END-IF
GC0410                 WHEN COB-SCR-F8
GC0410                     IF S-SOURCE = SPACE
GC0410                         MOVE Selection-Char TO S-SOURCE
GC0410                     ELSE
GC0410                         MOVE ' ' TO S-SOURCE
GC0410                     END-IF
GC0410                 WHEN COB-SCR-F9
GC0410                     IF S-XREF = SPACE
GC0410                         MOVE Selection-Char TO S-XREF
GC0410                     ELSE
GC0410                         MOVE ' ' TO S-XREF
GC0410                     END-IF
                       WHEN COB-SCR-ESC
                           PERFORM 900-Terminate
GC0310                 WHEN CK-S-F1
                           MOVE SPACES         TO S-CfgS
                           MOVE Selection-Char TO S-Cfg-BS2000
GC0310                 WHEN CK-S-F2
                           MOVE SPACES         TO S-CfgS
                           MOVE Selection-Char TO S-Cfg-COBOL85
GC0310                 WHEN CK-S-F3
                           MOVE SPACES         TO S-CfgS
                           MOVE Selection-Char TO S-Cfg-COBOL2002
GC0310                 WHEN CK-S-F4
                           MOVE SPACES         TO S-CfgS
                           MOVE Selection-Char TO S-Cfg-DEFAULT
GC0310                 WHEN CK-S-F5
                           MOVE SPACES         TO S-CfgS
                           MOVE Selection-Char TO S-Cfg-IBM
GC0310                 WHEN CK-S-F6
                           MOVE SPACES         TO S-CfgS
                           MOVE Selection-Char TO S-Cfg-MF
GC0310                 WHEN CK-S-F7
                           MOVE SPACES         TO S-CfgS
                           MOVE Selection-Char TO S-Cfg-MVS
                       WHEN OTHER
                           MOVE 'An unsupported key was pressed'
                             TO Output-Message
                   END-EVALUATE
               ELSE
                   SET 88-No-Switch-Changes TO TRUE
               END-IF
           END-PERFORM
           .

       209-Done.
           EXIT.
      /
       210-Run-Compiler SECTION.
      *****************************************************************
      ** Run the compiler using the switch settings we've prepared.  **
      *****************************************************************

       211-Init.
           MOVE SPACES TO Cmd
                          Cobc-Cmd
                          Output-Message
           DISPLAY
               Switches-Screen
           END-DISPLAY
           MOVE 1 TO I
           EVALUATE TRUE
               WHEN S-Cfg-BS2000 NOT = SPACES
                   MOVE 'bs2000' TO Config-File
               WHEN S-Cfg-COBOL85  NOT = SPACES
                   MOVE 'cobol85' TO Config-File
               WHEN  S-Cfg-COBOL2002  NOT = SPACES
                   MOVE 'cobol2002' TO Config-File
               WHEN  S-Cfg-IBM  NOT = SPACES
                   MOVE 'ibm' TO Config-File
               WHEN  S-Cfg-MF  NOT = SPACES
                   MOVE 'mf' TO Config-File
               WHEN  S-Cfg-MVS  NOT = SPACES
                   MOVE 'mvs' TO Config-File
               WHEN OTHER
                   MOVE 'default' TO Config-File
           END-EVALUATE
           .

       212-Build-Compile-Command.
GC0909    MOVE SPACES TO Cobc-Cmd
GC0909     STRING 'cobc -std='
GC0909         TRIM(Config-File,TRAILING)
GC0909         ' '
GC0909         INTO Cobc-Cmd
GC0909         WITH POINTER I
GC0909     END-STRING
           IF S-SUBROUTINE NOT = ' '
               STRING '-m '
                   DELIMITED SIZE INTO Cobc-Cmd
                   WITH POINTER I
               END-STRING
           ELSE
               STRING '-x '
                   DELIMITED SIZE INTO Cobc-Cmd
                   WITH POINTER I
               END-STRING
           END-IF
           IF S-DEBUG NOT = ' '
               STRING '-fdebugging-line '
                   DELIMITED SIZE INTO Cobc-Cmd
                   WITH POINTER I
               END-STRING
           END-IF
           IF S-NOTRUNC NOT = ' '
               STRING '-fnotrunc '
                   DELIMITED SIZE INTO Cobc-Cmd
                   WITH POINTER I
               END-STRING
           END-IF
           IF S-TRACEALL NOT = ' '
GC0809         STRING '-ftraceall '
                   DELIMITED SIZE INTO Cobc-Cmd
                   WITH POINTER I
               END-STRING
           END-IF
           IF S-TRACE NOT = ' '
               STRING '-ftrace '
                   DELIMITED SIZE INTO Cobc-Cmd
                   WITH POINTER I
               END-STRING
           END-IF

GC0709     IF S-EXTRA > SPACES
GC0709         STRING ' '
GC0709                TRIM(S-Extra,TRAILING)
GC0709                ' '
GC0709                DELIMITED SIZE INTO Cobc-Cmd
GC0709                WITH POINTER I
GC0709         END-STRING
GC0709     END-IF
GC0909     STRING TRIM(Prog-File-Name,TRAILING)
GC0909         DELIMITED SIZE INTO Cobc-Cmd
GC0909         WITH POINTER I
GC0909     END-STRING
           .

       213-Run-Compiler.
GC0410     MOVE ' Compiling...' TO Output-Message
GC0410     DISPLAY
GC0410         Switches-Screen
GC0410     END-DISPLAY
GC0609     SET 88-Output-File-Avail TO TRUE
           MOVE SPACES TO Cmd
           STRING TRIM(Cobc-Cmd,TRAILING)
                  ' 2>'
                  TRIM(Cobc-Output-File,TRAILING)
                  DELIMITED SIZE
                  INTO Cmd
           END-STRING
           CALL 'SYSTEM'
               USING TRIM(Cmd,TRAILING)
           END-CALL
GC0909     IF RETURN-CODE = 0
GC0909         SET 88-Compile-OK TO TRUE
GC0909     ELSE
GC0909         SET 88-Compile-Failed TO TRUE
GC0909     END-IF
GC0909     IF 88-Compile-OK
GC0909         OPEN INPUT Cobc-Output
GC0909         READ Cobc-Output
GC0909             AT END
GC0909                 CONTINUE
GC0909             NOT AT END
GC0909                 SET 88-Compile-OK-Warn TO TRUE
GC0909         END-READ
GC0909         CLOSE Cobc-Output
GC0909     END-IF
GC0909     MOVE SPACES TO Output-Message
           IF 88-Compile-OK
GC0909         MOVE ' Compilation Was Successful' TO Output-Message
GC0909         DISPLAY
GC0909             Switches-Screen
GC0909         END-DISPLAY
GC0909         CALL 'C$SLEEP'
GC0909             USING 2
GC0909         END-CALL
GC0909         MOVE SPACES TO Output-Message
GC0609         SET 88-Complete TO TRUE
           ELSE
GC0909         DISPLAY
GC0909             Blank-Screen
GC0909         END-DISPLAY
GC0909         IF 88-Compile-OK-Warn
GC0909             DISPLAY ' Compilation was successful, but ' &
GC0909                     'warnings were generated:'
SCROLL*                AT LINE 24 COLUMN 1
SCROLL*                WITH SCROLL UP 1 LINE
GC0909             END-DISPLAY
GC0909         ELSE
GC0909             DISPLAY 'Compilation Failed:'
SCROLL*                AT LINE 24 COLUMN 1
SCROLL*                WITH SCROLL UP 1 LINE
GC0909             END-DISPLAY
GC0909         END-IF
GC0609         SET 88-Compile-Failed TO TRUE
GC0609         SET 88-Complete TO TRUE
GC0909         DISPLAY ' '
SCROLL*            AT LINE 24 COLUMN 1
SCROLL*            WITH SCROLL UP 1 LINE
GC0909         END-DISPLAY
GC0909         OPEN INPUT Cobc-Output
GC0909         PERFORM FOREVER
GC0909             READ Cobc-Output AT END
GC0909                 EXIT PERFORM
GC0909             END-READ
GC0909             DISPLAY TRIM(Cobc-Output-Rec,TRAILING)
SCROLL*                AT LINE 24 COLUMN 1
SCROLL*                WITH SCROLL UP 1 LINE
GC0909             END-DISPLAY
GC0909         END-PERFORM
GC0909         CLOSE Cobc-Output
GC0909         DISPLAY ' '
SCROLL*            AT LINE 24 COLUMN 1
SCROLL*            WITH SCROLL UP 2 LINES
GC0909         END-DISPLAY
GC0909         DISPLAY 'Press ENTER to close:'
SCROLL*            AT LINE 24 COLUMN 1
SCROLL*            WITH SCROLL UP 1 LINE
GC0909         END-DISPLAY
GC0909         ACCEPT Dummy
GC0909             FROM CONSOLE
GC0909         END-ACCEPT
GC0909         DISPLAY
GC0909             Blank-Screen
GC0909         END-DISPLAY
           END-IF
           .

       219-Done.
           IF 88-Compile-Failed
               PERFORM 900-Terminate
           END-IF
           .
      /
GC0410 220-Make-Listing SECTION.
GC0410*****************************************************************
GC0410** Generate a source and/or xref listing using XREF            **
GC0410*****************************************************************
GC0410
GC0410 221-Init.
GC0410     MOVE ' Generating cross-reference listing...'
GC0410       TO Output-Message
GC0410     DISPLAY
GC0410         Switches-Screen
GC0410     END-DISPLAY
GC0410     CALL "CBL_DELETE_FILE"
GC0410         USING CONCATENATE(TRIM(Prog-Name,Trailing),".lst")
GC0410     END-CALL
GC0410     MOVE 0 TO RETURN-CODE
GC0410     .
GC0410
GC0410 213-Run-OCXref.
GC0410     MOVE SPACES TO Output-Message
GC0410     CALL 'LISTING'
GC0410         USING S-SOURCE
GC0410               S-XREF
GC0410               File-Name
GC0410         ON EXCEPTION
GC0410             MOVE ' LISTING module is not available'
GC0410               TO Output-Message
GC0410             MOVE 1 TO RETURN-CODE
GC0410     END-CALL
GC0410     IF RETURN-CODE = 0
GC0410         MOVE ' Listing generated'
GC0410           TO Output-Message
GC0410         IF OS-Windows OR OS-Cygwin
GC0410             MOVE SPACES TO Cmd
GC0410             STRING
GC0410                 'cmd /c '
GC0410                 TRIM(Prog-Name,TRAILING)
GC0410                 '.lst'
GC0410                 DELIMITED SIZE INTO Cmd
GC0410             END-STRING
GC0410             CALL 'SYSTEM'
GC0410                 USING TRIM(Cmd,TRAILING)
GC0410             END-CALL
GC0410         END-IF
GC0410     ELSE
GC0410         IF Output-Message = SPACES
GC0410             MOVE ' Listing generation failed'
GC0410               TO Output-Message
GC0410         END-IF
GC0410     END-IF
GC0410     DISPLAY
GC0410         Switches-Screen
GC0410     END-DISPLAY
GC0410     CALL 'C$SLEEP'
GC0410         USING 2
GC0410     END-CALL
GC0410     .
      /
       230-Run-Program SECTION.
      *****************************************************************
      ** Run the compiled program                                    **
      *****************************************************************

       232-Build-Command.
GC0909     MOVE SPACES TO Cmd
GC0909     MOVE 1 TO I
           IF S-SUBROUTINE NOT = ' '
           OR S-DLL NOT = ' '
               STRING 'cobcrun ' DELIMITED SIZE
                      INTO Cmd
                      WITH POINTER I
               END-STRING
           END-IF
           IF Prog-Folder NOT = SPACES
GC0909         IF OS-Cygwin AND Prog-Folder (2:1) = ':'
GC0909             STRING '/cygdrive/'
GC0909                 INTO Cmd
GC0909                 WITH POINTER I
GC0909             END-STRING
GC0909             STRING LOWER-CASE(Prog-Folder (1:1))
GC0909                 INTO Cmd
GC0909                 WITH POINTER I
GC0909             END-STRING
GC0909             PERFORM VARYING J FROM 3 BY 1
GC0909                       UNTIL J > LENGTH(TRIM(Prog-Folder))
GC0909                 IF Prog-Folder (J:1) = '\'
GC0909                     STRING '/'
GC0909                         INTO Cmd
GC0909                         WITH POINTER I
GC0909                     END-STRING
GC0909                 ELSE
GC0909                     STRING Prog-Folder (J:1)
GC0909                         INTO Cmd
GC0909                         WITH POINTER I
GC0909                     END-STRING
GC0909                 END-IF
GC0909             END-PERFORM
GC0909         ELSE
GC0410             STRING '"' TRIM(Prog-Folder,TRAILING)
GC0909                 INTO Cmd
GC0909                 WITH POINTER I
GC0909             END-STRING
GC0909         END-IF
GC0909         STRING Dir-Char
GC0909             INTO Cmd
GC0909             WITH POINTER I
GC0909         END-STRING
GC0909     ELSE
GC0909         IF OS-Cygwin OR OS-UNIX
GC0909             STRING './'
GC0909                 INTO Cmd
GC0909                 WITH POINTER I
GC0909             END-STRING
GC0909         END-IF
           END-IF
GC0909     STRING TRIM(Prog-Name,TRAILING)
GC0909         INTO Cmd
GC0909         WITH POINTER I
GC0909     END-STRING
GC0909     IF S-SUBROUTINE = ' '
GC0909     AND S-DLL NOT = ' '
GC0909         STRING '.exe' DELIMITED SIZE
                      INTO Cmd
                      WITH POINTER I
               END-STRING
           END-IF
           IF S-ARGS NOT = SPACES
GC0809         STRING ' ' TRIM(S-ARGS,TRAILING)
                   INTO Cmd
                   WITH POINTER I
               END-STRING
           END-IF
           IF OS-Unknown OR OS-Windows
GC0410         STRING '"&&pause'
                   INTO Cmd
                   WITH POINTER I
               END-STRING
           ELSE
               STRING ';echo "Press ENTER to close...";read'
                   INTO Cmd
                   WITH POINTER I
               END-STRING
           END-IF
           .

       233-Run-Program.
GC0909     DISPLAY
GC0909         Blank-Screen
GC0909     END-DISPLAY

           CALL 'SYSTEM'
               USING TRIM(Cmd,TRAILING)
           END-CALL
           PERFORM 900-Terminate
           .

       239-Done.
           EXIT.
      /
       900-Terminate SECTION.
      *****************************************************************
      ** Display a message and halt the program                      **
      *****************************************************************

       901-Display-Message.
GC0909     IF Output-Message > SPACES
GC0909         DISPLAY
GC0909             Switches-Screen
GC0909         END-DISPLAY
GC0909         CALL 'C$SLEEP'
GC0909             USING 2
GC0909         END-CALL
GC0909     END-IF
           DISPLAY
               Blank-Screen
           END-DISPLAY
           .

       909-Done.
           GOBACK
           .

       END PROGRAM OCic.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.  GETOSTYPE.
      *****************************************************************
      ** This subprogram determine the OS type the program is run-   **
      ** ning under, passing that result back in RETURN-CODE as fol- **
      ** lows:                                                       **
      **                                                             **
      ** 0:   Cannot be determined                                   **
      ** 1:   Native Windows or Windows/MinGW                        **
      ** 2:   Cygwin                                                 **
      ** 3:   UNIX/Linux/MacOS                                       **
      *****************************************************************
      **  DATE  CHANGE DESCRIPTION                                   **
      ** ====== ==================================================== **
      ** GC0909 Initial coding.                                      **
      *****************************************************************
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           FUNCTION ALL INTRINSIC.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Env-Path                    PIC X(1024).
       01  Tally                       USAGE BINARY-LONG.
       PROCEDURE DIVISION.
       000-Main SECTION.
       010-Get-TEMP-Var.
           MOVE SPACES TO Env-Path
           ACCEPT Env-Path
               FROM ENVIRONMENT "PATH"
               ON EXCEPTION
                   MOVE 0 TO RETURN-CODE
                   GOBACK
           END-ACCEPT
           IF Env-Path = SPACES
               MOVE 0 TO RETURN-CODE
           ELSE
               MOVE 0 TO Tally
               INSPECT Env-Path
                   TALLYING Tally FOR ALL ";"
               IF Tally = 0 *> Must be some form of UNIX
                   MOVE 0 TO Tally
                   INSPECT Env-Path
                       TALLYING TALLY FOR ALL "/cygdrive/"
                   IF Tally = 0 *> UNIX/MacOS
                       MOVE 3 TO RETURN-CODE
                   ELSE *> Cygwin
                       MOVE 2 TO RETURN-CODE
                   END-IF
               ELSE *> Assume Windows[/MinGW]
                   MOVE 1 TO RETURN-CODE
               END-IF
           END-IF
           GOBACK
           .
       END PROGRAM GETOSTYPE.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.  CHECKSOURCE.
      *****************************************************************
      ** This subprogram will scan a line of source code it is given **
      ** looking for "LINKAGE SECTION" or "IDENTIFICATION DIVISION". **
      **                                                             **
      **  ****NOTE****   ****NOTE****    ****NOTE****   ****NOTE***  **
      **                                                             **
      ** These two strings must be found IN THEIR ENTIRETY within    **
      ** the 1st 80 columns of program source records, and cannot    **
      ** follow either a "*>" sequence OR a "*" in col 7.            **
      *****************************************************************
      **  DATE  CHANGE DESCRIPTION                                   **
      ** ====== ==================================================== **
      ** GC0809 Initial coding.                                      **
      *****************************************************************
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           FUNCTION ALL INTRINSIC.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Compressed-Src.
           05 CS-Char                  OCCURS 80 TIMES PIC X(1).

       01  Flags.
           05 F-Found-SPACE            PIC X(1).
              88 88-Skipping-SPACE     VALUE 'Y'.
              88 88-Not-Skipping-SPACE VALUE 'N'.

       01  I                           USAGE BINARY-CHAR.

       01  J                           USAGE BINARY-CHAR.
       LINKAGE SECTION.
       01  Argument-1.
           02 A1-Char                  OCCURS 80 TIMES PIC X(1).

       01  Argument-2                  PIC X(1).
           88 88-A2-LINKAGE-SECTION         VALUE 'L'.
           88 88-A2-IDENTIFICATION-DIVISION VALUE 'I'.
           88 88-A2-Nothing-Special         VALUE ' '.
       PROCEDURE DIVISION USING Argument-1, Argument-2.
       000-Main SECTION.

       010-Initialize.
           SET 88-A2-Nothing-Special TO TRUE
           IF A1-Char (7) = '*'
               GOBACK
           END-IF
           .

       020-Compress-Multiple-SPACES.
           SET 88-Not-Skipping-SPACE TO TRUE
           MOVE 0 TO J
           MOVE SPACES TO Compressed-Src
           PERFORM VARYING I FROM 1 BY 1
                     UNTIL I > 80
               IF A1-Char (I) = SPACE
                   IF 88-Not-Skipping-SPACE
                       ADD 1 TO J
                       MOVE UPPER-CASE(A1-Char (I)) TO CS-Char (J)
                       SET 88-Skipping-SPACE TO TRUE
                   END-IF
               ELSE
                   SET 88-Not-Skipping-SPACE TO TRUE
                   ADD 1 TO J
                   MOVE A1-Char (I) TO CS-Char (J)
               END-IF
           END-PERFORM
           .

       030-Scan-Compressed-Src.
           PERFORM VARYING I FROM 1 BY 1
                     UNTIL I > 66
               EVALUATE TRUE
                   WHEN CS-Char (I) = '*'
                       IF Compressed-Src (I : 2) = '*>'
                           GOBACK
                       END-IF
                   WHEN (CS-Char (I) = 'L') AND (I < 66)
                       IF Compressed-Src (I : 15) = 'LINKAGE SECTION'
                           SET 88-A2-LINKAGE-SECTION TO TRUE
                           GOBACK
                       END-IF
                   WHEN (CS-Char (I) = 'I') AND (I < 58)
                       IF Compressed-Src (I : 23) = 'IDENTIFICATION ' &
                                                       'DIVISION'
                           SET 88-A2-IDENTIFICATION-DIVISION TO TRUE
                           GOBACK
                       END-IF
               END-EVALUATE
           END-PERFORM
           .

       099-Never-Found-Either-One.
           GOBACK
           .
       END PROGRAM CHECKSOURCE.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.  LISTING.
      *****************************************************************
      ** This subprogram generates a cross-reference listing of an   **
      ** OpenCOBOL program.                                          **
      **                                                             **
      ** Linkage:      CALL "LISTING" USING <source>                 **
      **                                    <xref>                   **
      **                                    <filename>               **
      **                                                             **
      **               Where:                                        **
      **                  <source>   is a PIC X(1) flag indicating   **
      **                             whether or not a source listing **
      **                             should be produced (space=NO,   **
      **                             non-space=yes)                  **
      **                  <xref>     is a PIC X(1) flag indicating   **
      **                             whether or not an xref listing  **
      **                             should be produced (space=NO,   **
      **                             non-space=yes)                  **
      **                  <filename> is the [path]filename of the    **
      **                             program being listed and/or     **
      **                             xreffed in a PIC X(256) form.   **
      *****************************************************************
      **                                                             **
      ** AUTHOR:       GARY L. CUTLER                                **
      **               CutlerGL@gmail.com                            **
      **               Copyright (C) 2010, Gary L. Cutler, GPL       **
      **                                                             **
      ** DATE-WRITTEN: April 1, 2010                                 **
      **                                                             **
      *****************************************************************
      **  DATE  CHANGE DESCRIPTION                                   **
      ** ====== ==================================================== **
      ** GC0410 Initial coding                                       **
      ** GC0710 Handle duplicate data names (i.e. "CORRESPONDING" or **
      **        qualified items) better; ignore "END PROGRAM" recs   **
      **        so program name doesn't appear in listing.           **
      *****************************************************************
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           FUNCTION ALL INTRINSIC.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT Expand-Code          ASSIGN TO Expanded-Src-Filename
                                       ORGANIZATION IS LINE SEQUENTIAL.
           SELECT Report-File          ASSIGN TO Report-Filename
                                       ORGANIZATION IS LINE SEQUENTIAL.
           SELECT Sort-File            ASSIGN TO DISK.
           SELECT Source-Code          ASSIGN TO Src-Filename
                                       ORGANIZATION IS LINE SEQUENTIAL.
       DATA DIVISION.
       FILE SECTION.
       FD  Expand-Code.
       01  Expand-Code-Rec.
           05 ECR-1                    PIC X.
           05 ECR-2-256                PIC X(256).
       01  Expand-Code-Rec-Alt.
           05 ECR-1-128                PIC X(128).
           05 ECR-129-256              PIC X(128).

       FD  Report-File.
       01  Report-Rec                  PIC X(135).

       SD  Sort-File.
       01  Sort-Rec.
           05 SR-Prog-ID               PIC X(15).
           05 SR-Token-UC              PIC X(32).
           05 SR-Token                 PIC X(32).
           05 SR-Section               PIC X(15).
           05 SR-Line-No-Def           PIC 9(6).
           05 SR-Reference.
              10 SR-Line-No-Ref        PIC 9(6).
              10 SR-Ref-Flag           PIC X(1).

       FD  Source-Code.
       01  Source-Code-Rec.
GC0410     05 SCR-1-128.
GC0410        10 FILLER                PIC X(6).
GC0410        10 SCR-7                 PIC X(1).
GC0410        10 FILLER                PIC X(121).
           05 SCR-129-256              PIC X(128).

       WORKING-STORAGE SECTION.
       78  Line-Nos-Per-Rec            VALUE 8.

       01  Cmd                         PIC X(256).

       01  Delim                       PIC X(2).

       01  Detail-Line-S.
           05 DLS-Line-No              PIC ZZZZZ9.
           05 FILLER                   PIC X(1).
           05 DLS-Statement            PIC X(128).

       01  Detail-Line-X.
           05 DLX-Prog-ID              PIC X(15).
           05 FILLER                   PIC X(1).
           05 DLX-Token                PIC X(32).
           05 FILLER                   PIC X(1).
           05 DLX-Line-No-Def          PIC ZZZZZ9.
           05 FILLER                   PIC X(1).
           05 DLX-Section              PIC X(15).
           05 FILLER                   PIC X(1).
           05 DLX-Reference            OCCURS Line-Nos-Per-Rec TIMES.
              10 DLX-Line-No-Ref       PIC ZZZZZ9.
              10 DLX-Ref-Flag          PIC X(1).
              10 FILLER                PIC X(1).

       01  Dummy                       PIC X(1).

       01  Env-TEMP                    PIC X(256).

       01  Expanded-Src-Filename       PIC X(256).

       01  Filename                    PIC X(256).

       01  Flags.
GC0710     05 F-Duplicate              PIC X(1).
           05 F-First-Record           PIC X(1).
           05 F-In-Which-Pgm           PIC X(1).
              88 In-Main-Module        VALUE 'M'.
              88 In-Copybook           VALUE 'C'.
           05 F-Last-Token-Ended-Sent  PIC X(1).
           05 F-Processing-PICTURE     PIC X(1).
           05 F-Token-Ended-Sentence   PIC X(1).
GC0710     05 F-Verb-Has-Been-Found    PIC X(1).

       01  Group-Indicators.
           05 GI-Prog-ID               PIC X(15).
           05 GI-Token                 PIC X(32).

       01  Heading-1S.
           05 FILLER                   PIC X(125) VALUE
              "OpenCOBOL 1.1 06FEB2009 Source Listing - " &
              "OCic Copyright (C) 2009-2010, Gary L. Cutler, GPL".
           05 H1S-Date                 PIC 9999/99/99.

       01  Heading-1X.
           05 FILLER                   PIC X(125) VALUE
              "OpenCOBOL 1.1 06FEB2009 Cross-Reference Listing - " &
              "OCic Copyright (C) 2009-2010, Gary L. Cutler, GPL".
           05 H1X-Date                 PIC 9999/99/99.

       01  Heading-2                   PIC X(135).

       01  Heading-4S                  PIC X(16) VALUE
           "Line   Statement".

       01  Heading-4X                  PIC X(96) VALUE
           "PROGRAM-ID      Identifier/Register/Function     Defn   Wher
      -    "e Defined   References (* = Updated)".

       01  Heading-5S                  PIC X(135) VALUE
           "====== =====================================================
      -    "============================================================
      -    "===============".

       01  Heading-5X                  PIC X(135) VALUE
           "=============== ================================ ====== ====
      -    "=========== ================================================
      -    "===============".

       01  Held-Reference              PIC X(100).

       01  I                           USAGE BINARY-LONG.

       01  J                           USAGE BINARY-LONG.

       01  Lines-Left                  USAGE BINARY-LONG.

       01  Lines-Per-Page              USAGE BINARY-LONG.

       01  Lines-Per-Page-ENV          PIC X(256).

       01  Num-UserNames               USAGE BINARY-LONG.

       01  PIC-X10                     PIC X(10).

       01  PIC-X32                     PIC X(32).

       01  PIC-X256                    PIC X(256).

       01  Program-Path                PIC X(256).

       01  Report-Filename             PIC X(256).

       01  Reserved-Words.
           05 FILLER PIC X(33) VALUE "IABS".
           05 FILLER PIC X(33) VALUE "VACCEPT".
           05 FILLER PIC X(33) VALUE " ACCESS".
           05 FILLER PIC X(33) VALUE "IACOS".
           05 FILLER PIC X(33) VALUE " ACTIVE-CLASS".
           05 FILLER PIC X(33) VALUE "VADD".
           05 FILLER PIC X(33) VALUE " ADDRESS".
           05 FILLER PIC X(33) VALUE " ADVANCING".
           05 FILLER PIC X(33) VALUE "KAFTER".
           05 FILLER PIC X(33) VALUE " ALIGNED".
           05 FILLER PIC X(33) VALUE " ALL".
           05 FILLER PIC X(33) VALUE "VALLOCATE".
           05 FILLER PIC X(33) VALUE " ALPHABET".
           05 FILLER PIC X(33) VALUE " ALPHABETIC".
           05 FILLER PIC X(33) VALUE " ALPHABETIC-LOWER".
           05 FILLER PIC X(33) VALUE " ALPHABETIC-UPPER".
           05 FILLER PIC X(33) VALUE " ALPHANUMERIC".
           05 FILLER PIC X(33) VALUE " ALPHANUMERIC-EDITED".
           05 FILLER PIC X(33) VALUE " ALSO".
           05 FILLER PIC X(33) VALUE "VALTER".
           05 FILLER PIC X(33) VALUE " ALTERNATE".
           05 FILLER PIC X(33) VALUE " AND".
           05 FILLER PIC X(33) VALUE "IANNUITY".
           05 FILLER PIC X(33) VALUE " ANY".
           05 FILLER PIC X(33) VALUE " ANYCASE".
           05 FILLER PIC X(33) VALUE " ARE".
           05 FILLER PIC X(33) VALUE " AREA".
           05 FILLER PIC X(33) VALUE " AREAS".
           05 FILLER PIC X(33) VALUE " ARGUMENT-NUMBER".
           05 FILLER PIC X(33) VALUE " ARGUMENT-VALUE".
           05 FILLER PIC X(33) VALUE " AS".
           05 FILLER PIC X(33) VALUE " ASCENDING".
           05 FILLER PIC X(33) VALUE "IASIN".
           05 FILLER PIC X(33) VALUE " ASSIGN".
           05 FILLER PIC X(33) VALUE " AT".
           05 FILLER PIC X(33) VALUE "IATAN".
           05 FILLER PIC X(33) VALUE " AUTHOR".
           05 FILLER PIC X(33) VALUE " AUTO".
           05 FILLER PIC X(33) VALUE " AUTO-SKIP".
           05 FILLER PIC X(33) VALUE " AUTOMATIC".
           05 FILLER PIC X(33) VALUE " AUTOTERMINATE".
           05 FILLER PIC X(33) VALUE " BACKGROUND-COLOR".
           05 FILLER PIC X(33) VALUE " BASED".
           05 FILLER PIC X(33) VALUE " BEEP".
           05 FILLER PIC X(33) VALUE " BEFORE".
           05 FILLER PIC X(33) VALUE " BELL".
           05 FILLER PIC X(33) VALUE " BINARY".
           05 FILLER PIC X(33) VALUE " BINARY-C-LONG".
           05 FILLER PIC X(33) VALUE " BINARY-CHAR".
           05 FILLER PIC X(33) VALUE " BINARY-DOUBLE".
           05 FILLER PIC X(33) VALUE " BINARY-LONG".
           05 FILLER PIC X(33) VALUE " BINARY-SHORT".
           05 FILLER PIC X(33) VALUE " BIT".
           05 FILLER PIC X(33) VALUE " BLANK".
           05 FILLER PIC X(33) VALUE " BLINK".
           05 FILLER PIC X(33) VALUE " BLOCK".
           05 FILLER PIC X(33) VALUE " BOOLEAN".
           05 FILLER PIC X(33) VALUE " BOTTOM".
           05 FILLER PIC X(33) VALUE "YBY".
           05 FILLER PIC X(33) VALUE "IBYTE-LENGTH".
           05 FILLER PIC X(33) VALUE "MC01".
           05 FILLER PIC X(33) VALUE "MC02".
           05 FILLER PIC X(33) VALUE "MC03".
           05 FILLER PIC X(33) VALUE "MC04".
           05 FILLER PIC X(33) VALUE "MC05".
           05 FILLER PIC X(33) VALUE "MC06".
           05 FILLER PIC X(33) VALUE "MC07".
           05 FILLER PIC X(33) VALUE "MC08".
           05 FILLER PIC X(33) VALUE "MC09".
           05 FILLER PIC X(33) VALUE "MC10".
           05 FILLER PIC X(33) VALUE "MC11".
           05 FILLER PIC X(33) VALUE "MC12".
           05 FILLER PIC X(33) VALUE "VCALL".
           05 FILLER PIC X(33) VALUE "VCANCEL".
           05 FILLER PIC X(33) VALUE " CF".
           05 FILLER PIC X(33) VALUE " CH".
           05 FILLER PIC X(33) VALUE " CHAINING".
           05 FILLER PIC X(33) VALUE "ICHAR".
           05 FILLER PIC X(33) VALUE " CHARACTER".
           05 FILLER PIC X(33) VALUE " CHARACTERS".
           05 FILLER PIC X(33) VALUE " CLASS".
           05 FILLER PIC X(33) VALUE " CLASS-ID".
           05 FILLER PIC X(33) VALUE "VCLOSE".
           05 FILLER PIC X(33) VALUE "ICOB-CRT-STATUS".
           05 FILLER PIC X(33) VALUE " CODE".
           05 FILLER PIC X(33) VALUE " CODE-SET".
           05 FILLER PIC X(33) VALUE " COL".
           05 FILLER PIC X(33) VALUE " COLLATING".
           05 FILLER PIC X(33) VALUE " COLS".
           05 FILLER PIC X(33) VALUE " COLUMN".
           05 FILLER PIC X(33) VALUE " COLUMNS".
           05 FILLER PIC X(33) VALUE "ICOMBINED-DATETIME".
           05 FILLER PIC X(33) VALUE " COMMA".
           05 FILLER PIC X(33) VALUE " COMMAND-LINE".
           05 FILLER PIC X(33) VALUE "VCOMMIT".
           05 FILLER PIC X(33) VALUE " COMMON".
           05 FILLER PIC X(33) VALUE " COMP".
           05 FILLER PIC X(33) VALUE " COMP-1".
           05 FILLER PIC X(33) VALUE " COMP-2".
           05 FILLER PIC X(33) VALUE " COMP-3".
           05 FILLER PIC X(33) VALUE " COMP-4".
           05 FILLER PIC X(33) VALUE " COMP-5".
           05 FILLER PIC X(33) VALUE " COMP-X".
           05 FILLER PIC X(33) VALUE " COMPUTATIONAL".
           05 FILLER PIC X(33) VALUE " COMPUTATIONAL-1".
           05 FILLER PIC X(33) VALUE " COMPUTATIONAL-2".
           05 FILLER PIC X(33) VALUE " COMPUTATIONAL-3".
           05 FILLER PIC X(33) VALUE " COMPUTATIONAL-4".
           05 FILLER PIC X(33) VALUE " COMPUTATIONAL-5".
           05 FILLER PIC X(33) VALUE " COMPUTATIONAL-X".
           05 FILLER PIC X(33) VALUE "VCOMPUTE".
           05 FILLER PIC X(33) VALUE "ICONCATENATE".
           05 FILLER PIC X(33) VALUE " CONDITION".
           05 FILLER PIC X(33) VALUE "KCONFIGURATION".
           05 FILLER PIC X(33) VALUE "MCONSOLE".
           05 FILLER PIC X(33) VALUE " CONSTANT".
           05 FILLER PIC X(33) VALUE " CONTAINS".
           05 FILLER PIC X(33) VALUE " CONTENT".
           05 FILLER PIC X(33) VALUE "VCONTINUE".
           05 FILLER PIC X(33) VALUE " CONTROL".
           05 FILLER PIC X(33) VALUE " CONTROLS".
           05 FILLER PIC X(33) VALUE "KCONVERTING".
           05 FILLER PIC X(33) VALUE " COPY".
           05 FILLER PIC X(33) VALUE " CORR".
           05 FILLER PIC X(33) VALUE " CORRESPONDING".
           05 FILLER PIC X(33) VALUE "ICOS".
           05 FILLER PIC X(33) VALUE "KCOUNT".
           05 FILLER PIC X(33) VALUE " CRT".
           05 FILLER PIC X(33) VALUE " CURRENCY".
           05 FILLER PIC X(33) VALUE "ICURRENT-DATE".
           05 FILLER PIC X(33) VALUE " CURSOR".
           05 FILLER PIC X(33) VALUE " CYCLE".
           05 FILLER PIC X(33) VALUE "KDATA".
           05 FILLER PIC X(33) VALUE " DATA-POINTER".
           05 FILLER PIC X(33) VALUE " DATE".
           05 FILLER PIC X(33) VALUE " DATE-COMPILED".
           05 FILLER PIC X(33) VALUE " DATE-MODIFIED".
           05 FILLER PIC X(33) VALUE "IDATE-OF-INTEGER".
           05 FILLER PIC X(33) VALUE "IDATE-TO-YYYYMMDD".
           05 FILLER PIC X(33) VALUE " DATE-WRITTEN".
           05 FILLER PIC X(33) VALUE " DAY".
           05 FILLER PIC X(33) VALUE "IDAY-OF-INTEGER".
           05 FILLER PIC X(33) VALUE " DAY-OF-WEEK".
           05 FILLER PIC X(33) VALUE "IDAY-TO-YYYYDDD".
           05 FILLER PIC X(33) VALUE " DE".
           05 FILLER PIC X(33) VALUE " DEBUGGING".
           05 FILLER PIC X(33) VALUE " DECIMAL-POINT".
           05 FILLER PIC X(33) VALUE " DECLARATIVES".
           05 FILLER PIC X(33) VALUE " DEFAULT".
           05 FILLER PIC X(33) VALUE "VDELETE".
           05 FILLER PIC X(33) VALUE " DELIMITED".
           05 FILLER PIC X(33) VALUE "KDELIMITER".
           05 FILLER PIC X(33) VALUE " DEPENDING".
           05 FILLER PIC X(33) VALUE " DESCENDING".
           05 FILLER PIC X(33) VALUE " DESTINATION".
           05 FILLER PIC X(33) VALUE " DETAIL".
           05 FILLER PIC X(33) VALUE " DISABLE".
           05 FILLER PIC X(33) VALUE " DISK".
           05 FILLER PIC X(33) VALUE "VDISPLAY".
           05 FILLER PIC X(33) VALUE "VDIVIDE".
           05 FILLER PIC X(33) VALUE "KDIVISION".
           05 FILLER PIC X(33) VALUE "KDOWN".
           05 FILLER PIC X(33) VALUE " DUPLICATES".
           05 FILLER PIC X(33) VALUE " DYNAMIC".
           05 FILLER PIC X(33) VALUE "IE".
           05 FILLER PIC X(33) VALUE " EBCDIC".
           05 FILLER PIC X(33) VALUE " EC".
           05 FILLER PIC X(33) VALUE "VELSE".
GC0710     05 FILLER PIC X(33) VALUE "KEND".
           05 FILLER PIC X(33) VALUE " END-ACCEPT".
           05 FILLER PIC X(33) VALUE " END-ADD".
           05 FILLER PIC X(33) VALUE " END-CALL".
           05 FILLER PIC X(33) VALUE " END-COMPUTE".
           05 FILLER PIC X(33) VALUE " END-DELETE".
           05 FILLER PIC X(33) VALUE " END-DISPLAY".
           05 FILLER PIC X(33) VALUE " END-DIVIDE".
           05 FILLER PIC X(33) VALUE " END-EVALUATE".
           05 FILLER PIC X(33) VALUE " END-IF".
           05 FILLER PIC X(33) VALUE " END-MULTIPLY".
           05 FILLER PIC X(33) VALUE " END-OF-PAGE".
           05 FILLER PIC X(33) VALUE " END-PERFORM".
           05 FILLER PIC X(33) VALUE " END-READ".
           05 FILLER PIC X(33) VALUE " END-RETURN".
           05 FILLER PIC X(33) VALUE " END-REWRITE".
           05 FILLER PIC X(33) VALUE " END-SEARCH".
           05 FILLER PIC X(33) VALUE " END-START".
           05 FILLER PIC X(33) VALUE " END-STRING".
           05 FILLER PIC X(33) VALUE " END-SUBTRACT".
           05 FILLER PIC X(33) VALUE " END-UNSTRING".
           05 FILLER PIC X(33) VALUE " END-WRITE".
           05 FILLER PIC X(33) VALUE "VENTRY".
           05 FILLER PIC X(33) VALUE "KENVIRONMENT".
           05 FILLER PIC X(33) VALUE " ENVIRONMENT-NAME".
           05 FILLER PIC X(33) VALUE " ENVIRONMENT-VALUE".
           05 FILLER PIC X(33) VALUE " EO".
           05 FILLER PIC X(33) VALUE " EOL".
           05 FILLER PIC X(33) VALUE " EOP".
           05 FILLER PIC X(33) VALUE " EOS".
           05 FILLER PIC X(33) VALUE " EQUAL".
           05 FILLER PIC X(33) VALUE "KEQUALS".
           05 FILLER PIC X(33) VALUE " ERASE".
           05 FILLER PIC X(33) VALUE " ERROR".
           05 FILLER PIC X(33) VALUE " ESCAPE".
           05 FILLER PIC X(33) VALUE "VEVALUATE".
           05 FILLER PIC X(33) VALUE " EXCEPTION".
           05 FILLER PIC X(33) VALUE "IEXCEPTION-FILE".
           05 FILLER PIC X(33) VALUE "IEXCEPTION-LOCATION".
           05 FILLER PIC X(33) VALUE " EXCEPTION-OBJECT".
           05 FILLER PIC X(33) VALUE "IEXCEPTION-STATEMENT".
           05 FILLER PIC X(33) VALUE "IEXCEPTION-STATUS".
           05 FILLER PIC X(33) VALUE " EXCLUSIVE".
           05 FILLER PIC X(33) VALUE "VEXIT".
           05 FILLER PIC X(33) VALUE "IEXP".
           05 FILLER PIC X(33) VALUE "IEXP10".
           05 FILLER PIC X(33) VALUE " EXTEND".
           05 FILLER PIC X(33) VALUE " EXTERNAL".
           05 FILLER PIC X(33) VALUE "IFACTORIAL".
           05 FILLER PIC X(33) VALUE " FACTORY".
           05 FILLER PIC X(33) VALUE " FALSE".
           05 FILLER PIC X(33) VALUE "KFD".
           05 FILLER PIC X(33) VALUE "KFILE".
           05 FILLER PIC X(33) VALUE " FILE-CONTROL".
           05 FILLER PIC X(33) VALUE " FILE-ID".
           05 FILLER PIC X(33) VALUE " FILLER".
           05 FILLER PIC X(33) VALUE " FINAL".
           05 FILLER PIC X(33) VALUE " FIRST".
           05 FILLER PIC X(33) VALUE " FLOAT-BINARY-16".
           05 FILLER PIC X(33) VALUE " FLOAT-BINARY-34".
           05 FILLER PIC X(33) VALUE " FLOAT-BINARY-7".
           05 FILLER PIC X(33) VALUE " FLOAT-DECIMAL-16".
           05 FILLER PIC X(33) VALUE " FLOAT-DECIMAL-34".
           05 FILLER PIC X(33) VALUE " FLOAT-EXTENDED".
           05 FILLER PIC X(33) VALUE " FLOAT-LONG".
           05 FILLER PIC X(33) VALUE " FLOAT-SHORT".
           05 FILLER PIC X(33) VALUE " FOOTING".
           05 FILLER PIC X(33) VALUE " FOR".
           05 FILLER PIC X(33) VALUE " FOREGROUND-COLOR".
           05 FILLER PIC X(33) VALUE " FOREVER".
           05 FILLER PIC X(33) VALUE " FORMAT".
           05 FILLER PIC X(33) VALUE "MFORMFEED".
           05 FILLER PIC X(33) VALUE "IFRACTION-PART".
           05 FILLER PIC X(33) VALUE "VFREE".
           05 FILLER PIC X(33) VALUE " FROM".
           05 FILLER PIC X(33) VALUE " FULL".
           05 FILLER PIC X(33) VALUE " FUNCTION".
           05 FILLER PIC X(33) VALUE " FUNCTION-ID".
           05 FILLER PIC X(33) VALUE " FUNCTION-POINTER".
           05 FILLER PIC X(33) VALUE "VGENERATE".
           05 FILLER PIC X(33) VALUE " GET".
           05 FILLER PIC X(33) VALUE "KGIVING".
           05 FILLER PIC X(33) VALUE " GLOBAL".
           05 FILLER PIC X(33) VALUE "VGO".
           05 FILLER PIC X(33) VALUE "VGOBACK".
           05 FILLER PIC X(33) VALUE " GREATER".
           05 FILLER PIC X(33) VALUE " GROUP".
           05 FILLER PIC X(33) VALUE " GROUP-USAGE".
           05 FILLER PIC X(33) VALUE " HEADING".
           05 FILLER PIC X(33) VALUE " HIGH-VALUE".
           05 FILLER PIC X(33) VALUE " HIGH-VALUES".
           05 FILLER PIC X(33) VALUE " HIGHLIGHT".
           05 FILLER PIC X(33) VALUE " I-O".
           05 FILLER PIC X(33) VALUE " I-O-CONTROL".
           05 FILLER PIC X(33) VALUE "KID".
           05 FILLER PIC X(33) VALUE "KIDENTIFICATION".
           05 FILLER PIC X(33) VALUE "VIF".
           05 FILLER PIC X(33) VALUE " IGNORE".
           05 FILLER PIC X(33) VALUE " IGNORING".
           05 FILLER PIC X(33) VALUE " IN".
           05 FILLER PIC X(33) VALUE " INDEX".
           05 FILLER PIC X(33) VALUE "KINDEXED".
           05 FILLER PIC X(33) VALUE " INDICATE".
           05 FILLER PIC X(33) VALUE " INFINITY".
           05 FILLER PIC X(33) VALUE " INHERITS".
           05 FILLER PIC X(33) VALUE " INITIAL".
           05 FILLER PIC X(33) VALUE " INITIALISED".
           05 FILLER PIC X(33) VALUE "VINITIALIZE".
           05 FILLER PIC X(33) VALUE " INITIALIZED".
           05 FILLER PIC X(33) VALUE "VINITIATE".
           05 FILLER PIC X(33) VALUE " INPUT".
           05 FILLER PIC X(33) VALUE "KINPUT-OUTPUT".
           05 FILLER PIC X(33) VALUE "VINSPECT".
           05 FILLER PIC X(33) VALUE " INSTALLATION".
           05 FILLER PIC X(33) VALUE "IINTEGER".
           05 FILLER PIC X(33) VALUE "IINTEGER-OF-DATE".
           05 FILLER PIC X(33) VALUE "IINTEGER-OF-DAY".
           05 FILLER PIC X(33) VALUE "IINTEGER-PART".
           05 FILLER PIC X(33) VALUE " INTERFACE".
           05 FILLER PIC X(33) VALUE " INTERFACE-ID".
           05 FILLER PIC X(33) VALUE "KINTO".
           05 FILLER PIC X(33) VALUE " INTRINSIC".
           05 FILLER PIC X(33) VALUE " INVALID".
           05 FILLER PIC X(33) VALUE " INVOKE".
           05 FILLER PIC X(33) VALUE " IS".
           05 FILLER PIC X(33) VALUE " JUST".
           05 FILLER PIC X(33) VALUE " JUSTIFIED".
           05 FILLER PIC X(33) VALUE " KEY".
           05 FILLER PIC X(33) VALUE " LABEL".
           05 FILLER PIC X(33) VALUE " LAST".
           05 FILLER PIC X(33) VALUE " LEADING".
           05 FILLER PIC X(33) VALUE " LEFT".
           05 FILLER PIC X(33) VALUE " LEFT-JUSTIFY".
           05 FILLER PIC X(33) VALUE "ILENGTH".
           05 FILLER PIC X(33) VALUE " LESS".
           05 FILLER PIC X(33) VALUE " LIMIT".
           05 FILLER PIC X(33) VALUE " LIMITS".
           05 FILLER PIC X(33) VALUE " LINAGE".
           05 FILLER PIC X(33) VALUE "ILINAGE-COUNTER".
           05 FILLER PIC X(33) VALUE " LINE".
           05 FILLER PIC X(33) VALUE " LINE-COUNTER".
           05 FILLER PIC X(33) VALUE " LINES".
           05 FILLER PIC X(33) VALUE "KLINKAGE".
           05 FILLER PIC X(33) VALUE "KLOCAL-STORAGE".
           05 FILLER PIC X(33) VALUE " LOCALE".
           05 FILLER PIC X(33) VALUE "ILOCALE-DATE".
           05 FILLER PIC X(33) VALUE "ILOCALE-TIME".
           05 FILLER PIC X(33) VALUE "ILOCALE-TIME-FROM-SECONDS".
           05 FILLER PIC X(33) VALUE " LOCK".
           05 FILLER PIC X(33) VALUE "ILOG".
           05 FILLER PIC X(33) VALUE "ILOG10".
           05 FILLER PIC X(33) VALUE " LOW-VALUE".
           05 FILLER PIC X(33) VALUE " LOW-VALUES".
           05 FILLER PIC X(33) VALUE " LOWER".
           05 FILLER PIC X(33) VALUE "ILOWER-CASE".
           05 FILLER PIC X(33) VALUE " LOWLIGHT".
           05 FILLER PIC X(33) VALUE " MANUAL".
           05 FILLER PIC X(33) VALUE "IMAX".
           05 FILLER PIC X(33) VALUE "IMEAN".
           05 FILLER PIC X(33) VALUE "IMEDIAN".
           05 FILLER PIC X(33) VALUE " MEMORY".
           05 FILLER PIC X(33) VALUE "VMERGE".
           05 FILLER PIC X(33) VALUE " METHOD".
           05 FILLER PIC X(33) VALUE " METHOD-ID".
           05 FILLER PIC X(33) VALUE "IMIDRANGE".
           05 FILLER PIC X(33) VALUE "IMIN".
           05 FILLER PIC X(33) VALUE " MINUS".
           05 FILLER PIC X(33) VALUE "IMOD".
           05 FILLER PIC X(33) VALUE " MODE".
           05 FILLER PIC X(33) VALUE "VMOVE".
           05 FILLER PIC X(33) VALUE " MULTIPLE".
           05 FILLER PIC X(33) VALUE "VMULTIPLY".
           05 FILLER PIC X(33) VALUE " NATIONAL".
           05 FILLER PIC X(33) VALUE " NATIONAL-EDITED".
           05 FILLER PIC X(33) VALUE " NATIVE".
           05 FILLER PIC X(33) VALUE " NEGATIVE".
           05 FILLER PIC X(33) VALUE " NESTED".
           05 FILLER PIC X(33) VALUE "VNEXT".
           05 FILLER PIC X(33) VALUE " NO".
           05 FILLER PIC X(33) VALUE " NOT".
           05 FILLER PIC X(33) VALUE " NULL".
           05 FILLER PIC X(33) VALUE " NULLS".
           05 FILLER PIC X(33) VALUE " NUMBER".
           05 FILLER PIC X(33) VALUE "INUMBER-OF-CALL-PARAMETERS".
           05 FILLER PIC X(33) VALUE " NUMBERS".
           05 FILLER PIC X(33) VALUE " NUMERIC".
           05 FILLER PIC X(33) VALUE " NUMERIC-EDITED".
           05 FILLER PIC X(33) VALUE "INUMVAL".
           05 FILLER PIC X(33) VALUE "INUMVAL-C".
           05 FILLER PIC X(33) VALUE " OBJECT".
           05 FILLER PIC X(33) VALUE " OBJECT-COMPUTER".
           05 FILLER PIC X(33) VALUE " OBJECT-REFERENCE".
           05 FILLER PIC X(33) VALUE " OCCURS".
           05 FILLER PIC X(33) VALUE " OF".
           05 FILLER PIC X(33) VALUE " OFF".
           05 FILLER PIC X(33) VALUE " OMITTED".
           05 FILLER PIC X(33) VALUE " ON".
           05 FILLER PIC X(33) VALUE " ONLY".
           05 FILLER PIC X(33) VALUE "VOPEN".
           05 FILLER PIC X(33) VALUE " OPTIONAL".
           05 FILLER PIC X(33) VALUE " OPTIONS".
           05 FILLER PIC X(33) VALUE " OR".
           05 FILLER PIC X(33) VALUE "IORD".
           05 FILLER PIC X(33) VALUE "IORD-MAX".
           05 FILLER PIC X(33) VALUE "IORD-MIN".
           05 FILLER PIC X(33) VALUE " ORDER".
           05 FILLER PIC X(33) VALUE " ORGANIZATION".
           05 FILLER PIC X(33) VALUE " OTHER".
           05 FILLER PIC X(33) VALUE " OUTPUT".
           05 FILLER PIC X(33) VALUE " OVERFLOW".
           05 FILLER PIC X(33) VALUE " OVERLINE".
           05 FILLER PIC X(33) VALUE " OVERRIDE".
           05 FILLER PIC X(33) VALUE " PACKED-DECIMAL".
           05 FILLER PIC X(33) VALUE " PADDING".
           05 FILLER PIC X(33) VALUE " PAGE".
           05 FILLER PIC X(33) VALUE " PAGE-COUNTER".
           05 FILLER PIC X(33) VALUE " PARAGRAPH".
           05 FILLER PIC X(33) VALUE "VPERFORM".
           05 FILLER PIC X(33) VALUE " PF".
           05 FILLER PIC X(33) VALUE " PH".
           05 FILLER PIC X(33) VALUE "IPI".
           05 FILLER PIC X(33) VALUE "KPIC".
           05 FILLER PIC X(33) VALUE "KPICTURE".
           05 FILLER PIC X(33) VALUE " PLUS".
           05 FILLER PIC X(33) VALUE "KPOINTER".
           05 FILLER PIC X(33) VALUE " POSITION".
           05 FILLER PIC X(33) VALUE " POSITIVE".
           05 FILLER PIC X(33) VALUE " PRESENT".
           05 FILLER PIC X(33) VALUE "IPRESENT-VALUE".
           05 FILLER PIC X(33) VALUE " PREVIOUS".
           05 FILLER PIC X(33) VALUE "MPRINTER".
           05 FILLER PIC X(33) VALUE " PRINTING".
           05 FILLER PIC X(33) VALUE "KPROCEDURE".
           05 FILLER PIC X(33) VALUE " PROCEDURE-POINTER".
           05 FILLER PIC X(33) VALUE " PROCEDURES".
           05 FILLER PIC X(33) VALUE " PROCEED".
           05 FILLER PIC X(33) VALUE " PROGRAM".
           05 FILLER PIC X(33) VALUE "KPROGRAM-ID".
           05 FILLER PIC X(33) VALUE " PROGRAM-POINTER".
           05 FILLER PIC X(33) VALUE " PROMPT".
           05 FILLER PIC X(33) VALUE " PROPERTY".
           05 FILLER PIC X(33) VALUE " PROTOTYPE".
           05 FILLER PIC X(33) VALUE " QUOTE".
           05 FILLER PIC X(33) VALUE " QUOTES".
           05 FILLER PIC X(33) VALUE " RAISE".
           05 FILLER PIC X(33) VALUE " RAISING".
           05 FILLER PIC X(33) VALUE "IRANDOM".
           05 FILLER PIC X(33) VALUE "IRANGE".
           05 FILLER PIC X(33) VALUE " RD".
           05 FILLER PIC X(33) VALUE "VREAD".
           05 FILLER PIC X(33) VALUE "VREADY".
           05 FILLER PIC X(33) VALUE " RECORD".
           05 FILLER PIC X(33) VALUE " RECORDING".
           05 FILLER PIC X(33) VALUE " RECORDS".
           05 FILLER PIC X(33) VALUE " RECURSIVE".
           05 FILLER PIC X(33) VALUE "KREDEFINES".
           05 FILLER PIC X(33) VALUE " REEL".
           05 FILLER PIC X(33) VALUE " REFERENCE".
           05 FILLER PIC X(33) VALUE " RELATIVE".
           05 FILLER PIC X(33) VALUE "VRELEASE".
           05 FILLER PIC X(33) VALUE "IREM".
           05 FILLER PIC X(33) VALUE " REMAINDER".
           05 FILLER PIC X(33) VALUE " REMARKS".
           05 FILLER PIC X(33) VALUE " REMOVAL".
           05 FILLER PIC X(33) VALUE "KRENAMES".
           05 FILLER PIC X(33) VALUE "KREPLACING".
           05 FILLER PIC X(33) VALUE "KREPORT".
           05 FILLER PIC X(33) VALUE " REPORTING".
           05 FILLER PIC X(33) VALUE " REPORTS".
           05 FILLER PIC X(33) VALUE " REPOSITORY".
           05 FILLER PIC X(33) VALUE " REPRESENTS-NOT-A-NUMBER".
           05 FILLER PIC X(33) VALUE " REQUIRED".
           05 FILLER PIC X(33) VALUE " RESERVE".
           05 FILLER PIC X(33) VALUE " RESUME".
           05 FILLER PIC X(33) VALUE " RETRY".
           05 FILLER PIC X(33) VALUE "VRETURN".
           05 FILLER PIC X(33) VALUE "IRETURN-CODE".
           05 FILLER PIC X(33) VALUE "KRETURNING".
           05 FILLER PIC X(33) VALUE "IREVERSE".
           05 FILLER PIC X(33) VALUE " REVERSE-VIDEO".
           05 FILLER PIC X(33) VALUE " REWIND".
           05 FILLER PIC X(33) VALUE "VREWRITE".
           05 FILLER PIC X(33) VALUE " RF".
           05 FILLER PIC X(33) VALUE " RH".
           05 FILLER PIC X(33) VALUE " RIGHT".
           05 FILLER PIC X(33) VALUE " RIGHT-JUSTIFY".
           05 FILLER PIC X(33) VALUE "VROLLBACK".
           05 FILLER PIC X(33) VALUE " ROUNDED".
           05 FILLER PIC X(33) VALUE " RUN".
           05 FILLER PIC X(33) VALUE " SAME".
           05 FILLER PIC X(33) VALUE "KSCREEN".
           05 FILLER PIC X(33) VALUE " SCROLL".
           05 FILLER PIC X(33) VALUE "KSD".
           05 FILLER PIC X(33) VALUE "VSEARCH".
           05 FILLER PIC X(33) VALUE "ISECONDS-FROM-FORMATTED-TIME".
           05 FILLER PIC X(33) VALUE "ISECONDS-PAST-MIDNIGHT".
           05 FILLER PIC X(33) VALUE "KSECTION".
           05 FILLER PIC X(33) VALUE " SECURE".
           05 FILLER PIC X(33) VALUE " SECURITY".
           05 FILLER PIC X(33) VALUE " SEGMENT-LIMIT".
           05 FILLER PIC X(33) VALUE " SELECT".
           05 FILLER PIC X(33) VALUE " SELF".
           05 FILLER PIC X(33) VALUE " SENTENCE".
           05 FILLER PIC X(33) VALUE " SEPARATE".
           05 FILLER PIC X(33) VALUE " SEQUENCE".
           05 FILLER PIC X(33) VALUE " SEQUENTIAL".
           05 FILLER PIC X(33) VALUE "VSET".
           05 FILLER PIC X(33) VALUE " SHARING".
           05 FILLER PIC X(33) VALUE "ISIGN".
           05 FILLER PIC X(33) VALUE " SIGNED".
           05 FILLER PIC X(33) VALUE " SIGNED-INT".
           05 FILLER PIC X(33) VALUE " SIGNED-LONG".
           05 FILLER PIC X(33) VALUE " SIGNED-SHORT".
           05 FILLER PIC X(33) VALUE "ISIN".
           05 FILLER PIC X(33) VALUE " SIZE".
           05 FILLER PIC X(33) VALUE "VSORT".
           05 FILLER PIC X(33) VALUE " SORT-MERGE".
           05 FILLER PIC X(33) VALUE "ISORT-RETURN".
           05 FILLER PIC X(33) VALUE " SOURCE".
           05 FILLER PIC X(33) VALUE " SOURCE-COMPUTER".
           05 FILLER PIC X(33) VALUE " SOURCES".
           05 FILLER PIC X(33) VALUE " SPACE".
           05 FILLER PIC X(33) VALUE " SPACE-FILL".
           05 FILLER PIC X(33) VALUE " SPACES".
           05 FILLER PIC X(33) VALUE " SPECIAL-NAMES".
           05 FILLER PIC X(33) VALUE "ISQRT".
           05 FILLER PIC X(33) VALUE " STANDARD".
           05 FILLER PIC X(33) VALUE " STANDARD-1".
           05 FILLER PIC X(33) VALUE " STANDARD-2".
           05 FILLER PIC X(33) VALUE "ISTANDARD-DEVIATION".
           05 FILLER PIC X(33) VALUE "VSTART".
           05 FILLER PIC X(33) VALUE " STATUS".
           05 FILLER PIC X(33) VALUE "VSTOP".
           05 FILLER PIC X(33) VALUE "ISTORED-CHAR-LENGTH".
           05 FILLER PIC X(33) VALUE "VSTRING".
           05 FILLER PIC X(33) VALUE "ISUBSTITUTE".
           05 FILLER PIC X(33) VALUE "ISUBSTITUTE-CASE".
           05 FILLER PIC X(33) VALUE "VSUBTRACT".
           05 FILLER PIC X(33) VALUE "ISUM".
           05 FILLER PIC X(33) VALUE " SUPER".
           05 FILLER PIC X(33) VALUE "VSUPPRESS".
           05 FILLER PIC X(33) VALUE "MSWITCH-1".
           05 FILLER PIC X(33) VALUE "MSWITCH-2".
           05 FILLER PIC X(33) VALUE "MSWITCH-3".
           05 FILLER PIC X(33) VALUE "MSWITCH-4".
           05 FILLER PIC X(33) VALUE "MSWITCH-5".
           05 FILLER PIC X(33) VALUE "MSWITCH-6".
           05 FILLER PIC X(33) VALUE "MSWITCH-7".
           05 FILLER PIC X(33) VALUE "MSWITCH-8".
           05 FILLER PIC X(33) VALUE " SYMBOLIC".
           05 FILLER PIC X(33) VALUE " SYNC".
           05 FILLER PIC X(33) VALUE " SYNCHRONIZED".
           05 FILLER PIC X(33) VALUE "MSYSERR".
           05 FILLER PIC X(33) VALUE "MSYSIN".
           05 FILLER PIC X(33) VALUE "MSYSIPT".
           05 FILLER PIC X(33) VALUE "MSYSLIST".
           05 FILLER PIC X(33) VALUE "MSYSLST".
           05 FILLER PIC X(33) VALUE "MSYSOUT".
           05 FILLER PIC X(33) VALUE " SYSTEM-DEFAULT".
           05 FILLER PIC X(33) VALUE " TABLE".
           05 FILLER PIC X(33) VALUE "KTALLYING".
           05 FILLER PIC X(33) VALUE "ITAN".
           05 FILLER PIC X(33) VALUE " TAPE".
           05 FILLER PIC X(33) VALUE "VTERMINATE".
           05 FILLER PIC X(33) VALUE " TEST".
           05 FILLER PIC X(33) VALUE "ITEST-DATE-YYYYMMDD".
           05 FILLER PIC X(33) VALUE "ITEST-DAY-YYYYDDD".
           05 FILLER PIC X(33) VALUE " THAN".
           05 FILLER PIC X(33) VALUE " THEN".
           05 FILLER PIC X(33) VALUE " THROUGH".
           05 FILLER PIC X(33) VALUE " THRU".
           05 FILLER PIC X(33) VALUE " TIME".
           05 FILLER PIC X(33) VALUE " TIMES".
           05 FILLER PIC X(33) VALUE "KTO".
           05 FILLER PIC X(33) VALUE " TOP".
           05 FILLER PIC X(33) VALUE " TRAILING".
           05 FILLER PIC X(33) VALUE " TRAILING-SIGN".
           05 FILLER PIC X(33) VALUE "VTRANSFORM".
           05 FILLER PIC X(33) VALUE "ITRIM".
           05 FILLER PIC X(33) VALUE " TRUE".
           05 FILLER PIC X(33) VALUE " TYPE".
           05 FILLER PIC X(33) VALUE " TYPEDEF".
           05 FILLER PIC X(33) VALUE " UNDERLINE".
           05 FILLER PIC X(33) VALUE " UNIT".
           05 FILLER PIC X(33) VALUE " UNIVERSAL".
           05 FILLER PIC X(33) VALUE "VUNLOCK".
           05 FILLER PIC X(33) VALUE " UNSIGNED".
           05 FILLER PIC X(33) VALUE " UNSIGNED-INT".
           05 FILLER PIC X(33) VALUE " UNSIGNED-LONG".
           05 FILLER PIC X(33) VALUE " UNSIGNED-SHORT".
           05 FILLER PIC X(33) VALUE "VUNSTRING".
           05 FILLER PIC X(33) VALUE " UNTIL".
           05 FILLER PIC X(33) VALUE "KUP".
           05 FILLER PIC X(33) VALUE " UPDATE".
           05 FILLER PIC X(33) VALUE " UPON".
           05 FILLER PIC X(33) VALUE " UPPER".
           05 FILLER PIC X(33) VALUE "IUPPER-CASE".
           05 FILLER PIC X(33) VALUE " USAGE".
           05 FILLER PIC X(33) VALUE "VUSE".
           05 FILLER PIC X(33) VALUE " USER-DEFAULT".
           05 FILLER PIC X(33) VALUE "KUSING".
           05 FILLER PIC X(33) VALUE " VAL-STATUS".
           05 FILLER PIC X(33) VALUE " VALID".
           05 FILLER PIC X(33) VALUE " VALIDATE".
           05 FILLER PIC X(33) VALUE " VALIDATE-STATUS".
           05 FILLER PIC X(33) VALUE " VALUE".
           05 FILLER PIC X(33) VALUE " VALUES".
           05 FILLER PIC X(33) VALUE "IVARIANCE".
           05 FILLER PIC X(33) VALUE "KVARYING".
           05 FILLER PIC X(33) VALUE " WAIT".
           05 FILLER PIC X(33) VALUE "VWHEN".
           05 FILLER PIC X(33) VALUE "IWHEN-COMPILED".
           05 FILLER PIC X(33) VALUE " WITH".
           05 FILLER PIC X(33) VALUE " WORDS".
           05 FILLER PIC X(33) VALUE "KWORKING-STORAGE".
           05 FILLER PIC X(33) VALUE "VWRITE".
           05 FILLER PIC X(33) VALUE "IYEAR-TO-YYYY".
           05 FILLER PIC X(33) VALUE " YYYYDDD".
           05 FILLER PIC X(33) VALUE " YYYYMMDD".
           05 FILLER PIC X(33) VALUE " ZERO".
           05 FILLER PIC X(33) VALUE " ZERO-FILL".
           05 FILLER PIC X(33) VALUE " ZEROES".
           05 FILLER PIC X(33) VALUE " ZEROS".
       01  Reserved-Word-Table         REDEFINES Reserved-Words.
           05 Reserved-Word            OCCURS 591 TIMES
                                       ASCENDING KEY RW-Word
                                       INDEXED RW-Idx.
              10 RW-Type               PIC X(1).
              10 RW-Word               PIC X(32).

       01  Saved-Section               PIC X(15).

       01  Search-Token                PIC X(32).

       01  Source-Line-No              PIC 9(6).

       01  Src-Ptr                     USAGE BINARY-LONG.

       01  Syntax-Parsing-Items.
           05 SPI-Current-Char         PIC X(1).
              88 Current-Char-Is-Punct VALUE "=", "(", ")", "*", "/",
                                             "&", ";", ",", "<", ">",
                                             ":".
              88 Current-Char-Is-Quote VALUE '"', "'".
              88 Current-Char-Is-X     VALUE "x", "X".
              88 Current-Char-Is-Z     VALUE "z", "Z".
           05 SPI-Current-Division     PIC X(1).
              88 In-IDENTIFICATION-DIVISION VALUE "I", "?".
              88 In-ENVIRONMENT-DIVISION    VALUE "E".
              88 In-DATA-DIVISION           VALUE "D".
              88 In-PROCEDURE-DIVISION      VALUE "P".
           05 SPI-Current-Line-No      PIC 9(6).
           05 SPI-Current-Program-ID.
              10 FILLER                PIC X(12).
              10 SPI-CP-13-15          PIC X(3).
           05 SPI-Current-Section.
              10 SPI-CS-1              PIC X(1).
              10 SPI-CS-2-14.
                 15 FILLER             PIC X(10).
                 15 SPI-CS-11-14       PIC X(3).
              10 SPI-CS-15             PIC X(1).
           05 SPI-Current-Token        PIC X(32).
           05 SPI-Current-Token-UC     PIC X(32).
           05 SPI-Current-Verb         PIC X(12).
           05 SPI-Next-Char            PIC X(1).
              88 Next-Char-Is-Quote    VALUE '"', "'".
           05 SPI-Prior-Token          PIC X(32).
           05 SPI-Token-Type           PIC X(1).
              88 Token-Is-EOF             VALUE HIGH-VALUES.
              88 Token-Is-Identifier      VALUE "I".
              88 Token-Is-Key-Word        VALUE "K", "V".
              88 Token-Is-Literal-Alpha   VALUE "L".
              88 Token-Is-Literal-Number  VALUE "N".
              88 Token-Is-Verb            VALUE "V".
GC0710        88 Token-Is-Reserved-Word   VALUE " ".

       01  Tally                       USAGE BINARY-LONG.

       01  Todays-Date                 PIC 9(8).

       LINKAGE SECTION.
       01  Produce-Source-Listing      PIC X(1).
       01  Produce-Xref-Listing        PIC X(1).
       01  Src-Filename                PIC X(256).
      /
       PROCEDURE DIVISION USING Produce-Source-Listing
                                Produce-Xref-Listing
                                Src-Filename.
       000-Main SECTION.
       001-Init.
           PERFORM 100-Initialization
           PERFORM 200-Execute-cobc
           OPEN OUTPUT Report-File
           IF Produce-Source-Listing NOT = SPACE
               PERFORM 500-Produce-Source-Listing
           END-IF
           IF Produce-Xref-Listing NOT = SPACE
               SORT Sort-File
                   ASCENDING KEY    SR-Prog-ID
                                    SR-Token-UC
                                    SR-Line-No-Ref
                   INPUT PROCEDURE  300-Tokenize-Source
                   OUTPUT PROCEDURE 400-Produce-Xref-Listing
           END-IF
           CLOSE Report-File
           GOBACK
           .
      /
       100-Initialization SECTION.
      *****************************************************************
      ** Perform all program-wide initialization operations          **
      *****************************************************************
       101-Establish-Working-Env.
           MOVE TRIM(Src-Filename,Leading) TO Src-Filename
           ACCEPT Env-TEMP
               FROM ENVIRONMENT "TEMP"
           END-ACCEPT
           ACCEPT Lines-Per-Page-ENV
               FROM ENVIRONMENT "OCXREF_LINES"
           END-ACCEPT
           INSPECT Src-Filename REPLACING ALL "\" BY "/"
           INSPECT Env-TEMP REPLACING ALL "\" BY "/"
           MOVE Src-Filename TO Program-Path
           MOVE Program-Path TO Heading-2
           CALL "C$JUSTIFY"
               USING Heading-2, "Right"
           END-CALL
           MOVE LENGTH(TRIM(Src-Filename,Trailing)) TO I
           MOVE 0 TO J
           PERFORM UNTIL Src-Filename(I:1) = '/'
                      OR I = 0
               SUBTRACT 1 FROM I
               ADD      1 TO   J
           END-PERFORM
           UNSTRING Src-Filename((I + 1):J) DELIMITED BY "."
               INTO Filename, Dummy
           END-UNSTRING
           STRING TRIM(Env-TEMP,Trailing)
                  "/"
                  TRIM(Filename,Trailing)
                  ".i"
                  DELIMITED SIZE
                  INTO Expanded-Src-Filename
           END-STRING
           STRING Program-Path(1:I)
                  TRIM(Filename,Trailing)
                  ".lst"
                  DELIMITED SIZE
                  INTO Report-Filename
           END-STRING
           IF Lines-Per-Page-ENV NOT = SPACES
               MOVE NUMVAL(Lines-Per-Page-ENV) TO Lines-Per-Page
           ELSE
               MOVE 60 TO Lines-Per-Page
           END-IF
           ACCEPT Todays-Date
               FROM DATE YYYYMMDD
           END-ACCEPT
           MOVE Todays-Date TO H1X-Date
                               H1S-Date
           MOVE "????????????..." TO SPI-Current-Program-ID
           MOVE SPACES            TO SPI-Current-Verb
                                     Held-Reference
           MOVE "Y" TO F-First-Record
           .
      /
       200-Execute-cobc SECTION.
       201-Build-Cmd.
           STRING "cobc -E "
                  TRIM(Program-Path, Trailing)
                  " > "
                  TRIM(Expanded-Src-Filename,Trailing)
                  DELIMITED SIZE
                  INTO Cmd
           END-STRING
           CALL "SYSTEM"
               USING Cmd
           END-CALL
           IF RETURN-CODE NOT = 0
               DISPLAY
                   "Cross-reference terminated by previous errors"
                   UPON SYSERR
               END-DISPLAY
               GOBACK
           END-IF
           .

       209-Exit.
           EXIT
           .
      /
       300-Tokenize-Source SECTION.
       301-Driver.
           OPEN INPUT Expand-Code
           MOVE SPACES TO Expand-Code-Rec
           MOVE 256 TO Src-Ptr
           MOVE 0 TO Num-UserNames
                     SPI-Current-Line-No
           MOVE "?" TO SPI-Current-Division
GC0710     MOVE "N" TO F-Verb-Has-Been-Found.
           PERFORM FOREVER
               PERFORM 310-Get-Token
               IF Token-Is-EOF
                   EXIT PERFORM
               END-IF
               MOVE UPPER-CASE(SPI-Current-Token)
                 TO SPI-Current-Token-UC
               IF Token-Is-Verb
                   MOVE SPI-Current-Token-UC TO SPI-Current-Verb
                                                SPI-Prior-Token
                   IF Held-Reference NOT = SPACES
                       MOVE Held-Reference TO Sort-Rec
                       MOVE SPACES         TO Held-Reference
                       RELEASE Sort-Rec
                   END-IF
               END-IF
               EVALUATE TRUE
               WHEN In-IDENTIFICATION-DIVISION
                   PERFORM 320-IDENTIFICATION-DIVISION
               WHEN In-ENVIRONMENT-DIVISION
                   PERFORM 330-ENVIRONMENT-DIVISION
               WHEN In-DATA-DIVISION
                   PERFORM 340-DATA-DIVISION
               WHEN In-PROCEDURE-DIVISION
                   PERFORM 350-PROCEDURE-DIVISION
               END-EVALUATE
               IF Token-Is-Key-Word
                   MOVE SPI-Current-Token-UC TO SPI-Prior-Token
               END-IF
               IF F-Token-Ended-Sentence = "Y"
               AND SPI-Current-Division NOT = "I"
                   MOVE SPACES TO SPI-Prior-Token
                                  SPI-Current-Verb
               END-IF

           END-PERFORM
           CLOSE Expand-Code
           EXIT SECTION
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       310-Get-Token.
      *>-- Position to 1st non-blank character
           MOVE F-Token-Ended-Sentence TO F-Last-Token-Ended-Sent
           MOVE "N" TO F-Token-Ended-Sentence
           PERFORM UNTIL Expand-Code-Rec(Src-Ptr : 1) NOT = SPACE
               IF Src-Ptr > 255
                   READ Expand-Code AT END
                       IF Held-Reference NOT = SPACES
                           MOVE Held-Reference TO Sort-Rec
                           MOVE SPACES         TO Held-Reference
                           RELEASE Sort-Rec
                       END-IF
                       SET Token-Is-EOF TO TRUE
                       MOVE 0 TO SPI-Current-Line-No
                       EXIT PARAGRAPH
                   END-READ
                   IF ECR-1 = "#"
                       PERFORM 311-Control-Record
                   ELSE
                       PERFORM 312-Expand-Code-Record
                   END-IF
               ELSE
                   ADD 1 TO Src-Ptr
               END-IF
           END-PERFORM
      *>-- Extract token string
           MOVE Expand-Code-Rec(Src-Ptr : 1)    TO SPI-Current-Char
           MOVE Expand-Code-Rec(Src-Ptr + 1: 1) TO SPI-Next-Char
           IF SPI-Current-Char = "."
               ADD 1 TO Src-Ptr
               MOVE SPI-Current-Char TO SPI-Current-Token
               MOVE SPACE TO SPI-Token-Type
               MOVE "Y" TO F-Token-Ended-Sentence
               EXIT PARAGRAPH
           END-IF
           IF Current-Char-Is-Punct
           AND SPI-Current-Char = "="
           AND SPI-Current-Division = "P"
               ADD 1 TO Src-Ptr
               MOVE "EQUALS" TO SPI-Current-Token
               MOVE "K"      TO SPI-Token-Type
               EXIT PARAGRAPH
           END-IF
           IF Current-Char-Is-Punct *> So subscripts don't get flagged w/ "*"
           AND SPI-Current-Char = "("
           AND SPI-Current-Division = "P"
               MOVE SPACES TO SPI-Prior-Token
           END-IF
           IF Current-Char-Is-Punct
               ADD 1 TO Src-Ptr
               MOVE SPI-Current-Char TO SPI-Current-Token
               MOVE SPACE TO SPI-Token-Type
               EXIT PARAGRAPH
           END-IF
           IF Current-Char-Is-Quote
               ADD 1 TO Src-Ptr
               UNSTRING Expand-Code-Rec
                   DELIMITED BY SPI-Current-Char
                   INTO SPI-Current-Token
                   WITH POINTER Src-Ptr
               END-UNSTRING
               IF Expand-Code-Rec(Src-Ptr : 1) = "."
                   MOVE "Y" TO F-Token-Ended-Sentence
                   ADD 1 TO Src-Ptr
               END-IF
               SET Token-Is-Literal-Alpha TO TRUE
               EXIT PARAGRAPH
           END-IF
           IF Current-Char-Is-X AND Next-Char-Is-Quote
               ADD 2 TO Src-Ptr
               UNSTRING Expand-Code-Rec
                   DELIMITED BY SPI-Next-Char
                   INTO SPI-Current-Token
                   WITH POINTER Src-Ptr
               END-UNSTRING
               IF Expand-Code-Rec(Src-Ptr : 1) = "."
                   MOVE "Y" TO F-Token-Ended-Sentence
                   ADD 1 TO Src-Ptr
               END-IF
               SET Token-Is-Literal-Number TO TRUE
               EXIT PARAGRAPH
           END-IF
           IF Current-Char-Is-Z AND Next-Char-Is-Quote
               ADD 2 TO Src-Ptr
               UNSTRING Expand-Code-Rec
                   DELIMITED BY SPI-Next-Char
                   INTO SPI-Current-Token
                   WITH POINTER Src-Ptr
               END-UNSTRING
               IF Expand-Code-Rec(Src-Ptr : 1) = "."
                   MOVE "Y" TO F-Token-Ended-Sentence
                   ADD 1 TO Src-Ptr
               END-IF
               SET Token-Is-Literal-Alpha TO TRUE
               EXIT PARAGRAPH
           END-IF
           IF F-Processing-PICTURE = "Y"
               UNSTRING Expand-Code-Rec
                   DELIMITED BY ". " OR " "
                   INTO SPI-Current-Token
                   DELIMITER IN Delim
                   WITH POINTER Src-Ptr
               END-UNSTRING
               IF Delim = ". "
                   MOVE "Y" TO F-Token-Ended-Sentence
                   ADD 1 TO Src-Ptr
               END-IF
               IF UPPER-CASE(SPI-Current-Token) = "IS"
                   MOVE SPACE TO SPI-Token-Type
                   EXIT PARAGRAPH
               ELSE
                   MOVE "N" TO F-Processing-PICTURE
                   MOVE SPACE TO SPI-Token-Type
                   EXIT PARAGRAPH
               END-IF
           END-IF
           UNSTRING Expand-Code-Rec
               DELIMITED BY ". " OR " " OR "=" OR "(" OR ")" OR "*"
                                 OR "/" OR "&" OR ";" OR "," OR "<"
                                 OR ">" OR ":"
               INTO SPI-Current-Token
               DELIMITER IN Delim
               WITH POINTER Src-Ptr
           END-UNSTRING
           IF Delim = ". "
               MOVE "Y" TO F-Token-Ended-Sentence
           END-IF
           IF Delim NOT = ". " AND " "
               SUBTRACT 1 FROM Src-Ptr
           END-IF
      *>-- Classify Token
           MOVE UPPER-CASE(SPI-Current-Token) TO Search-Token
           IF Search-Token = "EQUAL" OR "EQUALS"
               MOVE "EQUALS" TO SPI-Current-Token
               MOVE "K"      TO SPI-Token-Type
               EXIT PARAGRAPH
           END-IF
           SEARCH ALL Reserved-Word
               WHEN RW-Word (RW-Idx) = Search-Token
                   MOVE RW-Type (RW-Idx) TO SPI-Token-Type
GC0710             IF Token-Is-Verb
GC0710                 MOVE "Y" TO F-Verb-Has-Been-Found
GC0710             END-IF
                   EXIT PARAGRAPH
           END-SEARCH
      *>-- Not a reserved word, must be a user name
           SET Token-Is-Identifier TO TRUE *> NEEDS EXPANSION!!!!
           PERFORM 313-Check-For-Numeric-Token
           IF Token-Is-Literal-Number
               IF  (F-Last-Token-Ended-Sent = "Y")
               AND (SPI-Current-Division = "D")
                   MOVE "LEVEL #" TO SPI-Current-Token
                   MOVE "K"       TO SPI-Token-Type
                   EXIT PARAGRAPH
               ELSE
                   EXIT PARAGRAPH
               END-IF
           END-IF
           EXIT PARAGRAPH
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       311-Control-Record.
           UNSTRING ECR-2-256
               DELIMITED BY '"'
               INTO PIC-X10, PIC-X256, Dummy
           END-UNSTRING
           INSPECT PIC-X10 REPLACING ALL '"' BY SPACE
           COMPUTE I = NUMVAL(PIC-X10) - 1
           IF TRIM(PIC-X256,Trailing) = TRIM(Program-Path,Trailing)
               MOVE I TO SPI-Current-Line-No
               SET In-Main-Module TO TRUE
               IF Saved-Section NOT = SPACES
                   MOVE Saved-Section TO SPI-Current-Section
               END-IF
           ELSE
               SET In-Copybook TO TRUE
               IF Saved-Section = SPACES
                   MOVE SPI-Current-Section TO Saved-Section
               END-IF
               MOVE LENGTH(TRIM(PIC-X256,Trailing)) TO I
               MOVE 0 TO J
               PERFORM UNTIL PIC-X256(I:1) = '/'
                          OR I = 0
                   SUBTRACT 1 FROM I
                   ADD      1 TO   J
               END-PERFORM
               UNSTRING PIC-X256((I + 1):J) DELIMITED BY "."
                   INTO Filename, Dummy
               END-UNSTRING
               MOVE "["      TO SPI-CS-1
               MOVE Filename TO SPI-CS-2-14
               IF SPI-CS-11-14 NOT = SPACES
                   MOVE "..." TO SPI-CS-11-14
               END-IF
               MOVE "]"      TO SPI-CS-15
           END-IF
           MOVE SPACES TO Expand-Code-Rec *> Force another READ
           MOVE 256    TO Src-Ptr
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       312-Expand-Code-Record.
           MOVE 1 TO Src-Ptr
           IF In-Main-Module
               ADD 1 To SPI-Current-Line-No
           END-IF
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       313-Check-For-Numeric-Token.
           MOVE SPI-Current-Token TO PIC-X32
           INSPECT PIC-X32
               REPLACING TRAILING SPACES BY "0"
           IF PIC-X32 IS NUMERIC                     *> Simple Unsigned Integer
               SET Token-Is-Literal-Number TO TRUE
               EXIT PARAGRAPH
           END-IF
           IF PIC-X32(1:1) = "+" OR "-"
               MOVE "0" TO PIC-X32(1:1)
           END-IF
           MOVE 0 TO Tally
           INSPECT PIC-X32
               TALLYING Tally FOR ALL "."
           IF Tally = 1
               INSPECT PIC-X32 REPLACING ALL "." BY "0"
           END-IF
           IF PIC-X32 IS NUMERIC
               SET Token-Is-Literal-Number TO TRUE
               EXIT PARAGRAPH
           END-IF
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       320-IDENTIFICATION-DIVISION.
GC0710     MOVE "N" TO F-Verb-Has-Been-Found
           IF Token-Is-Key-Word AND SPI-Current-Token = "DIVISION"
               MOVE SPI-Prior-Token TO SPI-Current-Division
               EXIT PARAGRAPH
           END-IF
           IF SPI-Prior-Token = "PROGRAM-ID"
               MOVE SPACES TO SPI-Prior-Token
               MOVE SPI-Current-Token TO SPI-Current-Program-ID
               IF SPI-CP-13-15 NOT = SPACES
                   MOVE "..." TO SPI-CP-13-15
               END-IF
               EXIT PARAGRAPH
           END-IF
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       330-ENVIRONMENT-DIVISION.
           IF Token-Is-Key-Word AND SPI-Current-Token = "DIVISION"
               MOVE SPI-Prior-Token TO SPI-Current-Division
               EXIT PARAGRAPH
           END-IF
           IF Token-Is-Key-Word AND SPI-Current-Token = "SECTION"
               MOVE SPI-Prior-Token TO SPI-Current-Section
               EXIT PARAGRAPH
           END-IF
           IF Token-Is-Identifier
               PERFORM 361-Release-Ref
           END-IF
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       340-DATA-DIVISION.
           IF Token-Is-Key-Word AND SPI-Current-Token = "DIVISION"
               MOVE SPI-Prior-Token TO SPI-Current-Division
               EXIT PARAGRAPH
           END-IF
           IF Token-Is-Key-Word AND SPI-Current-Token = "SECTION"
               MOVE SPI-Prior-Token TO SPI-Current-Section
               EXIT PARAGRAPH
           END-IF
           IF  (SPI-Current-Token = "PIC" OR "PICTURE")
           AND (Token-Is-Key-Word)
               MOVE "Y" TO F-Processing-PICTURE
               EXIT PARAGRAPH
           END-IF
GC0710     IF Token-Is-Reserved-Word
GC0710     AND SPI-Prior-Token = "LEVEL #"
GC0710         MOVE SPACES TO SPI-Prior-Token
GC0710         EXIT PARAGRAPH
GC0710     END-IF
           IF Token-Is-Identifier
               EVALUATE SPI-Prior-Token
               WHEN "FD"
                   PERFORM 360-Release-Def
                   MOVE SPACES TO SPI-Prior-Token
               WHEN "SD"
                   PERFORM 360-Release-Def
                   MOVE SPACES TO SPI-Prior-Token
               WHEN "LEVEL #"
                   PERFORM 360-Release-Def
                   MOVE SPACES TO SPI-Prior-Token
               WHEN "INDEXED"
                   PERFORM 360-Release-Def
                   MOVE SPACES TO SPI-Prior-Token
               WHEN "USING"
                   PERFORM 362-Release-Upd
                   MOVE SPACES TO SPI-Prior-Token
               WHEN "INTO"
                   PERFORM 362-Release-Upd
                   MOVE SPACES TO SPI-Prior-Token
               WHEN OTHER
                   PERFORM 361-Release-Ref
               END-EVALUATE
               EXIT PARAGRAPH
           END-IF
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       350-PROCEDURE-DIVISION.
           IF SPI-Current-Section NOT = "PROCEDURE"
               MOVE "PROCEDURE" TO SPI-Current-Section
           END-IF
GC0710     IF SPI-Current-Token-UC = "PROGRAM"
GC0710     AND SPI-Prior-Token = "END"
GC0710         MOVE "?" TO SPI-Current-Division
GC0710         EXIT PARAGRAPH
GC0710     END-IF
           IF Token-Is-Key-Word AND SPI-Current-Token = "DIVISION"
               MOVE SPI-Prior-Token TO SPI-Current-Division
               EXIT PARAGRAPH
           END-IF
           IF SPI-Current-Verb = SPACES
GC0710     AND F-Verb-Has-Been-Found = "Y"
               IF Token-Is-Identifier
                   PERFORM 360-Release-Def
                   MOVE SPACES TO SPI-Prior-Token
               END-IF
               EXIT PARAGRAPH
           END-IF
           IF NOT Token-Is-Identifier
               EXIT PARAGRAPH
           END-IF
           EVALUATE SPI-Current-Verb
           WHEN "ACCEPT"
               PERFORM 351-ACCEPT
           WHEN "ADD"
               PERFORM 351-ADD
           WHEN "ALLOCATE"
               PERFORM 351-ALLOCATE
           WHEN "CALL"
               PERFORM 351-CALL
           WHEN "COMPUTE"
               PERFORM 351-COMPUTE
           WHEN "DIVIDE"
               PERFORM 351-DIVIDE
           WHEN "FREE"
               PERFORM 351-FREE
           WHEN "INITIALIZE"
               PERFORM 351-INITIALIZE
           WHEN "INSPECT"
               PERFORM 351-INSPECT
           WHEN "MOVE"
               PERFORM 351-MOVE
           WHEN "MULTIPLY"
               PERFORM 351-MULTIPLY
           WHEN "PERFORM"
               PERFORM 351-PERFORM
           WHEN "SET"
               PERFORM 351-SET
           WHEN "STRING"
               PERFORM 351-STRING
           WHEN "SUBTRACT"
               PERFORM 351-SUBTRACT
           WHEN "TRANSFORM"
               PERFORM 351-TRANSFORM
           WHEN "UNSTRING"
               PERFORM 351-UNSTRING
           WHEN OTHER
               PERFORM 361-Release-Ref
           END-EVALUATE
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       351-ACCEPT.
           EVALUATE SPI-Prior-Token
           WHEN "ACCEPT"
               PERFORM 362-Release-Upd
               MOVE SPACES TO SPI-Prior-Token
           WHEN OTHER
               PERFORM 361-Release-Ref
           END-EVALUATE
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       351-ADD.
           EVALUATE SPI-Prior-Token
           WHEN "GIVING"
               PERFORM 362-Release-Upd
           WHEN "TO"
               PERFORM 362-Release-Upd
           WHEN OTHER
               PERFORM 361-Release-Ref
           END-EVALUATE
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       351-ALLOCATE.
           EVALUATE SPI-Prior-Token
           WHEN "ALLOCATE"
               PERFORM 362-Release-Upd
               MOVE SPACES TO SPI-Prior-Token
           WHEN "RETURNING"
               PERFORM 362-Release-Upd
           WHEN OTHER
               PERFORM 361-Release-Ref
           END-EVALUATE
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       351-CALL.
           EVALUATE SPI-Prior-Token
           WHEN "RETURNING"
               PERFORM 362-Release-Upd
           WHEN "GIVING"
               PERFORM 362-Release-Upd
           WHEN OTHER
               PERFORM 361-Release-Ref
           END-EVALUATE
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       351-COMPUTE.
           EVALUATE SPI-Prior-Token
           WHEN "COMPUTE"
               PERFORM 362-Release-Upd
           WHEN OTHER
               PERFORM 361-Release-Ref
           END-EVALUATE
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       351-DIVIDE.
           EVALUATE SPI-Prior-Token
           WHEN "INTO"
               PERFORM 363-Set-Upd
               MOVE Sort-Rec TO Held-Reference
           WHEN "GIVING"
               IF Held-Reference NOT = SPACES
                   MOVE Held-Reference To Sort-Rec
                   MOVE SPACES         To Held-Reference
                                          SR-Ref-Flag
                   RELEASE Sort-Rec
               END-IF
               PERFORM 362-Release-Upd
           WHEN "REMAINDER"
               PERFORM 362-Release-Upd
           WHEN OTHER
               PERFORM 361-Release-Ref
           END-EVALUATE
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       351-FREE.
           PERFORM 362-Release-Upd
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       351-INITIALIZE.
           EVALUATE SPI-Prior-Token
           WHEN "INITIALIZE"
               PERFORM 362-Release-Upd
           WHEN "REPLACING"
               PERFORM 361-Release-Ref
           END-EVALUATE
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       351-INSPECT.
           EVALUATE SPI-Prior-Token
           WHEN "INSPECT"
               PERFORM 364-Set-Ref
               MOVE SPACES TO Held-Reference
               MOVE SPACES TO SPI-Prior-Token
           WHEN "TALLYING"
               PERFORM 362-Release-Upd
               MOVE SPACES TO SPI-Prior-Token
           WHEN "REPLACING"
               IF Held-Reference NOT = SPACES
                   MOVE Held-Reference TO Sort-Rec
                   MOVE SPACES         TO Held-Reference
                   MOVE "*"            TO SR-Ref-Flag
                   RELEASE Sort-Rec
               END-IF
               MOVE SPACES TO SPI-Prior-Token
           WHEN "CONVERTING"
               IF Held-Reference NOT = SPACES
                   MOVE Held-Reference TO Sort-Rec
                   MOVE SPACES         TO Held-Reference
                   MOVE "*"            TO SR-Ref-Flag
                   RELEASE Sort-Rec
               END-IF
               MOVE SPACES TO SPI-Prior-Token
           WHEN OTHER
               PERFORM 361-Release-Ref
           END-EVALUATE
          .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       351-MOVE.
           EVALUATE SPI-Prior-Token
           WHEN "TO"
               PERFORM 362-Release-Upd
           WHEN OTHER
               PERFORM 361-Release-Ref
           END-EVALUATE
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       351-MULTIPLY.
           EVALUATE SPI-Prior-Token
           WHEN "BY"
               PERFORM 363-Set-Upd
               MOVE Sort-Rec TO Held-Reference
           WHEN "GIVING"
               MOVE Held-Reference TO Sort-Rec
               MOVE SPACES         TO Held-Reference
                                      SR-Ref-Flag
               RELEASE Sort-Rec
               PERFORM 362-Release-Upd
           WHEN OTHER
               PERFORM 361-Release-Ref
           END-EVALUATE
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       351-PERFORM.
           EVALUATE SPI-Prior-Token
           WHEN "VARYING"
               PERFORM 362-Release-Upd
               MOVE SPACES TO SPI-Prior-Token
           WHEN "AFTER"
               PERFORM 362-Release-Upd
               MOVE SPACES TO SPI-Prior-Token
           WHEN OTHER
               PERFORM 361-Release-Ref
           END-EVALUATE
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       351-SET.
           EVALUATE SPI-Prior-Token
           WHEN "SET"
               PERFORM 362-Release-Upd
           WHEN OTHER
               PERFORM 361-Release-Ref
           END-EVALUATE
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       351-STRING.
           EVALUATE SPI-Prior-Token
           WHEN "INTO"
               PERFORM 362-Release-Upd
           WHEN "POINTER"
               PERFORM 362-Release-Upd
           WHEN OTHER
               PERFORM 361-Release-Ref
           END-EVALUATE
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       351-SUBTRACT.
           EVALUATE SPI-Prior-Token
           WHEN "GIVING"
               PERFORM 362-Release-Upd
           WHEN "FROM"
               PERFORM 362-Release-Upd
           WHEN OTHER
               PERFORM 361-Release-Ref
           END-EVALUATE
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       351-TRANSFORM.
           EVALUATE SPI-Prior-Token
           WHEN "TRANSFORM"
               PERFORM 362-Release-Upd
               MOVE SPACES TO SPI-Prior-Token
           WHEN OTHER
               PERFORM 361-Release-Ref
           END-EVALUATE
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       351-UNSTRING.
           EVALUATE SPI-Prior-Token
           WHEN "INTO"
               PERFORM 362-Release-Upd
           WHEN "DELIMITER"
               PERFORM 362-Release-Upd
           WHEN "COUNT"
               PERFORM 362-Release-Upd
           WHEN "POINTER"
               PERFORM 362-Release-Upd
           WHEN "TALLYING"
               PERFORM 362-Release-Upd
           WHEN OTHER
               PERFORM 361-Release-Ref
           END-EVALUATE
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       360-Release-Def.
           MOVE SPACES TO Sort-Rec
           MOVE SPI-Current-Program-ID TO SR-Prog-ID
           MOVE SPI-Current-Token-UC   TO SR-Token-UC
           MOVE SPI-Current-Token      TO SR-Token
           MOVE SPI-Current-Section    TO SR-Section
           MOVE SPI-Current-Line-No    TO SR-Line-No-Def
           MOVE 0                      TO SR-Line-No-Ref
           RELEASE Sort-Rec
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       361-Release-Ref.
           PERFORM 364-Set-Ref
           RELEASE Sort-Rec
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       362-Release-Upd.
           PERFORM 363-Set-Upd
           RELEASE Sort-Rec
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       363-Set-Upd.
           MOVE SPACES TO Sort-Rec
           MOVE SPI-Current-Program-ID TO SR-Prog-ID
           MOVE SPI-Current-Token-UC   TO SR-Token-UC
           MOVE SPI-Current-Token      TO SR-Token
           MOVE SPI-Current-Section    TO SR-Section
           MOVE SPI-Current-Line-No    TO SR-Line-No-Ref
           MOVE "*"                    TO SR-Ref-Flag
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       364-Set-Ref.
           MOVE SPACES TO Sort-Rec
           MOVE SPI-Current-Program-ID TO SR-Prog-ID
           MOVE SPI-Current-Token-UC   TO SR-Token-UC
           MOVE SPI-Current-Token      TO SR-Token
           MOVE SPI-Current-Section    TO SR-Section
           MOVE SPI-Current-Line-No    TO SR-Line-No-Ref
           .
      /
       400-Produce-Xref-Listing SECTION.
       401-Init.
           MOVE SPACES       TO Detail-Line-X
                                Group-Indicators
           MOVE 0            TO I
                                Lines-Left
GC0710     MOVE 'N'          TO F-Duplicate
           .

       402-Process-Sorted-Recs.
           PERFORM FOREVER
               RETURN Sort-File AT END
                   EXIT PERFORM
               END-RETURN
               IF SR-Prog-ID  NOT = GI-Prog-ID
               OR SR-Token-UC NOT = GI-Token
GC0710             MOVE 'N' TO F-Duplicate
                   IF Detail-Line-X NOT = SPACES
                       PERFORM 410-Generate-Report-Line
                   END-IF
                   IF SR-Prog-ID NOT = GI-Prog-ID
                       MOVE 0 TO Lines-Left
                   END-IF
                   MOVE SR-Prog-ID  TO GI-Prog-ID
                   MOVE SR-Token-UC TO GI-Token
               END-IF
GC0710         IF SR-Token-UC = GI-Token
GC0710         AND SR-Line-No-Def NOT = SPACES
GC0710         AND Detail-Line-X NOT = SPACES
GC0710             MOVE 'Y' TO F-Duplicate
GC0710             PERFORM 410-Generate-Report-Line
GC0710             MOVE 0                          TO I
GC0710             MOVE SR-Prog-ID                 TO DLX-Prog-ID
GC0710             MOVE '  (Duplicate Definition)' TO DLX-Token
GC0710             MOVE SR-Section                 TO DLX-Section
GC0710             MOVE SR-Line-No-Def             TO DLX-Line-No-Def
GC0710             EXIT PERFORM CYCLE
GC0710         END-IF
GC0710         IF SR-Token-UC = GI-Token
GC0710         AND SR-Line-No-Def = SPACES
GC0710         AND F-Duplicate = 'Y'
GC0710             MOVE 'N' TO F-Duplicate
GC0710             PERFORM 410-Generate-Report-Line
GC0710             MOVE 0                          TO I
GC0710             MOVE SR-Prog-ID                 TO DLX-Prog-ID
GC0710             MOVE '  (Duplicate References)' TO DLX-Token
GC0710         END-IF
               IF Detail-Line-X = SPACES
                   MOVE SR-Prog-ID         TO DLX-Prog-ID
                   MOVE SR-Token           TO DLX-Token
                   MOVE SR-Section         TO DLX-Section
                   IF SR-Line-No-Def NOT = SPACES
                       MOVE SR-Line-No-Def TO DLX-Line-No-Def
                   END-IF
               END-IF
               IF SR-Reference > '000000'
                   ADD 1 TO I
                   IF I > Line-Nos-Per-Rec
                       PERFORM 410-Generate-Report-Line
                       MOVE 1 TO I
                   END-IF
                   MOVE SR-Line-No-Ref TO DLX-Line-No-Ref (I)
                   MOVE SR-Ref-Flag    TO DLX-Ref-Flag    (I)
               END-IF
           END-PERFORM
           IF Detail-Line-X NOT = SPACES
               PERFORM 410-Generate-Report-Line
           END-IF
           EXIT SECTION
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       410-Generate-Report-Line.
           IF Lines-Left < 1
               IF F-First-Record = "Y"
                   MOVE "N" TO F-First-Record
                   WRITE Report-Rec FROM Heading-1X BEFORE 1
               ELSE
                   MOVE SPACES TO Report-Rec
                   WRITE Report-Rec                 BEFORE PAGE
                   MOVE SPACES TO Report-Rec
                   WRITE Report-Rec                 BEFORE 1
                   WRITE Report-Rec FROM Heading-1X BEFORE 1
               END-IF
               WRITE Report-Rec FROM Heading-2  BEFORE 1
               WRITE Report-Rec FROM Heading-4X BEFORE 1
               WRITE Report-Rec FROM Heading-5X BEFORE 1
               COMPUTE
                   Lines-Left = Lines-Per-Page - 4
               END-COMPUTE
           END-IF
           WRITE Report-Rec FROM Detail-Line-X BEFORE 1
           MOVE SPACES TO Detail-Line-X
           MOVE 0 TO I
           SUBTRACT 1 FROM Lines-Left
           .
      /
       500-Produce-Source-Listing SECTION.
       501-Generate-Source-Listing.
           OPEN INPUT Source-Code
                      Expand-Code
           MOVE 0 TO Source-Line-No
           PERFORM FOREVER
               READ Expand-Code AT END
                   EXIT PERFORM
               END-READ
               IF ECR-1 = "#"
                   PERFORM 510-Control-Record
               ELSE
                   PERFORM 520-Expand-Code-Record
               END-IF
           END-PERFORM
           CLOSE Source-Code
                 Expand-Code
           EXIT SECTION
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       510-Control-Record.
           UNSTRING ECR-2-256
               DELIMITED BY '"'
               INTO PIC-X10, PIC-X256, Dummy
           END-UNSTRING
           IF TRIM(PIC-X256,Trailing) = TRIM(Program-Path,Trailing) *> Main Pgm
               SET In-Main-Module TO TRUE
               IF Source-Line-No > 0
                   READ Expand-Code END-READ
               END-IF
           ELSE *> COPY
               SET In-Copybook TO TRUE
           END-IF
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       520-Expand-Code-Record.
           IF In-Main-Module
               ADD 1 To SPI-Current-Line-No
               READ Source-Code AT END NEXT SENTENCE END-READ
               ADD 1 TO Source-Line-No
               MOVE SPACES         TO Detail-Line-S
               MOVE Source-Line-No TO DLS-Line-No
               MOVE SCR-1-128      TO DLS-Statement
GC0410         IF SCR-7 = "/"
GC0410             MOVE 0 TO Lines-Left
GC0410         END-IF
               PERFORM 530-Generate-Source-Line
               IF SCR-129-256 NOT = SPACES
                   MOVE SPACES      TO Detail-Line-S
                   MOVE SCR-129-256 TO DLS-Statement
                   PERFORM 530-Generate-Source-Line
               END-IF
           ELSE
               IF Expand-Code-Rec NOT = SPACES
                   MOVE SPACES         TO Detail-Line-S
                   MOVE ECR-1-128      TO DLS-Statement
                   PERFORM 530-Generate-Source-Line
                   IF ECR-129-256 NOT = SPACES
                       MOVE SPACES      TO Detail-Line-S
                       MOVE ECR-129-256 TO DLS-Statement
                       PERFORM 530-Generate-Source-Line
                   END-IF
               END-IF
           END-IF
           .
      *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       530-Generate-Source-Line.
           IF Lines-Left < 1
               IF F-First-Record = "Y"
                   MOVE "N" TO F-First-Record
                   WRITE Report-Rec FROM Heading-1S BEFORE 1
               ELSE
                   MOVE SPACES TO Report-Rec
                   WRITE Report-Rec                 BEFORE PAGE
                   MOVE SPACES TO Report-Rec
                   WRITE Report-Rec                 BEFORE 1
                   WRITE Report-Rec FROM Heading-1S BEFORE 1
               END-IF
               WRITE Report-Rec FROM Heading-2  BEFORE 1
               WRITE Report-Rec FROM Heading-4S BEFORE 1
               WRITE Report-Rec FROM Heading-5S BEFORE 1
               COMPUTE
                   Lines-Left = Lines-Per-Page - 4
               END-COMPUTE
           END-IF
           WRITE Report-Rec FROM Detail-Line-S BEFORE 1
           MOVE SPACES TO Detail-Line-S
           SUBTRACT 1 FROM Lines-Left
           .

       END PROGRAM LISTING.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.