File: 0fw_tut.fw

package info (click to toggle)
funnelweb-doc 3.2d-4.2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,744 kB
  • sloc: perl: 241; makefile: 23
file content (6445 lines) | stat: -rw-r--r-- 224,800 bytes parent folder | download | duplicates (5)
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
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
@!345678901234567890123456789012345678901234567890123456789012345678901234567890
@!******************************************************************************

@t vskip 50 mm
@t title titlefont centre "FunnelWeb Tutorial Manual Web"
@t vskip 10 mm
@t title smalltitlefont centre "by Ross N. Williams"
@t title smalltitlefont centre "18 April 1999"
@t vskip 10 mm
@t title smalltitlefont centre "Copyright (c) Ross N. Williams, 1992."
@t new_page
@t vskip 20 mm
@t title titlefont centre "Contents"
@t vskip 10 mm
@t table_of_contents
@t new_page

@!******************************************************************************
@!******************************************************************************

@A@<FunnelWeb Tutorial Manual Web@>

This document contains the FunnelWeb source for the
FunnelWeb tutorial manual web. When processed by the
FunnelWeb macro preprocessor, this file will generate all
the text files in the web.

@!******************************************************************************

@B@<Copyright Notice@>

This FunnelWeb source file and all works derived from it
(including, but not limited to, the output files and printed
documentation that can be extracted using the FunnelWeb
preprocessor) are copyright as shown below, and the
copyright message in the copyright macro applies to all of
these works. The enclosing macro is called at the start of
each FunnelWeb output file so that the copyright message
appears in each output file as well as in this FunnelWeb
source file.

@$@<Copyright notice/HTML@>@M@{@-
Copyright @<(C)@> Ross N. Williams 1992,1999. All rights reserved.@}

Permission is granted to redistribute and use this manual in
any medium, with or without modification, provided that all
notices (including, without limitation, the copyright
notice, this permission notice, any record of modification,
and all legal notices) are preserved on all copies, that all
modifications are clearly marked, and that modified versions
are not represented as the original version unless all the
modifications since the manual's original release by Ross N.
Williams (www.ross.net) consist of translations or other
transformations that alter only the manual's form, not its
content. THIS MANUAL IS PROVIDED "AS IS" AND WITHOUT ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND
FITNESS FOR A PARTICULAR PURPOSE. TO THE EXTENT PERMITTED BY
LAW THERE IS ABSOLUTELY NO WARRANTY.

@!******************************************************************************

@p maximum_input_line_length = 500
@p maximum_output_line_length = 500

@!******************************************************************************

@B@<Change Log@>

@$@<Change log@>@Z@{
18-Apr-1999 RNW Converted original 1992 FunnelWeb manual to this web (+ref web).
08-May-1999 RNW Documented new HTML +u option.
12-May-1999 RNW Documented @@L library feature.
13-May-1999 RNW Added the chapter on webmaking.
29-Dec-1999 RNW Added sidebar image strut to stop it collapsing.
30-Dec-1999 RNW Added the HTML style page.
30-Dec-1999 RNW Added the emacs mode page.
30-Dec-1999 RNW Changed manual version number scheme.
31-Dec-1999 RNW Tweaked the wholistic debugging page.
03-Jan-2000 RNW Changed copyright permission notice.
06-Jan-2000 RNW Added black background table to sidebar to cope with no-images.
09-Jan-2000 RNW Moved main version notice into a macro in the fw include file.
@}

@!******************************************************************************

@B@<General Notes@>

@$@<General Information@>@Z@{
Checking Procedure
------------------
* Spelling check.
* WebLint check.

Shipping Procedure
------------------
* Use FunnelWeb to ENEO *.html
* Run FunnelWeb. Eliminate all warnings.
* Nuke the old web.
* Upload the new web.
* Briefly surf to check.
@}

FORMATTING NOTE: Experimentation has shown that any page containing a
VERBATIM wider than 55 characters must be set to /wide.

@!******************************************************************************

@B@<Things To Do@>

@$@<Things to do@>@Z@{
TTDList
-------

@}

@!******************************************************************************

@B@<Conversion Of Printed Manual@>

The FunnelWeb documentation used to be embodied in a single printed manual
called The FunnelWeb User's Manual. Here's a record of how the material
in the manual ended up in the FunnelWeb documentation webs:

@$@<Printed Manual Conversion@>@Z@{
Printed User Manual Section     Where It Ended Up
---------------------------     -----------------
Preface                         DELETED
Acknowledgements                Copyright page of all FunnelWeb webs.
Presentation Notes              DELETED
1. A Tutorial Introduction      Tut: Chapters 1..4.
2. FunnelWeb Hints.             Tut: Chapter 5..6.
3. FunnelWeb Definition.        Ref: Most of the reference manual.
4. FunnelWeb Installation.      Mainweb,Dev
5. FunnelWeb Administration.    DELETED, but 5.2 => Main: stability
Glossary                        Ref: Glossary.
References                      Ref: References.

Printed Hacker Manual Section   Where It Ended Up
-----------------------------   -----------------
Preface                         Dev: Home page intro.
Acknowledgements                Copyright page of all FunnelWeb webs.
Presentation Notes              DELETED
1. FunnelWeb Design             Dev: Chapter 2.
2. FunnelWeb Implementation     Dev: Chapter 3.
3. FunnelWeb Modification       Dev: Chapter 4.
4. FunnelWeb Future             Dev: Chapter 5.
A. GNU Licence V2               Dev: Chapter 6.
References                      Ref: References.
@}

@!******************************************************************************

@B@<Graphic Design Notes@>

These notes record the details of how the graphics in this web were created.
This will enable the graphics to be easily recreated, duplicated, or modified
if necessary.

@$@<Graphic Design Notes@>@Z@{
Sidebar is 50x1200 colour=(0,0,0).

Title
   Bookman Black SSi, 20pt, Antialias


@}

@!******************************************************************************
@!******************************************************************************

@B@<Parameter Macros@>

@$@<Body@>@M@{@-
<BODY BACKGROUND="@<Bin@>background.gif"
      BGCOLOR=@<White@>
      TEXT="#000000"
      VLINK="#660000"
      LINK="#FF0000"
      ALINK="#CC0000">@}

@$@<FunnelWeb WWW@>@Z@M@{../@}
@$@<FunnelWeb Tutorial WWW@>@Z@M@{@}
@$@<FunnelWeb Reference WWW@>@Z@M@{../reference/@}
@$@<FunnelWeb Developer WWW@>@Z@M@{../developer/@}

@!******************************************************************************

@B@<Page Macros@>

The following macros provide macros to set up the top and bottom of pages.

@!------------------------------------------------------------------------------

@$@<SideLink@>@(@2@)@Z@M@{<A HREF="@1"><FONT COLOR="#FFFFFF">@2</FONT></A>@<BR@>@}
@$@<SideLink/bold/target@>@(@3@)@M@{@<WindowLink@>@(@1@,@2@,<FONT COLOR="#FFFFFF"><B>@3</B></FONT>@)@<BR@>@}
@$@<SideLink/bold@>@(@2@)@M@{<A HREF="@1"><FONT COLOR="#FFFFFF"><B>@2</B></FONT></A>@<BR@>@}

@$@<Begin FWTutMan margin@>@M@{
<TABLE WIDTH="490">
<TR>
<TD WIDTH="130" VALIGN="top">
@<HStrut@>@(130@)@<BR@>

@<Sidebar menu@>

</TD>
<TD WIDTH="360" VALIGN="top">
@<Begin size3@>
@}

@$@<Begin FWTutMan margin/wide@>@M@{
<TABLE WIDTH="590">
<TR>
<TD WIDTH="130" VALIGN="top">
@<HStrut@>@(130@)@<BR@>

@<Sidebar menu@>

</TD>
<TD WIDTH="460" VALIGN="top">
@<Begin size3@>
@}

@$@<End FWTutMan margin@>@M@{
@<End size3@>
</TD>
</TR>
@<End table@>
@}

@$@<Sidebar menu@>@M@{@-
@<Begin size2@>
@<BR@>
@<RossNet linklogo IMAGE@>@<BR@>
@<BR@>
@<FunnelWeb linklogo IMAGE@>@<BR@>
@<BR@>
@<Begin tablecolour@>@(#000000@)
@<SideLink/bold/target@>@(@<FunnelWeb Reference WWW@>index.html@,@<FunnelWeb Reference WINDOWNAME@>@,Reference@)
@<BR@>
@<SideLink/bold/target@>@(@<FunnelWeb Developer WWW@>index.html@,@<FunnelWeb Developer WINDOWNAME@>@,Developer@)
@<BR@>
@<SideLink/bold@>@(@<FunnelWeb Tutorial WWW@>index.html@,Tutorial@)
@<SideLink@>@(@<Intro FILE@>@,@<Intro HEADING/short@>@)
@<SideLink@>@(@<Macro FILE@>@,@<Macro HEADING/short@>@)
@<SideLink@>@(@<Type FILE@>@,@<Type HEADING/short@>@)
@<SideLink@>@(@<Example FILE@>@,@<Example HEADING/short@>@)
@<SideLink@>@(@<Hints FILE@>@,@<Hints HEADING/short@>@)
@<SideLink@>@(@<Examples FILE@>@,@<Examples HEADING/short@>@)
@<SideLink@>@(@<Web FILE@>@,@<Web HEADING/short@>@)

@<BR@>
@<SideLink/bold@>@(@<FunnelWeb_search FILE@>@,SEARCH@)
@<End size2@>
@<End tablecolour@>
@}

@!------------------------------------------------------------------------------

@$@<Begin FWTutMan page/H1@>@(@1@)@Z@M@{
<HTML>
@<Header comment@>
<HEAD>
<TITLE>@1</TITLE>
@<Suppress hyperlink underlining@>
</HEAD>
@<Body@>
@<Begin FWTutMan margin@>
@<RunningHeader IMAGE@>
@<FWTutMan heading@>@(@1@)
@}

@$@<Begin FWTutMan page/wide/H1@>@(@1@)@Z@M@{
<HTML>
@<Header comment@>
<HEAD>
<TITLE>@1</TITLE>
@<Suppress hyperlink underlining@>
</HEAD>
@<Body@>
@<Begin FWTutMan margin/wide@>
@<RunningHeader IMAGE@>
@<FWTutMan heading@>@(@1@)
@}

@!------------------------------------------------------------------------------

@$@<End FWTutMan page@>@Z@M@{
@<HR@>
@<Begin size2@>
@<Link@>@(mailto:@<Ross webmaster EMAIL@>@,Webmaster@)@<_@>@<_@>@<_@>
<A HREF="@<Copyright FILE@>">@<Copyright notice/HTML@></A><BR>
@<End size2@>
@<End FWTutMan margin@>

</BODY>

@<Trailer comment@>
</HTML>@}

@$@<Page title prefix@>@Z@M@{@}

@!******************************************************************************

@B@<Images@>

@$@<RunningHeader IMAGE@>@M@{
<A HREF="@<FunnelWeb Reference WWW@>index.html"><IMG SRC="@<Bin@>title.gif"
 WIDTH="302" HEIGHT="24"
 BORDER="0" ALT="FunnelWeb Tutorial Manual"
 HSPACE="0" VSPACE="0"></A>@}

@!******************************************************************************

@B@<General Macros@>

@$@<FWTutMan heading@>@(@1@)@M@{@-
@<P@>@<Size5@>@(@1@)@<BR@>@}

@$@<FWTutMan subheading@>@(@1@)@M@{@-
@<P@>@<BR@>@<Size4@>@(@<B@>@(@1@)@)@<BR@>@}

@$@<FWTutMan subsubheading@>@(@1@)@Z@M@{@-
@<P@>@<BR@>@<Size3@>@(@<B@>@(@1@)@)@<BR@>@}

@$@<FWTutMan subsubsubheading@>@(@1@)@Z@M@{@-
@<P@>@<BR@>@<Size3@>@(@<U@>@(@1@)@)@<BR@>@}

@$@<FWTutMan heading/nospace@>@(@1@)@Z@M@{@-
@<Size4@>@(@<B@>@(@1@)@)@<BR@>@}

@$@<FWTutMan heading/center@>@(@1@)@Z@M@{@-
@<P@>@<BR@>
@<Begin center@>
@<Size5@>@(@<B@>@(@1@)@)@<BR@>
@<End center@>@}


@!******************************************************************************

@$@<FWTutMan keywords and decription@>@{
<META NAME="description"
 CONTENT="The FunnelWeb Tutorial Manual. FunnelWeb is a portable
          free literate programming tool.">

<META NAME="keywords"
 CONTENT="funnelweb,FunnelWeb,funnel,web,
          tutorial,manual,tutorial manual,
          literate programming,literate,programming,literate-programming,
          documentation,
          macro,macros,preprocessor,macro preprocessor,
          software,free,freeware,
          open source,open,source,gnu,gpl,copyleft,
          web,development,tool,web tool">
@}

@!******************************************************************************
@!******************************************************************************

@A@<HTML Pages@>

This section contains the HTML pages of the web.

@!******************************************************************************

@$@<Index HEADING@>@M@{FunnelWeb Tutorial Manual@}
@$@<Index FILE@>@M@{index.html@}
@O@<index.html@>@{@-
<HTML>

<HEAD>
@<FWTutMan keywords and decription@>
@<Suppress hyperlink underlining@>
<TITLE>@<Index HEADING@></TITLE>
</HEAD>

@<Body@>

@<Begin FWTutMan margin@>

@<RunningHeader IMAGE@>

@<FunnelWeb manual version notice@>

@<P@>@<Bigger@>@(T@)HIS TUTORIAL MANUAL provides a friendly
introduction to the FunnelWeb literate programming
preprocessor

@<P@>This Tutorial Manual does not provide a definitive
description of FunnelWeb, so if you have a specific technical
question, you should refer to the @<FunnelWeb Reference Manual@>,
which is definitive. To perform a keyword search
of the Reference Manual and/or this Tutorial manual, click
on SEARCH in the margin.

@<P@>
@<Begin size4@>
@<Begin indent@>

@<HeadStyle@>@(@<Intro FILE@>@,@<Intro HEADING@>@)
   @<Intro index@>

@<HeadStyle@>@(@<Macro FILE@>@,@<Macro HEADING@>@)
   @<Macro index@>

@<HeadStyle@>@(@<Type FILE@>@,@<Type HEADING@>@)
   @<Type index@>

@<HeadStyle@>@(@<Example FILE@>@,@<Example HEADING@>@)

@<HeadStyle@>@(@<Hints FILE@>@,@<Hints HEADING@>@)
   @<Hints index@>

@<HeadStyle@>@(@<Examples FILE@>@,@<Examples HEADING@>@)
   @<Examples index@>

@<HeadStyle@>@(@<Web FILE@>@,@<Web HEADING@>@)
   @<Web index@>

@<End indent@>
@<End size4@>

@<End FWTutMan page@>
@}

@$@<HeadStyle@>@(@2@)@M@{@<P@><A HREF="@1"><B>@2</B></A><BR>@}

@!******************************************************************************

@$@<Intro HEADING@>@M@{@<SH@>@(1@)Introduction@}
@$@<Intro HEADING/short@>@M@{@<SH@>@(1@)Introduction@}
@$@<Intro FILE@>@M@{intro.html@}
@O@<intro.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Intro HEADING@>@)

@<P@>

@<Intro index@>

@<Nav/first@>@(@<Index FILE@>@,@<Index FILE@>@,@<Macro FILE@>@)

@<End FWTutMan page@>
@}

@$@<Intro index@>@M@{
@<Begin size3@>
@<Begin indent/narrow@>
@<Link@>@(@<Intro_what FILE@>@,@<Intro_what HEADING@>@)@<BR@>
@<Link@>@(@<Intro_whatfw FILE@>@,@<Intro_whatfw HEADING@>@)@<BR@>
@<Link@>@(@<Intro_name FILE@>@,@<Intro_name HEADING@>@)@<BR@>
@<Link@>@(@<Intro_tutorial FILE@>@,@<Intro_tutorial HEADING@>@)@<BR@>
@<Link@>@(@<Intro_hello FILE@>@,@<Intro_hello HEADING@>@)@<BR@>
@<End indent/narrow@>
@<End size3@>
@}

@!==============================================================================

@$@<Intro_what HEADING@>@M@{@<SH@>@(1.1@)What Is Literate Programming?@}
@$@<Intro_what FILE@>@M@{intro_what.html@}
@O@<intro_what.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Intro_what HEADING@>@)
@<X@>@(literate programming@)

@<P@>A traditional computer program consists of a text file
containing program code. Scattered in amongst the program
code are comments which describe the various parts of the
code.

@<P@>In @<NewTerm@>@(literate programming@) the emphasis is
reversed. Instead of writing code containing documentation,
the literate programmer writes documentation containing
code. No longer does the English commentary injected into a
program have to be hidden in comment delimiters at the top
of the file, or under procedure headings, or at the end of
lines. Instead, it is wrenched into the daylight and made
the main focus. The @<DQ@>@(program@) then becomes primarily
a document directed at humans, with the code being herded
between @<DQ@>@(code delimiters@) from where it can be
extracted and shuffled out sideways to the language system
by literate programming tools.

@<P@>The effect of this simple shift of emphasis can be so
profound as to change one's whole approach to programming.
Under the literate programming paradigm, the central
activity of programming becomes that of conveying meaning to
other intelligent beings rather than merely convincing the
computer to behave in a particular way. It is the difference
between performing and exposing a magic trick.@<X@>@(magic
trick@)

@<P@>In order to program in a literate style, particular
tools are required.@<XX@>@(tools@,literate programming@) The
traditional approach (used in the FunnelWeb system) is to
have some sort of text-file-in/text-file-out utility that
reads a literate program (containing a program commentary
peppered with scraps of program text) and writes out a file
containing all the program code and a file containing
typesetter commands representing the entire input document,
documentation, code, and all. See the diagram below.

@<P@>
@<Begin verbatim@>
      +-----------------------------------------+
      | File containing the program description |
      | peppered with scraps of program code.   |
      | This is what the programmer works on.   |
      |          (e.g. sloth.web)               |
      +-----------------------------------------+
                         |
                         v
           o---------------------------o
           | Literate Programming Tool |
           o---------------------------o
                         |
            +------------+-------------+
            |                          |
            v                          v
   +------------------+   +--------------------------+
   |   Traditional    |   | Documentation file       |
   | Computer Program |   | (e.g. sloth.tex)         |
   |  (e.g. sloth.c)  |   | (e.g. sloth.html)        |
   +------------------+   +--------------------------+

@<End verbatim@>
@<CaptionTitle@>@(Traditional architecture of literate programming tools.@)
@<Begin blockquote@>
@<Begin size2@>
Literate programming tools could be organized in a number of
ways. However, to fit in with current file and command line
based environments, most tools conform to the traditional
architecture shown here in which the user feeds in a file
containing a literate program, and the literate programming
utility generates program files and a documentation file.
@<End size2@>
@<End blockquote@>

@<P@>Given the coming age of hypertext@<X@>@(hypertext@)
systems, this is probably not the best approach. However, it
does mesh beautifully with current text files and command
line interfaces, the expectation of linear presentations in
the documents we read, and the particular requirements of
current programming languages and typesetting systems. It is
certainly not a bad approach.

@<P@>With this structure in place, the literate programming
system can provide far more than just a reversal of the
priority of comments and code. In its full blown form, a
good literate programming facility can provide total support
for the essential thrust of literate programming, which is
that computer programs should be written more for the human
reader than for the compiler. In particular, a literate
programming system can provide:@<XS@>@(literate
programming@,facilities@)

@<Narrowthing@>@(Re-ordering of code:@,Programming languages
often force the programmer to give the various parts of a
computer program in a particular
order.@<XX@>@(program@,ordering@) For example, the
Pascal@<X@>@(Pascal@) programming language@<Paper@>@(BSI82@)
imposes the ordering: constants, types, variables,
procedures, code. Pascal also requires that procedures
appear in an order consistent with the partial ordering
imposed by the static call graph (but forward declarations
allow this to be bypassed). In contrast, the literate style
requires that the programmer be free to present the computer
program in any order whatsoever. The facility to do this is
implemented in literate programming tools by providing text
@<I@>@(macros@) that can be defined and used in any order.@)

@<Narrowthing@>@(Typeset code and
documentation:@,Traditionally program listings are dull
affairs consisting of pages of fan-form paper imprinted with
meandering coastlines of structured text in a boring font.
In contrast, literate programming systems are capable of
producing documentation that is superior in two ways. First,
because most of the documentation text is fed straight to
the typesetter, the programmer can make use of all the power
of the underlying typesetter, resulting in documentation
that has the same presentation as an ordinary typeset
document. Second, because the literate programming utility
sees all the code, it can use its knowledge of the
programming language and the features of the typesetting
language to typeset the program code as if it were appearing
in a technical journal. It is the difference between:@)

@<P@>
@<Begin verbatim@>
    while sloth@<<@>walrus loop
       sloth:=sloth+1;
    end loop
@<End verbatim@>

and

@<Begin indent@>
@<B@>@(while@) @<I@>@(sloth@)@<<@>@<I@>@(walrus@) @<B@>@(loop@)@<BR@>
@<_@>@<_@>@<_@>@<_@>@<_@>@<_@>@<I@>@(sloth@)=@<I@>@(sloth@)+1;@<BR@>
@<B@>@(end@) @<B@>@(loop@)
@<End indent@>

@<P@>Unfortunately, while FunnelWeb provides full
typesetting of the documentation, it typesets all of its
code in the style of the first of these two examples. To
typeset in the style of the second requires knowledge of the
programming language, and the current version of FunnelWeb
is programming language independent. At a later stage, it is
possible that FunnelWeb will be modified to read in a file
containing information about the target programming language
to be used to assist in typesetting the code properly.

@<Narrowthing@>@(Cross referencing:@,Because@<X@>@(cross
referencing@) the literate tool sees all the code and
documentation, it is able to generate extensive cross
referencing information in the typeset documentation. This
makes the printed program document more easy to navigate and
partially compensates for the lack of an automatic searching
facility when reading printed documentation.@)

@<P@>In the end, the details don't matter. The most
significant benefit that literate programming offers is
@<I@>@(its capacity to transform the state of mind of the
programmer@).@<XS@>@(literate programming@,most significant
benefit@) It is well known that the act of explaining
something can transform one's understanding of it. This is
one of the justifications behind the powerful combination of
research and teaching in
universities @<Paper@>@(Rosovsky90@).@<X@>@(universities@)
Similarly, by constantly explaining the unfolding program
code in English to an imaginary reader, the programmer
transforms his perception of the code, laying it open,
prone, to the critical eye.@<XX@>@(explaining@,code@)

@<P@>The result of this exposure is a higher quality of
programming. When exposed to the harsh light of the literate
eye, bugs crawl out, special cases vanish, and sloppy code
evaporates. As a rule, literate programs take longer to write
than ordinary programs, but the total development
time@<XX@>@(development@,time@) is the same or less because
the time taken to write and document the program carefully
is compensated for by a reduced debugging and maintenance
time. Thus literate programming does not merely assist in
the preparation of documentation, but also makes significant
contributes to the process of programming itself. In
practice this has turned out to be a contribution far more
important than the mere capacity to produce typeset
documentation.

@<P@>For more information on literate programming, the
reader is directed to Knuth's early founding work
@<Paper@>@(Knuth83@) and @<Paper@>@(Knuth84@). For more
recent information refer to @<Paper@>@(Smith91@), which
provides a comprehensive bibliography up to 1990.


@<Nav/first@>@(@<Intro FILE@>@,@<Intro FILE@>@,@<Intro_whatfw FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Intro_whatfw HEADING@>@M@{@<SH@>@(1.2@)What Is FunnelWeb?@}
@$@<Intro_whatfw FILE@>@M@{intro_whatfw.html@}
@O@<intro_whatfw.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Intro_whatfw HEADING@>@)
@<XX@>@(FunnelWeb@,overview@)

@<P@>FunnelWeb is a particular literate programming system
that is implemented by a single C program. FunnelWeb takes
as input a single @<TT@>@(.fw@) @<NewTerm@>@(input file@)
and writes one or more @<NewTerm@>@(product files@) and a
@<NewTerm@>@(documentation file@) (see below).

@<P@>
@<Begin verbatim@>
                   +-----------+
                   | sloth.fw  |
                   +-----------+
                         |
                         v
               o-------------------o
               | FUNNELWEB Program |
               o-------------------o
                         |
             +-----------+-----------+
             |                       |
             v                       v
     +----------------+    +--------------------+
     |  Product File  |    | Documentation File |
     | (e.g. sloth.c) |    | (e.g. sloth.html)  |
     |                |    | (e.g. sloth.tex)   |
     +----------------+    +--------------------+

@<End verbatim@>
@<CaptionTitle@>@(Architecture of FunnelWeb.@)

@<P@>In literate programming systems, it is usual to refer
to the product file as a @<DQ@>@(program file@). However, as
FunnelWeb is a general tool that can be used to prepare all
sorts of text files that are not computer programs, the more
generic term @<DQ@>@(product file@) was chosen. Product
files should be carefully distinguished from the term
@<NewTerm@>@(output files@) which refers to all of the
output files produced by FunnelWeb.

@<P@>FunnelWeb is distinguished by the following
characteristics:

@<Narrowthing@>@(Simplicity:@,A@<X@>@(simplicity@) governing
design goal of FunnelWeb is to provide a @<I@>@(simple@)
tool that could be easily learnt and completely mastered.
This manual is thick because it is comprehensive and lingers
on the ways in which FunnelWeb can be used. The tool itself
is quite simple.@)

@<Narrowthing@>@(Reliability:@,Another@<X@>@(reliability@)
design goal is to provide a tool that will protect the user
as much as possible from silly errors. Macro preprocessors
are notorious for causing obscure errors. Every attempt has
been made in FunnelWeb to keep the syntax robust. For
example, in FunnelWeb the syntax of macro calls has been
purposely designed to be highly visible so that the reader
is always aware when the macro facility is being invoked.@)

@<Narrowthing@>@(Language and Typesetter
Independence:@,Unlike Knuth's
original@<XX@>@(language@,independence@)@<XX@>@(typesetter@,independence@)
Web system which was specific to the Pascal programming
language@<Paper@>@(BSI82@) and the TeX typesetting
language@<Paper@>@(Knuth84@), FunnelWeb strives to be
language and typesetter independent.
FunnelWeb is completely language independent. FunnelWeb
input files can be typesetter independent too, and
FunnelWeb can generate documentation in TeX and HTML formats.@)

@<Narrowthing@>@(Portability:@,FunnelWeb@<X@>@(portability@)
has been written in the C programming language with great
emphasis on portability. FunnelWeb currently runs on the
Sun, OpenVMS, IBM PC, and Mac.@)

@<Narrowthing@>@(Controllable:@,FunnelWeb@<X@>@(controllability@)
is an extremely controllable tool. To protect users'
investment in source files constructed in the FunnelWeb
macro language, the C source code to FunnelWeb has been
released under a GNU General Public License
(GPL).@<XX@>@(GNU@,license@) This means
that it will always be available to everyone. Furthermore,
license has been granted for the FunnelWeb User's Manual to
be copied freely so long as they are not modified. All this
means that FunnelWeb is not going to disappear suddenly.@)

@<Narrowthing@>@(A Production Tool:@,Above@<X@>@(production
tool@) all, FunnelWeb has been designed to be a production
tool and every effort has been made to ensure that it will
operate effectively in a professional environment. FunnelWeb
is @<DQ@>@(open@) and portable. There is a comprehensive
user manual. Its error messages are comprehensive. It is
fast. Finally, it has been designed with the experience of
three years of using FunnelWeb@<_@>V1.@)

@<Nav@>@(@<Intro_what FILE@>@,@<Intro FILE@>@,@<Intro_name FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Intro_name HEADING@>@M@{@<SH@>@(1.3@)The Name FunnelWeb@}
@$@<Intro_name FILE@>@M@{intro_name.html@}
@O@<intro_name.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Intro_name HEADING@>@)
@<XX@>@(FunnelWeb@,name@)

@<P@>The name @<DQ@>@(FunnelWeb@) was chosen because it
contains the name @<DQ@>@(WEB@), which is the name of
Knuth's system. It was also chosen because it has a
distinctly Australian flavour.

@<P@>Funnel-web spiders@<XX@>@(Funnel-web@,spider@) are
found in Northern and Eastern Australia. They are about
three to four centimetres long and are very poisonous. The
Sydney@<X@>@(Sydney@) Funnel-web spider (@<I@>@(Atrax
robustus@)@<X@>@(Atrax robustus@)), common in Sydney, has
caused the most trouble and has been responsible for several
deaths. Funnel-web spiders love to crawl into temporarily
discarded shoes where they later react in a hostile manner
to an unsuspecting foot. They are known to hang on once they
sink their fangs in. Funnel-web spiders derive their name
from the shape of their webs which are horizontally-aligned
narrowing tubes, open at one end@<Paper@>@(ANZE@).

@<P@>The Funnel-web spider, like the tiger
snake@<XX@>@(tiger@,snake@) and the white pointer
shark,@<XX@>@(white pointer@,shark@) is secretly regarded by
Australians as a kind of national
treasure.@<XN@>@(Edna@,Everage@)@<XN@>@(Barry@,Humphries@)

@<P@>
@<Begin indent@>
@<B@>@(F@) is for Funnel-web@<BR@>
Our furry-legged foe.@<BR@>
He sleeps in your slipper@<BR@>
And breakfasts on toe.@<BR@>
--- One verse from @<I@>@(A Megastar's Mantras: Things that Mean a Lot to Me@),@<BR@>
@<_@>@<_@>@<_@>@<_@>@<_@>@<_@>@<_@>by Dame Edna Everage@<Paper@>@(Humphries91@).@<BR@>
@<End indent@>

@<Nav@>@(@<Intro_whatfw FILE@>@,@<Intro FILE@>@,@<Intro_tutorial FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Intro_tutorial HEADING@>@M@{@<SH@>@(1.4@)Using These Tutorials@}
@$@<Intro_tutorial FILE@>@M@{intro_tutorial.html@}
@O@<intro_tutorial.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Intro_tutorial HEADING@>@)
@<X@>@(tutorial@)@<XX@>@(tutorial@,introduction@)

@<P@>Much of the rest of this manual consists of
introductory tutorials on FunnelWeb. Ideally you should have
a working version of FunnelWeb in front of you so that you
can try out the examples yourself. There is no need to try
all the examples, so long as you type in enough to feel
comfortable with what you are reading.

@<P@>For best effect, you should create a new, temporary,
empty directory in which to experiment with FunnelWeb. That
way, it will be more obvious when FunnelWeb creates an
output file. You can either type in the examples in this
chapter directly, or copy and paste them directly from
this manual or the FunnelWeb test suite. The test files called
@<TT@>@(ex01.fw@) through @<TT@>@(ex16.fw@) and
@<TT@>@(hi01.fw@) through @<TT@>@(hi10.fw@) contain the
examples in the manual.

@<P@>If you do not yet have an installed copy of FunnelWeb,
refer to the main @<FunnelWeb@> web for full details on how
to obtain and install a copy of FunnelWeb. If you are not
sure if you have an installed copy, try invoking FunnelWeb
by giving the command @<DQP@>@(fw@). If this yields an error
such as @<DQ@>@(command not found@) then you do not have a
properly installed version of FunnelWeb.

@<Nav@>@(@<Intro_name FILE@>@,@<Intro FILE@>@,@<Intro_hello FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Intro_hello HEADING@>@M@{@<SH@>@(1.5@)A Hello World Document@}
@$@<Intro_hello FILE@>@M@{intro_hello.html@}
@O@<intro_hello.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Intro_hello HEADING@>@)
@<X@>@(hello world document@)

@<P@>Just as one starts the process of learning a new
programming language with a @<DQ@>@(Hello World@) program,
when learning  FunnelWeb, you can start with a @<DQ@>@(Hello
World@) document. And here it is! Edit a text file called
@<TT@>@(hello.fw@) and put the following text in it. (Note:
The second character is the letter @<DQ@>@(Oh@), not the
digit @<DQ@>@(Zero@)).

@<P@>
@<Begin verbatim@>
@@O@@@<<@>hello.txt@@@<>@>@@{Hello World@@+@@}
@<End verbatim@>

@<P@>To @<DQ@>@(run@) this @<DQ@>@(program@), invoke
FunnelWeb using the @<DQP@>@(fw@) command as
follows.@<X@>@(invoking FunnelWeb@)

@<P@>
@<Begin verbatim@>
fw hello
@<End verbatim@>

@<P@>@<I@>@(If this command doesn't work, then chances are
that FunnelWeb has not been installed on your machine. Refer
to the main @<FunnelWeb@> web for full details on how to
obtain and install a copy of FunnelWeb.@)

@<P@>There should be no errors. If there are, have a look at
the listing file @<TT@>@(hello.lis@), which should contain
an explanation of the error, and compare the area in the
file where the error occurred with the text above. If there
are no errors, you will find that the following two files
have been created.

@<P@>
@<Begin verbatim@>
hello.lis   - The LISTING file.
hello.txt   - The PRODUCT file.
@<End verbatim@>

@<P@>Take a look at @<TT@>@(hello.txt@). It should contain a
single line with the text @<TT@>@(Hello World@). Let's take
another look at the input file.

@<P@>
@<Begin verbatim@>
@@O@@@<<@>hello.txt@@@<>@>@@{Hello World@@+@@}
@<End verbatim@>

@<P@>The whole structure of the input file is controlled by
@<DQP@>@(@@@), called the @<NewTerm@>@(special character@),
which introduces @<NewTerm@>@(special sequence@)s. A
scanner's-eye view of the command line looks like this:

@<P@>
@<Begin verbatim@>
@@O  @@@<<@>  "hello.txt"  @@@<>@>
@@{  "Hello World"  @@+  @@}
@<End verbatim@>

@<P@>The @<TT@>@(@@@) character controls everything. In this
file we have six different special sequences that together
form a single macro definition. The
@<TT@>@(@@@<<@>@)@<X@>@(@@@<<@>@) and
@<TT@>@(@@@<>@>@)@<X@>@(@@@<>@>@) delimit the name of the
macro. The @<TT@>@(@@O@)@<X@>@(@@O@) signals the start of
the macro definition and indicates that the macro is to be
connected to a product file with the same name as the macro
(This is is why we got a product file when we ran
FunnelWeb). The @<TT@>@(@@{@) and
@<TT@>@(@@}@)@<X@>@(@@braces@) delimit the body of the
macro. Finally, the @<TT@>@(@@+@)@<X@>@(@@+@) instructs that
an end of line sequence should be inserted at that point in
the product file.

@<P@>If you think this syntax looks messy, then you're
right. It @<I@>@(is@) messy. FunnelWeb @<I@>@(could@) have
employed a @<DQ@>@(simpler@) notation in which more of the
@<TT@>@(@@@) sequences were eliminated. For example:

@<P@>
@<Begin verbatim@>
Warning: This example is NOT legal FunnelWeb.

#hello.txt{Hello World+}
@<End verbatim@>

@<P@>However, if such a syntax were used, the user (you!)
would have to remember that @<TT@>@(#@) starts a new macro.
You would also have to remember that the characters
@<TT@>@(}@) and @<TT@>@(+@) cannot be used in a macro body
without a fuss. And so on. FunnelWeb is messier, but
provides one simple rule:@<XX@>@(simple@,rule@)
@<I@>@(Nothing special happens unless the special character
@<TT@>@(@@@) appears.@)

@<P@>This means that in FunnelWeb, you can look at large
blocks of text in the confidence that (unlike for the C
pre-processor@<XX@>@(C@,preprocessor@)) there are no macro
calls hidden in there. If there were, there would be an
@<TT@>@(@@@) character! (The only exception to this
rule occurs where the user has explicitly changed the
special character using the @<TT@>@(@@=@)@<X@>@(@@=@)
special sequence).

@<P@>Let's take another look at the hello world program.

@<P@>
@<Begin verbatim@>
@@O@@@<<@>hello.txt@@@<>@>@@{Hello World@@+@@}
@<End verbatim@>

@<P@>In its current form, it consists of a single macro
definition. This definition, while completely valid on its
own, only represents half the power of FunnelWeb. In fact
you could say that it is a @<DQ@>@(Hello Northern Hemisphere
Program@).@<X@>@(Hello Northern Hemisphere Program@) To turn
it into a proper FunnelWeb @<DQ@>@(Hello World@) program, we
need to add some documentation.

@<P@>A FunnelWeb input file consists of a sequence of macro
definitions surrounded by a sea of documentation which is
just ordinary text. Modify your hello world document so that
it looks like this:

@<P@>
@<Begin verbatim@>
This hello world document was
created by -insert your name here-.

@@O@@@<<@>hello.txt@@@<>@>@@{Hello World@@+@@}

It writes out a file called hello.txt
containing the string ``Hello World''.
@<End verbatim@>

@<P@>Now run it through FunnelWeb, but this time, add a
@<TT@>@(+t@) to the command line.

@<P@>
@<Begin verbatim@>
fw hello +t
@<End verbatim@>

@<P@>If all goes well, you should find that you now have

@<P@>
@<Begin verbatim@>
hello.lis   - A LISTING       file.
hello.tex   - A DOCUMENTATION file (in TeX format).
hello.txt   - A PRODUCT       file.
@<End verbatim@>

@<P@>Take a look at @<TT@>@(hello.txt@). You will find that
it is identical to the @<TT@>@(hello.txt@) of the previous
run. Only macro definitions affect the product files that
FunnelWeb produces (as a result of @<TT@>@(@@O@) macro
definitions). The surrounding documentation has @<I@>@(no@)
effect. In contrast, the new file, @<TT@>@(hello.tex@) (have
a look at it now) which was created as a result of your
adding the @<TT@>@(+t@) option contains a fairly full
representation of the input file. Whereas
@<TT@>@(hello.txt@) is the @<I@>@(product file@) of
FunnelWeb, @<TT@>@(hello.tex@) is the @<I@>@(documentation
file@).

@<P@>Try typesetting the documentation file now using the
TeX typesetting program.  Then print it. The following
commands are an example of the sort of commands you will
have to give to do this.

@<P@>
@<Begin verbatim@>
tex hello               ! Typeset the doc.
lpr -Pcslw -d hello.dvi ! Print the typeset doc.
@<End verbatim@>

@<P@>If you don't have TeX, you can generate an
HTML documentation file instead. Here's how:

@<P@>
@<Begin verbatim@>
fw hello +u
@<End verbatim@>

@<P@>The documentation should consist of single page containing
the two lines of documentation along with a typeset representation
of the macro. At this point, you have exercised the two main
aspects of FunnelWeb.@<XX@>@(FunnelWeb@,two main aspects@)
Starting with an input file containing macros (or in this
case macro) and documentation, you have successfully
generated a product file based on the macros, and a
documentation file, based on the entire document.

@<P@>The next two sections focus on FunnelWeb's macro
facilities and its typesetting facilities. By tradition, the
generation of program files from a literate text is called
@<NewTerm@>@(Tangling@), and the generation of typeset
documentation is called @<NewTerm@>@(Weaving@). In
FunnelWeb, these two functions are aspects of a single
computer program. However, in Knuth's WEB@<X@>@(WEB@)
system, the two functions are embodied in two separate
computer programs called Tangle and Weave, presumably
because, as everyone knows, @<DQ@>@(it takes two to
Tangle@).

@<Nav/last@>@(@<Intro_tutorial FILE@>@,@<Intro FILE@>@,@<Intro FILE@>@)

@<End FWTutMan page@>
@}

@!******************************************************************************

@$@<Macro HEADING@>@M@{@<SH@>@(2@)Macro Facilities Tutorial@}
@$@<Macro HEADING/short@>@M@{@<SH@>@(2@)Macros@}
@$@<Macro FILE@>@M@{macro.html@}
@O@<macro.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Macro HEADING@>@)
@<XX@>@(tutorial@,macro facilities@)

@<P@>
@<Macro index@>

@<Nav@>@(@<Intro FILE@>@,@<Index FILE@>@,@<Type FILE@>@)

@<End FWTutMan page@>
@}

@$@<Macro index@>@M@{
@<Begin size3@>
@<Begin indent/narrow@>
@<Link@>@(@<Macro_simple FILE@>@,@<Macro_simple HEADING@>@)@<BR@>
@<Link@>@(@<Macro_times FILE@>@,@<Macro_times HEADING@>@)@<BR@>
@<Link@>@(@<Macro_indent FILE@>@,@<Macro_indent HEADING@>@)@<BR@>
@<Link@>@(@<Macro_additive FILE@>@,@<Macro_additive HEADING@>@)@<BR@>
@<Link@>@(@<Macro_param FILE@>@,@<Macro_param HEADING@>@)@<BR@>
@<Link@>@(@<Macro_library FILE@>@,@<Macro_library HEADING@>@)@<BR@>
@<Link@>@(@<Macro_expansion FILE@>@,@<Macro_expansion HEADING@>@)@<BR@>
@<Link@>@(@<Macro_include FILE@>@,@<Macro_include HEADING@>@)@<BR@>
@<End indent/narrow@>
@<End size3@>
@}

@!==============================================================================

@$@<Macro_simple HEADING@>@M@{@<SH@>@(2.1@)Simple Macros@}
@$@<Macro_simple FILE@>@M@{macro_simple.html@}
@O@<macro_simple.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Macro_simple HEADING@>@)
@<XX@>@(tutorial@,simple macros@)@<XX@>@(tutorial@,macros simple@)

@<P@>The original @<DQ@>@(Hello World@) program consisted of
a single macro definition.

@<P@>
@<Begin verbatim@>
@@O@@@<<@>hello.txt@@@<>@>@@{Hello World@@+@@}
@<End verbatim@>

@<P@>In fact, this is a rather exceptional macro, as it
causes its expansion to be written to a product file. The
@<TT@>@(@@O@)@<X@>@(@@O@) (for @<B@>@(O@)utput) signals this. In
FunnelWeb, most macros are defined using
@<TT@>@(@@$@).@<X@>@(@@dollar@) This  results in a macro
that does not generate a product file, but which can be
called in other macros (including @<TT@>@(@@O@) macros). Let
us expand the hello world program to include some other
macros.

@<P@>
@<Begin verbatim@>
@@O@@@<<@>hello.txt@@@<>@>@@{@@@<<@>Greetings@@@<>@>@@+@@}

@@$@@@<<@>H@@@<>@>==@@{Hello@@}
@@$@@@<<@>W@@@<>@>==@@{World@@}

@@$@@@<<@>Greetings@@@<>@>==@@{@@@<<@>H@@@<>@> @@@<<@>W@@@<>@>@@}
@<End verbatim@>

@<P@>Type in the file and run it through FunnelWeb using the command:

@<P@>
@<Begin verbatim@>
fw hello
@<End verbatim@>

@<P@>The product file (result.out) should look like this:

@<P@>
@<Begin verbatim@>
Hello World
@<End verbatim@>

@<P@>This short program illustrates some of the features of
ordinary macros in FunnelWeb. Consider the @<TT@>@(@@O@)
macro. Instead of containing straight text (@<DQ@>@(Hello
World@)), it now contains the macro call
@<TT@>@(@@@<<@>Greetings@@@<>@>@). A FunnelWeb macro can
be called from within the body of another macro just by
giving the macro name delimited in @<TT@>@(@@@<<@>@) and
@<TT@>@(@@@<>@>@).

@<P@>At the bottom of the file is the definition of the
@<TT@>@(@@@<<@>Greetings@@@<>@>@) macro. The definition
is similar to the definition of @<TT@>@(hello.txt@) except
that it starts with @<TT@>@(@@$@) to indicate that no
product file is desired from this macro (directly). It also
employs the optional @<TT@>@(==@) syntax which has no
semantic impact, but can be used to make definitions
clearer. The body of the
@<TT@>@(@@@<<@>Greetings@@@<>@>@) macro consists of
calls to the @<TT@>@(H@) and @<TT@>@(W@) macros which are
defined immediately above.

@<P@>Note that the macros are not constrained to be defined
in any particular order. One of the main features of
literate programming tools is that they allow the different
parts of the text document being developed (usually a
computer program) to be layed out in any
order.@<XX@>@(order@,program@)@<XX@>@(program@,layout@) So
long as there is a definition somewhere in the input file
for every macro call, FunnelWeb will sort it all out.

@<P@>In fact, FunnelWeb's macro facility is very
simple.@<XX@>@(macro@,bindings@) Unlike many macro
preprocessors which allow macros to define other macros,
FunnelWeb completely finishes parsing and analysing the
macros in the input file before it starts expanding them
into product files. Other preprocessors allow macros to be
redefined like variables (as in, say, TeX@<X@>@(TeX@))
taking on many different values as the macro pre-processor
travels through the input file. In contrast, FunnelWeb has
no concept of @<DQ@>@(different times@) and treats the input
as one huge static orderless, timeless, collection of
definitions. In FunnelWeb, there is only ever one time, and
so there can only ever be one value/definition for each
macro.

@<Nav@>@(@<Macro FILE@>@,@<Macro FILE@>@,@<Macro_times FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Macro_times HEADING@>@M@{@<SH@>@(2.2@)Number of Times Called@}
@$@<Macro_times FILE@>@M@{macro_times.html@}
@O@<macro_times.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Macro_times HEADING@>@)
@<X@>@(number of times called@)@<XX@>@(calls@,number@)@<XX@>@(invocation@,number@)

@<P@>So far we have seen only tiny, degenerate input files.
The next example moves up to the level of @<DQ@>@(trivial@),
but starts to convey the flavour of the way FunnelWeb can be
used in practice. Normally, there would be documentation
text appearing between the macros, but this has been omitted
so as to keep the focus on the macros themselves. Although
the next example is much longer than the previous example,
the only new construct is @<TT@>@(@@-@) which can appear
only at the end of a line, and suppresses
it,@<XX@>@(EOL@,suppression@) preventing it from appearing
in the text. The @<TT@>@(@@-@)@<X@>@(@@-@) construct allows
the text of a macro to be aligned at the left margin, rather
than having the first line hanging at the end of the
@<TT@>@(@@{@). FunnelWeb could have been set up so that
this end of line marker was suppressed. However, it would
have been a special case that would have broken the very
memorable rule @<DQ@>@(the text of a macro is the text
appearing between the @<TT@>@(@@{@) and @<TT@>@(@@}@)@).

@<P@>Type the following text into the file
@<TT@>@(hello.fw@) and run it through FunnelWeb. The file
contains some intentional errors so be sure to type it in
exactly and worry only if FunnelWeb @<I@>@(doesn't@)
generate some errors.

@<P@>
@<Begin verbatim@>
@@O@@@<<@>hello.c@@@<>@>==@@{@@-
@@@<<@>Include Files@@@<>@>
@@@<<@>Include Files@@@<>@>
@@@<<@>Main Program@@@<>@>
@@}

@@$@@@<<@>Main Program@@@<>@>==@@{@@-
main()
{
 doit();
}
@@}

@@$@@@<<@>Subroutine@@@<>@>==@@{@@-
void doit()
{
 int i;
 for (i=0;i@<<@>10;i++)
   {
    @@@<<@>Print@@@<>@>
    @@@<<@>Print@@@<>@>
   }
}@@}

@@$@@@<<@>Print@@@<>@>==@@{@@-
printf("Hello World!");
printf("\n");@@}

@@$@@@<<@>Scan@@@<>@>==@@{scanf@@}

@@$@@@<<@>Include Files@@@<>@>==@@{@@-
#include @<<@>stdio.h@<>@>
#include @<<@>stdlib.h@<>@>@@}
@<End verbatim@>

@<P@>What happened? Well, if you haven't typed the file in
properly, you may get some miscellaneous syntax errors. Fix
these before continuing. If the file has been correctly
typed, you should be faced with some error messages to do
with the number of times some of the macros are called.

@<P@>By default, FunnelWeb insists that each macro defined
is invoked exactly once. However, the file above defines
macros that are used more than once and a macro that is not
used at all. Let us examine the errors.

@<P@>First, we see that FunnelWeb has alerted us to the fact
that the @<TT@>@(Include Files@) macro has been called
twice. Once alerted to this, a quick look at the program
convinces us that calling the macro twice is a mistake, and
that one of the calls should be deleted.

@<P@>Second, we note that FunnelWeb has alerted us to the
fact that the @<TT@>@(@@@<<@>subroutine@@@<>@>@) macro
is never called. Again, a quick look at the program tells us
that this is a mistake (and a very common one in the use of
FunnelWeb), and that a call to the
@<TT@>@(@@@<<@>subroutine@@@<>@>@) macro should be
inserted just above the call to the @<TT@>@(@@@<<@>Main
Program@@@<>@>@) macro in the definition of
@<TT@>@(@@@<<@>hello.c@@@<>@>@).

@<P@>These two cases demonstrate why these checks have been
placed in FunnelWeb. It is nearly always acceptable for a
macro to be called once. However, if a macro is not called
at all, or called more than once, this is often a sign that
the user has made a mistake.

@<P@>These checks have a dark side too. In addition to the
errors mentioned above, FunnelWeb has generated two similar
errors that do not help us.

@<P@>First, we are alerted to the fact that the
@<TT@>@(@@@<<@>print@@@<>@>@) macro has been called
twice. Clearly, in this case, this is not a problem, and so
here FunnelWeb's fussiness is a nuisance.

@<P@>Second, we are alerted to the fact that the
@<TT@>@(@@@<<@>scan@@@<>@>@) macro has never been
called. Like the @<TT@>@(@@@<<@>print@@@<>@>@) macro,
this macro was defined as a notational convenience, and
clearly it does not matter here if it is not used. Again,
FunnelWeb is being a nuisance.

@<P@>The four cases above demonstrate the light and dark
side of FunnelWeb's insistence that each macro be called
exactly once. To resolve the conflict without reducing the
strength of the checking, FunnelWeb provides two special
sequences @<TT@>@(@@Z@) (for @<B@>@(Z@)ero) and @<TT@>@(@@M@)
(for @<B@>@(M@)any) that can be attached to macro definitions.
Presence of the @<TT@>@(@@Z@)@<XX@>@(@@Z@,tutorial@) tag
allows the designated macro to be called zero times.
Presence of the @<TT@>@(@@M@)@<XX@>@(@@M@,tutorial@) tag
allows the designated macro to be called more than once. A
single macro may carry both tags. It is always true that all
macros are allowed to be called exactly once.

@<P@>Here is the revised program with the errors fixed, by
eliminating or adding macro calls, or by adding tags. Try
processing the file now. There should be no errors.

@<P@>
@<Begin verbatim@>
@@O@@@<<@>hello.c@@@<>@>==@@{@@-
@@@<<@>Include Files@@@<>@>
@@@<<@>Function@@@<>@>
@@@<<@>Main Program@@@<>@>
@@}

@@$@@@<<@>Main Program@@@<>@>==@@{@@-
main()
{
 doit();
}
@@}

@@$@@@<<@>Function@@@<>@>==@@{@@-
void doit()
{
 int i;
 for (i=0;i@<<@>10;i++)
   {
    @@@<<@>Print@@@<>@>
    @@@<<@>Print@@@<>@>
   }
}@@}

@@$@@@<<@>Print@@@<>@>@@M==@@{@@-
printf("Hello World!");
printf("\n");@@}

@@$@@@<<@>Scan@@@<>@>@@Z==@@{scanf@@}

@@$@@@<<@>Include Files@@@<>@>==@@{@@-
#include @<<@>stdio.h@<>@>
#include @<<@>stdlib.h@<>@>@@}
@<End verbatim@>

@<Nav@>@(@<Macro_simple FILE@>@,@<Macro FILE@>@,@<Macro_indent FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Macro_indent HEADING@>@M@{@<SH@>@(2.3@)Indentation@}
@$@<Macro_indent FILE@>@M@{macro_indent.html@}
@O@<macro_indent.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Macro_indent HEADING@>@)
@<XX@>@(indentation@,macro calls@)

@<P@>The body of the @<TT@>@(print@) macro of the previous
example contains two lines of text. A literal substitution
of this macro's body in its context would result in:

@<P@>
@<Begin verbatim@>
   {
    printf("Hello World!");
printf("\n");
    printf("Hello World!");
printf("\n");
   }
@<End verbatim@>

@<P@>But instead, it comes out as (have a look at this part
of @<TT@>@(hello.c@) now):

@<P@>
@<Begin verbatim@>
   {
    printf("Hello World!");
    printf("\n");
    printf("Hello World!");
    printf("\n");
   }
@<End verbatim@>

@<P@>The explanation is that FunnelWeb indents each line of
multiline macros by the level of indentation at the point of
call. This means that, as in the case above, program texts,
which are usually highly indented, come out looking
@<DQ@>@(right@).

@<P@>In other circumstances, where the model of the text is
one dimensional, FunnelWeb's indentation could become an
impediment or even a danger. In these cases, it can be
switched off by including the FunnelWeb
@<NewTerm@>@(pragma@) line

@<P@>
@<Begin verbatim@>
@@p indentation = none
@<End verbatim@>

@<P@>anywhere in the input file.

@<P@>One of the design goals of FunnelWeb is to allow the
user total control over the product files. This contrasts
with the approach of Knuth's WEB@<X@>@(WEB@) system
@<Paper@>@(Knuth83@) (upon which FunnelWeb is based), which
mangles the input text at the Pascal@<X@>@(Pascal@) program
syntax level, truncating identifiers, converting the text to
upper case, and paragraphing text. Here is an example of
part of a Pascal program produced by
WEB@<XX@>@(output@,WEB@) (from page@<_@>14 of
@<Paper@>@(Knuth83@)):

@<P@>
@<Begin verbatim@>
IF R=0 THEN XREF[P]:=XREFPTR ELSE
XMEM[R].XLINKFIELD:=XREFPTR;END;{:51}
{58:}FUNCTION IDLOOKUP(T:EIGHTBITS):NAMEPOINTER;
LABEL 31;
VAR I:0..LONGBUFSIZE;H:0..HASHSIZE;K:0..MAXBYTES;
W:0..1;
L:0..LONGBUFSIZE;P:NAMEPOINTER;BEGIN
L:=IDLOC-IDFIRST;{59:}
H:=BUFFER[IDFIRST];I=IDFIRST+1;
WHILE I@<<@>IDLOC DO BEGIN H:=(H+H+BUFFER[I])MOD
HASHSIZE;I=I+1;END{:59};
@<End verbatim@>
@! CHECKED: I can't believe I actually typed this mess in.
@! Had to add in some line breaks to make it fit in web page.

@<P@>Knuth's theory is that the program generated by a
literate programming system should be treated as object code
and hence should look like object code too.@<X@>@(object
code@) While this may be an admirable approach in the long
run, the present programming environment is one of faulty
compilers and buggy tools. The FunnelWeb view is that, in
this environment, the programmer needs all the help he can
get and that therefore he should be allowed total control
over the product file. Another reason for FunnelWeb's
providing total control over the product file, is that
FunnelWeb is intended to be target language independent, and
so even if Knuth's view were adopted, it would not be clear
what a legitimate transformation of the text could be.

@<Nav@>@(@<Macro_times FILE@>@,@<Macro FILE@>@,@<Macro_additive FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Macro_additive HEADING@>@M@{@<SH@>@(2.4@)Additive Macros@}
@$@<Macro_additive FILE@>@M@{macro_additive.html@}
@O@<macro_additive.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Macro_additive HEADING@>@)
@<XX@>@(additive@,macros@)

@<P@>Sometimes it is convenient to build up the definition
of a macro in stages throughout the input file. In
FunnelWeb, this can be done using an @<NewTerm@>@(additive
macro@). An additive macro is identical to an ordinary macro
except that@<XX@>@(tutorial@,==@)@<XX@>@(tutorial@,+=@)

@<P@>
@<Begin list/ordered@>
@<Item@> It has @<TT@>@(+=@) instead of @<TT@>@(==@).
@<Item@> It can be defined in one or more parts throughout the input file.
The definition of the macro is the concatenation of all the parts in the
order in which they appear.
@<End list/ordered@>

@<P@>The following example shows how additive macros can be
used to scatter and regroup information, in this case
assisting in the lucid construction of a data
abstraction@<XX@>@(data@,abstraction@) in a language
(Pascal@<X@>@(Pascal@)) that does not support them
explicitly.

@<P@>
@<Begin verbatim@>
@@!******************************

@@O@@@<<@>prog.pas@@@<>@>==@@{@@-
program adt(input,output);
@@@<<@>Types@@@<>@>
@@@<<@>Variables@@@<>@>
@@@<<@>Procedures@@@<>@>
begin startproc; end.
@@}

@@!******************************

@@$@@@<<@>Types@@@<>@>+=@@{@@-
type buffer_type =
   record
   length : integer;
   buf : array[1..100] of char;
   end;
@@}

@@$@@@<<@>Variables@@@<>@>+=@@{@@-
bigbuf : buffer_type;
@@}

@@$@@@<<@>Procedures@@@<>@>+=@@{@@-
procedure buf_init (var b : buffer_type               )
   {Body of buf_init}
procedure buf_add  (var b : buffer_type;     ch : char)
   {Body of buf_add}
procedure buf_get  (var b : buffer_type; var ch : char)
   {Body of buf_get}
@@}

@@!******************************

@@$@@@<<@>Types@@@<>@>+=@@{@@-
type complex_type = record r,i : real; end;
@@}

@@$@@@<<@>Procedures@@@<>@>+=@@{@@-
procedure cm_set (var c: complex_type; a,b: real)
   {Body of cm_set}
procedure cm_add (a,b: complex_type; var c: complex_type)
   {Body of cm_add}
{Other procedures and functions}
@@}

@@!******************************

{...more pieces of program...}

@@!******************************
@<End verbatim@>

@<P@>It is important to remember that the definition of each
macro does not change throughout the input file. FunnelWeb
parses the entire input file and assembles all the macro
definitions before it even starts to expand macros. As a
result, each additive macro can only have one definition,
and that definition is the concatenation of all its parts.

@<P@>The example above shows how additive macros can be used
to rearrange the presentation of a computer program in the
order in which the user wishes to discuss it rather than the
order in which the compiler requires that it be consumed. It
is easy, however, to abuse the feature of additive macros.
In many cases, the same effect can be obtained more clearly
by replacing each part of an additive macro in-situ using
uniquely named non-additive macros, and then collect them
together as a group at the point where the additive macro is
called. Doing this is more work, and is more error prone,
but can result in a clearer exposition. The following
program illustrates this alternative approach.

@<P@>
@<Begin verbatim@>
@@!******************************

@@O@@@<<@>prog.pas@@@<>@>==@@{@@-
program adt(input,output);
@@@<<@>Types@@@<>@>
@@@<<@>Variables@@@<>@>
@@@<<@>Procedures@@@<>@>
begin startproc; end.
@@}

@@$@@@<<@>Types@@@<>@>==@@{@@-
@@@<<@>Buffer type@@@<>@>
@@@<<@>Complex type@@@<>@>
@@}

@@$@@@<<@>Variables@@@<>@>==@@{@@-
@@@<<@>Buffer variable@@@<>@>
@@}

@@$@@@<<@>Procedures@@@<>@>==@@{@@-
@@@<<@>Buffer procedures@@@<>@>
@@@<<@>Complex procedures@@@<>@>
@@}

@@!******************************

@@$@@@<<@>Buffer type@@@<>@>==@@{@@-
type buffer_type = record
                   length : integer;
                   buf : array[1..100] of char;
                   end;
@@}

@@$@@@<<@>Buffer variable@@@<>@>==@@{@@-
bigbuf : buffer_type;
@@}

@@$@@@<<@>Buffer procedures@@@<>@>==@@{@@-
procedure buf_init(var b : buffer_type)
   {Body of buf_init}
procedure buf_add(var b : buffer_type; ch : char)
   {Body of buf_add}
procedure buf_get(var b : buffer_type; var ch : char)
   {Body of buf_get}
@@}

@@!******************************

@@$@@@<<@>Complex type@@@<>@>==@@{@@-
type complex_type = record r,i : real; end;
@@}

@@$@@@<<@>Complex procedures@@@<>@>+=@@{@@-
procedure cm_set(var c: complex_type; a,b : real)
   {Body of cm_set}
procedure cm_add(a,b : complex_type; var c: complex_type)
   {Body of cm_add}
{Other procedures and functions}
@@}

@@!******************************

{...more pieces of program...}

@@!******************************
@<End verbatim@>

@<P@>One of advantages of FunnelWeb (and literate
programming in general) is that (as shown above) it allows
the user to lay out the program in whatever order is
desired@<XX@>@(program@,layout@) with near total
independence from the ordering requirements of the target
programming language.

@<P@>Additive macros are allowed to be tagged with
@<TT@>@(@@Z@) and @<TT@>@(@@M@) just as other macros can,
but the tags must appear only on the first definition of the
macro. Additive macros cannot be connected directly to
product files.

@<Nav@>@(@<Macro_indent FILE@>@,@<Macro FILE@>@,@<Macro_param FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Macro_param HEADING@>@M@{@<SH@>@(2.5@)Parameterized Macros@}
@$@<Macro_param FILE@>@M@{macro_param.html@}
@O@<macro_param.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Macro_param HEADING@>@)
@<XX@>@(parameterized@,macros@)

@<P@>No self-respecting macro preprocessor would be complete
without some form of macro parameterization, and FunnelWeb
is no exception. FunnelWeb allows each macro to have from
zero to nine formal parameters@<XX@>@(formal@,parameters@)
named @<TT@>@(@@1@)@<X@>@(@@1...@), @<TT@>@(@@2@),
@<TT@>@(@@3@), @<TT@>@(@@4@), @<TT@>@(@@5@), @<TT@>@(@@6@),
@<TT@>@(@@7@), @<TT@>@(@@8@), and @<TT@>@(@@9@).

@<P@>To define a macro with one or more parameters, insert a
formal parameter list@<XX@>@(formal@,parameters@) just after
the macro name in the macro definition. Because macro
parameters have fixed names
(@<TT@>@(@@1@)@<LDots@>@<TT@>@(@@9@)), there is no need to
specify the names of formal parameters in the formal
parameter list. All that need be conveyed is how many
parameters the macro has. Here is an example of the
definition of a macro having three parameters:

@<P@>
@<Begin verbatim@>
@@$@@@<<@>While loop@@@<>@>@@(@@3@@)@@M==@@{@@-
@@1
while (@@2)
  {
   @@3
  }
@@}
@<End verbatim@>

@<P@>To call a parameterized macro, an actual
parameter@<XX@>@(actual@,parameters@) list must be supplied
that contains exactly the same number of actual parameters
as there are formal parameters in the definition of the
macro being called. An actual parameter list is delimited by
@<TT@>@(@@(@)@<X@>@(@@(@) and @<TT@>@(@@)@),@<X@>@(@@}@) and
parameters are @<I@>@(separated@) by
@<TT@>@(@@,@).@<X@>@(@@,@) The actual parameters themselves
are general FunnelWeb expressions (see the
@<FunnelWeb Reference Manual@> for the exact syntax) and can
be inserted into the list directly or can be delimited by
@<TT@>@(@@"@)@<X@>@(@@"@) so as to allow some white space to
assist in formatting the actual parameters. Here are some
examples of calls of the @<TT@>@(While loop@) macro defined
above.

@<P@>
@<Begin verbatim@>
@@! First form of actual parameters
@@! without whitespace and double quotes.
@@@<<@>While loop@@@<>@>@@(@@-
x=1;@@,x@<<@>=10@@,printf("X=%u\n",x);@@)

@@! Second form of actual parameters. The double
@@! quotes allow non-active whitespace that helps
@@! to lay out the actual parameters neatly. This
@@! call is functionally identical to the one above.
@@@<<@>While loop@@@<>@>@@(
   @@"x:=1;@@" @@,
   @@"x@<<@>=10@@" @@,
   @@"printf("X=%u\n",x);@@" @@)

@@! The two forms can be mixed in a single call.
@@@<<@>While loop@@@<>@>@@(x=1;@@,x@<<@>=10@@,
              @@"printf("X=%u\n",x);@@" @@)
@<End verbatim@>

@<P@>A few rules about parameterized macros are worth
mentioning. Macros that do not have any parameters must have
no formal or actual parameter lists.@<XS@>@(parameter
list@,absent@) Additive macros can have parameters, but the
formal parameter list must appear in the first definition
part only.

@<P@>Here is another example of the use of parameterized
macros. This time, parameters and macro calls are used in a
FunnelWeb input file that constructs an O(n)
representation of a song@<X@>@(song@)@<X@>@(twelve bugs of
christmas@) whose full size is O(n^2) in the number n of
unique lines.@<X@>@(rec.humor.funny@)@<XN@>@(Pat@,Scannel@)

@<P@>
@<Begin verbatim@>
@@O@@@<<@>Twelve_bugs.txt@@@<>@>==@@{@@-
The Twelve Bugs of Christmas
----------------------------
@@@<<@>Verse@@@<>@>@@(@@"first@@"    @@,@@@<<@>1@@@<>@>@@)
@@@<<@>Verse@@@<>@>@@(@@"second@@"   @@,@@@<<@>2@@@<>@>@@)
@@@<<@>Verse@@@<>@>@@(@@"third@@"    @@,@@@<<@>3@@@<>@>@@)
@@@<<@>Verse@@@<>@>@@(@@"fourth@@"   @@,@@@<<@>4@@@<>@>@@)
@@@<<@>Verse@@@<>@>@@(@@"fifth@@"    @@,@@@<<@>5@@@<>@>@@)
@@@<<@>Verse@@@<>@>@@(@@"sixth@@"    @@,@@@<<@>6@@@<>@>@@)
@@@<<@>Verse@@@<>@>@@(@@"seventh@@"  @@,@@@<<@>7@@@<>@>@@)
@@@<<@>Verse@@@<>@>@@(@@"eighth@@"   @@,@@@<<@>8@@@<>@>@@)
@@@<<@>Verse@@@<>@>@@(@@"ninth@@"    @@,@@@<<@>9@@@<>@>@@)
@@@<<@>Verse@@@<>@>@@(@@"tenth@@"    @@,@@@<<@>A@@@<>@>@@)
@@@<<@>Verse@@@<>@>@@(@@"eleventh@@" @@,@@@<<@>B@@@<>@>@@)
@@@<<@>Verse@@@<>@>@@(@@"twelfth@@"  @@,@@@<<@>C@@@<>@>@@)

This song appeared in the internet newsgroup
rec.humor.funny on 24-Dec-1991. It was contributed
by Pat Scannell (scannell@@@@darkstar.ma30.bull.com).
@@}

@@$@@@<<@>Verse@@@<>@>@@(@@2@@)@@M==@@{@@-
For the @@1 bug of Christmas, my manager said to me
     @@2
@@}

@@$@@@<<@>1@@@<>@>@@M==@@{@@-
See if they can do it again.@@}
@@$@@@<<@>2@@@<>@>@@M==@@{@@-
Ask them how they did it and@@+@@@<<@>1@@@<>@>@@}
@@$@@@<<@>3@@@<>@>@@M==@@{@@-
Try to reproduce it@@+@@@<<@>2@@@<>@>@@}
@@$@@@<<@>4@@@<>@>@@M==@@{@@-
Run with the debugger@@+@@@<<@>3@@@<>@>@@}
@@$@@@<<@>5@@@<>@>@@M==@@{@@-
Ask for a dump@@+@@@<<@>4@@@<>@>@@}
@@$@@@<<@>6@@@<>@>@@M==@@{@@-
Reinstall the software@@+@@@<<@>5@@@<>@>@@}
@@$@@@<<@>7@@@<>@>@@M==@@{@@-
Say they need an upgrade@@+@@@<<@>6@@@<>@>@@}
@@$@@@<<@>8@@@<>@>@@M==@@{@@-
Find a way around it@@+@@@<<@>7@@@<>@>@@}
@@$@@@<<@>9@@@<>@>@@M==@@{@@-
Blame it on the hardware@@+@@@<<@>8@@@<>@>@@}
@@$@@@<<@>A@@@<>@>@@M==@@{@@-
Change the documentation@@+@@@<<@>9@@@<>@>@@}
@@$@@@<<@>B@@@<>@>@@M==@@{@@-
Say it's not supported@@+@@@<<@>A@@@<>@>@@}
@@$@@@<<@>C@@@<>@>@@M==@@{@@-
Tell them it's a feature@@+@@@<<@>B@@@<>@>@@}
@<End verbatim@>

@<Nav@>@(@<Macro_additive FILE@>@,@<Macro FILE@>@,@<Macro_library FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Macro_library HEADING@>@M@{@<SH@>@(2.6@)Library Macros@}
@$@<Macro_library FILE@>@M@{macro_library.html@}
@O@<macro_library.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Macro_library HEADING@>@)
@<XX@>@(library@,macros@)

@<P@>FunnelWeb provides a library macro feature that allows
you to redefine macros. Normally, FunnelWeb will generate an
error if you attempt to define a macro of a particular name
more than once. However, if you attach a different number of
@<TT@>@(@@L@) markers (up to five) to each definition,
FunnelWeb accepts the multiple definitions, and at tangle time
uses the definition with the least number of @<TT@>@(@@L@)s.
For example:

@<P@>
@<Begin verbatim@>
@@$@@@<<@>ugly duckling@@@<>@>@@L@@L@@{egg@@}
@@$@@@<<@>ugly duckling@@@<>@>@@{swan@@}
@@$@@@<<@>ugly duckling@@@<>@>@@L@@{signet@@}
@<End verbatim@>

@<P@>In this example, the ugly duckling macro will expand
to @<TT@>@(swan@) because the swan definition has the least
number of @<TT@>@(@@L@) markers (@<ie@>the lowest library level).

@<P@>No two definitions may have the same name and level, but
definitions having the same name, but differing levels, are
independent of each other and can have different call number
constraints. They can even be defined additively,
with their multipart definitions interlaced. For example:

@<P@>
@<Begin verbatim@>
@@$@@@<<@>ugly duckling@@@<>@>@@L@@L+=@@{eg@@}
@@$@@@<<@>ugly duckling@@@<>@>@@L+=@@{sig@@}
@@$@@@<<@>ugly duckling@@@<>@>@@L@@L+=@@{g@@}
@@$@@@<<@>ugly duckling@@@<>@>@@L+=@@{net@@}
@<End verbatim@>

@<P@>Here, two macros having the same
name (@<TT@>@(ugly duckling@)) are defined at library
levels one and two. Each of these macros is defined in
two additive parts. The first macro is at level two
and has the value @<TT@>@(egg@). The second macro is
at level one and has the value @<TT@>@(signet@).
If this macro name were referenced by another macro, it
would be expanded to @<TT@>@(signet@), as this is the
value of the definition with the lowest library level.

@<FWTutMan subheading@>@(Uses Of Library Macros@)

@<P@>When using FunnelWeb as a macro preprocessor (@<eg@>for
the generation of HTML webs), it's convenient to be able to
define include files that contain large numbers of commonly
used macro definitions. However, sometimes, some macros must
be redefined. By tagging such macros in the include file
using @<TT@>@(@@L@), such redefinition is made possible.

@<Nav@>@(@<Macro_param FILE@>@,@<Macro FILE@>@,@<Macro_expansion FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Macro_expansion HEADING@>@M@{@<SH@>@(2.7@)Macro Expansion@}
@$@<Macro_expansion FILE@>@M@{macro_expansion.html@}
@O@<macro_expansion.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Macro_expansion HEADING@>@)
@<XX@>@(macro@,expansion@)

@<P@>One of the strengths of FunnelWeb is that, when writing
product files, it does not attempt to evaluate any text
expression (@<eg@>text block, parameter, macro call) in
memory@<XX@>@(memory@,use of@) and then write the result
out. Instead, it always writes out what it is expanding
dynamically and directly. This means that you need not
fear defining macros that expand to huge amounts of text and
then calling those macros in other macros, or passing those
huge macros as parameters to other macros. In all cases,
FunnelWeb expands directly to the product file, and there
can be no danger in running out of memory during expansion
(except for running out of stack space and other marginally
used resources in pathological cases).

@<P@>The only thing to remember in this regard is that
FunnelWeb always stores the entire @<I@>@(input@) file and
all included files, in their entirety in memory, for the
duration of the run.

@<P@>Here is an example, that illustrates how robust
FunnelWeb is:

@<P@>
@<Begin verbatim@>
@@! FunnelWeb copes well with the following
@@! macro definitions. (Providing that it has
@@! a little over ten megabytes of memory).

@@O@@@<<@>woppa.txt@@@<>@>==@@{@@-
@@@<<@>Quote@@@<>@>@@(@@@<<@>Humungeous@@@<>@>@@)@@+@@}

@@$@@@<<@>Quote@@@<>@>@@(@@1@@)==@@{"@@1"@@}

@@$@@@<<@>Humungeous@@@<>@>==@@{@@-
...Ten Megabytes of Text...
@@}
@<End verbatim@>

@<Nav@>@(@<Macro_library FILE@>@,@<Macro FILE@>@,@<Macro_include FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Macro_include HEADING@>@M@{@<SH@>@(2.8@)Include Files@}
@$@<Macro_include FILE@>@M@{macro_include.html@}
@O@<macro_include.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Macro_include HEADING@>@)
@<XX@>@(include@,files@)

@<P@>FunnelWeb provides a nested include file facility that
can be used for a number of purposes. When FunnelWeb runs
into a single line containing the special sequence
@<TT@>@(@@i@)@<X@>@(@@i@) followed by a blank, followed by a
file name, it reads in the designated file and replaces the
line containing the command (including the end of line
marker at the end of the line) with the entire contents of
the designated file. For example, if there was a file called
@<TT@>@(camera.txt@) containing the two
lines:@<XX@>@(poem@,camera@)@<XX@>@(animal@,poem@)

@<P@>
@<Begin verbatim@>
'Cos I shoot with a camera instead of a gun.
The animals flock to be petted and fed,
@<End verbatim@>

@<P@>and another file called @<TT@>@(poem.fw@)
containing the following four lines@<X@>@(shooting@)

@<P@>
@<Begin verbatim@>
I like to go shooting, it's a whole lot of fun,
@@i camera.txt
Cos they know my camera isn't loaded with lead.
- RNW, 04-Jan-1991.
@<End verbatim@>

@<P@>Then, if FunnelWeb were to process @<TT@>@(poem.fw@),
the result would be as if FunnelWeb had read in:

@<P@>
@<Begin verbatim@>
I like to go shooting, it's a whole lot of fun,
'Cos I shoot with a camera instead of a gun.
The animals flock to be petted and fed,
'Cos they know my camera isn't loaded with lead.
- RNW, 04-Jan-1991.
@<End verbatim@>

@<P@>FunnelWeb expands include files before it starts
scanning and parsing the included text. The result is that
include files can contain anything that can be found in a
FunnelWeb file. The following example illustrates the level
at which the include mechanism operates. If
@<TT@>@(main.fw@) contains

@<P@>
@<Begin verbatim@>
@@O@@@<<@>output.dat@@@<>@>==@@{@@-
@@i inc.fw
This is the text of the sloth macro.
@@}
@<End verbatim@>

@<P@>and inc.fw contains

@<P@>
@<Begin verbatim@>
@@@<<@>Sloth@@@<>@>
@@}

@@$@@@<<@>Sloth@@@<>@>==@@{@@-
@<End verbatim@>

@<P@>Then if FunnelWeb were applied to @<TT@>@(main.fw@), it would see:

@<P@>
@<Begin verbatim@>
@@O@@@<<@>output.dat@@@<>@>==@@{@@-
@@@<<@>Sloth@@@<>@>
@@}

@@$@@@<<@>Sloth@@@<>@>==@@{@@-
This is the text of the sloth macro.
@@}
@<End verbatim@>

@<P@>which it would process in the normal manner. The only
special sequence processing that takes place at a level
lower than include files is the processing of the
@<TT@>@(@<<@>special@<>@>=@<<@>newspecial@<>@>@)
sequence which changes the special character.@<XX@>@(special
character@,changing@)

@<P@>A few other facts about include files are worth
mentioning here. Include files inherit the directory
specification supplied using the @<TT@>@(+I@) command line
option. The special character is saved at the start of each
include file and restored to its previous value at the end
of each include file. Include files can be nested up to ten
levels. Recursive included files@<XX@>@(include
files@,recursive@) will always cause an infinite recursion
as there is no bottoming out mechanism available. Include
files must contain an integer number of lines (@<ie@>the
last line must be terminated with an end of line marker).
Once FunnelWeb has seen @<DQP@>@(@@i@<_@>@) at the start of a
line, it will grab the rest of the line raw and treat it as
a file name. There is no place on the line for things like
FunnelWeb comments (see later) or extraneous text.

@<P@>Include files can be used for many purposes, but are
particularly useful for hauling in macro
libraries.@<XX@>@(macro@,libraries@)

@<Nav/last@>@(@<Macro_expansion FILE@>@,@<Macro FILE@>@,@<Macro FILE@>@)

@<End FWTutMan page@>
@}

@!******************************************************************************

@$@<Type HEADING@>@M@{@<SH@>@(3@)Typesetting Facilities Tutorial@}
@$@<Type HEADING/short@>@M@{@<SH@>@(3@)Typesetting@}
@$@<Type FILE@>@M@{type.html@}
@O@<type.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Type HEADING@>@)

@<P@>
@<Type index@>

@<Nav@>@(@<Macro FILE@>@,@<Index FILE@>@,@<Example FILE@>@)

@<End FWTutMan page@>
@}

@$@<Type index@>@M@{
@<Begin size3@>
@<Begin indent/narrow@>
@<Link@>@(@<Type_overview FILE@>@,@<Type_overview HEADING@>@)@<BR@>
@<Link@>@(@<Type_independence FILE@>@,@<Type_independence HEADING@>@)@<BR@>
@<Link@>@(@<Type_hierarchy FILE@>@,@<Type_hierarchy HEADING@>@)@<BR@>
@<Link@>@(@<Type_printed FILE@>@,@<Type_printed HEADING@>@)@<BR@>
@<Link@>@(@<Type_literals FILE@>@,@<Type_literals HEADING@>@)@<BR@>
@<Link@>@(@<Type_header FILE@>@,@<Type_header HEADING@>@)@<BR@>
@<Link@>@(@<Type_comments FILE@>@,@<Type_comments HEADING@>@)@<BR@>
@<End indent/narrow@>
@<End size3@>
@}

@!==============================================================================

@$@<Type_overview HEADING@>@M@{@<SH@>@(3.1@)Overview@}
@$@<Type_overview FILE@>@M@{type_overview.html@}
@O@<type_overview.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Type_overview HEADING@>@)
@<XX@>@(overview@,typesetting@)

@<P@>The previous sections of this manual have focused solely on the
macro facilities of FunnelWeb (which are more or less covered
completely). As a result, the example documents you have
seen so far have been gross distortions of @<DQ@>@(normal@)
FunnelWeb documents. Normal FunnelWeb documents
often contain as much
documentation as code.@<X@>@(documentation vs
code@)@<X@>@(code vs documentation@) While there
are applications where FunnelWeb can be used solely as a
macro preprocessor, many applications will use its
typesetting facilities as well.

@<P@>The macro definitions discussed in the macro tutorial
completely define the contents of the product files that
FunnelWeb will generate. These macro definitions can be
arranged in any order, and nothing external to them can
affect the contents of the product files. The macros can be
thought of as a group of self-contained islands.

@<P@>Although FunnelWeb will can process the macros all on
their own, the full power of FunnelWeb is realized only when
the macros are surrounded by a sea of documentation. This
sea can take two forms: directives and free text. Some of
the directives control things such as the maximum input line
length. However, most of them are typesetting directives
that affect the printed documentation. Thus a FunnelWeb
document can be viewed as a sequence of @<NewTerm@>@(macro
definitions@), @<NewTerm@>@(directives@), and
@<NewTerm@>@(free text@).

@<P@>Unlike the product files which consist of unscrambled
macro calls, the documentation file is more or less a direct
representation of the input file. Each part of the input
file appears in the documentation file in the order in which
it appears in the input file. However, each different kind
of part is typeset [Note: Here the term @<DQ@>@(typeset@)
is used loosely to refer to FunnelWeb's generation of
typesetter commands for each construct in the input file.
Strictly, the term should be used only to describe the
actions of a typesetter program (@<eg@>TeX).] in a
different manner. Macros are typeset in a particular style,
with the macro body appearing in @<TT@>@(tt font@) (see some
FunnelWeb printed documentation for an example). Typesetter
directives have specific defined effects (more later). Free
text is typeset exactly as it is, except that each block of
text between blank lines is filled and justified as a
paragraph.

@<P@>The following example demonstrates how all this works.
Type in the following as @<TT@>@(example.fw@) and run it
through FunnelWeb with the command @<DQP@>@(fw@<_@>example@<_@>+t@).
The @<DQP@>@(+t@) instructs FunnelWeb to generate a
documentation file called @<TT@>@(example.tex@). Run the
file through TeX and print it. Examine the files
@<TT@>@(example.out@) and @<TT@>@(example.tex@).

@<P@>
@<Begin verbatim@>
You are reading some free text before the
macro. Free text can consist of any text
(not containing the FunnelWeb special
character) including typesetter commands
such as $, %, #, and TeX which
will be typeset to appear exactly as
they do in the input file!
Look out! Here comes a macro!

@@O@@@<<@>example.out@@@<>@>==@@{@@-
This text is part of
a macro definition.
@@}

This is free text following the macro. This
sentence contains two @@{inline@@} typesetter
@@/directives@@/. Now here is a non-inline
typesetting directive.

@@t new_page

This sentence will appear on the next page.
@<End verbatim@>

@<P@>At the top of the @<TT@>@(example.tex@) documentation
file will be a set of TeX macro definitions. The TeX code
corresponding to the input above appears at the end of the
file. It should look something like this.

@<P@>
@<Begin verbatim@>
You are reading some free text before the
macro. Free text can consist of any text
(not containing the FunnelWeb special
character) including typesetter commands
such as \$, \%, \#, and \TeX{} which
will be typeset to appear exactly as
they do in the input file!
Look out! Here comes a macro!

\fwbeginmacro
\fwfilename{example.out,1}\fwequals
\fwodef \fwbtx[This text is part of
a macro definition.
]fwetx=%
\fwcdef
\fwbeginmacronotes
\fwisafile{This macro is attached to an output file.}
\fwendmacronotes
\fwendmacro

This is free text following the macro. This sentence contains
two \fwlit{inline} typesetter \fwemp{directives}.
Now here is a non-inline typesetting directive.

\fwnewpage

This sentence will appear on the next page.
@<End verbatim@>

@<P@>The following points explain the @<TT@>@(example.tex@)
file.

@<Narrowthing@>@(You don't have to know TeX:@,If you don't
know TeX, don't pay too much attention to this section. You
don't need to know TeX to use FunnelWeb.@)

@<Narrowthing@>@(In order:@,FunnelWeb has merely transformed
the input. It hasn't rearranged it.@)

@<Narrowthing@>@(Free text:@,Most of the free text has been
simply copied over. The TeX typesetter justifies and fills
all paragraphs fed to it by default, so most of the text has
just been copied verbatim.@)

@<Narrowthing@>@(TeX codes:@,The characters and sequences
which TeX treats as special have been neutralized in the
documentation file. For example, @<DQP@>@($@) has become
@<DQP@>@(\$@). By default, FunnelWeb allows the user to
write any text as free text and not have to worry about
accidentally invoking typesetter features.@)

@<Narrowthing@>@(fw sequences:@,The @<TT@>@(fw@) sequences
(@<eg@>@<TT@>@(\fwbeginmacro@)) invoke TeX macros
defined earlier in the documentation file (and not shown
here).@)

@<Narrowthing@>@(The macro:@,The macro is typeset using a
set of predefined TeX macros. See the printed documentation
to see what this looks like on paper.@)

@<Narrowthing@>@(Typesetter directives:@,Unlike the TeX
command sequences (which were neutralized), the FunnelWeb
typesetter directives turn into TeX macro calls. For
example, @<DQP@>@(@@{inline@@}@) became
@<DQP@>@(\fwlit{inline}@).@)

@<P@>FunnelWeb can also generate documentation in HTML form.
Just replace the @<TT@>@(+t@) option with the @<TT@>@(+u@) option.

@<P@>In summary, FunnelWeb produces typeset documentation
that transforms, but does not reorder, the input file.
Macros are typeset in a specific style. FunnelWeb typesetter
directives have particular well-defined effects. Free text
is filled and justified, but will otherwise appear in the
printed documentation exactly as it appears in the input
file.

@<Nav/first@>@(@<Type FILE@>@,@<Type FILE@>@,@<Type_independence FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Type_independence HEADING@>@M@{@<SH@>@(3.2@)Typesetter Independence@}
@$@<Type_independence FILE@>@M@{type_independence.html@}
@O@<type_independence.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Type_independence HEADING@>@)
@<XX@>@(typesetter@,independence@)

@<P@>FunnelWeb encourages
typesetter independence by neutralizing all TeX (or HTML) control
sequences before writing them out. The result is that you
don't have worry about upsetting or depending on TeX by
accidentally including some special character or sequence.
By default your input file is @<NewTerm@>@(typesetter
independent@).

@<P@>This scheme differs from other literate programming
tools (including very early versions of FunnelWeb) which
copy their free text  directly to the documentation file,
the justification being that the programmer can use the full
power of the typesetter language to describe the program.
The disadvantages of doing this are first that the
programmer is required to know the typesetting language and
second that the input file becomes typesetter dependent.
FunnelWeb avoids these problems by nobbling the free text
be default.

@<P@>However, FunnelWeb does provide a trapdoor for those
who want their free text to be fed directly to TeX. To open
the trapdoor, simply include one of the following pragmas
somewhere in your input file.

@<P@>
@<Begin verbatim@>
@@p typesetter = tex
@@p typesetter = html
@<End verbatim@>

@<P@>See the @<FunnelWeb Reference Manual@> for more information.

@<P@>FunnelWeb leaves the degree to which the user wishes to
bind a particular document to a particular typesetter up to
the user. In some cases, the extra typesetting power may
compensate for the lack of portability. However, as a rule,
it is best to avoid typesetter-specific commands, so as to
allow your input files to be formatted at a later date for
different typesetters. FunnelWeb includes a number of its
own typesetter commands so as to support
typesetter-independent input files. The following sections
describe some of these commands. In particular, the next
section describes the most powerful FunnelWeb typesetting
directives which allow the user to structure the document
hierarchically.

@<Nav@>@(@<Type_overview FILE@>@,@<Type FILE@>@,@<Type_hierarchy FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Type_hierarchy HEADING@>@M@{@<SH@>@(3.3@)Hierarchical Structure@}
@$@<Type_hierarchy FILE@>@M@{type_hierarchy.html@}
@O@<type_hierarchy.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Type_hierarchy HEADING@>@)
@<XX@>@(hierarchical@,structure@)

@<P@>The tree structure is one of the most effective
structuring tools that exists, deriving its power from the
principal of divide and conquor. So effective is it that the
internal organization of most technical books are tree
structures which are concisely summarized in the table of
contents. In contrast, computer programs are usually
presented as flat sequences of text to be consumed by an
anonymous compiler.

@<P@>In order to bring program documentation up to the
structural sophistication commonplace in technical books,
FunnelWeb provides five levels of section
headings@<XX@>@(section@,headings@) implemented by the five
special sequences @<TT@>@(@@A@),@<X@>@(@@A...@)
@<TT@>@(@@B@), @<TT@>@(@@C@), @<TT@>@(@@D@), and
@<TT@>@(@@E@). These must always appear at the start of a
line. @<TT@>@(@@A@) is the highest level section (@<eg@>like
LaTeX's @<TT@>@(\chapter@)) and @<TT@>@(@@E@) is the
lowest level section (@<eg@>like LaTeX's
@<TT@>@(\subsubsubsection@)). Section headings can
appear anywhere in the free text of a FunnelWeb input file
(@<ie@>anywhere except inside a macro definition).

@<P@>Each section heading@<XX@>@(name@,section@) in a
FunnelWeb document has an associated name. The name of a
section can be provided explicitly by supplying it delimited
by @<TT@>@(@@@<<@>@) and @<TT@>@(@@@<>@>@) immediately
after the section sequence (@<eg@>@<TT@>@(@@A@)), or
implicitly by not providing an explicit name, in which case
the section takes the name of the first macro defined
between the section header in question and the following
section header. An error is generated if a section has not
been given an explicit name and does not contain any macro
definitions. Here are some example headings:

@<P@>
@<Begin verbatim@>
@@A@@@<<@>Feed the Penguins and Save the World@@@<>@>
@@B@@@<<@>Feed the Penguins@@@<>@>
@@C@@@<<@>Feed the little penguins@@@<>@>
@@C@@@<<@>Feed the big penguins@@@<>@>
@@B@@@<<@>Save the World@@@<>@>
@@C@@@<<@>Save Europe@@@<>@>
@@C@@@<<@>Save Africa@@@<>@>

@@C This heading hasn't been given an
explicit name, but will inherit the name
@<TT@>@(Save the rest of the world@)
from the macro definition below.

@@$@@@<<@>Save the rest of the world@@@<>@>@@Z==@@{...@@}
@<End verbatim@>

@<P@>The feature of having unnamed sections inherit the name
of the first macro defined within their scope is present
because a common style of writing in FunnelWeb is to have
one section per macro definition. Because, under this style,
each section describes a single macro, it usually turns out
that the macro name makes a good name for the section too.
The inheritance mechanism prevents duplication of the
name.@<XX@>@(section name@,inheritance@)

@<P@>Apart from the requirement that each section have an
explicit or implicit name and that its special sequence
appear at the start of a line, the only other restriction on
section headings is that a section heading at level n
cannot appear immediately after a section heading at level
n-1 or less. In other words, the hierarchy cannot be
broken. For example, an @<TT@>@(@@C@) cannot appear after an
@<TT@>@(@@A@) heading unless there is an intervening
@<TT@>@(@@B@) heading.

@<P@>
@<Begin verbatim@>
@@A@@@<<@>The Top Heading@@@<>@>
@@C@@@<<@>Level C here is not allowed after an A@@@<>@>
@<End verbatim@>

@<P@>This rule extends to the start of the file; if there
are any headings at all, the first one must be an
@<TT@>@(@@A@) heading. The following file, while short, is
in error.

@<P@>
@<Begin verbatim@>
This FunnelWeb input file is in error
because its first section heading
is at level C rather than level A.
@@C@@@<<@>2@@@<>@>
@<End verbatim@>

@<Nav@>@(@<Type_independence FILE@>@,@<Type FILE@>@,@<Type_printed FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Type_printed HEADING@>@M@{@<SH@>@(3.4@)Understanding the Printed Documentation@}
@$@<Type_printed FILE@>@M@{type_printed.html@}
@O@<type_printed.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Type_printed HEADING@>@)

@<P@>Type in the following file, and use FunnelWeb and TeX
to generate the corresponding printed
documentation.@<XX@>@(programmer's@,cheer@)@<XX@>@(hacker's@,cheer@)
@<XX@>@(hacker's@,dictionary@)

@<P@>
@<Begin verbatim@>
@@A@@@<<@>Table of Contents@@@<>@>

@@t table_of_contents

@@A@@@<<@>Macros for Moral Support@@@<>@>

The following macro contain comments that provide moral
support.

@@$@@@<<@>Programmer's Cheer@@@<>@>@@M==@@{
-- Shift to the left!
-- Shift to the right!
-- Pop up, push down!
-- Byte! Byte! Byte!
-- (From "The New Hacker's Dictionary").
@@}

The next macro is similar but is
distributed throughout the program.

@@$@@@<<@>Hacker's Cheer@@@<>@>+=@@{
-- Pointer to the left@@+@@}

@@A@@@<<@>An Extremely Imperative Stack Abstraction@@@<>@>

@@B@@@<<@>Define the Stack@@@<>@>

@@$@@@<<@>Hacker's Cheer@@@<>@>+=@@{@@-
-- Pointer to the right@@+@@}

@@$@@@<<@>Stack Type@@@<>@>@@Z==@@{@@-
type stack = record ... end;@@}

@@B@@@<<@>Push the Stack@@@<>@>

@@$@@@<<@>Hacker's Cheer@@@<>@>+=@@{@@-
-- Hack that code@@+@@}

@@$@@@<<@>Push Procedure@@@<>@>@@Z==@@{@@-
procedure push(var b:stack; v:value);
@@@<<@>Programmer's Cheer@@@<>@> {...}@@}

@@B@@@<<@>Pop the Stack@@@<>@>

@@$@@@<<@>Hacker's Cheer@@@<>@>+=@@{@@-
-- Tight! Tight! Tight!@@+@@}

@@$@@@<<@>Pop Procedure@@@<>@>@@Z==@@{@@-
procedure pop(var b:stack);

@@@<<@>Programmer's Cheer@@@<>@> {...}@@}

@@B@@@<<@>Rough the Stack Up a Bit@@@<>@>

@@$@@@<<@>Hacker's Cheer@@@<>@>+=@@{@@-
-- (RNW, 04-Jan-1991).@@+@@}

@@$@@@<<@>Rough Procedure@@@<>@>@@Z==@@{@@-
procedure rough(var b:stack);
@@@<<@>Hacker's Cheer@@@<>@> {...}@@}

@@O@@@<<@>dummy.txt@@@<>@>==@@{dummy@@+@@}
@<End verbatim@>

@<P@>An examination of the printed documentation reveals a
lot about how FunnelWeb's presentation works.

@<P@>First, notice how the @<TT@>@(@@t@) typesetter
directive at the top of the file has caused a table of
contents to appear. This is one of FunnelWeb's typesetting
features and is discussed in a later section. The table of
contents shows that the sections have been numbered
hierarchically.

@<P@>Now take a look at the typeset macro definitions. Most
important are the numbers in square brackets that follow
each macro name. As well as numbering the headings
@<I@>@(hierarchically@), FunnelWeb @<I@>@(independently@)
numbers the macro definitions @<I@>@(sequentially@). The
first macro definition (for @<DQ@>@(Programmer's Cheer@)) is
numbered 1. The second (for @<DQ@>@(Hacker's Cheer@)) is
numbered 2 and so on. Note that it is not macros that are
numbered, but macro definitions. The distinction is
necessary because some macros (such as the @<DQ@>@(Hacker's
Cheer@) macro) are additive. It is important to realize that
there is no relationship between the numbers of the headings
and the numbers of the macro definitions.

@<P@>Now take a look at the notes beneath the body of each
macro definition. All macro definitions are followed by a
note indicating the definitions in which the macro is
called. Additive macros have an additional list, listing the
definitions in which they are defined.

@<P@>Finally, take a look at the macro @<I@>@(call@) of
@<DQ@>@(Programmer's Cheer@) in section@<_@>3.2 of the printed
documentation. Macro calls are set in slanted roman (so that
they can be distinguished from the @<TT@>@(tt font@) code)
and are followed by the number of the defining macro
definition. In this case, the macro was defined in
definition@<_@>1. Further down, the call to the @<DQ@>@(Hacker's
Cheer@) macro indicates that the macro was defined in
definition@<_@>2. In fact the macro is additive and definition@<_@>2
is just the first of many definitions. To list all
definitions in a call to an additive macro would be
unnecessarily messy.

@<Nav@>@(@<Type_hierarchy FILE@>@,@<Type FILE@>@,@<Type_literals FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Type_literals HEADING@>@M@{@<SH@>@(3.5@)Literals and Emphasis@}
@$@<Type_literals FILE@>@M@{type_literals.html@}
@O@<type_literals.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Type_literals HEADING@>@)
@<X@>@(literal construct@)@<X@>@(emphasis construct@)

@<P@>When writing about program code, it is often desirable
to be able to indicate that a particular word or phrase be
typeset in the same manner as the code being discussed. For
example, one might talk about the variable @<TT@>@(topval@)
or the procedure @<TT@>@(stack_pop@) and wish for them to
be typeset as they are in this sentence. This, of course, is
simple to do using TeX macros, but use of the (more general)
FunnelWeb typesetting directives to do the same work has the
added benefit of keeping the document portable to other
typesetters.

@<P@>FunnelWeb provides two in-text type modification
constructs: @<TT@>@(@@{...@@}@) and
@<TT@>@(@@/...@@/@)@<X@>@(@@slash@)@<X@>@(@@braces@) where
@<LDots@> is raw text. The @<TT@>@(@@{...@@}@) construct
sets the enclosed text in the same manner as the text of
macro definitions is set. The @<TT@>@(@@/...@@/@) construct
emphasises its enclosed text in some typesetter-dependent
fashion. Typically the emphasised text is set in italics.

@<P@>Here is an example of how these constructs might be
used:

@<P@>
@<Begin verbatim@>
The following procedure @@{put_sloth@@} writes the
@@{sloth@@} variable to the output file. Note: @@/The output
file must be opened for writing at this point or the program
will crash!@@/
@<End verbatim@>

@<Nav@>@(@<Type_printed FILE@>@,@<Type FILE@>@,@<Type_header FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Type_header HEADING@>@M@{@<SH@>@(3.6@)Adding A Header Page@}
@$@<Type_header FILE@>@M@{type_header.html@}
@O@<type_header.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Type_header HEADING@>@)
@<X@>@(header page@)

@<P@>FunnelWeb provides a few typesetter-independent
typesetting constructs which are specifically designed for
the construction of header pages. These constructs are
usually best placed at the top of your input file, but can
be placed anywhere the document if desired to create header
pages right through. The two main restrictions on these
constructs is that the @<TT@>@(@@t@) must start at the start
of a line (which cannot contain comments), and that the
constructs cannot appear inside a macro definition. Here is
what the top of an input file might look like:

@<P@>
@<Begin verbatim@>
@@t vskip 40 mm
@@t title titlefont centre "Hairy Wombat"
@@t title titlefont centre "Simulation"
@@t vskip 10 mm
@@t title smalltitlefont centre "A Program in Six Parts"
@@t title smalltitlefont centre "Simulating the Life of"
@@t title smalltitlefont centre "Some Hairy Wombats"
@@t vskip 20 mm
@@t title normalfont left "By Zqitzypba Ypongslrzz"
@@t new_page
@@t table_of_contents
@@t new_page
@<End verbatim@>

@<P@>The @<TT@>@(@@t@) at the start of each line indicates
that each entire line is a typesetter directive. The
@<TT@>@(vskip@)@<XX@>@(vskip@,directive@) directive
instructs FunnelWeb to skip some vertical space (measured in
millimetres). The @<TT@>@(title@)
directive@<XX@>@(title@,directive@) instructs FunnelWeb to
position a string of text on a single line of its own.
Options are provided for font and alignment. The first word
after @<TT@>@(title@) is the font which can be one of (in
decreasing order of size) @<TT@>@(titlefont@),
@<TT@>@(smalltitlefont@), and @<TT@>@(normalfont@). The
second word after @<TT@>@(title@) is the desired alignment
of the text. The options here are @<TT@>@(left@),
@<TT@>@(right@), and @<TT@>@(centre@). The
@<TT@>@(new_page@) directive@<XX@>@(newpage@,directive@)
instructs FunnelWeb to skip to a new page. Finally, the
@<TT@>@(table_of_contents@) directive@<XX@>@(table of
contents@,directive@) instructs FunnelWeb to insert a table
of contents at that point in the text.

@<Nav@>@(@<Type_literals FILE@>@,@<Type FILE@>@,@<Type_comments FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Type_comments HEADING@>@M@{@<SH@>@(3.7@)Comments@}
@$@<Type_comments FILE@>@M@{type_comments.html@}
@O@<type_comments.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Type_comments HEADING@>@)
@<X@>@(comments@)

@<P@>A FunnelWeb comment commences with the
@<TT@>@(@@!@)@<X@>@(@@!@) sequence and continues up to, but
not including, the end of line marker at the end of the line
that the comment sequence is on. Comments can be placed on
any line except @<TT@>@(@@i@) include, @<TT@>@(@@p@) pragma,
and @<TT@>@(@@t@) typesetter directive lines.

@<P@>The text following the FunnelWeb comment sequence
@<TT@>@(@@!@) will not appear in the product files or the
documentation file. It is only for the eyes of those who
bother to look at the original @<TT@>@(.fw@) input file.
Typically FunnelWeb comments are used to describe the way in
which particular FunnelWeb constructs are being used.
Example:

@<P@>
@<Begin verbatim@>
@@! This macro is really revolting.
@@! Please forgive me. I had to do it!
@@$@@@<<@>Revolt Me@@@<>@>==@@{@@-
@@#X@@(@@#Y@@(@@#Z@@,@@"@@#Z@@"@@)=
6@@,Teapot@@,@@"@@#Q@@(45@@)@@"@@,Tiger@@)@@}
@<End verbatim@>

@<Nav/last@>@(@<Type_header FILE@>@,@<Type FILE@>@,@<Type FILE@>@)

@<End FWTutMan page@>
@}

@!******************************************************************************

@$@<Example HEADING@>@M@{@<SH@>@(4@)A Complete Example@}
@$@<Example HEADING/short@>@M@{@<SH@>@(4@)Example@}
@$@<Example FILE@>@M@{example.html@}
@O@<example.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Example HEADING@>@)
@<XX@>@(complete@,example@)@<XX@>@(FunnelWeb@,Example@)

@<P@>To finish off the chapter, a complete example of a
FunnelWeb input file is presented. Although unrealistically
short, it gives a better idea of what a typical FunnelWeb
@<TT@>@(.fw@) file looks like.

@<P@>
@<Begin verbatim@>
@@!---------------------------------------!
@@!  Start of FunnelWeb Example .fw File  !
@@!---------------------------------------!

@@t vskip 40 mm
@@t title titlefont centre "Powers:"
@@t title titlefont centre "An Example of"
@@t title titlefont centre "A Short"
@@t title titlefont centre "FunnelWeb .fw File"
@@t vskip 10 mm
@@t title smalltitlefont centre "by Ross Williams"
@@t title smalltitlefont centre "26 January 1992"
@@t vskip 20 mm
@@t table_of_contents

@@A@@@<<@>FunnelWeb Example Program@@@<>@>

This  program writes  out each  of the  first @@{p@@}
powers of  the first  @@{n@@} integers. These  constant
parameters are located  here so that they  are easy to
change.

@@$@@@<<@>Constants@@@<>@>==@@{@@-
n : constant natural := 10;   -- [1,n] numbers?
p : constant natural :=  5;   -- [1,p]) powers?@@}

@@B Here is  the outline of the  program. This FunnelWeb
file  generates a single Ada output file  called
@@{Power.ada@@}. The main program consists  of a loop that
iterates once for each number to be written out.

@@O@@@<<@>Power.ada@@@<>@>==@@{@@-
@@@<<@>Pull in packages@@@<>@>

procedure example is
   @@@<<@>Constants@@@<>@>
begin -- example
   for i in 1..n loop
      @@@<<@>Write out the first p powers@@@<>@>
   end loop;
end example;
@@}

@@B In this section,  we pull in the packages that this
program  needs to run. In fact, all we need is the IO
package so that we can write out the results. To use the IO
package, we first of all need  to haul it in (@@{with
text_io@@}) and then we need to make all its identifiers
visible at the top level (@@{use text_io@@}).

@@$@@@<<@>Pull in packages@@@<>@>@@{@-
with text_io; use text_io;@@}

@@B Here is  the bit that writes out  the first @@{p@@}
powers of  @@{i@@}. The power values  are  calculated
incrementally  in  @@{ip@@}  to  avoid  the  use  of  the
exponentiation operator.

@@$@@@<<@>Write out the first p powers@@@<>@>@@{@@-
declare
   ip : natural := 1;
begin
   for power in 1..p loop
      ip:=ip*i;
      put(natural'image(ip) & " ");
   end loop;
   new_line;
end;@@}

@@!---------------------------------------!
@@!   End of FunnelWeb Example .fw File   !
@@!---------------------------------------!
@<End verbatim@>

@<FWTutMan subheading@>@(Summary@)

@<P@>FunnelWeb's functionality can be split into two parts:
a macro preprocessor, and support for typesetting. The
reader should be aware that the examples in this manual,
constructed as they have been to demonstrate particular
features of FunnelWeb, do not present a realistic picture of
the best use of the tool. Only the example above comes
close.

@<Nav@>@(@<Type FILE@>@,@<Index FILE@>@,@<Hints FILE@>@)

@<End FWTutMan page@>
@}

@!******************************************************************************

@$@<Hints HEADING@>@M@{@<SH@>@(5@)FunnelWeb Hints@}
@$@<Hints HEADING/short@>@M@{@<SH@>@(5@)Hints@}
@$@<Hints FILE@>@M@{hints.html@}
@O@<hints.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Hints HEADING@>@)

@<P@>This section contains a grab bag of hints about how
FunnelWeb can be used. This chapter probably should not be
read until you have commenced using FunnelWeb, or at the
very least, tried out some of the examples in earlier
chapters. Those who find themselves using FunnelWeb
frequently should read this chapter at some stage so as to
ensure that they are getting the most out of it.

@<P@>Most of the examples in this chapter have been placed in the
FunnelWeb regression test suite. The files to
examine are @<TT@>@(hi01.fw@) through @<TT@>@(hi10.fw@).

@<P@>
@<Hints index@>

@<Nav@>@(@<Example FILE@>@,@<Index FILE@>@,@<Examples FILE@>@)

@<End FWTutMan page@>
@}

@$@<Hints index@>@M@{
@<Begin size3@>
@<Begin indent/narrow@>
@<Link@>@(@<Hints_names FILE@>@,@<Hints_names HEADING@>@)@<BR@>
@<Link@>@(@<Hints_qnames FILE@>@,@<Hints_qnames HEADING@>@)@<BR@>
@<Link@>@(@<Hints_martinet FILE@>@,@<Hints_martinet HEADING@>@)@<BR@>
@<Link@>@(@<Hints_eols FILE@>@,@<Hints_eols HEADING@>@)@<BR@>
@<Link@>@(@<Hints_conditionals FILE@>@,@<Hints_conditionals HEADING@>@)@<BR@>
@<Link@>@(@<Hints_headings FILE@>@,@<Hints_headings HEADING@>@)@<BR@>
@<Link@>@(@<Hints_efficiency FILE@>@,@<Hints_efficiency HEADING@>@)@<BR@>
@<Link@>@(@<Hints_interactive FILE@>@,@<Hints_interactive HEADING@>@)@<BR@>
@<Link@>@(@<Hints_default FILE@>@,@<Hints_default HEADING@>@)@<BR@>
@<Link@>@(@<Hints_make FILE@>@,@<Hints_make HEADING@>@)@<BR@>
@<Link@>@(@<Hints_dangers FILE@>@,@<Hints_dangers HEADING@>@)@<BR@>
@<Link@>@(@<Hints_debugging FILE@>@,@<Hints_debugging HEADING@>@)@<BR@>
@<Link@>@(@<Hints_tabs FILE@>@,@<Hints_tabs HEADING@>@)@<BR@>
@<Link@>@(@<Hints_htmlstyle FILE@>@,@<Hints_htmlstyle HEADING@>@)@<BR@>
@<Link@>@(@<Hints_emacs FILE@>@,@<Hints_emacs HEADING@>@)@<BR@>
@<End indent/narrow@>
@<End size3@>
@}

@!==============================================================================

@$@<Hints_names HEADING@>@M@{@<SH@>@(5.1@)Macro Names@}
@$@<Hints_names FILE@>@M@{hints_names.html@}
@O@<hints_names.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Hints_names HEADING@>@)
@<XX@>@(macro@,names@)@<XX@>@(macro@,identifiers@)

@<P@>When using FunnelWeb, the choice of macro names can be
as important to the readability of a program as the choice
of program identifiers, and it is important that you
know the range of options available.

@<Narrowthing@>@(Names are case sensitive and exact
matching:@,Macro names are case sensitive and are matched
exactly. The strings used as a macro name at the point of
definition and call must be @<I@>@(identical@) for the
connection to be made.@)

@<Narrowthing@>@(Names can contain any printable
character:@,FunnelWeb is less restrictive about its macro
names than most programming languages are about their
identifiers. A FunnelWeb macro name can contain any sequence
of printable characters, including blanks and punctuation.
Names can start and end with any character. However, names cannot
cross line boundaries. The following are all legal macro
names:@)

@<Begin verbatim@>
        @@@<<@>This macro expands to some really bad code@@@<>@>
        @@@<<@>@@@<>@>
        @@@<<@>453 #$ %&# --===~~1"@<>@>@<>@>@<>@>@@@<>@>
        @@@<<@>@<<@>@@@<>@>
        @@@<<@>@<<@>@<>@>@@@<>@>
        @@@<<@>a b c d e f g@@@<>@>
        @@@<<@>       !     @@@<>@>
        @@@<<@>?? ...@@@<>@>
        @@@<<@>"Who's been hacking MY program" said Father Bear.@@@<>@>
        @@@<<@>Update the maximum and return for more data@@@<>@>
@<End verbatim@>

@<Narrowthing@>@(Names must be no more than a maximum limit
in length:@,Names can be no longer than a predefined maximum
length (80). Currently this length cannot be modified without
recompiling FunnelWeb.@)

@<P@>Typically, macro names will consist of a short English
phrase or sentence that describes the contents of the macro.

@<Nav/first@>@(@<Hints FILE@>@,@<Hints FILE@>@,@<Hints_qnames FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Hints_qnames HEADING@>@M@{@<SH@>@(5.2@)Quick Names@}
@$@<Hints_qnames FILE@>@M@{hints_qnames.html@}
@O@<hints_qnames.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Hints_qnames HEADING@>@)
@<XX@>@(quick@,names@)

@<P@>Sometimes a particular macro must be used extremely
often. When this happens, it is desirable to make the macro's
name as short as possible. The shortest ordinary FunnelWeb
macro name is the empty name@<XX@>@(empty@,name@)
@<DQP@>@(@@@<<@>@@@<>@>@), which is four characters long.
Single-character names are five characters long.

@<P@>To cater for the cases where really short names are
needed, FunnelWeb provides a @<NewTerm@>@(quick name@)
syntax that allows one-character macro names to be specified
in two less characters. Quick names take the form of the
special character, followed by a hash (@<TT@>@(#@)) followed
by a single character. Examples:

@<P@>
@<Begin verbatim@>
   @@#A     @@#|     @@#&     @@#m
@<End verbatim@>

@<P@>This form of macro name has the same syntactic
functionality as an ordinary name and can be substituted
wherever an ordinary name can be. In fact quick names live
in the same namespace as ordinary macro names. For example
the quickname @<TT@>@(@@#A@) is the @<I@>@(same name@)
(refers to the same macro) as the ordinary name
@<TT@>@(@@@<<@>A@@@<>@>@).

@<P@>Because quick names look syntactically @<DQ@>@(open@)
(@<ie@>they do not have a closing@<TT@>@(@@@<>@>@) as
ordinary names do), it is best to avoid them except where a
macro must be called very often.

@<Nav@>@(@<Hints_names FILE@>@,@<Hints FILE@>@,@<Hints_martinet FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Hints_martinet HEADING@>@M@{@<SH@>@(5.3@)FunnelWeb the Martinet@}
@$@<Hints_martinet FILE@>@M@{hints_martinet.html@}
@O@<hints_martinet.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Hints_martinet HEADING@>@)
@<XX@>@(FunnelWeb@,rules@)@<XX@>@(FunnelWeb@,martinet@)

@<P@>There are many ways in which a macro preprocessor can
cause unexpected difficulties. FunnelWeb seeks to avoid many
of these problems by performing a number of checks. This
section describes some of the checks that FunnelWeb
performs.

@<Narrowthing@>@(Trailing blanks in the input
file:@,Trailing blanks@<XX@>@(trailing@,blanks@) are usually
not dangerous, but FunnelWeb disallows them anyway. All
trailing blanks in the @<I@>@(input@) (@<TT@>@(.fw@) file)
are flagged as errors by FunnelWeb. FunnelWeb does not flag
trailing blanks in any of its output files.@)

@<Narrowthing@>@(Input line length:@,FunnelWeb has a maximum
input line length.@<XX@>@(input line@,length@) If FunnelWeb
reads an input line longer than this length, it flags the
line with an error message. The maximum length can be
changed using a pragma (see the @<FunnelWeb Reference Manual@>).@)

@<Narrowthing@>@(Product file line length:@,FunnelWeb
watches the length of output lines@<XX@>@(output
line@,length@) and all output lines longer than the limit
are flagged with error messages. The maximum length can be
changed using a pragma. That FunnelWeb polices output lines
is very important. Some programs can behave very strangely
if they get an input line that is too long (@<eg@>Fortran
compilers@<XX@>@(Fortran@,compilers@) can simply ignore text
past a certain column!) and once FunnelWeb starts expanding
macros using indentation, it is sometimes not obvious how
wide the product file will be.@)

@<Narrowthing@>@(Control characters:@,The presence of
control characters@<XX@>@(control@,characters@) in a text
file can result in some confusing behaviour downstream when
the file is presented to various programs. Unfortunately,
some text editors@<XX@>@(text@,editors@) allow control
characters to be inserted into the text rather too easily,
and it is all too easy to be tripped up. FunnelWeb prevents
these problems by flagging with diagnostics all
non-end-of-line control characters detected in the input
(@<TT@>@(.fw@)) file (even TABs@<X@>@(tabs@)). The result is
that the user is guaranteed that product files generated
from FunnelWeb contain no unintentional control characters.
This said, FunnelWeb does allow the insertion of control
characters in the output file by explicitly specifying them
in the text using a @<TT@>@(@@^@) control sequence.@)

@<Narrowthing@>@(Number of invocations:@,FunnelWeb checks
the number of times that@<XX@>@(invocations@,number@) each
macro is called and issues an error if the total is not one.
The @<TT@>@(@@Z@) (for zero) and @<TT@>@(@@M@) (for many)
macro attributes can be used to bypass these checks.@)

@<Narrowthing@>@(Recursion:@,Because@<XX@>@(recursion@,macro@)
FunnelWeb does not provide any conditional constructs, all
recursively defined macros must, by definition, expand
infinitely*, and are therefore unacceptable. FunnelWeb
performs @<I@>@(static@) checks to detect recursion,
detecting it before macro expansion commences. The user need
not fear that FunnelWeb will lock up or spew forth if a
recursive macro is accidentally specified.
(* Note: A special case exists where there is
recursion but no content. In this case, the expansion is
finite (the empty string) even though the operation of
expanding is infinite. FunnelWeb does not treat this case
specially).@)

@<Nav@>@(@<Hints_qnames FILE@>@,@<Hints FILE@>@,@<Hints_eols FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Hints_eols HEADING@>@M@{@<SH@>@(5.4@)Fiddling With End of Lines@}
@$@<Hints_eols FILE@>@M@{hints_eols.html@}
@O@<hints_eols.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Hints_eols HEADING@>@)
@<XX@>@(EOL@,fiddling with@)@<XX@>@(end-of-line@,fiddling with@)@<X@>@(spacing@)

@<P@>One of the  fiddly aspects of programming  with
FunnelWeb is coping  with end of lines. If  you want  your
product file to be  well indented without multiple blank
lines  or code run-ons,  you have to spend a  little time
working out how the end of line markers get moved around.

@<P@>The rule  to remember is that, disregarding the
effects of  special sequences within a macro body,
@<I@>@(the body of a macro consists of exactly the text
between the opening @<TT@>@(@@{@) and the  closing
@<TT@>@(@@}@)@). This text includes end of line markers.

@<P@>If for example you call a macro in a sequence of
code@<LDots@>

@<P@>
@<Begin verbatim@>
while the_walrus_is_sleepy do
   begin
   writeln('zzzzzzz');
   @@@<<@>Wake up the walrus@@@<>@>
   writeln('Umpharumpha...');
   end;
@<End verbatim@>

@<P@>where @<TT@>@(@<<@>wake up the walrus@<>@>@) is defined
as follows

@<P@>
@<Begin verbatim@>
@@$@@@<<@>Wake up the walrus@@@<>@>==@@{
wake_up_the_walrus(the_walrus);
@@}
@<End verbatim@>

@<P@>then when @<TT@>@(@<<@>Wake up the walrus@<>@>@) is
expanded you will get

@<P@>
@<Begin verbatim@>
while the_walrus_is_sleepy do
   begin
   writeln("zzzzzzz");

   wake_up_the_walrus(the_walrus);

   writeln("Umpharumpha...");
   end;
@<End verbatim@>

@<P@>The blank  lines were  introduced by  the end  on line
markers included  in the definition of @<TT@>@(@<<@>Wake up
the walrus@<>@>@). A  good solution to this  problem is to
suppress the end of line markers by defining the macro as
follows

@<P@>
@<Begin verbatim@>
@@$@@@<<@>Wake up the walrus@@@<>@>==@@{@@-
wake_up_the_walrus(the_walrus);@@}
@<End verbatim@>

@<P@>This is the usual form of macro definitions in
FunnelWeb files.

@<P@>In additive macros, this format  does not work properly
because the end of line that is suppressed by the trailing
@<TT@>@(@@}@) does not get replaced by the end of line at
the end of the macro invocation. For example the definition

@<P@>
@<Begin verbatim@>
@@$@@@<<@>Wake up the walrus@@@<>@>+=@@{@@-
wake_up_the_walrus_once(the_walrus);@@}
@<End verbatim@>

@<P@>later followed by

@<P@>
@<Begin verbatim@>
@@$@@@<<@>Wake up the walrus@@@<>@>+=@@{@@-
wake_up_the_walrus_again(the_walrus);@@}
@<End verbatim@>

@<P@>is equivalent to the single definition

@<P@>
@<Begin verbatim@>
@@$@@@<<@>Wake up the walrus@@@<>@>==@@{@@-
wake_up_the_walrus_once(the_walrus);@@-
wake_up_the_walrus_again(the_walrus);@@}
@<End verbatim@>

@<P@>Putting the trailing @<TT@>@(@@}@)  on a new line at
the end of  the macro (except for the last definition part)
solves the problem.

@<P@>
@<Begin verbatim@>
@@$@@@<<@>Wake up the walrus@@@<>@>+=@@{@@-
wake_up_the_walrus_once(the_walrus);
@@}
@<End verbatim@>

@<P@>later followed by

@<P@>
@<Begin verbatim@>
@@$@@@<<@>Wake up the walrus@@@<>@>+=@@{@@-
wake_up_the_walrus_again(the_walrus);@@}
@<End verbatim@>

@<P@>is equivalent to the single definition

@<P@>
@<Begin verbatim@>
@@$@@@<<@>Wake up the walrus@@@<>@>==@@{@@-
wake_up_the_walrus_once(the_walrus);
wake_up_the_walrus_again(the_walrus);@@}
@<End verbatim@>

@<P@>Managing end of line markers is tricky, but once you
establish  a convention for coping with them, the problem
disappears into the background.

@<Nav@>@(@<Hints_martinet FILE@>@,@<Hints FILE@>@,@<Hints_conditionals FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Hints_conditionals HEADING@>@M@{@<SH@>@(5.5@)Fudging Conditionals@}
@$@<Hints_conditionals FILE@>@M@{hints_conditionals.html@}
@O@<hints_conditionals.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Hints_conditionals HEADING@>@)
@<XX@>@(fudging@,conditionals@)

@<P@>As a macro preprocessor, one facility that FunnelWeb
lacks is a conditional facility (such as C's
@<TT@>@(#ifdef@)). It might, therefore, come as a surprise
to know that the FunnelWeb V1 actually had a
built in conditional facility. The facility allowed the
programmer to specify a construct that would select from one
of a number of macro expressions depending on the value of a
controlling macro expression.

@<P@>In three years the construct was never used.

@<P@>The reason was that conditional constructs could be
fudged nearly as easily as they could be used. Because of
this, the inbuilt conditional feature was removed in the
FunnelWeb V2. Not only did this simplify the
program, but is also allowed recursive macros to be detected
through static analysis rather than during macro expansion.

@<P@>There are two basic ways to fudge a conditional. First,
the comment facility of the target programming language may
be employed. For example, in Ada,@<X@>@(Ada@) comments
commence with @<DQP@>@(--@) and terminate at the end of the
line. Using this fact, it is easy to construct macros that
can be called at the start of each target line and which
turn on and off the lines so marked by defining the macro to
be the empty string (ON) or the comment symbol
(@<TT@>@(--@)) (OFF). For example:

@<P@>@<Begin verbatim@>
@@A@@@<<@>Debug Macro@@@<>@>

The following macro determines whether debug code
will be included in the program. All lines of
debug code commence with a call to this macro and
so we can turn all that code on or off here by
defining this macro to be either empty or the
single-line comment symbol (@<TT@>@(--@)). Note
the use of a quick macro name.

@@$@@#D@@M==@@{@@}  @@! Turns the debug code ON.
@@! Use this definition to turn
@@! the debug code OFF: @@$@@#D==@@{--@@}

... then later in the file...

@@$@@@<<@>Sloth incrementing loop@@@<>@>==@@{@@-
while sloth@<<@>walrus loop
   @@#D assert(sloth@<<@>walrus,"Sloth bomb.");
   @@#D assert(timer@<<@>timermax,"Timer bomb.");
   inc(sloth);
end loop@@}
@<End verbatim@>

@<P@>The other way to fudge a conditional is to
define a macro with a single parameter. A call to
the macro is then wrapped around all the
conditional code in the program. The macro can
then be defined to present or ignore the code of
its argument. For example:

@<P@>
@<Begin verbatim@>
@@A@@@<<@>Debug Macro@@@<>@>

The following macro determines whether debug code
will be included in the program. All debug code is
wrapped by a call to this macro and so we can turn
all the debug code on or off here by defining this
macro to be either empty or its parameter.

@@$@@#D@@(@@1@@)@@M==@@{@@1@@}  @@! Debug code ON.
@@! Use this definition to turn the
@@! debug code OFF: @@$@@#D@@(@@1@@)==@@{@@}

... then later in the file...

@@$@@@<<@>Sloth incrementing loop@@@<>@>==@@{@@-
while sloth@<<@>walrus loop
   @@#D@@(assert(sloth@<<@>walrus,"Sloth bomb.");
        assert(timer@<<@>timermax,"Timer bomb");@@)
   inc(sloth);
end loop@@}
@<End verbatim@>

@<P@>In languages that allow multi-line comments (@<eg@>C
with @<TT@>@(/*@) and @<TT@>@(*/@)), comments can be used to
eliminate the conditioned code rather than absence.  For
example:

@<P@>
@<Begin verbatim@>
@@! Comments out the debug code
@@$@@#D@@(@@1@@)@@M==@@{/* @@1 */@@}
@<End verbatim@>

@<P@>(Note: If this example were ever actually used, the
programmer would have to be careful not to place comments in
the argument code. Nested comments in C are non-portable.)

@<P@>The parameterized macro idea can be generalized to
support the choice of more than one mutually exclusive
alternative. For example:

@<P@>
@<Begin verbatim@>
@@A This module contains non-portable code that
must execute on Hewlett Packard, Sun, and DEC
workstations. The following FunnelWeb macro is
defined to choose between these three. The first
parameter is the HP code, the second is the Sun
code, and the third is the DEC code. Whichever
parameter constitutes the body of this macro
determines which machine the code is being
targeted for.

@@$@@@<<@>Machine specific code@@@<>@>@@(@@3@@)@@M==@@{@@-
@@1@@}  @@! Configure for HP.

...then later in the file...

@@@<<@>Machine specific code@@@<>@>@@(
@@"get_command_line(comline)@@"           @@, @@! HP.
@@"scan_command_line(128,comline);@@"     @@, @@! Sun.
@@"dcl_get_command_line(comline,256);@@"  @@) @@! DEC.
@<End verbatim@>

@<P@>Of course, this could also be performed using three
separate macros. The main advantage of using a single macro
is that the mutual exclusivity is enforced. Also, because
FunnelWeb ensures that the number of formal and actual
parameters are the same, this method lessens the chance that
a machine will be forgotten in some places.

@<Nav@>@(@<Hints_eols FILE@>@,@<Hints FILE@>@,@<Hints_headings FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Hints_headings HEADING@>@M@{@<SH@>@(5.6@)Changing the Strength of Headings@}
@$@<Hints_headings FILE@>@M@{hints_headings.html@}
@O@<hints_headings.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Hints_headings HEADING@>@)
@<XX@>@(headings@,strength@)@<XX@>@(typesetting@,strength@)
@<XX@>@(section@,strength@)@<XX@>@(font@,size@)

@<P@>FunnelWeb provides five heading levels: @<TT@>@(@@A@),
@<TT@>@(@@B@), @<TT@>@(@@C@), @<TT@>@(@@D@), and
@<TT@>@(@@E@) to which it binds five different typographical
strengths. These bindings are static; a level @<TT@>@(@@A@)
heading will always be typeset in a particular font size
regardless of the size of the document. The font sizes have
been preset to be @<DQ@>@(reasonable@) for a range of
document sizes, but may be inappropriate for very small or
large documents.

@<P@>FunnelWeb does not currently provide an
@<DQ@>@(official@) way (@<eg@>a pragma) to change the
typesetting strength of headings. This feature might be
added in later versions. Meanwhile, a hack is available that
will do the job, providing that you do not mind the hack
being TeX-specific and probably FunnelWeb-version specific.

@<P@>Inside the set of TeX macro definitions that FunnelWeb
writes at the top of every documentation file are five
@<DQ@>@(library@) definitions
@<TT@>@(fwliba@)@<LDots@>@<TT@>@(fwlibe@) which provide five
different typesetting strengths for headings. Near the end
of the set of definitions, FunnelWeb binds these macros to
five other macros @<TT@>@(fwseca@)@<LDots@>@<TT@>@(fwsece@)
which are invoked directly in the generated TeX code to
typeset the headings.

@<P@>
@<Begin verbatim@>
\def\fwseca#1#2{\fwliba{#1@@,#2}}
\def\fwsecb#1#2{\fwlibb{#1@@,#2}}
\def\fwsecc#1#2{\fwlibc{#1@@,#2}}
\def\fwsecd#1#2{\fwlibd{#1@@,#2}}
\def\fwsece#1#2{\fwlibe{#1@@,#2}}
@<End verbatim@>

@<P@>This means that the typesetting strength of the
headings in a FunnelWeb document can be changed by
redefining these macros at the top of a FunnelWeb document.
For example:

@<P@>
@<Begin verbatim@>
@@p typesetter = tex
\def\fwseca#1#2{\fwlibc{#1@@,#2}}
@<End verbatim@>

@<P@>would set @<TT@>@(@@A@) headings at the same strength
as the default strength of @<TT@>@(@@C@) headings. The
@<TT@>@(typesetter@) directive is necessary to ensure that
the TeX control sequences get through to the documentation
file unfiltered.

@<P@>The following will tone down all headings by two levels
(with the @<TT@>@(@@D@) and @<TT@>@(@@E@) levels being
allocated the default @<TT@>@(@@E@) typesetting strength
because there is nothing weaker).

@<P@>
@<Begin verbatim@>
@@p typesetter = tex
\def\fwseca#1#2{\fwlibc{#1@@,#2}}
\def\fwsecb#1#2{\fwlibd{#1@@,#2}}
\def\fwsecc#1#2{\fwlibe{#1@@,#2}}
\def\fwsecd#1#2{\fwlibe{#1@@,#2}}
\def\fwsece#1#2{\fwlibe{#1@@,#2}}
@<End verbatim@>

@<P@>These definitions affect only the headings that follow
them, and so they should be placed at the top of the
FunnelWeb input file.

@<P@>To change the style of headings in HTML output, just
modify the style settings near the top of the HTML file.

@<Nav@>@(@<Hints_conditionals FILE@>@,@<Hints FILE@>@,@<Hints_efficiency FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Hints_efficiency HEADING@>@M@{@<SH@>@(5.7@)Efficiency Notes@}
@$@<Hints_efficiency FILE@>@M@{hints_efficiency.html@}
@O@<hints_efficiency.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Hints_efficiency HEADING@>@)
@<XX@>@(FunnelWeb@,efficiency@)@<XX@>@(efficiency@,notes@)

@<P@>The following notes are worth keeping in mind when
using FunnelWeb.

@<Narrowthing@>@(Memory:@,When@<X@>@(memory@)@<XX@>@(input@,files@)
FunnelWeb processes an input file, it reads the entire input
file, and all the included files into memory. (Note: If a
file is included n times, FunnelWeb keeps n copies in
memory). This organization does not pose a constraint on
machines with large memories, but could present a problem on
the smaller machines such as the PC.@)

@<Narrowthing@>@(Speed:@,FunnelWeb@<X@>@(speed@) is not a
slow program. However, it is not particularly fast either.
If the speed at which FunnelWeb runs is important to you,
then the thing to keep in mind is that FunnelWeb has been
optimized to deal efficiently with large slabs of text.
FunnelWeb treats input files as a sequence of text slabs and
special sequences (@<eg@>@<TT@>@(@@+@)) and whenever it hits
a special sequence, it has to stop and think. Thus, while a
ten megabyte text slab would be manipulated as a single
token, in a few milliseconds, a similar ten megabyte chunk
filled with special sequences would take a lot longer. If
FunnelWeb is running slowly, look to see if the input
contains a high density of special sequences. This can
sometimes happen if FunnelWeb is being used as a backend
macro processor and its input is being generated
automatically by some other program.@)

@<Narrowthing@>@(Macro
expansion:@,When@<XX@>@(macro@,expansion@) tangling
(expanding macros), FunnelWeb never expands a macro
expression into memory; it always writes it to the product
file as it goes. This is a powerful fact, because it means
that you can write macros containing an unlimited amount of
text, and pass such macros as parameters to other macros
without becoming concerned about overflowing some kind of
buffer memory. In short, FunnelWeb does not impose any
limits on the size of macro bodies or their expansions.@)

@<Nav@>@(@<Hints_headings FILE@>@,@<Hints FILE@>@,@<Hints_interactive FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Hints_interactive HEADING@>@M@{@<SH@>@(5.8@)Interactive Mode@}
@$@<Hints_interactive FILE@>@M@{hints_interactive.html@}
@O@<hints_interactive.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Hints_interactive HEADING@>@)
@<X@>@(interactive mode@)@<X@>@(keyboard mode@)

@<P@>As well as having a command line interface with lots of
options, FunnelWeb also provides a command language and a
mode (@<DQ@>@(interactive mode@)) in which commands in the
language can be typed interactively. The FunnelWeb command
interpreter was created primarily to support regression
testing,@<XX@>@(regression@,testing@) but can also be useful
to FunnelWeb users.

@<P@>FunnelWeb's command
interpreter@<XX@>@(command@,interpreter@) reads one command
per line and can read a stream of commands either from a
text file, or from the console. The interpreter can
understand over twenty commands. See the
@<FunnelWeb Reference Manual@> for a full list. However,
most of them
were designed to support regression testing and will not be
of use to the casual user.

@<P@>The commands that are of greatest use to the casual
user are:@<XX@>@(useful@,commands@)

@<P@>
@<Begin verbatim@>
     !               - Ignores the whole line.
     EXECUTE fn      - Execute the specified file.
     FW options      - Invoke FunnelWeb-proper once.
     SET options     - Sets options.
     SHOW            - Displays current options.
     TRACE ON        - Turns command tracing ON.
     QUIT            - Quits FunnelWeb.
@<End verbatim@>

@<P@>To distinguish here between invocations of the
FunnelWeb program and FunnelWeb runs inside the shell, we
call the latter @<NewTerm@>@(FunnelWeb proper@). The
@<DQP@>@(FW@) command invokes FunnelWeb proper with the
specified options which take the same syntax as they do on
the command line. The only restriction is that none of the
action options can be turned on except @<DQP@>@(+F@) which
must be turned on.

@<P@>The @<DQP@>@(SET@) command@<XX@>@(set@,command@) has
the same syntax as the @<DQP@>@(FW@) command except that it
does not allow @<I@>@(any@) action options to be specified.
It's sole effect is to set default option values for the
rest of the run.

@<P@>The @<DQP@>@(SHOW@)@<XX@>@(show@,command@) command
displays the current default options.

@<P@>By default, FunnelWeb does not echo the commands that
it processes in a script. The @<DQP@>@(TRACE
ON@)@<XX@>@(trace on@,command@) command turns on such
tracing.

@<P@>These commands can be combined to streamline the use of
FunnelWeb. For example, you might wish to create a script
called @<TT@>@(typeset.fws@) to process a whole group of
files.

@<P@>
@<Begin verbatim@>
trace on
!This script typesets the whole program.
! Set no listing file, no product files,
! but specify a documentation file
! and specify the directory into which
! it should be placed.
set -L -O +T/usr/ross/typeset/
fw prog1
fw prog2
fw prog3
fw prog4
@<End verbatim@>

@<P@>There are a few ways in which this script can be run.
The simplest is simply to specify it in the @<DQP@>@(+X@)
option of a FunnelWeb invocation. FunnelWeb shellscripts
default to @<DQP@>@(@<<@>current_directory@<>@>@) and
@<DQP@>@(.fws@).

@<P@>
@<Begin verbatim@>
fw +xtypeset
@<End verbatim@>

@<P@>The second alternative is
to enter interactive mode.

@<P@>
@<Begin verbatim@>
fw +k
@<End verbatim@>

@<P@>From there, you can execute
the script using:

@<P@>
@<Begin verbatim@>
execute typeset
@<End verbatim@>

@<P@>Interactive mode could be very useful to those with
multiple-window workstations.@<X@>@(workstations@) The user
could create a window containing an interactive session of
FunnelWeb, and then switch between windows, editing, and
executing FunnelWeb proper and other programs.

@<P@>If you find yourself using the command interpreter a
lot, be sure to read about the other commands that are
available in the @<FunnelWeb Reference Manual@>.

@<Nav@>@(@<Hints_efficiency FILE@>@,@<Hints FILE@>@,@<Hints_default FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Hints_default HEADING@>@M@{@<SH@>@(5.9@)Setting Up Default Options@}
@$@<Hints_default FILE@>@M@{hints_default.html@}
@O@<hints_default.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Hints_default HEADING@>@)
@<XX@>@(options@,setting defaults@)@<XX@>@(default@,options@)

@<P@>If you do not like FunnelWeb's default settings for its
command line options, there are a number of ways in which
you can change them.

@<Narrowthing@>@(Define an @<DQ@>@(alias@):@,Use your
operating system @<DQP@>@(alias@)@<X@>@(alias@) facility to
create an alias for FunnelWeb containing the desired
options. FunnelWeb processes options from left to right, so
you can override these defaults later if you wish.@)

@<Narrowthing@>@(Create a script called
@<DQP@>@(fwinit.fws@):@,When FunnelWeb starts up, it
executes a script called
@<DQP@>@(fwinit.fws@)@<X@>@(fwinit.fws@)
if@<XX@>@(startup@,script@)@<XX@>@(initialization@,script@)
such a script exists in the current directory. You can use
this fact to set options before the run of FunnelWeb proper
by creating such a script and placing a single
@<DQP@>@(set@) command in it containing the desired options.
The main trouble with this approach is that the options in
the @<TT@>@(set@) command will be processed @<I@>@(after@)
the command line options, which means that you won't be able
to override them on the command line.@)

@<P@>For example, you might be involved more with presenting
programs than with running them, and want FunnelWeb to
generate a documentation file by default, but not to produce
listing or product files by default. In Unix you could do
this with:

@<P@>
@<Begin verbatim@>
alias fw fw -L -O +T
@<End verbatim@>

@<Nav@>@(@<Hints_interactive FILE@>@,@<Hints FILE@>@,@<Hints_make FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Hints_make HEADING@>@M@{@<SH@>@(5.10@)FunnelWeb and Make@}
@$@<Hints_make FILE@>@M@{hints_make.html@}
@O@<hints_make.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Hints_make HEADING@>@)
@<X@>@(make utility@)@<XX@>@(file@,dependencies@)

@<P@>The Unix @<TT@>@(Make@) program allows a set of
dependencies between a set of files to be described, and
then uses these dependencies to control the way in which the
files are created and updated. Typically, @<TT@>@(Make@) is
used to control the process of transforming a collection of
source code files to one or more executable files. As the
use of FunnelWeb implies an extra stage to this process, it
is natural to include the transformation of @<TT@>@(.fw@)
files to source code files as part of the @<TT@>@(Make@)
process. This is easy to do, but the user should be aware of
one aspect of FunnelWeb which can cause problems.

@<P@>It is often useful, when using FunnelWeb, to create a
FunnelWeb @<TT@>@(.fw@) file that generates more than one
product file. That is, a single @<TT@>@(.fw@) file may have
many macro definitions connected to product files so that
when the FunnelWeb @<TT@>@(.fw@) file is processed by
FunnelWeb, several files are created. For example, this
facility is convenient for placing a single package's
@<TT@>@(.h@) and @<TT@>@(.c@) files within the same
FunnelWeb @<TT@>@(.fw@) file.

@<P@>The use of multiple product files, however, provokes a
problem with dependencies. Suppose for example that a
FunnelWeb @<TT@>@(prog.fw@) produces two product files
@<TT@>@(proc.spec@) (a package specification) and
@<TT@>@(prog.body@) (a package body). If the package is
accessed in the way that packages normally are, it will be
quite common for the programmer to want to modify the
package body without modifying the program specification. So
the programmer will edit the @<TT@>@(prog.fw@) file to
change the package body. The result of running this through
FunnelWeb will be the desired new package body file.
However, FunnelWeb will also produce a new package
specification product file @<I@>@(even though it may be
identical to the previous version!@) The result is that the
newly created (with a recent file date) specification
package file could provoke a huge remake of much of the
program in which it resides.

@<P@>To solve the problem, FunnelWeb includes a command line
option (@<TT@>@(D@) for
Delete),@<XX@>@(D@,option@)@<XX@>@(delete@,output files@)
which when turned on (using @<DQP@>@(+D@)) causes FunnelWeb
to suppress@<XX@>@(suppression@,file@) product and
documentation files that are identical to the previously
existing versions of the same files. For example, if, during
a FunnelWeb  run, a macro was connected to a product file
called @<TT@>@(x.dat@), and the macro expanded to
@<I@>@(exactly@) the same text as is contained in
@<TT@>@(x.dat@) then FunnelWeb would simply @<I@>@(never
write the product file@), the file @<TT@>@(x.dat@) would be
untouched and, as a result, no further @<TT@>@(Make@)
propagations would take place.

@<P@>FunnelWeb implements this feature by writing each
product file to a temporary file with a temporary file name.
It then compares the temporary file with the target file. If
the two are identical, it deletes the temporary file. If the
two are different it deletes the target file and renames the
temporary file to the target file.

@<P@>Use of the @<TT@>@(D@) facility means that the
programmer need not be punished (by extra @<TT@>@(Make@)
propagations) for describing more than one product file in
the same FunnelWeb file.

@<Nav@>@(@<Hints_default FILE@>@,@<Hints FILE@>@,@<Hints_dangers FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Hints_dangers HEADING@>@M@{@<SH@>@(5.11@)The Dangers Of FunnelWeb@}
@$@<Hints_dangers FILE@>@M@{hints_dangers.html@}
@O@<hints_dangers.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Hints_dangers HEADING@>@)
@<XX@>@(FunnelWeb@,dangers@)@<XX@>@(FunnelWeb@,pitfalls@)

@<P@>Like many tools that are general and flexible,
FunnelWeb can be used in a variety of ways, both good and
bad. One of the original appeals of the literate approach to
programming for Knuth,@<XN@>@(Donald@,Knuth@) the inventor
of literate programming,@<XX@>@(literate@,programming@) was
that it allows the programmer to describe the target program
bottom up, top down, size to side, or chaotically if
desired.

@<P@>The flexibility that the literate style of
programming leaves much room for bad documentation
as well as good documentation. Years of experience
with FunnelWeb has revealed the following
stylistic pitfalls which the experienced FunnelWeb
user should take care to avoid. (Note: The fact that
these faults are listed here does not mean that
the author has eliminated them in his own work.
Rather, it is mainly the author's own mistakes
that have resulted in this list being compiled.
The author immediately confesses to several of the
faults listed here, most notably that of Pavlov
documentation).

@<Narrowthing@>@(Spaghetti
organization:@,By@<XX@>@(spaghetti@,organization@) far the
worst problem that arises in connection with the literate
style occurs where the programmer has used the literate tool
to completely scramble the program so that the program is
described and layed out in an unordered, undisciplined
@<DQ@>@(stream of consciousness@).@<X@>@(stream of
consciousness@) In such cases the programmer may be using
the literate style as a crutch to avoid having to think
about structuring the presentation.@)

@<Narrowthing@>@(Boring
organization:@,At@<XX@>@(boring@,organization@) the other
extreme, a program may be organized in such a strict way
that it is essentially laid out in the order most
@<DQ@>@(desired@) by the target programming language. For
example, each macro might contain a single procedure, with
all the macros being called by a macro connected to a file
at the top. In many cases a boring structure may be entirely
appropriate, but the programmer should be warned that it is
easy to slip into such a normative style, largely forgetting
the descriptive structural power that FunnelWeb provides.@)

@<Narrowthing@>@(Poor random
access:@,Using@<XX@>@(random@,access@) FunnelWeb, it is
quite possible to write programs like novels@<X@>@(novels@)
--- to be read from cover to cover. Sometimes the story is
very exciting, with data structures making dashing triumphs
and optimized code bringing the story to a satisfying
conclusion. These programs can be works of art.
Unfortunately, without careful construction, such
@<DQ@>@(novel-programs@) can become very hard to access
randomly by (say) a maintenance
programmer@<XX@>@(maintenance@,programmer@) who wishes only
to dive in and fix a specific problem. If the entire program
is scrambled for sequential exposition, it can be hard to
find the parts relating to a single function. Somehow a
balance must be struck in the document between the needs of
the sequential and of the random-access reader. This balance
will depend on the intended use of the program.@)

@<Narrowthing@>@(Too-interdependent
documentation:@,Sometimes,
when@<XX@>@(documentation@,interdependent@) editing a
program written using FunnelWeb, one knows how to modify the
program, but one is unsure of how to update the surrounding
documentation! The documentation may be woven into such a
network of facts that it seems that changing a small piece
of code could invalidate many pieces of documentation
scattered throughout the document. The documentation becomes
a big tar pit in which movement is impossible. For example,
if you have talked about a particular data structure
invariant throughout a document, changing that invariant in
a small way could mean having to update all the
documentation without touching much code. In such cases, the
documentation is too interdependent. This could be
symptomatic of an excessibly interconnected program, or of
an excessively verbose or redundant documenting style. In
any case, a balance must be struck between the
conversational style that encourages redundancy (by
mentioning things many times) and the normalized database
approach where each fact is given at only one point, and the
reader is left to figure out the implications throughout the
document.@)

@<Narrowthing@>@(Pavlov
documentation:@,By@<XX@>@(pavlov@,documentation@) placing so
much emphasis on the documentation, FunnelWeb naturally
provides slots where documentation @<DQ@>@(should@) go. For
example, a FunnelWeb user may feel that there may be a
rather unpleasant gap between a @<TT@>@(@@C@) marker and the
following macro. In many cases @<I@>@(no@) commentary is
needed, and the zone is better left blank rather than being
filled with the kind of uninformative waffle one often finds
filling the slots of structured documentation written
according to a military standards
(@<eg@>MIL-STD-2167A).@<X@>@(MIL-STD-2167A@)@<X@>@(2167A@) (Note:
This is not a criticism of 2167A, only of the way it is
sometimes used). The lesson is to add documentation only
when it adds something. The lesson in Strunk and
White@<Paper@>@(Strunk79@) (p.@<_@>23) holds for program
documentation as it does for other writing: @<DQ@>@(Vigorous
writing is concise. A sentence should contain no unnecessary
words, a paragraph no unnecessary sentences, for the same
reason that a drawing should have no unnecessary lines and a
machine no unnecessary parts. This requires not that the
writer make all his sentences short, or that he avoid all
detail and treat his subjects only in outline, but that
every word tell.@).@)

@<Narrowthing@>@(Duplicate
documentation:@,Where@<XX@>@(duplicate@,documentation@) the
programmer is generating product files that must exist on
their own within the entire programming environment
(@<eg@>the case of a programmer in a team who is using
FunnelWeb for his own benefit but must generate (say)
commented Ada@<X@>@(Ada@) specification package files) there
is a tendency for the comments in the target code to
duplicate the commentary in the FunnelWeb text. This may or
may not be a problem, depending on the situation.
However, if this is happening, it is certainly worth the
programmer spending some time deciding if one or other of
the FunnelWeb or inline-comment documentation should be
discarded. In many cases, a mixture can be used, with the
FunnelWeb documentation referring the reader to the inline
comments where they are present. For example:@)

@<P@>
@<Begin verbatim@>
@@A Here is the header comment for the list package
specification. The reader should read these comments
carefully as they define a list. There is no need to
duplicate the comments in this text.

@@$@@@<<@>Specification package comments@@@<>@>==@@{@@-
-- LIST PACKAGE
-- ============
-- * A LIST consists of zero or more ITEMS.
-- * The items are numbered 1 to N where N
--   is the number of items in the list.
-- * If the list is non-empty, item 1
--   is called the HEAD of the list.
-- * If the list is non-empty, item N
--   is called the TAIL of the list.
-- ...
@@}
@<End verbatim@>

@<Narrowthing@>@(Overdocumenting:@,Another@<XX@>@(over@,documentation@)
evil that can arise when using FunnelWeb is to over-document
the target program. In some of Knuth's earlier (@<eg@>1984)
examples of literate programming, each variable is given its
own description and each piece of code has a detailed
explanation. This level of analysis, while justified for
tricky tracts of code, is probably not warranted for most of
the code that constitutes most programs. Such
over-commenting can even have the detrimental affect of
obscuring the code, making it hard to understand because it
is so scattered (see @<DQ@>@(spaghetti organization@)
earlier). It is up to the user to decide when a stretch of
just a few lines of code should be pulled to bits and
analysed and when it is clearer to leave it alone.@)

@<Narrowthing@>@(@,In the case where there are a few rather tricky
lines of code, a detailed explanation may be appropriate.
The following example contains a solution to a problem
outlined in section 16.3 of the book @<DQ@>@(The Science of
Programming@) by David Gries@<Paper@>@(Gries81@).@)

@<P@>
@<Begin verbatim@>
@@C@@@<<@>Calculation of the longest plateau in b@@@<>@>

This section contains a solution to a problem
outlined in section 16.3 of the book @@/The
Science of Programming@@/ by David Gries[Gries81].

@@D Given a sorted array @@{b[1..N]@@} of
integers, we wish to determine the @@/length@@/ of
the longest run of identically valued elements in
the array. This problem is defined by the
following precondition and postcondition.

@@$@@@<<@>Precondition@@@<>@>==@@{/* Pre: sorted(b). */@@}
@@$@@@<<@>Postcondition@@@<>@>==@@{@@-
/* Post: sorted(b) and p is the length */
/* of the longest run in b[1..N].      */@@}

@@D We approach a solution to the problem by
deciding to try the approach of scanning through
the array one element at a time maintaining a
useful invariant through each iteration. A loop
variable array index @@{i@@} is created for this
purpose. The bound function is @@{N-i@@}. Here is
the invariant.

@@$@@@<<@>Invariant@@@<>@>==@@{@@-
/* Invariant: sorted(b) and 1@<<@>=i@<<@>=N and   */
/*            p is len of longest run in b[1..i]. */@@}

@@D Establishing the invariant above in the
initial, degenerate case is easy.

@@$@@@<<@>Establish plateau loop invariant@@@<>@>@@{@-
i=1; p=1;@@}

@@D At this stage, we have the following loop
structure. Note that when both the invariant and
@@{i == N@@} are true, the postcondition holds and
the loop can terminate.

@@$@@@<<@>p=len(longest run in sorted b[1..N])@@@<>@>@@{@@-
@@@<<@>Precondition@@@<>@>
@@@<<@>Establish plateau loop invariant@@@<>@>
while (i != N)
  {
   @@@<<@>Invariant@@@<>@>
   @@@<<@>Loop body@@@<>@>
  }
@@@<<@>Postcondition@@@<>@>
@@}

@@D Now there remains only the loop body whose
sole task is to increase @@{i@@} (and so decrease
the value of the bound function) while maintaining
the invariant. If @@{p@@} is the length of the
longest run seen so far (i.e. in b[1..i]), then,
because the array is sorted, the extension of our
array range to @@{b[1..i+1]@@} can only result in
an increase in @@{p@@} if the new element
terminates a run of length @@{p+1@@}. The increase
can be at most 1. Because the array is sorted, we
need only compare the endpoints of this possible
run to see if it exists. This is performed as
shown below.

@@$@@@<<@>Loop body@@@<>@>==@@{@-
i++; if (b[i] != b[i-p]) p++;@@}
@<End verbatim@>

@<P@>Where the code is more obvious,
it is often better to let the code speak for itself.

@<P@>
@<Begin verbatim@>
@@C The following function compares two C
strings and returns TRUE iff they are identical.

@@$@@@<<@>Function comp@@@<>@>==@@{@@-
bool comp(p,q)
char *p,*q;
{
 while (TRUE)
   {
    if (*p != *q  ) return FALSE;
    if (*p == '\0') return TRUE;
    p++; q++;
   }
}
@@}
@<End verbatim@>

@<Nav@>@(@<Hints_make FILE@>@,@<Hints FILE@>@,@<Hints_debugging FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Hints_debugging HEADING@>@M@{@<SH@>@(5.12@)Wholistic Debugging@}
@$@<Hints_debugging FILE@>@M@{hints_debugging.html@}
@O@<hints_debugging.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Hints_debugging HEADING@>@)

@<P@>Surprising though it may be, FunnelWeb has a role
to play in the @<B@>@(debugging@) of programs. My
experience in programming has led me to the concept of
@<NewTerm@>@(wholistic debugging@). When many programmers
detect a bug, their first reaction seems to be to jump into
the debugger@<X@>@(debugger@) where they often spend many
hours stepping through endless stretches of code and
generally wasting a lot of time.

@<P@>In contrast, my first reaction when I detect a bug is
to realize that @<B@>@(the code must not be in good enough
shape if such a bug can arise!@) The presence of the bug is
taken as symptomatic of the lack of general health of the
code. If that bug occurred, why not another? In response to
this realization, my reaction is not to enter the debugger,
but rather to return to the original code and tend it like a
garden,@<XX@>@(code@,gardening@) adding more comments,
reworking the weaker parts, adding assertions, and looking
for faults. In many cases, the search for faults does not
even centre on the specific bug that arose, but does tend to
focus on the area of code where the bug is likely to be.

@<P@>The result is often that the original bug is located
more quickly than it would have been had the debugger been
involved. But even if it isn't, there are other benefits. A
programmer who enters the debugger may stay there for hours
and still not find the bug. The result is frustration and no
positive gain at all. In contrast, by tending to the code,
the programmer is making forward progress at all times (the
code is constantly improving) even if the bug is not
immediately found. At the end of ten hours, the programmer
can at least feel that the code is @<DQ@>@(ten hours
better@), whereas the debugger freak will likely feel
defeated. All this makes code tending better psychologically
as well as a more efficient approach to debugging.

@<P@>I call this technique wholistic debugging, for it is
like the difference between conventional and wholistic
medicine.@<XX@>@(wholistic@,medicine@) Go to a conventional
doctor with a headache and he might send off for head
X-rays, perform allergy tests and perform many other
debugging activities. Go to a wholistic doctor with the same
problem and he might look to see if you are fit, assess your
mental health, and ask you if your marriage is working. Both
approaches are appropriate at different times, but I believe
that, on balance, in programming the wholistic approach is
not used enough.

@<Nav@>@(@<Hints_dangers FILE@>@,@<Hints FILE@>@,@<Hints_tabs FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Hints_tabs HEADING@>@M@{@<SH@>@(5.13@)TABs@}
@$@<Hints_tabs FILE@>@M@{hints_tabs.html@}
@O@<hints_tabs.html@>@{@-
@<Begin FWTutMan page/wide/H1@>@(@<Hints_tabs HEADING@>@)

@<P@>FunnelWeb is designed to protect its user from spurious
non-printable characters that might creep into a source file,
and so it classifies any occurrence of such a character as
an error.

@<P@>FunnelWeb's idea of printable is any character in the
range ASCII [32..126]. A number of people have complained
about this, saying that they want to include 8-bit
characters in their FunnelWeb input files. Currently there
is no fix for this except to insert characters explicitly
into the output using a @<TT@>@(@@^@) sequence (see the
@<FunnelWeb Reference Manual@> for more details).

@<P@>In particular, FunnelWeb flags TAB characters in its
input file as errors because TABs are essentially invisible
control characters with very poorly-defined semantics; it's
FunnelWeb's job to keep an eye on the input file to ensure
that the programmer doesn't get any nasty surprises and as
TABs can cause several kinds of surprises, they are excluded.

@<P@>A lot of people have complained about this aspect of
FunnelWeb. Unfortunately, this issue has not yet been
resolved. If you actually @<I@>@(need@) TABs in the output
file (@<eg@>for a makefile), then you should insert TABs
explicitly using a @<TT@>@(@@^D(009)@) sequence (see the
@<FunnelWeb Reference Manual@> for more details).

@<P@>The following C program removes TABs. The program was
kindly donated by John Skaller. Warning: This program
doesn't have any error checking.

@<Begin verbatim@>
/* UNTAB Program                                            */
/* =============                                            */
/* Author       : John Skaller (maxtal@@extro.ucc.su.oz.au) */
/* Organization : MAXTAL P/L 6 Mackay St ASHFIELD 2131.     */
/* Usage        : untab 2 <infile >outfile                  */
/* Status       : Public domain.                            */

#include <stdio.h>

int main(int argv, char **argc)
{
        int n=2;
        if(argv==2)sscanf(argc[1],"%d",&n);
        int ch=getchar();
        int column=0;
        while(ch!=-1){
                if(ch=='\n'){putchar('\n'); column=0;}
                else if(ch==9){
                        putchar(' '); column++;
                        while(column % n){putchar(' '); column++;}
                }
                else { putchar(ch); column++;}
                ch=getchar();
        }
}
@<End verbatim@>

@<Nav@>@(@<Hints_debugging FILE@>@,@<Hints FILE@>@,@<Hints_htmlstyle FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Hints_htmlstyle HEADING@>@M@{@<SH@>@(5.14@)HTML Style@}
@$@<Hints_htmlstyle FILE@>@M@{hints_htmlstyle.html@}
@O@<hints_htmlstyle.html@>@{@-
@<Begin FWTutMan page/wide/H1@>@(@<Hints_htmlstyle HEADING@>@)

@<P@>If you specify the @<TT@>@(+U@) command line option,
FunnelWeb will generate a @<TT@>@(.html@) documentation file
containing HTML. In the @<TT@>@(@<<@>HEAD@<>@>@) section of
this file, FunnelWeb defines the style of the file by including
a style directive similar to the following:

@<P@>
@<Begin verbatim@>
   @<<@>STYLE TYPE="text/css"@<>@>
   @<<@>!--
   A {text-decoration: none}
   H1 { font-family: sans-serif; font-size: large }
   H2 { font-family: sans-serif; font-size: medium;
        font-weight: bold }
   H3 { font-family: sans-serif; font-size: medium }
   H4 { font-family: sans-serif; font-size: small }
   H5 { font-family: sans-serif; font-size: small }
   // --@<>@>
   @<<@>/STYLE@<>@>
@<End verbatim@>

@<P@>If you do not like this style, you can change it simply by
editing the @<TT@>@(.html@) file and changing the style directive in
the @<TT@>@(@<<@>HEAD@<>@>@) section. However, this change will be
overwritten the next time you regenerate the HTML file.

@<P@>Another way to define your own style is to turn off FunnelWeb's
automatic @<DQ@>@(escaping@) of special characters with:

@<P@>
@<Begin verbatim@>
@@p typesetter = html
@<End verbatim@>

@<P@>You can then include a style directive in one one of the very
early comment parts of your FunnelWeb source file, where it will
override the one written by FunnelWeb in the @<TT@>@(@<<@>HEAD@<>@>@)
section. The disadvantage is that your FunnelWeb source file becomes
typesetter-dependent.


@<Nav@>@(@<Hints_tabs FILE@>@,@<Hints FILE@>@,@<Hints_emacs FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Hints_emacs HEADING@>@M@{@<SH@>@(5.15@)A FunnelWeb Mode For Emacs@}
@$@<Hints_emacs FILE@>@M@{hints_emacs.html@}
@O@<hints_emacs.html@>@{@-
@<Begin FWTutMan page/wide/H1@>@(@<Hints_emacs HEADING@>@)

@<P@>@<Tony Coates@> has created a FunnelWeb Emacs mode, which he has
made generally available. The mode is written as a FunnelWeb file. To
use the mode, click on the link below. A new window should appear
containing a plain text file which is the FunnelWeb source for the
mode. Save the plain text file on your disk as @<TT@>@(fwmode.fw@) and
then invoke FunnelWeb  using @<TT@>@(fw fwmode@) to generate the emacs
mode files @<TT@>@(fw-mode.el@) and @<TT@>@(switch-mode.el@).

@<P@>
@<Begin indent@>
   @<Size4@>@(@<Link/blank@>@(fwmode.txt@,FunnelWeb Emacs Mode FunnelWeb Source File@)@)
@<End indent@>

@<Nav/last@>@(@<Hints_htmlstyle FILE@>@,@<Hints FILE@>@,@<Hints FILE@>@)

@<End FWTutMan page@>
@}

@O@<fwmode.txt@>@{@-
@i 0fwmode
@}

@!******************************************************************************

@$@<Examples HEADING@>@M@{@<SH@>@(6@)Examples of FunnelWeb Applications@}
@$@<Examples HEADING/short@>@M@{@<SH@>@(6@)Examples@}
@$@<Examples FILE@>@M@{examples.html@}
@O@<examples.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Examples HEADING@>@)
@<XX@>@(FunnelWeb@,example applications@)@<XX@>@(FunnelWeb@,applications@)

@<P@>Despite (or perhaps because of) its flexibility and
simplicity, FunnelWeb can be applied to quite a number of
different text processing and documenting problems. This
section gives some examples of some of the more interesting
real problems that FunnelWeb has solved.

@<P@>
@<Examples index@>

@<Nav@>@(@<Hints FILE@>@,@<Index FILE@>@,@<Web FILE@>@)

@<End FWTutMan page@>
@}

@$@<Examples index@>@M@{
@<Begin size3@>
@<Begin indent/narrow@>
@<Link@>@(@<Examples_postscript FILE@>@,@<Examples_postscript HEADING@>@)@<BR@>
@<Link@>@(@<Examples_adt FILE@>@,@<Examples_adt HEADING@>@)@<BR@>
@<Link@>@(@<Examples_languages FILE@>@,@<Examples_languages HEADING@>@)@<BR@>
@<Link@>@(@<Examples_function FILE@>@,@<Examples_function HEADING@>@)@<BR@>
@<Link@>@(@<Examples_comments FILE@>@,@<Examples_comments HEADING@>@)@<BR@>
@<Link@>@(@<Examples_sharing FILE@>@,@<Examples_sharing HEADING@>@)@<BR@>
@<Link@>@(@<Examples_generics FILE@>@,@<Examples_generics HEADING@>@)@<BR@>
@<End indent/narrow@>
@<End size3@>
@}

@!==============================================================================

@$@<Examples_postscript HEADING@>@M@{@<SH@>@(6.1@)Analyzing the Monster Postscript Header File@}
@$@<Examples_postscript FILE@>@M@{examples_postscript.html@}
@O@<examples_postscript.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Examples_postscript HEADING@>@)
@<XX@>@(macro@,names@)@<XX@>@(macro@,identifiers@)
@<XX@>@(monster file@,postscript@)

@<P@>During my Ph.D. candidature, I determined at one point
that it would be very desirable to automatically insert
diagrams from the @<I@>@(MacDraw@)@<X@>@(MacDraw@) program
on my Macintosh into TeX@<X@>@(TeX@) @<TT@>@(insert@)ions in
my thesis.@<XX@>@(PhD@,thesis@) This would allow diagrams to
float around with the text and be printed automatically
rather than having to be printed separately and stuck in
with real glue. On the face of it, the problem seemed
inherently solvable, as the Macintosh@<X@>@(Macintosh@) could
generate PostScript@<X@>@(PostScript@) for each diagram and
this PostScript could presumably be inserted into the
PostScript generated using TeX.

@<P@>The only trouble was that the Macintosh PostScript code
for the diagrams relied on an Apple PostScript header
file.@<XX@>@(postscript@,header file@) This meant that the
header file had to be included at the start of the TeX
PostScript if the inserted PostScript for the diagrams was
to work. Unfortunately, merely including the header file at
the top didn't work, and it turned out that a rather
detailed analysis of some parts of the Apple header file was
required in order to perform the necessary surgery on the
header file to make it work. This analysis was severely
aggravated by the fact that the PostScript header file was
virtually unreadable. Basically it was about 50K of
interwoven definitions, that looked as if it had been run
through a word processor. There was no way that the code
could be understood clearly without some kind of
reformatting. Two other aspects of the problem further
complicated the analysis:

@<P@>
@<Begin list@>

@<Item@>The definitions of interest (@<ie@>the ones causing
the problems) were scattered throughout the heaeder file.

@<Item@>Many definitions could not be moved within the
header file. For one or more
reasons (@<eg@>to keep a definition within the activation of
a particular dictionary @<TT@>@(begin@) and @<TT@>@(end@))
it would have been unwise to move the definitions of
interest to the same point in the file.

@<End list@>

@<P@>In fact the file was so messy and complicated that, as
a rule, it had to be handled with kid gloves. It would have
been unwise to re-arrange the definitions or to insert
comments.

@<P@>To my surprise, FunnelWeb provided an unexpected
solution to the problem. First I replaced all occurrences of
the @<TT@>@(@@@) in the header file with @<TT@>@(@@@@@).
Second, I placed the entire header file in a FunnelWeb macro
definition connected to a product file. I then processed the
file and checked to make sure that the product file was
identical to the original file. By doing all this I had
placed the header file under FunnelWeb control. I then left
the macro definition largely untouched, but replaced the
PostScript definitions of interest with FunnelWeb macro
calls, moving the actual PostScript definitions into
FunnelWeb macro definitions at the end of the FunnelWeb
file.

@<P@>
@<Begin verbatim@>
@@O@@@<<@>LaserHeader.ps@@@<>@>==@@{@@-
Unreadable Postscript code
@@@<<@>Print routine@@@<>@>
Unreadable Postscript code
@@@<<@>Zap routine@@@<>@>
Unreadable Postscript code
@@}

@@A This routine looks as if it does this, but really is
does that, blah, blah blah.

@@$@@@<<@>Print routine@@@<>@>==@@{@@-
/print { push pop pop push turn around
         and jump up and down and print it} def
@@}

@@A This routine zaps the...

@@$@@@<<@>Zap routine@@@<>@>==@@{@@-
/zap { push pop pop push turn around and
       jump up and down and print it} def
@@}
@<End verbatim@>

@<P@>Use of FunnelWeb meant that I was able to pluck out the
definitions of interest (a very small part of the whole
file) and collect them as a group at the end of the file
where they could be studied. Because each definition was
safely contained in a macro, it was possible to write a
detailed commentary of each routine without fear of
affecting the final PostScript code in any way at all. Once
this analysis was completed, it was possible to perform
surgery on the offending PostScript definitions in an
extremely controlled way. In particular, the FunnelWeb input
file served as a repository for all the different versions
of particular routines that were tried in order to get the
definitions to work. A new (@<B@>@(Z@)ero) macro was created for
each version of each definition, and a commentary of how it
performed added above it.

@<P@>This case demonstrates that FunnelWeb is an extremely
powerful tool for dissecting and documenting cryptic text
files.@<XX@>@(cryptic@,text files@) Through the use of
macros, particular parts of the file can be isolated and
discussed without affecting the final product file in any
way. In the example above, only a small part of the file was
analysed, the rest being left as a blob, but in the general
case, a cryptic text file could be inserted into FunnelWeb
and then incrementally dissected (and possibly modified)
until the result is a fully documented literate program.
That this can be done without affecting the actual product
file demonstrates the high degree of descriptive control
that FunnelWeb provides.

@<Nav/first@>@(@<Examples FILE@>@,@<Examples FILE@>@,@<Examples_adt FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Examples_adt HEADING@>@M@{@<SH@>@(6.2@)Making Ada ADTs More Abstract@}
@$@<Examples_adt FILE@>@M@{examples_adt.html@}
@O@<examples_adt.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Examples_adt HEADING@>@)
@<X@>@(Ada@)@<X@>@(abstract data type@)@<X@>@(ADT@)

@<P@>Like many modern programming languages, Ada provides
mechanisms for hiding information and structure. In
particular, Ada provides a @<NewTerm@>@(package@) facility
that allows the programmer to declare objects in a package
definition and define them in a corresponding package body.
This works well for functions and procedures. However, in
the case of types, implementation issues (in particular, the
need to know the size of exported types) have led the
designers of Ada to force the placement of private type
definitions in the definition package rather than the
implementation package. This means that some implementation
details are present in the package definition for all to
see. While not actually dangerous (the user of the package
cannot make use of the information without recourse to
@<DQ@>@(Chapter@<_@>13@) of the Ada Language Reference
Manual@<Paper@>@(DOD83@)), this aspect of Ada is certainly
unpleasant.

@<P@>During the development of some Ada programs, FunnelWeb
was used to solve this problem. Instead of creating a
separate file for the package specification and package
body, a single FunnelWeb file was created containing two
sections, one for the each package part. The
@<DQ@>@(private@) part of the package specification was then
moved (using a FunnelWeb macro definition) to the section
describing the package body. Readers who wished only to read
the package specification could read only the first part,
which contained a fully documented description not
containing the private definition.

@<Nav@>@(@<Examples_postscript FILE@>@,@<Examples FILE@>@,@<Examples_languages FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Examples_languages HEADING@>@M@{@<SH@>@(6.3@)Multiple Language Systems@}
@$@<Examples_languages FILE@>@M@{examples_languages.html@}
@O@<examples_languages.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Examples_languages HEADING@>@)
@<XX@>@(multiple@,languages@)

@<P@>With the prevalence of open systems@<X@>@(open
systems@) and multi-vendor computing, it is often necessary
to construct systems consisting of programs written in a
number of different programming languages for a number of
different systems. For example, a particular functionality
might be implemented by a shellscript (invoked by the user)
that calls a C@<_@>program that makes a network connection to a
Pascal program that queries a database. Quite often all
these programs must conspire closely to execute their
function. In the normal case, they must be written
separately. FunnelWeb allows them to be written as a whole.

@<P@>By creating a single FunnelWeb file that creates many
product files in different languages, the programmer can
describe the interaction between the different programs in
any manner desired. Furthermore, because the different
product files  are all created in the same @<DQ@>@(text
space@) (@<ie@>in a single FunnelWeb file), it is easy for
them to share information.

@<P@>For example, in one real application FunnelWeb was used
to create a system for printing
files@<XX@>@(printing@,system@) on a laser
printer@<XX@>@(laser@,printer@) connected to a remote Vax
Unix machine from a local Vax VMS machine. The system
consisted of two files: a VMS DCL command procedure to run
on the local node, and a Unix shellscript to run on the
remote node. The user, by giving the print command, invoked
the local VMS command procedure, which in turn fired up the
remote Unix shellscript. The two scripts then cooperated to
transfer the files to be printed and print them.

@<P@>In addition to its usual documentation powers,
FunnelWeb assisted in the creation of this system in two
special ways. First, it allowed pieces of code from the two
different command procedures to be partially interwoven in a
description of their interaction. This is just not possible
with comments. Second, it facilitated the use of shared
information. For example, under some conditions, each file
to be printed would be renamed and copied to the remote
system using a particular constant filename
(@<eg@>@<DQP@>@(printfile.tmp@)). FunnelWeb allowed this
constant filename to be included in a single macro
definition which was invoked in the definition of each of
the scripts. This ensured that the two scripts used the same
name.

@<P@>
@<Begin verbatim@>
@@A The following macro contains the temporary
file name used to allow the two shellscripts to
transfer each file to be printed.

@@$@@@<<@>printfile@@@<>@>@@M==@@{printme.txt@@}

@@A Here are the scripts for the local VMS node
and the remote UNIX node.

@@O@@@<<@>vmscommandprocedure.com@@@<>@>==@@{@@-
DCL commands
copy @@@<<@>printfile@@@<>@> unixnode::
DCL commands
@@}

@@O@@@<<@>unixshellscript@@@<>@>==@@{@@-
unix commands
print @@@<<@>printfile@@@<>@>
unix commands
@@}
@<End verbatim@>

@<P@>In the case of the printing system, the entire system
was described and defined in a single FunnelWeb
@<TT@>@(.fw@) file. In larger systems containing many
FunnelWeb @<TT@>@(.fw@) files for many different modules in
many different languages, the same trick can be pulled by
placing FunnelWeb macro definitions for shared values into
FunnelWeb include files. For example, a suite of
implementations of network nodes, with each implementation
being in a different programming language for a different
target machine, could all share a table of configuration
constants defined in macros in a FunnelWeb include file.

@<P@>In summary, FunnelWeb's macro and include file
mechanisms provide a simple way for programs written in
different languages to share information. This reduces
redundancy between the systems and hence the chance of
inconsistencies arising.@<X@>@(sharing information@)

@<Nav@>@(@<Examples_adt FILE@>@,@<Examples FILE@>@,@<Examples_function FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Examples_function HEADING@>@M@{@<SH@>@(6.4@)The Case of the Small Function@}
@$@<Examples_function FILE@>@M@{examples_function.html@}
@O@<examples_function.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Examples_function HEADING@>@)
@<XX@>@(small@,functions@)

@<P@>Often, when programming, there is a need for a code
abstraction@<XX@>@(code@,abstraction@) facility that
operates at the text level. If the statement
@<DQP@>@(a:=3;@) occurs often, it may be best simply to
repeat it verbatim. If a sequence of one hundred statements
is repeated often, it is normal to remove the code to a
function and replace the occurrences by a function call.
However, in between these two extremes are cases where a
particular sequence of code is long enough and appears often
enough to be troublesome, but which is bound so messily to
its environment as to make a function call cumbersome.

@<P@>For example, the following line of statements
(referring to five variables declared @<I@>@(local@) to a
function) might appear ten times in a function:

@<P@>
@<Begin verbatim@>
a=b*3.14159; c=d % 256; e=e+1;
@<End verbatim@>

@<P@>Now the @<DQ@>@(normal@) rule of programming says that
these statements should be placed in a procedure (also
called a @<DQ@>@(function@) in the C programming language
used in this example), but here five local variables are
used. Use of a procedure (function) would result in a
procedure definition looking something like:

@<P@>
@<Begin verbatim@>
void frobit(a,b,c,d,e)
float *a,b;
int *c,d;
unsigned *e;
{*a=b @<<@>@<<@> 8; *c=d % 256; *e=*e+1;}
@<End verbatim@>

@<P@>and a procedure call something like

@<P@>
@<Begin verbatim@>
frobit(&a,b,&c,d,&e);
@<End verbatim@>

@<P@>This might be workable in a language that allowed
formal parameters to be specified to be bound only to
particular variables. Similarly, it might be possible to
avoid the parameter list in languages that support local
procedures that can access non-local variables (such as
Pascal@<X@>@(Pascal@)). However, in our example here, in the
C programming language, these options are not available, and
so we must either create a function with five parameters, or
use the C macro preprocessor@<XX@>@(preprocessor@,C@) (the
best solution). FunnelWeb provides the same macro facility
for languages that do not have a built-in preprocessor.

@<P@>In particularly speed-stressed applications, the
programmer may be reluctant to remove code to a procedure
because of the procedure-call overhead.@<XX@>@(procedure
call@,overhead@) FunnelWeb macros can help there too.

@<P@>In summary, there sometimes arises in programming
situations where the cost of defining a procedure is higher
than the benefits it will bestow. Common reasons for this
are the run-time procedure overhead and the messy binding
problems@<XX@>@(binding@,problems@) caused by removing
target code from its target context. FunnelWeb can help in
these situations by allowing the programmer to define a text
macro. This avoids all the problems and provides an
additional incentive for the programmer to describe the
piece of code so isolated.

@<Nav@>@(@<Examples_languages FILE@>@,@<Examples FILE@>@,@<Examples_comments FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Examples_comments HEADING@>@M@{@<SH@>@(6.5@)When Comments are Bad@}
@$@<Examples_comments FILE@>@M@{examples_comments.html@}
@O@<examples_comments.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Examples_comments HEADING@>@)
@<XX@>@(comments@,abuse@)@<XX@>@(eliminating@,comments@)

@<P@>In the @<DQ@>@(good old days@)@<X@>@(good old days@) of
small machine memories and interpreted BASIC,@<X@>@(BASIC@)
programmers would eliminate the @<DQP@>@(REM@)
statements@<XX@>@(REM@,statement@) (comments) from their
BASIC programs so as to save space and increase execution
speed. Whilst this was obviously an appalling programming
practice, the small memories and slow microprocessors often
made this tempting, if not necessary.

@<P@>Thankfully, times have changed since then, and most
code is now compiled rather than interpreted. However, from
time to time one still runs into an environment or
situation, or special-purpose language, where comments are
either unavailable (no comment feature) or undesirable. Here
FunnelWeb can be used to fully document the code without
resulting in any comments in the final code at all. For
example:@<XX@>@(header@,files@)

@<P@> @<Begin list@>

@<Item@>Comments in frequently used @<TT@>@(.h@) header
files in C programs@<XX@>@(C@,header@) can have a
significant impact on compilation speed. Often such header
files are fairly cryptic and really ought to be well
commented, but their authors are reluctant to.

@<Item@>Comments are undesirable in
PostScript@<X@>@(postscript@) header files that must be
transferred repeatedly along communications channels
(@<eg@>the Apple Macintosh LaserWriter header file).

@<Item@>Interpreted programs in embedded systems.

@<Item@>Hand written machine code in hex dump form could be
commented.

@<Item@>A programmer may wish to annotate a text data file
containing lists of numbers that is to be fed into a
statistical program that does not provide any comment
facility for its input file.

@<End list@>

@<P@>In all these situations, FunnelWeb allows full
integrated documentation without any impact on the final
code.

@<Nav@>@(@<Examples_function FILE@>@,@<Examples FILE@>@,@<Examples_sharing FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Examples_sharing HEADING@>@M@{@<SH@>@(6.6@)Documents That Share Text@}
@$@<Examples_sharing FILE@>@M@{examples_sharing.html@}
@O@<examples_sharing.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Examples_sharing HEADING@>@)
@<XX@>@(sharing@,text@)

@<P@>FunnelWeb is very useful when preparing multiple
documents that must share large slabs of identical text that
are being constantly modified.

@<P@>For example someone preparing two slightly different
user manuals for two slightly different audiences might want
the manuals to share large slabs of text, while still
allowing differences between them. The following example
shows how this can be done. The code is cluttered, but this
clutter would not be a problem if the lumps of text were
moderately large.

@<P@>
@<Begin verbatim@>
@@O@@@<<@>manual1.txt@@@<>@>==@@{@@@<<@>M1@@@<>@>@@+@@}
@@O@@@<<@>manual2.txt@@@<>@>==@@{@@@<<@>M2@@@<>@>@@+@@}

@@$@@@<<@>M1@@@<>@>+=@@{@@@<<@>T1@@@<>@>@@}
@@$@@@<<@>M2@@@<>@>+=@@{@@@<<@>T1@@@<>@>@@}
@@$@@@<<@>T1@@@<>@>@@M==@@{@@-
First lump of text shared by both documents.@@+@@}

@@$@@@<<@>M1@@@<>@>+=@@{Text for first document@@+@@}
@@$@@@<<@>M2@@@<>@>+=@@{Text for second document@@+@@}

@@$@@@<<@>M1@@@<>@>+=@@{@@@<<@>T2@@@<>@>@@}
@@$@@@<<@>M2@@@<>@>+=@@{@@@<<@>T2@@@<>@>@@}
@@$@@@<<@>T2@@@<>@>@@M==@@{@@-
Second lump of text shared by both documents.@@+@@}
@<End verbatim@>

@<P@>An alternative approach, which might work better in
situations where there are many small differences between
the two documents rather than a few large ones, is to define
a macro with two arguments, one for each product file
document. Write the document from top to bottom, but place
all stretches that differ between the two documents in a
macro call.@<XX@>@(annual@,report@)

@<P@>
@<Begin verbatim@>
@@! Set the definition of @@#D to
@@!    @@1 to create the shareholders report.
@@!    @@2 to create the customers report.
@@$@@#D@@(@@2@@)@@M==@@{@@1@@}

@@O@@@<<@>report.txt@@@<>@>==@@{@@-
ANNUAL REPORT TO @@#D@@(Shareholders@@,Customers@@)
=================@@#D@@(============@@,=========@@)
This has been a very good year for The Very Big
Corporation of America. With your help, we have
been able to successfully
@@#D@@(@@"screw the customers
          for every cent they have@@"@@,
     @@"knock the shareholders into
        submission to bring you lower prices@@"@@).
With gross earnings approaching six trillion
dollars, we have been able to
@@#D@@(@@"increase dividends@@"@@,
     @@"lower prices@@"@@).
We expect to have an even better year next year.
@@}
@<End verbatim@>

@<P@>One application where text sharing can be particularly
useful is in the preparation of computer
documentation@<XX@>@(examples@,documentation@) containing
examples. For example, a book describing a new programming
language might be full of examples of small programs written
in the language which the user might want to try without
having to type them all in. The @<DQ@>@(default@) approach
of keeping a copy of the examples in the text of the book
and another copy in separate files is cumbersome and error
prone, because both files have to be updated whenever an
example is changed. A more sophisticated approach is to
store each example in a separate file, and then use the
@<DQ@>@(include file@) facility of the word processor to
include each example in the text. This is a better solution,
but suffers from a few drawbacks. First, when editing the
book in a word processor, the examples in the book will not
be directly accessible or visible. To see an example, the
writer would have to open the file containing the example in
a separate window. This could become tedious if the text
contained many examples, as many texts do. Furthermore,
there is a risk that some example files will be included in
the wrong place. Second, because the book is dependent on
the included files, the book will end up consisting of a
directory of a hundred or more files instead of just a few.

@<P@>An alternative solution is to construct a single
FunnelWeb @<TT@>@(.fw@) file that, when processed, produces
both the book file and the example files. This solution
assumes that the book consists of a text file containing
commands for a typesetter such as TeX.

@<Begin verbatim@>
@@O@@@<<@>Book.tex@@@<>@>==@@{@@#B@@}

@@$@@#B+=@@{@@-
The first step to learning the object oriented
AdaCgol++ language is to examine a hello world
program.

\start{verbatim}
@@@<<@>Ex1@@@<>@>
\finish{verbatim}
@@}

@@$@@@<<@>Ex1@@@<>@>==@@{@@-
read iopack@@+Enter !World~! !Hello~! ex pr flu X[1]@@}
@@O@@@<<@>Ex1.c@@@<>@>==@@{@@@<<@>Ex1@@@<>@>@@}

@@$@@#B+=@@{@@-
To understand the program, think of the execution
state as a plate of cheese...
@@}
@<End verbatim@>

@<P@>Most of the file will consist of part
definitions of the additive macro @<TT@>@(@@#B@).
The definition is @<DQ@>@(broken@) to allow a
macro definition, wherever an example appears.

@<P@>The example above is a little messy because
FunnelWeb does not allow macros connected to
product files to be called, and it does not have
text expressions that write to an product file as
well as evaluating to text. Nevertheless, it
presents a fairly clean solution to the problem of
keeping the example programs in a computing text
up to date.

@<Nav@>@(@<Examples_comments FILE@>@,@<Examples FILE@>@,@<Examples_generics FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Examples_generics HEADING@>@M@{@<SH@>@(6.7@)Generics@}
@$@<Examples_generics FILE@>@M@{examples_generics.html@}
@O@<examples_generics.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Examples_generics HEADING@>@)
@<XX@>@(generics@,fudging@)

@<P@>It is well known that generics in programming languages
are closely aligned with textual substitution. In fact, a
good way to understand the generic facility of a new
programming language is to ask oneself the question
@<DQ@>@(In what way does this generic facility differ from
simple text substitution?@) The differences, if any,
typically have to do with the difference in scoping between
textual and intelligent substitution and whether the generic
code is shared or copied by the implementation. In most
cases the differences are quite minor.

@<P@>Because generic facilities are so closely aligned with
text substitution, it is possible to use FunnelWeb's
parameterized macros to provide generics in programming
languages that do not support generics. Simply write a
FunnelWeb macro whose parameters are the parameters of the
generic and whose body is the generic object.

@<P@>The following FunnelWeb file gives an example of a
fully worked Vax Pascal@<X@>@(Pascal@) generic set package
implemented using FunnelWeb parameterized macros. The
package was written by Barry Dwyer@<XN@>@(Barry@,Dwyer@) of
the Computer Science Department of the University of
Adelaide@<XX@>@(University@,Adelaide@) in 1987 and was
emailed to me on 11@<_@>November 1987. The generic package
provides a set abstraction@<XX@>@(set@,abstraction@)
implemented using linked lists. Note the clever use of the
instantiation parameters in type, function, and procedure
names.

@<P@>
@<Begin verbatim@>
@@$@@@<<@>Generic Set Module@@@<>@>@@(@@2@@)==@@{@@-
@@! @@1 is the base type, @@2 is the set type.
[inherit ('@@1'), environment ('@@2')]

module @@2;

type  @@2 = ^@@2Record;
      @@2Record = record
         Member: @@1;
         Next: @@2;
         end;

procedure Null@@2 (var Result: @@2);
begin new (Result);
Result^.Member := (- MaxInt)::@@1;
Result^.Next := nil end;

function IsNull@@2 (S: @@2): boolean;
begin
IsNull@@2 := S^.Member::integer = - MaxInt
end;

procedure ForEach@@1 (S: @@2; procedure DoIt (i: @@1));
var   ThisS, NextS: @@2;
begin ThisS := S;
while ThisS^.Member::integer @<<@>@<>@> - MaxInt do
   begin NextS := ThisS^.Next;
   DoIt (ThisS^.Member);
   ThisS := NextS end;
end;

function First@@1 (S: @@2): @@1;
begin First@@1 := S^.Member end;

function Is@@1InSet (i: @@1; S: @@2): boolean;
   procedure TestEquals (j: @@1);
   begin if Equal@@1 (i, j) then Is@@1InSet := true; end;
begin
Is@@1InSet := false;
ForEach@@1 (S, TestEquals);
end;

function Includes@@2 (S1, S2: @@2): boolean;
var Result: boolean;
   procedure TestIfInS1 (i: @@1);
   begin
   if Result then
      if not Is@@1InSet (i, S1) then
         Result := false;
   end;
begin Result := true;
ForEach@@1 (S2, TestIfInS1);
Includes@@2 := Result end;

function Disjoint@@2s (S1, S2: @@2): boolean;
var Result: boolean;
   procedure TestIfInS1 (i: @@1);
   begin
   if Result then
      if Is@@1InSet (i, S1) then
         Result := false;
   end;
begin Result := true;
ForEach@@1 (S2, TestIfInS1);
Disjoint@@2s := Result end;

function Equal@@2 (S1, S2: @@2): boolean;
begin
Equal@@2 := Includes@@2 (S1, S2) and
           Includes@@2 (S2, S1);
end;

procedure Insert@@1 (i: @@1; var S: @@2);
var   This, Pred, Succ: @@2;
begin
if not Is@@1InSet (i, S) then
   begin
   Pred := nil; Succ := S;
   while Succ^.Member::integer @<>@> i::integer do
      begin Pred := Succ; Succ := Succ^.Next end;
   if Succ^.Member::integer @<<@> i::integer then
      begin
      new (This);
      This^.Next := Succ;
      This^.Member := i;
      if Pred @<<@>@<>@> nil then
         Pred^.Next := This
      else
         S := This;
      end;
   end;
end;

procedure Insert@@1s (S1: @@2; var S2: @@2);
var   This, Pred, Succ: @@2;
   procedure Add@@1 (i: @@1);
   begin Insert@@1 (i, S2) end;
begin
ForEach@@1 (S1, Add@@1);
end;

procedure Remove@@1 (i: @@1; var S: @@2);
var   Pred, This: @@2;
begin
Pred := nil; This := S;
while not Equal@@1 (This^.Member, i) do begin
   Pred := This; This := This^.Next end;
if Pred @<<@>@<>@> nil then
   Pred^.Next := This^.Next
else
   S := This^.Next;
Dispose (This);
end;

procedure Dispose@@2 (var S: @@2);
var   Old: @@2;
begin
while S @<<@>@<>@> nil do
   begin
   Old := S;
   S := S^.Next;
   Dispose (Old)
   end;
end;

end.
@@}

@@O@@@<<@>NaryTreeSet.pas@@@<>@>==@@{@@-
  @@@<<@>Generic Set Module@@@<>@>@@-
@@(@@"NaryTree@@"@@,@@"NaryTreeSet@@"@@)@@}
@@O@@@<<@>NaryTreeSetSet.pas@@@<>@>==@@{@@-
  @@@<<@>Generic Set Module@@@<>@>@@-
@@(@@"NaryTreeSet@@"@@,@@"NaryTreeSetSet@@"@@)@@}
@<End verbatim@>

@<P@>A great advantage of the approach reflected in the
above example is that it allows the programmer to construct
a generic object in a language that does not supply
generics, @<I@>@(with complete
typesafety.@)@<XX@>@(typesafe@,generics@) This contrasts to
the approach that might be used in a language such as C
where the programmer might choose to construct a
@<DQ@>@(generic@) package by parameterizing a package with
pointers to @<TT@>@(void@). The resulting package is
powerful but extremely untypesafe. Such a generic list
package is used in the code of FunnelWeb itself and caused
no end of problems, as the compiler had no way of telling if
pointers to the correctly typed object were being handed to
the correct list-object/function combination.

@<P@>The major disadvantage of the text generic approach is
that it causes the code of the generic object to be
duplicated once for each instantiation. Depending on the
number and size of the instantiations, this may or may not
be acceptable.

@<P@>Where the duplication of code is unacceptable, a hybrid
approach may be taken. As in the C@<_@>example, the programmer
could write a single generic package using pointers to
@<TT@>@(void@) or some other untypesafe mechanism. Then the
programmer creates a FunnelWeb generic package whose
functions do nothing more than call the functions of the
untypesafe package, and whose types do nothing more than
contain the types of the untypesafe package. This solution
involves the use of untypesafe programming, but this is a
one-off and if done carefully and correctly, the result can
be a typesafe generic package involving minimal code
duplication.

@<Nav/last@>@(@<Examples_sharing FILE@>@,@<Examples FILE@>@,@<Examples FILE@>@)

@<End FWTutMan page@>
@}

@!******************************************************************************

@$@<Web HEADING@>@M@{@<SH@>@(7@)Making Webs With FunnelWeb@}
@$@<Web HEADING/short@>@M@{@<SH@>@(7@)Webmaking@}
@$@<Web FILE@>@M@{web.html@}
@O@<web.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Web HEADING@>@)

@<P@>FunnelWeb was designed for the purposes of literate
programming and was first created in 1986, long before the
internet's World Wide Web appeared. So it came as a pleasant
surprise to discover that FunnelWeb is an excellent tool for
the preparation of websites! All the FunnelWeb webs,
including the web you are reading right now, were created
using FunnelWeb itself. This chapter explains how you can
use FunnelWeb to make websites.

@<P@>
@<Web index@>

@<Nav/last@>@(@<Examples FILE@>@,@<Index FILE@>@,@<Index FILE@>@)

@<End FWTutMan page@>
@}

@$@<Web index@>@M@{
@<Begin size3@>
@<Begin indent/narrow@>
@<Link@>@(@<Web_introduction FILE@>@,@<Web_introduction HEADING@>@)@<BR@>
@<Link@>@(@<Web_start FILE@>@,@<Web_start HEADING@>@)@<BR@>
@<Link@>@(@<Web_messy FILE@>@,@<Web_messy HEADING@>@)@<BR@>
@<Link@>@(@<Web_errors FILE@>@,@<Web_errors HEADING@>@)@<BR@>
@<Link@>@(@<Web_style FILE@>@,@<Web_style HEADING@>@)@<BR@>
@<Link@>@(@<Web_libraries FILE@>@,@<Web_libraries HEADING@>@)@<BR@>
@<Link@>@(@<Web_param FILE@>@,@<Web_param HEADING@>@)@<BR@>
@<Link@>@(@<Web_conventions FILE@>@,@<Web_conventions HEADING@>@)@<BR@>
@<End indent/narrow@>
@<End size3@>
@}

@!==============================================================================

@$@<Web_introduction HEADING@>@M@{@<SH@>@(7.1@)Introduction@}
@$@<Web_introduction FILE@>@M@{web_introduction.html@}
@O@<web_introduction.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Web_introduction HEADING@>@)

@<P@>How can FunnelWeb be used to make webs? Easy!
Here's how it works. You create a single file called (say)
@<TT@>@(daves_web.fw@) containing a Funnelweb output
file macro (@<TT@>@(@@O@)) for each page in the the web
that you want to create. The @<TT@>@(daves_web.fw@) file
contains the entire web. When you feed it through FunnelWeb,
FunnelWeb generates all the HTML files in your web.

@<P@>
@<Begin verbatim@>
                 +--------------+
                 | daves_web.fw |
                 +--------------+
                        |
                        V
               o-------------------o
               | FunnelWeb Program |
               o-------------------o
                        |
                        V
       +----------------+----------------+
       |                |                |
+--------------+  +------------+  +------------+
| contact.html |  | index.html |  | links.html |
+--------------+  +------------+  +------------+
@<End verbatim@>

@<P@>Here are some key points about this application:

@<P@>
@<Begin list@>

@<Item@>First, FunnelWeb can only generate the text files in
your web (such as the @<TT@>@(.html@) files). You will still
need to create the image files using the image manipulation
tools you usually use; FunnelWeb does not help with the
graphics, nor does it provide a GUI. You have to write raw
HTML. However, FunnelWeb provides power tools for writing
the HTML.

@<Blank line@>

@<Item@>Second, this is not a literate-programming
application of webs. Here, FunnelWeb is being used purely as
a macro preprocessor, and there will never be any cause to
use FunnelWeb to generate documentation files (weaving). The
files generated as above are FunnelWeb @<I@>@(output@)
files, not FunnelWeb HTML documentation produced by the
FunnelWeb weaver. This is a raw macro preprocessor
application.

@<End list@>

@<P@>So what benefit is there in converting one's web to a
single FunnelWeb file? If you have just a small number of
pages in your web (as in the above diagram), there is
probably not much benefit. However, if you have several
pages in your web, FunnelWeb can provide huge benefits by
enabling you to control the relationships between the
various parts of your web and to parameterize it in whatever
ways you want to. The result is a consistent style, a
reduction of errors, and the power to execute broad ranging
changes to the web with very little fuss. For example,
FunnelWeb makes it easy to change the background of each
page in your web, or to add a copyright notice at the bottom
of every page.

@<P@>

@<P@>The advantages of using FunnelWeb to make webs are as follows:

@<P@>
@<Begin list@>
@<Item@>Web is represented by a single file.
@<Item@>No more multiple-file replace operations!
@<Item@>Define a consistent style for the web.
@<Item@>Parameterize the web. Make global changes easily.
@<Item@>Use the power of HTML without the messy HTML syntax.
@<Item@>Eliminates many syntax and spelling errors.
@<Item@>Eliminates bad (internal) links.
@<Item@>Eliminates form/CGI cross reference errors.
@<Item@>A flexible text power tool always available.
@<End list@>

@<P@>The disadvantages of using FunnelWeb to make webs are as
follows:

@<P@>
@<Begin list@>
@<Item@>No GUI interface. You have to write your web directly.
@<Item@>It is more difficult to position graphics precisely.
@<Item@>FunnelWeb files can look cryptic and messy.
@<Item@>You have to run FunnelWeb between changing your web and
viewing the changed pages.
@<End list@>

@<P@>Thus, if you make webs that are highly graphics
intensive, or if you are uncertain about writing HTML, you
should probably not use FunnelWeb. However, if you are
generating large webs with many similar pages, FunnelWeb
will eliminate much of the hassle in managing the whole
complex. For large webs, this management capability is
invaluable.

@<P@>Whatever its advantages and disadvantages, FunnelWeb is
certainly a @<B@>@(practical@) production-quality webmaking tool.
It has been used to make all of the webs in the following
web spaces (each of which contains several subwebs):

@<P@>
@<Begin indent@>
@<Ross Williams@>@<BR@>
@<Rocksoft@>@<BR@>
@<Veracity@>@<BR@>
@<End indent@>

@<Nav/first@>@(@<Web FILE@>@,@<Web FILE@>@,@<Web_start FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Web_start HEADING@>@M@{@<SH@>@(7.2@)Getting Started@}
@$@<Web_start FILE@>@M@{web_start.html@}
@O@<web_start.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Web_start HEADING@>@)

@<P@>This page contains a brief hands-on tutorial to get you started
in using FunnelWeb to make webs.

@<FWTutMan subheading@>@(Hello Web@)

@<P@>The best way to understand how FunnelWeb can help you make webs
is to work through a simple example. Here is one:

@<P@>
@<Begin verbatim@>@=#
@!************************************************

@O@#<<#>index.html@>@{
##<HTML##>

##<HEAD##>
##<TITLE##>Dave's Home Page##</TITLE##>
##</HEAD##>

##<BODY BGCOLOR=#@FFFFFF##>
##<P##>Welcome to my home page. Check out my
##<A HREF="links.html"##>links page##</A##>.
##</BODY##>

##</HTML##>
@}

@!************************************************

@O@##<links.html@##>@{
##<HTML##>

##<HEAD##>
##<TITLE##>Dave's Links##</TITLE##>
##</HEAD##>

##<BODY BGCOLOR=#@FFFFFF##>
##<P##>Here are my links:

##<P##>
##<A HREF="http://www.yahoo.com/"##>Yahoo##</A##>##<BR##>
##<A HREF="http://www.dilbert.com/"##>Dilbert##</A##>##<BR##>
##</BODY##>

##</HTML##>
@}

@!************************************************
#=@@<End verbatim@>

@<P@>Cut and paste the above text into a file called @<TT@>@(dave.fw@)
and run FunnelWeb on it by giving the command:

@<P@>
@<Begin verbatim@>
   fw dave
@<End verbatim@>

@<P@>
@<Begin blockquote@>
@<Begin size2@>
@<B@>@(Note:@) On my computer, when you cut and paste text
from a web page, the pasted text contains a block of blanks
before each line; you will have to delete these to make the
example work, as FunnelWeb requires the first line of macro
definitions to be in column one.
@<End size2@>
@<End blockquote@>

@<P@>If all goes well, FunnelWeb should write out two files
@<TT@>@(index.html@) and @<TT@>@(links.html@). That's the
generated web, and you should be able to browse it using your
favorite web browser.

@<FWTutMan subheading@>@(First Glimmers Of Usefulness@)

@<P@>The sole benefit we have obtained so far is that the web
is represented as a single file. This confers quite a few benefits
on its own for medium-sized webs, such as the elimination of
the need to perform multiple-file search and replace operations,
but it's really only a start.

@<P@>The next step is to recognise that the two pages above share
quite a lot of text and that that text can be removed into FunnelWeb
macros.

@<P@>
@<Begin verbatim@>@=#
@!************************************************

@$@##<Begin page@>@(@1@)@M@{
##<HTML##>
##<HEAD##>
##<TITLE##>@1##</TITLE##>
##</HEAD##>
##<BODY BGCOLOR=#@FFFFFF##>
@}

@$@##<End page@##>@M@{
##</BODY##>
##</HTML##>
@}

@!************************************************

@O@##<index.html@##>@{

@##<Begin page@##>@(Dave's Home Page@)

##<P##>Welcome to my home page. Check out my
##<A HREF="links.html"##>links page##</A##>.

@##<End page@##>
@}

@!************************************************

@O@##<links.html@##>@{
@##<Begin page@##>@(Dave's Links@)

##<P##>Here are my links:

##<P##>
##<A HREF="http://www.yahoo.com/"##>Yahoo##</A##>##<BR##>
##<A HREF="http://www.dilbert.com/"##>Dilbert##</A##>##<BR##>

@##<End page@##>
@}

@!************************************************
#=@@<End verbatim@>

@<P@>Now, although the file has actually got a little longer and
looks far more complicated than it did, we've actually managed
to extract two significant benefits from this reorganization.

@<Narrowthing@>@(Page style:@,First, almost without even
trying, we've created a page style. For example, to change
the colour of all the pages in the web, we need just change
the single body definition in the begin page macro.
Similarly, if we wanted to add a copyright notice at the
bottom of each page, we need change only the end page
macro.@)

@<Narrowthing@>@(Page overhead:@,Second, we've reduced the
amount of text required to define each page. Instead of
requiring ten lines of HTML to set up each page, we need
just two FunnelWeb calls (two lines); the rest is text
particular to the page being defined.@)

@<P@>These advantages may seem minor, but when scaled up to a
web containing a dozen or more pages, they become very significant.

@<P@>The newfound power, in the case of the example, can be demonstrated
by changing the web from black on white to blue on white, and by adding
another page:

@<P@>
@<Begin verbatim@>@=#
@!************************************************

@$@##<Begin page@##>@(@1@)@M@{
##<HTML##>
##<HEAD##>
##<TITLE##>@1##</TITLE##>
##</HEAD##>
##<BODY BGCOLOR=#@FFFFFF TEXT=#@000033##>
@}

@$@##<End page@##>@m@{
##</BODY##>
##</HTML##>
@}

@!************************************************

@O@##<index.html@##>@{
@##<Begin page@##>@(Dave's Home Page@)

##<P##>Welcome to my home page. Check out my
##<A HREF="links.html"##>links page##</A##> and my
##<A HREF="hobbies.html"##>hobbies page##</A##>.

@##<End page@##>
@}

@!************************************************

@O@##<links.html@##>@{
@##<Begin page@##>@(Dave's Links@)

##<P##>Here are my links:

##<P##>
##<A HREF="http://www.yahoo.com/"##>Yahoo##</A##>##<BR##>
##<A HREF="http://www.dilbert.com/"##>Dilbert##</A##>##<BR##>

@##<End page@##>
@}

@!************************************************

@O@##<hobbies.html@##>@{
@##<Begin page@##>@(Dave's Hobbies@)

##<P##>This page is under construction!

@##<End page@##>
@}

@!************************************************
#=@@<End verbatim@>

@<P@>Now that you have a Hello World file to play with, the remaining
sections of this chapter will discuss the ways in which you can
use the macro power now at your fingertips.

@<Nav@>@(@<Web_introduction FILE@>@,@<Web FILE@>@,@<Web_messy FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Web_messy HEADING@>@M@{@<SH@>@(7.3@)Replacing Messy HTML Constructs@}
@$@<Web_messy FILE@>@M@{web_messy.html@}
@O@<web_messy.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Web_messy HEADING@>@)

@<P@>One of the greatest benefits of using FunnelWeb is its ability
to replace messy slabs of HTML with a simple macro call. This page
provides lots of examples of this.

@<FWTutMan subheading@>@(Hyperlinks@)

@<P@>Hyperlinks are messy and you can eliminate their messiness
from your FunnelWeb web source by defining a macro for each link
you want to use. For example:

@<P@>
@<Begin verbatim@>@=#
@$@##<Dilbert@##>@Z@M@{@-
##<A HREF="http://www.dilbert.com/"##>Dilbert##</A##>@}
@$@##<Yahoo@##>@Z@M@{@-
##<A HREF="http://www.yahoo.com/"##>Yahoo##</A##>@}
#=@@<End verbatim@>

@<P@>While the definitions themselves are certainly messy,
having made them, we are now free to refer to Dilbert and
Yahoo within our webs in a very clean manner indeed. For
example, the links page of the previous example now becomes
just:

@<P@>
@<Begin verbatim@>@=#
@O@##<links.html@##>@{
@##<Begin page@##>@(Dave's Links@)

##<P##>Check out @##<Dilbert@##> and @##<Yahoo@##>!

@##<End page@##>
@}
#=@@<End verbatim@>

@<FWTutMan subheading@>@(Images@)

@<P@>Suppose we want to include a small image of a checkmark
at various points without a web page. Here's the HTML that
has to be included at each point:

@<P@>
@<Begin verbatim@>@=#
##<IMG SRC="bin/tick_red_12.gif"
WIDTH="12" HEIGHT="12"
HSPACE=4 VSPACE=0
ALT="*" BORDER="0"##>
#=@@<End verbatim@>

@<P@>Yuk! To eliminate this mess in our FunnelWeb/HTML, we
can define a macro for a tick mark as follows:

@<P@>
@<Begin verbatim@>@=#
@$@##<Tick@##>@M@{
##<IMG SRC="bin/tick_red_12.gif"
WIDTH="12" HEIGHT="12"
HSPACE=4 VSPACE=0
ALT="*" BORDER="0"##>@}
#=@@<End verbatim@>

@<P@>Now, using tick marks without your text is easy.
Here's an example:

@<P@>
@<Begin verbatim@>@=#
@##<Tick@##>Low cost.##<BR##>
@##<Tick@##>Easy installation.##<BR##>
@##<Tick@##>Available now!##<BR##>
#=@@<End verbatim@>

@<FWTutMan subheading@>@(Large Form Fields@)

@<P@>Another example is where you have form fields
with lots of options. Here's an example of a commonly
occurring form field that goes on for a couple of
hundred lines!

@<P@>
@<Begin verbatim@>@=#
##<SELECT NAME="Country"##>
##<OPTION##>United States
##<OPTION##>Afghanistan
##<OPTION##>Albania
...
##<OPTION##>Zambia
##<OPTION##>Zimbabwe
##</SELECT##>
#=@@<End verbatim@>

@<P@>Using FunnelWeb, you can move all this to a single macro
definition as follows:

@<P@>
@<Begin verbatim@>@=#
@$@##<Country form field@##>@M@(
##<SELECT NAME="Country"##>
##<OPTION##>United States
##<OPTION##>Afghanistan
##<OPTION##>Albania
...
##<OPTION##>Zambia
##<OPTION##>Zimbabwe
##</SELECT##>
#=@@<End verbatim@>

@<P@>Now, whenever you want a country field in a form, you can
just write:

@<P@>
@<Begin verbatim@>@=#
@##<Country form field@##>
#=@@<End verbatim@>

@<FWTutMan subheading@>@(Navigation Buttons@)

@<P@>Sometimes the navigation constructs that appear
within pages can become rather messy. Here's an example
where we have three buttons at the bottom of each page.

@<P@>
@<Begin verbatim@>@=#
##<TABLE WIDTH="100%"##>
##<TR##>
##<TD ALIGN="left"   VALIGN="bottom"##>##<
 A HREF="links.html"##>##<IMG SRC="bin/left.gif"##>##</A##>##</TD##>
##<TD ALIGN="center" VALIGN="bottom"##>##<
 A HREF="home.html"##>##<IMG SRC="bin/up.gif"##>##</A##>##</TD##>
##<TD ALIGN="right"  VALIGN="bottom"##>##<
 A HREF="hobbies.html"##>##<
 IMG SRC="bin/right.gif"##>##</A##>##</TD##>
##</TR##>
##</TABLE##>
#=@@<End verbatim@>

@<P@>We can move all this to a single macro definition
that has three parameters, one for each target page.

@<P@>
@<Begin verbatim@>@=#
@$@##<Nav@##>@(@3@)@Z@M@{
@##<P@##>
##<TABLE WIDTH="100%"##>
##<TR##>
##<TD ALIGN="left"   VALIGN="bottom"##>##<
 A HREF="@1"##>##<IMG SRC="bin/left.gif"##>##</A##>##</TD##>
##<TD ALIGN="center" VALIGN="bottom"##>##<
 A HREF="@2"##>##<IMG SRC="bin/up.gif"##>##</A##>##</TD##>
##<TD ALIGN="right"  VALIGN="bottom"##>##<
 A HREF="@3"##>##<IMG SRC="bin/right.gif"##>##</A##>##</TD##>
##</TR##>
##</TABLE##>
@}
#=@@<End verbatim@>

@<P@>Now, to add navigation buttons to a page,
we can just write (near the end of the page).

@<P@>
@<Begin verbatim@>@=#
@##<Nav@##>@(links.html@,home.html@,hobbies.html@)
#=@@<End verbatim@>

@<P@>If you wanted to, you could build the navigation
buttons into the @<TT@>@(@@@<<@>End page@@@<>@>@) macro
and set it up with three parameters instead.

@<Nav@>@(@<Web_start FILE@>@,@<Web FILE@>@,@<Web_errors FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Web_errors HEADING@>@M@{@<SH@>@(7.4@)Avoiding Errors And Inconsistencies@}
@$@<Web_errors FILE@>@M@{web_errors.html@}
@O@<web_errors.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Web_errors HEADING@>@)

@<P@>FunnelWeb provides the opportunity to eliminate all kinds of
errors and inconsistencies by replacing text names with FunnelWeb
macro names that cannot be misspelt without being detected by FunnelWeb.
This page provides some examples of this.

@<FWTutMan subheading@>@(Minor Style Elements@)

@<P@>Have you ever done this:

@<P@>
@<Begin verbatim@>@=#
This is ##<B Very Important##</B##>!
#=@@<End verbatim@>

@<P@>These kinds of errors can be eliminated by replacing HTML
constructs, even simple ones, by FunnelWeb macros:

@<P@>
@<Begin verbatim@>@=#
@$@##<B@##>@(@1@)@M@{##<B##>@1##</B##>@}
...
This is @##<B@##>@(Very Important@)!
#=@@<End verbatim@>

@<P@>While this is a bit messier, it eliminates the chance of an
error because if you get the syntax wrong, FunnelWeb will generate
an error at "compile time", which is a lot better than receiving
email from some random web visitor. It's true that the same level
of checking can be obtained by running an HTML syntax checker
over your web. However, if you're using FunnelWeb for all its
other benefits, you might as well use this aspect too.

@<FWTutMan subheading@>@(File Names In Hyperlinks@)

@<P@>Another source of error in webs is bad internal links.
This can occur when you rename a file and forget to "fix up"
all the links to it, and when you make a typing error when
typing in a filename in a hyperlink.

@<P@>You can use FunnelWeb to eliminate both of these kinds
of error, by defining a macro for each output file. This is
easier to do than explain:

@<P@>
@<Begin verbatim@>@=#
@!************************************************

@$@##<Begin page@##>@(@1@)@M@{
##<HTML##>
##<HEAD##>
##<TITLE##>@1##</TITLE##>
##</HEAD##>
##<BODY BGCOLOR=#@FFFFFF TEXT=#@000033##>
@}

@$@##<End page@##>@M@{
##</BODY##>
##</HTML##>
@}

@!************************************************

@O@##<index.html@##>@{
@##<Begin page@##>@(Dave's Home Page@)

##<P##>Welcome to my home page. Check out my
##<A HREF="@##<Links FILE@##>"##>links page##</A##> and my
##<A HREF="@##<Hobbies FILE@##>"##>hobbies page##</A##>.

@##<End page@##>
@}

@!************************************************

@$@##<Links FILE@##>@M@{links.html@}
@O@##<links.html@##>@{
@##<Begin page@##>@(Dave's Links@)

##<P##>Here are my links:

##<P##>
##<A HREF="http://www.yahoo.com/"##>Yahoo##</A##>##<BR##>
##<A HREF="http://www.dilbert.com/"##>Dilbert##</A##>##<BR##>

@##<End page@##>
@}

@!************************************************

@$@##<Hobbies FILE@##>@M@{hobbies.html@}
@O@##<hobbies.html@##>@{
@##<Begin page@##>@(Dave's Hobbies@)

##<P##>This page is under construction!

@##<End page@##>
@}

@!************************************************
#=@@<End verbatim@>

@<P@>Again, this technique introduces a little messiness, but
the benefits it brings are significant. Once you have deployed
this technique throughout your web source file, you will then
be free to change the names of any of your files without ever
having to worry about fixing up any links - they will all be
fixed automatically! Furthermore, if you delete an output
file from your FunnelWeb source file, FunnelWeb will alert
you to any "dangling links" because the references to the
deleted page take the form of calls to a macro that is no
longer defined! Of course, this only works if you don't mark
your filename macros with @<TT@>@(@@Z@).

@<P@>The only thing you have to get right is to ensure that
the filename of the output macro is the same as the value
of the corresponding naming macro. This isn't too hard to
do because they are always on adjacent lines.

@<P@>The benefit of eliminating all bad links from one's
web is a benefit that can be obtained by running an external
web analysis tool over your web. However, by using FunnelWeb
file naming macros, you can be SURE that the web can never
be generated with a bad link, whereas the web analysis tool
only works if you remember to run it!

@<FWTutMan subheading@>@(People's Names@)

@<P@>Sometimes you might have to create a web that contains lots
of long names that are hard to remember or spell. FunnelWeb
can help here by eliminating the chance of error. Just define
each name as macro and always call the macro when using the
name. The benefit of doing this is that FunnelWeb will always
detect a spelling error because if you make a spelling error
in the macro name, FunnelWeb will generate a "macro not defined"
error.

@<P@>
@<Begin verbatim@>@=#
@$@##<Marvin Hylrzbvwryvitz@##>@M@{Marvin Hylrzbvwryvitz@}
#=@@<End verbatim@>

@<P@>If you want to, you could used a shortened form. For example:

@<P@>
@<Begin verbatim@>@=#
@$@##<Marvin@##>@M@{Marvin Hylrzbvwryvitz@}
#=@@<End verbatim@>

@<FWTutMan subheading@>@(CGI Form Fields@)

@<P@>One of the organizational challenges of implementing
CGI form processing is getting all the field names right.
Because (normally) the form is in one file, and the CGI
script that processes it is in another file, it's very
easy to accidentally use different names for the same
field. For example, you might use @<TT@>@(email_adr@) in
one and @<TT@>@(email-adr@) in the other.

@<P@>FunnelWeb can be used to completely eliminate this
problem as follows:

@<P@>
@<Begin list/ordered@>

@<Item@>Put both the HTML file containing the form and the
CGI file that processes it within the @<TT@>@(.fw@) file
that embodies your web.

@<Blank line@>

@<Item@>Define a macro for the name of each field and use
the macro in both the form and the CGI script.

@<End list/ordered@>

@<P@>Here's an example:

@<P@>
@<Begin verbatim@>@=#
@!************************************************

@$@##<Email FIELD@##>@M@{email_adr@}

@!************************************************

@O@##<order.html@##>@{
@##<Begin page@##>@(Order Form@)

##<P##>
##<FORM ...##>
##<INPUT TYPE="text" NAME="@##<Email FIELD@##>"##>
...
##</FORM##>

@##<End page@##>
@}

@!************************************************

@O@##<order.cgi@##>@{@-
@##<Begin CGI page@##>
...
$v = $form{'@##<Email FIELD@##>'};
@##<End CGI page@##>
@}

@!************************************************
#=@@<End verbatim@>

@<P@>This technique more or less completely eliminates
mismatch errors in form field names, for if any such error
is made, FunnelWeb will generate a "macro not defined"
error. All you have to do to benefit from this technique
is get into the habit of using it.

@<FWTutMan subheading@>@(When Global Replace Fails@)

@<P@>Many people who write HTML directly use nerve wracking
multi-file global replaces to perform the kind of web
parameterization that FunnelWeb makes so easy.
Unfortunately, these global replacements can go badly wrong
because the target text may be used in many different
contexts. In some cases, this approach fails completely.

@<P@>For example, suppose that you have to create a hundred
page web that has to be laced with two email addresses: a
"business" email address and a "personal" email address. No
problem so far. However, suppose that you haven't yet chosen
a business domain name and, as a result,  at the current
time, the two email addresses are the same! If this were the
case, you would have to put your address throughout all the
pages and would LOSE the information of which were supposed
to be business addresses and which were supposed to be
personal ones.

@<P@>FunnelWeb solves this problem (and others like it)
completely by allowing you to define two macros one for each
context. For example:

@<P@>
@<Begin verbatim@>@=#
@$@##<Business EMAIL@##>@M@{dave@@someisp.com.au@}
@$@##<Personal EMAIL@##>@M@{dave@@someisp.com.au@}
#=@@<End verbatim@>

@<P@>These macros can then be used as appropriate. Later,
when the domain name comes through and the business address
changes, all that needs to be changed is a single definition:

@<P@>
@<Begin verbatim@>@=#
@$@##<Business EMAIL@##>@M@{dave@@megacorp.com.au@}
@$@##<Personal EMAIL@##>@M@{dave@@someisp.com.au@}
#=@@<End verbatim@>

@<P@>There is no need to perform a multi-file global replace
and evaluate the context of the use of each email address,
as the information was not lost when the web was originally
created, because of the two macros.

@<P@>This example is just one of many similar situations that
arise. By locating all the pages of your web in a single file
and allowing you to define macros for different purposes,
you can eliminate much of the time and danger of global
replacements.

@<Nav@>@(@<Web_messy FILE@>@,@<Web FILE@>@,@<Web_style FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Web_style HEADING@>@M@{@<SH@>@(7.5@)Defining A Consistent Style@}
@$@<Web_style FILE@>@M@{web_style.html@}
@O@<web_style.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Web_style HEADING@>@)

@<P@>We have already seen how FunnelWeb can be used, through the
use of @<TT@>@(@@@<<@>Begin page@@@<>@>@) and
@<TT@>@(@@@<<@>End page@@@<>@>@) macros to set up
a particular page style throughout a web.
However, this is really just the beginning of FunnelWeb's capacity
to manage the style of a web. This page provides some other ideas.

@<FWTutMan subheading@>@(Generic Style Macros@)

@<P@>HTML contains some tags such as @<TT@>@(@<<@>em@<>@>@)
that have a high-level meaning (@<DQ@>@(emphasis@)) rather than
a low-level meaning such as @<DQ@>@(italics@). You can use FunnelWeb
to create your own high level formatting macros so that you can later
change the style of the web just by changing the macro definitions.

@<P@>For example, suppose that your web contains lots of latin names
of plants. You've decided that you want to highlight the names, but
haven't decided how. Using FunnelWeb you can just define a macro:

@<P@>
@<Begin verbatim@>@=#
@$@##<Latin@##>@(@1@)@M@{##<B##>@1##</B##>@}
#=@@<End verbatim@>

@<P@>This means that all latin names will be set in bold. However,
if at a later date, you change your mind, you can just change the
definition to some other format.

@<FWTutMan subheading@>@(Margins@)

@<P@>Here's another example. Suppose that you want some parts of
the text in your web to be narrower than others. You can achive
this by defining and using a macro like this:

@<P@>
@<Begin verbatim@>@=#
@$@##<Narrower@##>@(@1@)@M@{@-
##<TABLE##>##<TR##>##<TD WIDTH="200"##>
@1
##</TD##>##</TR##>##</TABLE##>
@}
#=@@<End verbatim@>

@<P@>If at a later date, you want to change all the widths, you
just need to change the single definition.

@<Nav@>@(@<Web_errors FILE@>@,@<Web FILE@>@,@<Web_libraries FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Web_libraries HEADING@>@M@{@<SH@>@(7.6@)Defining Macro Libraries@}
@$@<Web_libraries FILE@>@M@{web_libraries.html@}
@O@<web_libraries.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Web_libraries HEADING@>@)

@<FWTutMan subheading@>@(Separating Macros Into An Include File@)

@<P@>Once you start using FunnelWeb to make webs, you'll discover
that you find yourself defining and using the same macros over and
over. Rather than redefining them for each new web you make, you
can place them all in a FunnelWeb include file, so that they can
be included in the FunnelWeb file for each web you make. Suppose
that we create a file called @<TT@>@(style.fwi@) containing the
following text:

@<P@>
@<Begin verbatim@>@=#
@$@##<Begin page@##>@(@1@)@M@{
##<HTML##>
##<HEAD##>
##<TITLE##>@1##</TITLE##>
##</HEAD##>
##<BODY BGCOLOR=#@FFFFFF TEXT=#@000033##>
@}

@$@##<End page@##>@{
##</BODY##>
##</HTML##>
@}

@$@##<Dilbert@##>@Z@M@{@-
##<A HREF="http://www.dilbert.com/"##>Dilbert##</A##>@}
@$@##<Yahoo@##>@Z@M@{@-
##<A HREF="http://www.yahoo.com/"##>Yahoo##</A##>@}
#=@@<End verbatim@>

@<P@>Once this is done, the main web file can become:

@<P@>
@<Begin verbatim@>@=#
@!************************************************

@i style

@!************************************************

@O@##<index.html@##>@{
@##<Begin page@##>@(Dave's Home Page@)

##<P##>Welcome to my home page. Check out my
##<A HREF="@##<Links FILE@##>"##>links page##</A##>.

@##<End page@##>
@}

@!************************************************

@$@##<Links FILE@##>@M@{links.html@}
@O@##<links.html@##>@{
@##<Begin page@##>@(Dave's Links@)

##<P##>Check out @##<Yahoo@##> and @##<Dilbert@##>.

@##<End page@##>
@}

@!************************************************
#=@@<End verbatim@>

@<P@>Now we're starting to see some real simplification!

@<P@>Note: It's important to attach @<TT@>@(@@Z@) to any
macro you place in an include file that you think might
not be called in some webs. If you don't, FunnelWeb will issue
@<DQ@>@(this macro is unused@) errors for the included
macros you don't use.

@<FWTutMan subheading@>@(Library Macros@)

@<P@>Once you've created one or more macro libraries in the
form of FunnelWeb include files, you might find that sometimes
you want to redefine some of the macros that the include
file provides. For example, suppose that we are preparing
an Australian web page and that when we refer to Yahoo, we
want to refer to the Australian Yahoo site. If we try to
redefine the Yahoo macro:

@<P@>
@<Begin verbatim@>@=#

@i style

...

@$@##<Yahoo@##>@Z@M@{@-
##<A HREF="http://www.yahoo.com.au/"##>Yahoo##</A##>@}
#=@@<End verbatim@>

@<P@>then FunnelWeb will issue an error @<DQ@>@(this macro
is already defined@). FunnelWeb does not allow macros to
be redefined because this could be dangerous in a programming
context. It would be very bad if a programmer thought they
was invoking one piece of text when they were really invoking
another. So FunnelWeb complains.

@<P@>To stop FunnelWeb complaining, you can tag with a library
macro marker @<TT@>@(@@L@) any macro in the include file that
you want to be able to redefine. For example:

@<P@>
@<Begin verbatim@>@=#
@$@##<Dilbert@##>@Z@M@L@{@-
##<A HREF="http://www.dilbert.com/"##>Dilbert##</A##>@}
@$@##<Yahoo@##>@Z@M@L@{@-
##<A HREF="http://www.yahoo.com/"##>Yahoo##</A##>@}
#=@@<End verbatim@>

@<P@>This allows us to redefined the Yahoo and Dilbert macros.

@<FWTutMan subheading@>@(Modifying Default Behaviour@)

@<P@>The library macro mechanism allows you to set up all kinds
of default behaviour that can be modified in specific webs. For
example, suppose that we rewrote the macro library as:

@<P@>
@<Begin verbatim@>@=#
@$@##<Begin page@##>@(@1@)@M@{
##<HTML##>
##<HEAD##>
##<TITLE##>@1##</TITLE##>
##</HEAD##>
@##<Body@##>
@}

@$@##<End page@##>@{
##</BODY##>
##</HTML##>
@}

@$@##<Body@##>@L@{@-
##<BODY BGCOLOR=#@FFFFFF TEXT=#@000033##>@}
#=@@<End verbatim@>

@<P@>Once this is done, we can modify the page background
and colours of any web by redefining the @<TT@>@(Body@)
macro without having to redefine the start and end
of page macros.

@<P@>
@<Begin verbatim@>@=#
@!************************************************

@i style

@$@##<Body@##>@{@-
##<BODY BGCOLOR=#@000000 TEXT=#@FFFFFF##>@}

@!************************************************

@O@##<index.html@##>@{
@##<Begin page@##>@(Dave's Home Page@)

##<P##>Welcome to my home page. Check out my
##<A HREF="@##<Links FILE@##>"##>links page##</A##>.

@##<End page@##>
@}

@!************************************************

@$@##<Links FILE@##>@M@{links.html@}
@O@##<links.html@##>@{
@##<Begin page@##>@(Dave's Links@)

##<P##>Check out @##<Yahoo@##> and @##<Dilbert@##>.

@##<End page@##>
@}

@!************************************************
#=@@<End verbatim@>

@<FWTutMan subheading@>@(Use Of Additive Macros@)

@<P@>Additive macros can be used to insert information into
the middle of macros already defined. For example, suppose
you defined:

@<P@>
@<Begin verbatim@>@=#
@$@##<Begin page@##>@(@1@)@M@{
##<HTML##>
##<HEAD##>
##<TITLE##>@1##</TITLE##>
@##<Header fields@##>
##</HEAD##>
##<BODY BGCOLOR=#@FFFFFF TEXT=#@000033##>
@}

@$@##<Header fields@##>+=@{@}
#=@@<End verbatim@>

@<P@>Once the header fields macro is in place, you can add text such
as style commands or keyword tags to each of the pages of your web
without having to modify the header include file. Just add a definition,
such as the following, to your main FunnelWeb file:

@<P@>
@<Begin verbatim@>@=#
@$@##<Header fields@##>+=@{
##<STYLE TYPE="text/css"##>
##<!-- A {text-decoration: none} // --##>
##</STYLE##>
@}
#=@@<End verbatim@>

@<FWTutMan subheading@>@(Selecting Absolute Or Relative Links@)

@<P@>Sometimes it's important to generate a web that uses
relative hyperlinks, and sometimes it's important to generate
a web that uses absolute hyperlinks. For example, it's important
to use relative links if you want to browse a web offline, or
if you want to ensure that username and password fields in
the URL are not obliterated by the following of an absolute link.
Absolute links are important where a web that is normally
adjacent to another web (and hence usually links to it using
a relative link) is separated and must be browsed offline.

@<P@>A good way to organize all this is to define FunnelWeb
macros for the URLs of webs in include files, but allow them
to be overruled by including files. For example, an
file might contain the following definitions:

@<P@>
@<Begin verbatim@>@=#
@$@##<Rocksoft WWW@##>@Z@M@L@{http://www.rocksoft.com/@}
@$@##<Ross WWW@##>@Z@M@L@{http://www.ross.net/@}
@$@##<Veracity WWW@##>@Z@M@L@{http://www.veracity.com/@}
#=@@<End verbatim@>

@<P@>These symbols are useful for referring to these various
webs from within these webs. However, it is convenient for
each subweb to refer to other subwebs using a relative path
rather than an absolute path, so when generating (say) a
subweb of the Ross webspace, the Ross macro could be redefined to:

@<P@>
@<Begin verbatim@>@=#
@$@##<Ross WWW@##>@Z@M@{../@}
#=@@<End verbatim@>

@<P@>This technique can be used in various forms to manage
the links in the online and offline versions of webs.

@<Nav@>@(@<Web_style FILE@>@,@<Web FILE@>@,@<Web_param FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Web_param HEADING@>@M@{@<SH@>@(7.7@)Parameterizing Entire Webs@}
@$@<Web_param FILE@>@M@{web_param.html@}
@O@<web_param.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Web_param HEADING@>@)

@<P@>The previous section has shown how individual macros within
included files can be redefined to modify the details of a web.
A more radical approach to web parameterization is to swap in
entire include files!

@<FWTutMan subheading@>@(Include Files As Parameter Sets@)

@<P@>Suppose that we have a web that we are providing to three
different web customers, where each web customer wants the web
customized for their business. One way to approach this
situation is to embody all the elements of the web that must
be changed into macros located in an include file. Then define
a different include file for each customer. So the include
file for one customer could be:

@<P@>
@<Begin verbatim@>@=#
@! Include file for MegaCorp
@$@##<Home page title@##>@{Welcome To MegaCorp@}
@$@##<Background colour@##>@{#@FFFFFF@}
@$@##<Emphasis@##>@(@1@)@M@{##<B##>@1##</B##>@}
#=@@<End verbatim@>

@<P@>whereas the include file for a different customer might be:

@<P@>
@<Begin verbatim@>@=#
@! Include file for MicroCorp
@$@##<Home page title@##>@{MicroCorp Home Page@}
@$@##<Background colour@##>@{#@000000@}
@$@##<Emphasis@##>@(@1@)@M@{##<I##>@1##</I##>@}
#=@@<End verbatim@>

@<P@>In this way you can parameterize the style of an entire
web, and generate different versions for different situations.

@<Nav@>@(@<Web_libraries FILE@>@,@<Web FILE@>@,@<Web_conventions FILE@>@)

@<End FWTutMan page@>
@}

@!==============================================================================

@$@<Web_conventions HEADING@>@M@{@<SH@>@(7.8@)Hints And Conventions@}
@$@<Web_conventions FILE@>@M@{web_conventions.html@}
@O@<web_conventions.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Web_conventions HEADING@>@)

@<FWTutMan subheading@>@(Where To Include Include Files@)

@<P@>It's better to include your include files at the end of the
main web file, as if FunnelWeb generates an error, the line number
in the listing file is easier to correlate with the main file if
several files have not been included.

@<FWTutMan subheading@>@(Separating Pages@)

@<P@>It's a good idea to separate the macro for each page in a web
in the FunnelWeb file, by a line of asterisks in a FunnelWeb comment.
This makes the FunnelWeb source file easier to work on in your
text editor.

@<P@>
@<Begin verbatim@>@=#
@!************************************************

@O@##<index.html@##>@{
@##<Begin page@##>@(Dave's Home Page@)

##<P##>Welcome to my home page. Check out my
##<A HREF="@##<Links FILE@##>"##>links page##</A##>.

@##<End page@##>
@}

@!************************************************

@$@##<Links FILE@##>@M@{links.html@}
@O@##<links.html@##>@{
@##<Begin page@##>@(Dave's Links@)

##<P##>Check out @##<Yahoo@##> and @##<Dilbert@##>.

@##<End page@##>
@}

@!************************************************
#=@@<End verbatim@>

@<FWTutMan subheading@>@(Input And Output Line Lengths@)

@<P@>When using FunnelWeb to create webs, you will probably find
that your input and output files have lines longer than the
FunnelWeb standard 80 characters. So you may wish to include the
following directives in your main and include files:

@<P@>
@<Begin verbatim@>@=#
@p maximum_input_line_length = 200
@p maximum_output_line_length = 200
#=@@<End verbatim@>

@<FWTutMan subheading@>@(Macro Naming Conventions@)

@<P@>Since 1994, I (@<Ross Williams@>) have been using FunnelWeb to
generate all the webs in all my webspaces. During this time, I have
developed some macro naming conventions which you may wish to adopt.

@<Narrowthing@>@(FILE:@,Use this suffix for macros that contain
the names of files that form part of the web.@)

@<Narrowthing@>@(WWW:@,Use this suffix for macros that define
web directory URLs, up to and including the trailing slash.
The URL may be absolute or relative, depending on the context.@)

@<Narrowthing@>@(WWW/abs:@,Use this suffix where the URL must
be absolute.@)

@<Narrowthing@>@(EMAIL:@,Use this suffix for email addresses.@)

@<Narrowthing@>@(FTP:@,Use this suffix for FTP directory addresses.@)

@<Narrowthing@>@(WINDOWNAME:@,Use this suffix for the names of
browser windows.@)

@<P@>Here are some examples:

@<P@>
@<Begin verbatim@>@=#
@$@##<Home FILE@##>@Z@M@{index.html@}
@$@##<Ross WWW@##>@Z@M@{http://www.ross.net/@}
@$@##<Ross WWW/abs@##>@Z@M@{http://www.ross.net/@}
@$@##<Ross EMAIL@##>@Z@M@{ross@ross.net@}
@$@##<Ross FTP@##>@Z@M@{@-
ftp://www.ross.net/clients/ross/@}
@$@##<Ross WINDOWNAME@##>@Z@M@{ross@}
#=@@<End verbatim@>

@<Nav/last@>@(@<Web_param FILE@>@,@<Web FILE@>@,@<Web FILE@>@)

@<End FWTutMan page@>
@}

@!******************************************************************************

@$@<Copyright FILE@>@M@{copyright.html@}
@O@<copyright.html@>@{@-
@<Begin FWTutMan page/H1@>@(@<Page title prefix@>Copyright and Credits@)

@<FunnelWeb webs copyright page contents@>

@<End FWTutMan page@>
@}

@!******************************************************************************

@B@<Search Form Section@>

The files in this section are all linked in with the FunnelWeb
include file.

@O@<search.html@>@{@-
@<Begin FWTutMan page/H1@>@(Search FunnelWeb Documentation@)

@<FunnelWeb search form@>@(@,@,checked@,@)

@<End FWTutMan page@>
@}

@!==============================================================================

@O@<search_form.cgi@>@{@-
@<FunnelWeb search CGICODE@>
@}

@!==============================================================================

@O@<search_head.txt@>@{@-
@<Begin FWTutMan page/H1@>@(Search Results@)
@<P@>
@}

@!==============================================================================

@O@<search_tail.txt@>@{@-
@<BR@>
@<P@>@<Back button@>@(Back To The Search Form@)
@<BR@>

@<End FWTutMan page@>
@}

@!==============================================================================

@O@<search_e_nokeywords.txt@>@{@-
@<Begin FWTutMan page/H1@>@(Error: No Keywords Specified@)

@<P@>You must specify one or more keywords to perform a search.

@<P@>@<Back button@>@(Back To The Search Form@)

@<End FWTutMan page@>
@}

@!==============================================================================

@O@<search_e_nomanual.txt@>@{@-
@<Begin FWTutMan page/H1@>@(Error: No Manual Selected@)

@<P@>You must specify one or more manuals (using the checkboxes) to
perform a search.

@<P@>@<Back button@>@(Back To The Search Form@)

@<End FWTutMan page@>
@}

@!******************************************************************************

@O@<0cleanup.vxf@>@{@-
eneo *.html
eneo *.shtml
eneo *.cgi
eneo *.txt
eneo *.lis
eneo *.pl
@}

@!******************************************************************************
@!******************************************************************************

@! Include the FunnelWeb webs master include file.
@! Specify a platform-specific relative (or absolute) path to the include file.
@! Unix    : @i ../0fw_inc.fwi
@! MacOS   : @i ::0fw_inc.fwi
@! OpenVMS : @i [-]0fw_inc.fwi

@i ../0fw_inc.fwi
@i ../0www_style.fwi
@i ../0www_links.fwi
@i ../0www_ross.fwi

@!******************************************************************************
@!******************************************************************************