aboutsummaryrefslogtreecommitdiffstats
path: root/slib_4.html
blob: 4aa89a0c09a52f60bfa571ee6528b48627db8aec (plain)
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                      "http://www.w3.org/TR/html40/loose.dtd">
<HTML>
<!-- Created on January, 10 2005 by texi2html 1.66 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>

-->
<HEAD>
<TITLE>SLIB: Textual Conversion Packages</TITLE>

<META NAME="description" CONTENT="SLIB: Textual Conversion Packages">
<META NAME="keywords" CONTENT="SLIB: Textual Conversion Packages">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="texi2html 1.66">

</HEAD>

<BODY LANG="en" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">

<A NAME="SEC45"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_3.html#SEC44"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC46"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_3.html#SEC21"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H1> 4. Textual Conversion Packages </H1>
<!--docid::SEC45::-->
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC46">4.1 Precedence Parsing</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC53">4.2 Format (version 3.0)</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Common-Lisp Format</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC54">4.3 Standard Formatted I/O</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Posix printf and scanf</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC61">4.4 Program and Arguments</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC69">4.5 HTML</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Generating</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC71">4.7 HTML Tables</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Databases meet HTML</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC74">4.8 HTTP and CGI</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Serve WWW sites</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC75">4.9 Parsing HTML</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'html-for-each</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC76">4.10 URI</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Uniform Resource Identifier</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC78">4.11 Printing Scheme</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Nicely</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC82">4.12 Time and Date</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC86">4.13 NCBI-DNA</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">DNA and protein sequences</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC87">4.14 Schmooz</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Documentation markup for Scheme programs</TD></TR>
</TABLE>
<P>

<A NAME="Precedence Parsing"></A>
<HR SIZE="6">
<A NAME="SEC46"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC47"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 4.1 Precedence Parsing </H2>
<!--docid::SEC46::-->
<P>

<CODE>(require 'precedence-parse)</CODE> or <CODE>(require 'parse)</CODE>
<A NAME="IDX170"></A>
<A NAME="IDX171"></A>
</P>
<P>

This package implements:
</P>
<P>

<UL>
<LI>
a Pratt style precedence parser;
<LI>
a <EM>tokenizer</EM> which congeals tokens according to assigned classes of
constituent characters;
<LI>
procedures giving direct control of parser rulesets;
<LI>
procedures for higher level specification of rulesets.
</UL>
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC47">4.1.1 Precedence Parsing Overview</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC48">4.1.2 Rule Types</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC49">4.1.3 Ruleset Definition and Use</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC50">4.1.4 Token definition</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC51">4.1.5 Nud and Led Definition</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC52">4.1.6 Grammar Rule Definition</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
</TABLE>
<P>

<A NAME="Precedence Parsing Overview"></A>
<HR SIZE="6">
<A NAME="SEC47"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC46"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC48"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC46"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.1.1 Precedence Parsing Overview </H3>
<!--docid::SEC47::-->
<P>

This package offers improvements over previous parsers.
</P>
<P>

<UL>
<LI>
Common computer language constructs are concisely specified.
<LI>
Grammars can be changed dynamically.  Operators can be assigned
different meanings within a lexical context.
<LI>
Rulesets don't need compilation.  Grammars can be changed incrementally.
<LI>
Operator precedence is specified by integers.
<LI>
All possibilities of bad input are handled <A NAME="DOCF3" HREF="slib_fot.html#FOOT3">(3)</A> and return as much structure as was
parsed when the error occured; The symbol <CODE>?</CODE> is substituted for
missing input.
</UL>
<P>

<A NAME="IDX172"></A>
The notion of <EM>binding power</EM> may be unfamiliar to those
accustomed to BNF grammars.
</P>
<P>

When two consecutive objects are parsed, the first might be the prefix
to the second, or the second might be a suffix of the first.
Comparing the left and right binding powers of the two objects decides
which way to interpret them.
</P>
<P>

Objects at each level of syntactic grouping have binding powers.
</P>
<P>

<A NAME="IDX173"></A>
A syntax tree is not built unless the rules explicitly do so.  The
call graph of grammar rules effectively instantiate the sytnax tree.
</P>
<P>

The JACAL symbolic math system
(<A HREF="http://swissnet.ai.mit.edu/~jaffer/JACAL.html">http://swissnet.ai.mit.edu/~jaffer/JACAL.html</A>) uses
<TT>precedence-parse</TT>.  Its grammar definitions in the file
`<TT>jacal/English.scm</TT>' can serve as examples of use.
</P>
<P>

<A NAME="Rule Types"></A>
<HR SIZE="6">
<A NAME="SEC48"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC47"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC49"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC46"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.1.2 Rule Types </H3>
<!--docid::SEC48::-->
<P>

Here are the higher-level syntax types and an example of each.
Precedence considerations are omitted for clarity.  See <A HREF="slib_4.html#SEC52">4.1.6 Grammar Rule Definition</A> for full details.
<A NAME="IDX174"></A>
</P>
<DL>
<DT><U>Grammar:</U> <B>nofix</B> <I>bye exit</I>
<DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>bye
</pre></td></tr></table>calls the function <CODE>exit</CODE> with no arguments.
</DL>
<A NAME="IDX175"></A>
<DL>
<DT><U>Grammar:</U> <B>prefix</B> <I>- negate</I>
<DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>- 42
</pre></td></tr></table>Calls the function <CODE>negate</CODE> with the argument <CODE>42</CODE>.
</DL>
<A NAME="IDX176"></A>
<DL>
<DT><U>Grammar:</U> <B>infix</B> <I>- difference</I>
<DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>x - y
</pre></td></tr></table>Calls the function <CODE>difference</CODE> with arguments <CODE>x</CODE> and <CODE>y</CODE>.
</DL>
<A NAME="IDX177"></A>
<DL>
<DT><U>Grammar:</U> <B>nary</B> <I>+ sum</I>
<DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>x + y + z
</pre></td></tr></table>Calls the function <CODE>sum</CODE> with arguments <CODE>x</CODE>, <CODE>y</CODE>, and
<CODE>y</CODE>.
</DL>
<A NAME="IDX178"></A>
<DL>
<DT><U>Grammar:</U> <B>postfix</B> <I>! factorial</I>
<DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>5 !
</pre></td></tr></table>Calls the function <CODE>factorial</CODE> with the argument <CODE>5</CODE>.
</DL>
<A NAME="IDX179"></A>
<DL>
<DT><U>Grammar:</U> <B>prestfix</B> <I>set set!</I>
<DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>set foo bar
</pre></td></tr></table>Calls the function <CODE>set!</CODE> with the arguments <CODE>foo</CODE> and
<CODE>bar</CODE>.
</DL>
<A NAME="IDX180"></A>
<DL>
<DT><U>Grammar:</U> <B>commentfix</B> <I>/* */</I>
<DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>/* almost any text here */
</pre></td></tr></table>Ignores the comment delimited by <CODE>/*</CODE> and <CODE>*/</CODE>.
</DL>
<A NAME="IDX181"></A>
<DL>
<DT><U>Grammar:</U> <B>matchfix</B> <I>{ list }</I>
<DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>{0, 1, 2}
</pre></td></tr></table>Calls the function <CODE>list</CODE> with the arguments <CODE>0</CODE>, <CODE>1</CODE>,
and <CODE>2</CODE>.
</DL>
<A NAME="IDX182"></A>
<DL>
<DT><U>Grammar:</U> <B>inmatchfix</B> <I>( funcall )</I>
<DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>f(x, y)
</pre></td></tr></table>Calls the function <CODE>funcall</CODE> with the arguments <CODE>f</CODE>, <CODE>x</CODE>,
and <CODE>y</CODE>.
</DL>
<A NAME="IDX183"></A>
<DL>
<DT><U>Grammar:</U> <B>delim</B> <I>;</I>
<DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>set foo bar;
</pre></td></tr></table>delimits the extent of the restfix operator <CODE>set</CODE>.
</DL>
<P>

<A NAME="Ruleset Definition and Use"></A>
<HR SIZE="6">
<A NAME="SEC49"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC48"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC50"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC46"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.1.3 Ruleset Definition and Use </H3>
<!--docid::SEC49::-->
<P>

<A NAME="IDX184"></A>
</P>
<DL>
<DT><U>Variable:</U> <B>*syn-defs*</B>
<DD>A grammar is built by one or more calls to <CODE>prec:define-grammar</CODE>.
The rules are appended to <VAR>*syn-defs*</VAR>.  The value of
<VAR>*syn-defs*</VAR> is the grammar suitable for passing as an argument to
<CODE>prec:parse</CODE>.
</DL>
<P>

<A NAME="IDX185"></A>
</P>
<DL>
<DT><U>Constant:</U> <B>*syn-ignore-whitespace*</B>
<DD>Is a nearly empty grammar with whitespace characters set to group 0,
which means they will not be made into tokens.  Most rulesets will want
to start with <CODE>*syn-ignore-whitespace*</CODE>
</DL>
<P>

In order to start defining a grammar, either
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(set! *syn-defs* '())
</pre></td></tr></table>or
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(set! *syn-defs* *syn-ignore-whitespace*)
</pre></td></tr></table><P>

<A NAME="IDX186"></A>
</P>
<DL>
<DT><U>Function:</U> <B>prec:define-grammar</B> <I>rule1 <small>...</small></I>
<DD>Appends <VAR>rule1</VAR> <small>...</small> to <VAR>*syn-defs*</VAR>.
<CODE>prec:define-grammar</CODE> is used to define both the character classes
and rules for tokens.
</DL>
<P>

Once your grammar is defined, save the value of <CODE>*syn-defs*</CODE> in a
variable (for use when calling <CODE>prec:parse</CODE>).
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define my-ruleset *syn-defs*)
</pre></td></tr></table><P>

<A NAME="IDX187"></A>
</P>
<DL>
<DT><U>Function:</U> <B>prec:parse</B> <I>ruleset delim</I>
<DD><A NAME="IDX188"></A>
<DT><U>Function:</U> <B>prec:parse</B> <I>ruleset delim port</I>
<DD>The <VAR>ruleset</VAR> argument must be a list of rules as constructed by
<CODE>prec:define-grammar</CODE> and extracted from <VAR>*syn-defs*</VAR>.
<P>

The token <VAR>delim</VAR> may be a character, symbol, or string.  A
character <VAR>delim</VAR> argument will match only a character token; i.e. a
character for which no token-group is assigned.  A symbols or string
will match only a token string; i.e. a token resulting from a token
group.
</P>
<P>

<CODE>prec:parse</CODE> reads a <VAR>ruleset</VAR> grammar expression delimited
by <VAR>delim</VAR> from the given input <VAR>port</VAR>.  <CODE>prec:parse</CODE>
returns the next object parsable from the given input <VAR>port</VAR>,
updating <VAR>port</VAR> to point to the first character past the end of the
external representation of the object.
</P>
<P>

If an end of file is encountered in the input before any characters are
found that can begin an object, then an end of file object is returned.
If a delimiter (such as <VAR>delim</VAR>) is found before any characters are
found that can begin an object, then <CODE>#f</CODE> is returned.
</P>
<P>

The <VAR>port</VAR> argument may be omitted, in which case it defaults to the
value returned by <CODE>current-input-port</CODE>.  It is an error to parse
from a closed port.
<A NAME="IDX189"></A>
</P>
</DL>
<P>

<A NAME="Token definition"></A>
<HR SIZE="6">
<A NAME="SEC50"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC49"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC51"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC46"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.1.4 Token definition </H3>
<!--docid::SEC50::-->
<P>

<A NAME="IDX190"></A>
</P>
<DL>
<DT><U>Function:</U> <B>tok:char-group</B> <I>group chars chars-proc</I>
<DD>The argument <VAR>chars</VAR> may be a single character, a list of
characters, or a string.  Each character in <VAR>chars</VAR> is treated as
though <CODE>tok:char-group</CODE> was called with that character alone.
<P>

The argument <VAR>chars-proc</VAR> must be a procedure of one argument, a
list of characters.  After <CODE>tokenize</CODE> has finished
accumulating the characters for a token, it calls <VAR>chars-proc</VAR> with
the list of characters.  The value returned is the token which
<CODE>tokenize</CODE> returns.
</P>
<P>

The argument <VAR>group</VAR> may be an exact integer or a procedure of one
character argument.  The following discussion concerns the treatment
which the tokenizing routine, <CODE>tokenize</CODE>, will accord to characters
on the basis of their groups.
</P>
<P>

When <VAR>group</VAR> is a non-zero integer, characters whose group number is
equal to or exactly one less than <VAR>group</VAR> will continue to
accumulate.  Any other character causes the accumulation to stop (until
a new token is to be read).
</P>
<P>

The <VAR>group</VAR> of zero is special.  These characters are ignored when
parsed pending a token, and stop the accumulation of token characters
when the accumulation has already begun.  Whitespace characters are
usually put in group 0.
</P>
<P>

If <VAR>group</VAR> is a procedure, then, when triggerd by the occurence of
an initial (no accumulation) <VAR>chars</VAR> character, this procedure will
be repeatedly called with each successive character from the input
stream until the <VAR>group</VAR> procedure returns a non-false value.
</P>
</DL>
<P>

The following convenient constants are provided for use with
<CODE>tok:char-group</CODE>.
</P>
<P>

<A NAME="IDX191"></A>
</P>
<DL>
<DT><U>Constant:</U> <B>tok:decimal-digits</B>
<DD>Is the string <CODE>&quot;0123456789&quot;</CODE>.
</DL>
<A NAME="IDX192"></A>
<DL>
<DT><U>Constant:</U> <B>tok:upper-case</B>
<DD>Is the string consisting of all upper-case letters
(&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;).
</DL>
<A NAME="IDX193"></A>
<DL>
<DT><U>Constant:</U> <B>tok:lower-case</B>
<DD>Is the string consisting of all lower-case letters
(&quot;abcdefghijklmnopqrstuvwxyz&quot;).
</DL>
<A NAME="IDX194"></A>
<DL>
<DT><U>Constant:</U> <B>tok:whitespaces</B>
<DD>Is the string consisting of all characters between 0 and 255 for which
<CODE>char-whitespace?</CODE> returns true.
</DL>
<P>

For the purpose of reporting problems in error messages, this package
keeps track of the <EM>current column</EM>.  When the column does not
simply track input characters, <CODE>tok:bump-column</CODE> can be used to
adjust the current-column.
</P>
<P>

<A NAME="IDX195"></A>
</P>
<DL>
<DT><U>Function:</U> <B>tok:bump-column</B> <I>pos port</I>
<DD>Adds <VAR>pos</VAR> to the current-column for input-port <VAR>port</VAR>.
</DL>
<P>

<A NAME="Nud and Led Definition"></A>
<HR SIZE="6">
<A NAME="SEC51"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC50"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC52"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC46"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.1.5 Nud and Led Definition </H3>
<!--docid::SEC51::-->
<P>

This section describes advanced features.  You can skip this section on
first reading.
</P>
<P>

The <EM>Null Denotation</EM> (or <EM>nud</EM>)
<A NAME="IDX196"></A>
of a token is the procedure and arguments applying for that token when
<EM>Left</EM>, an unclaimed parsed expression is not extant.
</P>
<P>

The <EM>Left Denotation</EM> (or <EM>led</EM>)
<A NAME="IDX197"></A>
of a token is the procedure, arguments, and lbp applying for that token
when there is a <EM>Left</EM>, an unclaimed parsed expression.
</P>
<P>

In his paper,
</P>
<P>

<BLOCKQUOTE>
Pratt, V. R.
Top Down Operator Precendence.
<CITE>SIGACT/SIGPLAN Symposium on Principles of Programming Languages</CITE>,
Boston, 1973, pages 41-51
</BLOCKQUOTE>
<P>

the <EM>left binding power</EM> (or <EM>lbp</EM>) was an independent property
of tokens.  I think this was done in order to allow tokens with NUDs but
not LEDs to also be used as delimiters, which was a problem for
statically defined syntaxes.  It turns out that <EM>dynamically
binding</EM> NUDs and LEDs allows them independence.
</P>
<P>

For the rule-defining procedures that follow, the variable <VAR>tk</VAR> may
be a character, string, or symbol, or a list composed of characters,
strings, and symbols.  Each element of <VAR>tk</VAR> is treated as though the
procedure were called for each element.
</P>
<P>

Character <VAR>tk</VAR> arguments will match only character tokens;
i.e. characters for which no token-group is assigned.  Symbols and
strings will both match token strings; i.e. tokens resulting from token
groups.
</P>
<P>

<A NAME="IDX198"></A>
</P>
<DL>
<DT><U>Function:</U> <B>prec:make-nud</B> <I>tk sop arg1 <small>...</small></I>
<DD>Returns a rule specifying that <VAR>sop</VAR> be called when <VAR>tk</VAR> is
parsed.  If <VAR>sop</VAR> is a procedure, it is called with <VAR>tk</VAR> and
<VAR>arg1</VAR> <small>...</small> as its arguments; the resulting value is incorporated
into the expression being built.  Otherwise, <CODE>(list <VAR>sop</VAR>
<VAR>arg1</VAR> <small>...</small>)</CODE> is incorporated.
</DL>
<P>

If no NUD has been defined for a token; then if that token is a string,
it is converted to a symbol and returned; if not a string, the token is
returned.
</P>
<P>

<A NAME="IDX199"></A>
</P>
<DL>
<DT><U>Function:</U> <B>prec:make-led</B> <I>tk sop arg1 <small>...</small></I>
<DD>Returns a rule specifying that <VAR>sop</VAR> be called when <VAR>tk</VAR> is
parsed and <VAR>left</VAR> has an unclaimed parsed expression.  If <VAR>sop</VAR>
is a procedure, it is called with <VAR>left</VAR>, <VAR>tk</VAR>, and <VAR>arg1</VAR>
<small>...</small> as its arguments; the resulting value is incorporated into the
expression being built.  Otherwise, <VAR>left</VAR> is incorporated.
</DL>
<P>

If no LED has been defined for a token, and <VAR>left</VAR> is set, the
parser issues a warning.
</P>
<P>

<A NAME="Grammar Rule Definition"></A>
<HR SIZE="6">
<A NAME="SEC52"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC51"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC53"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC46"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.1.6 Grammar Rule Definition </H3>
<!--docid::SEC52::-->
<P>

Here are procedures for defining rules for the syntax types introduced
in <A HREF="slib_4.html#SEC47">4.1.1 Precedence Parsing Overview</A>.
</P>
<P>

For the rule-defining procedures that follow, the variable <VAR>tk</VAR> may
be a character, string, or symbol, or a list composed of characters,
strings, and symbols.  Each element of <VAR>tk</VAR> is treated as though the
procedure were called for each element.
</P>
<P>

For procedures prec:delim, <small>...</small>, prec:prestfix, if the <VAR>sop</VAR>
argument is <CODE>#f</CODE>, then the token which triggered this rule is
converted to a symbol and returned.  A false <VAR>sop</VAR> argument to the
procedures prec:commentfix, prec:matchfix, or prec:inmatchfix has a
different meaning.
</P>
<P>

Character <VAR>tk</VAR> arguments will match only character tokens;
i.e. characters for which no token-group is assigned.  Symbols and
strings will both match token strings; i.e. tokens resulting from token
groups.
</P>
<P>

<A NAME="IDX200"></A>
</P>
<DL>
<DT><U>Function:</U> <B>prec:delim</B> <I>tk</I>
<DD>Returns a rule specifying that <VAR>tk</VAR> should not be returned from
parsing; i.e. <VAR>tk</VAR>'s function is purely syntactic.  The end-of-file
is always treated as a delimiter.
</DL>
<P>

<A NAME="IDX201"></A>
</P>
<DL>
<DT><U>Function:</U> <B>prec:nofix</B> <I>tk sop</I>
<DD>Returns a rule specifying the following actions take place when <VAR>tk</VAR>
is parsed:
<UL>
<LI>
If <VAR>sop</VAR> is a procedure, it is called with no arguments; the
resulting value is incorporated into the expression being built.
Otherwise, the list of <VAR>sop</VAR> is incorporated.
</UL>
</DL>
<P>

<A NAME="IDX202"></A>
</P>
<DL>
<DT><U>Function:</U> <B>prec:prefix</B> <I>tk sop bp rule1 <small>...</small></I>
<DD>Returns a rule specifying the following actions take place when <VAR>tk</VAR>
is parsed:
<UL>
<LI>
The rules <VAR>rule1</VAR> <small>...</small> augment and, in case of conflict, override
rules currently in effect.
<LI>
<CODE>prec:parse1</CODE> is called with binding-power <VAR>bp</VAR>.
<LI>
If <VAR>sop</VAR> is a procedure, it is called with the expression returned
from <CODE>prec:parse1</CODE>; the resulting value is incorporated into the
expression being built.  Otherwise, the list of <VAR>sop</VAR> and the
expression returned from <CODE>prec:parse1</CODE> is incorporated.
<LI>
The ruleset in effect before <VAR>tk</VAR> was parsed is restored;
<VAR>rule1</VAR> <small>...</small> are forgotten.
</UL>
</DL>
<P>

<A NAME="IDX203"></A>
</P>
<DL>
<DT><U>Function:</U> <B>prec:infix</B> <I>tk sop lbp bp rule1 <small>...</small></I>
<DD>Returns a rule declaring the left-binding-precedence of the token
<VAR>tk</VAR> is <VAR>lbp</VAR> and specifying the following actions take place
when <VAR>tk</VAR> is parsed:
<UL>
<LI>
The rules <VAR>rule1</VAR> <small>...</small> augment and, in case of conflict, override
rules currently in effect.
<LI>
One expression is parsed with binding-power <VAR>lbp</VAR>.  If instead a
delimiter is encountered, a warning is issued.
<LI>
If <VAR>sop</VAR> is a procedure, it is applied to the list of <VAR>left</VAR> and
the parsed expression; the resulting value is incorporated into the
expression being built.  Otherwise, the list of <VAR>sop</VAR>, the
<VAR>left</VAR> expression, and the parsed expression is incorporated.
<LI>
The ruleset in effect before <VAR>tk</VAR> was parsed is restored;
<VAR>rule1</VAR> <small>...</small> are forgotten.
</UL>
</DL>
<P>

<A NAME="IDX204"></A>
</P>
<DL>
<DT><U>Function:</U> <B>prec:nary</B> <I>tk sop bp</I>
<DD>Returns a rule declaring the left-binding-precedence of the token
<VAR>tk</VAR> is <VAR>bp</VAR> and specifying the following actions take place
when <VAR>tk</VAR> is parsed:
<UL>
<LI>
Expressions are parsed with binding-power <VAR>bp</VAR> as far as they are
interleaved with the token <VAR>tk</VAR>.
<LI>
If <VAR>sop</VAR> is a procedure, it is applied to the list of <VAR>left</VAR> and
the parsed expressions; the resulting value is incorporated into the
expression being built.  Otherwise, the list of <VAR>sop</VAR>, the
<VAR>left</VAR> expression, and the parsed expressions is incorporated.
</UL>
</DL>
<P>

<A NAME="IDX205"></A>
</P>
<DL>
<DT><U>Function:</U> <B>prec:postfix</B> <I>tk sop lbp</I>
<DD>Returns a rule declaring the left-binding-precedence of the token
<VAR>tk</VAR> is <VAR>lbp</VAR> and specifying the following actions take place
when <VAR>tk</VAR> is parsed:
<UL>
<LI>
If <VAR>sop</VAR> is a procedure, it is called with the <VAR>left</VAR> expression;
the resulting value is incorporated into the expression being built.
Otherwise, the list of <VAR>sop</VAR> and the <VAR>left</VAR> expression is
incorporated.
</UL>
</DL>
<P>

<A NAME="IDX206"></A>
</P>
<DL>
<DT><U>Function:</U> <B>prec:prestfix</B> <I>tk sop bp rule1 <small>...</small></I>
<DD>Returns a rule specifying the following actions take place when <VAR>tk</VAR>
is parsed:
<UL>
<LI>
The rules <VAR>rule1</VAR> <small>...</small> augment and, in case of conflict, override
rules currently in effect.
<LI>
Expressions are parsed with binding-power <VAR>bp</VAR> until a delimiter is
reached.
<LI>
If <VAR>sop</VAR> is a procedure, it is applied to the list of parsed
expressions; the resulting value is incorporated into the expression
being built.  Otherwise, the list of <VAR>sop</VAR> and the parsed
expressions is incorporated.
<LI>
The ruleset in effect before <VAR>tk</VAR> was parsed is restored;
<VAR>rule1</VAR> <small>...</small> are forgotten.
</UL>
</DL>
<P>

<A NAME="IDX207"></A>
</P>
<DL>
<DT><U>Function:</U> <B>prec:commentfix</B> <I>tk stp match rule1 <small>...</small></I>
<DD>Returns rules specifying the following actions take place when <VAR>tk</VAR>
is parsed:
<UL>
<LI>
The rules <VAR>rule1</VAR> <small>...</small> augment and, in case of conflict, override
rules currently in effect.
<LI>
Characters are read until and end-of-file or a sequence of characters
is read which matches the <EM>string</EM> <VAR>match</VAR>.
<LI>
If <VAR>stp</VAR> is a procedure, it is called with the string of all that
was read between the <VAR>tk</VAR> and <VAR>match</VAR> (exclusive).
<LI>
The ruleset in effect before <VAR>tk</VAR> was parsed is restored;
<VAR>rule1</VAR> <small>...</small> are forgotten.
</UL>
<P>

Parsing of commentfix syntax differs from the others in several ways.
It reads directly from input without tokenizing; It calls <VAR>stp</VAR> but
does not return its value; nay any value.  I added the <VAR>stp</VAR>
argument so that comment text could be echoed.
</P>
</DL>
<P>

<A NAME="IDX208"></A>
</P>
<DL>
<DT><U>Function:</U> <B>prec:matchfix</B> <I>tk sop sep match rule1 <small>...</small></I>
<DD>Returns a rule specifying the following actions take place when <VAR>tk</VAR>
is parsed:
<UL>
<LI>
The rules <VAR>rule1</VAR> <small>...</small> augment and, in case of conflict, override
rules currently in effect.
<LI>
A rule declaring the token <VAR>match</VAR> a delimiter takes effect.
<LI>
Expressions are parsed with binding-power <CODE>0</CODE> until the token
<VAR>match</VAR> is reached.  If the token <VAR>sep</VAR> does not appear between
each pair of expressions parsed, a warning is issued.
<LI>
If <VAR>sop</VAR> is a procedure, it is applied to the list of parsed
expressions; the resulting value is incorporated into the expression
being built.  Otherwise, the list of <VAR>sop</VAR> and the parsed
expressions is incorporated.
<LI>
The ruleset in effect before <VAR>tk</VAR> was parsed is restored;
<VAR>rule1</VAR> <small>...</small> are forgotten.
</UL>
</DL>
<P>

<A NAME="IDX209"></A>
</P>
<DL>
<DT><U>Function:</U> <B>prec:inmatchfix</B> <I>tk sop sep match lbp rule1 <small>...</small></I>
<DD>Returns a rule declaring the left-binding-precedence of the token
<VAR>tk</VAR> is <VAR>lbp</VAR> and specifying the following actions take place
when <VAR>tk</VAR> is parsed:
<UL>
<LI>
The rules <VAR>rule1</VAR> <small>...</small> augment and, in case of conflict, override
rules currently in effect.
<LI>
A rule declaring the token <VAR>match</VAR> a delimiter takes effect.
<LI>
Expressions are parsed with binding-power <CODE>0</CODE> until the token
<VAR>match</VAR> is reached.  If the token <VAR>sep</VAR> does not appear between
each pair of expressions parsed, a warning is issued.
<LI>
If <VAR>sop</VAR> is a procedure, it is applied to the list of <VAR>left</VAR> and
the parsed expressions; the resulting value is incorporated into the
expression being built.  Otherwise, the list of <VAR>sop</VAR>, the
<VAR>left</VAR> expression, and the parsed expressions is incorporated.
<LI>
The ruleset in effect before <VAR>tk</VAR> was parsed is restored;
<VAR>rule1</VAR> <small>...</small> are forgotten.
</UL>
</DL>
<P>

<A NAME="Format"></A>
<HR SIZE="6">
<A NAME="SEC53"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC52"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC54"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 4.2 Format (version 3.0) </H2>
<!--docid::SEC53::-->
<P>

&lt;A NAME=&quot;format&quot;&gt;&lt;/A&gt;
<A NAME="IDX210"></A>
</P>
<P>

The `<TT>format.scm</TT>' package was removed because it was not
reentrant.  <A HREF="http://swissnet.ai.mit.edu/~jaffer/SLIB.FAQ">http://swissnet.ai.mit.edu/~jaffer/SLIB.FAQ</A> explains
more about FORMAT's woes.
</P>
<P>

<A NAME="Standard Formatted I/O"></A>
<HR SIZE="6">
<A NAME="SEC54"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC53"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC55"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 4.3 Standard Formatted I/O </H2>
<!--docid::SEC54::-->
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC56">4.3.2 Standard Formatted Output</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'printf</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC60">4.3.3 Standard Formatted Input</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'scanf</TD></TR>
</TABLE>
<P>

<HR SIZE="6">
<A NAME="SEC55"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC54"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC56"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.3.1 stdio </H3>
<!--docid::SEC55::-->
<P>

<CODE>(require 'stdio)</CODE>
<A NAME="IDX211"></A>
</P>
<P>

<CODE>require</CODE>s <CODE>printf</CODE> and <CODE>scanf</CODE> and additionally defines
the symbols:
</P>
<P>

<A NAME="IDX212"></A>
</P>
<DL>
<DT><U>Variable:</U> <B>stdin</B>
<DD>Defined to be <CODE>(current-input-port)</CODE>.
</DL>
<A NAME="IDX213"></A>
<DL>
<DT><U>Variable:</U> <B>stdout</B>
<DD>Defined to be <CODE>(current-output-port)</CODE>.
</DL>
<A NAME="IDX214"></A>
<DL>
<DT><U>Variable:</U> <B>stderr</B>
<DD>Defined to be <CODE>(current-error-port)</CODE>.
</DL>
<P>

<A NAME="Standard Formatted Output"></A>
<HR SIZE="6">
<A NAME="SEC56"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC55"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC57"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC54"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.3.2 Standard Formatted Output </H3>
<!--docid::SEC56::-->
<P>

&lt;A NAME=&quot;printf&quot;&gt;&lt;/A&gt;
<CODE>(require 'printf)</CODE>
<A NAME="IDX215"></A>
</P>
<P>

<A NAME="IDX216"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>printf</B> <I>format arg1 <small>...</small></I>
<DD><A NAME="IDX217"></A>
<DT><U>Procedure:</U> <B>fprintf</B> <I>port format arg1 <small>...</small></I>
<DD><A NAME="IDX218"></A>
<DT><U>Procedure:</U> <B>sprintf</B> <I>str format arg1 <small>...</small></I>
<DD><A NAME="IDX219"></A>
<DT><U>Procedure:</U> <B>sprintf</B> <I>#f format arg1 <small>...</small></I>
<DD><A NAME="IDX220"></A>
<DT><U>Procedure:</U> <B>sprintf</B> <I>k format arg1 <small>...</small></I>
<DD><P>

Each function converts, formats, and outputs its <VAR>arg1</VAR> <small>...</small>
arguments according to the control string <VAR>format</VAR> argument and
returns the number of characters output.
</P>
<P>

<CODE>printf</CODE> sends its output to the port <CODE>(current-output-port)</CODE>.
<CODE>fprintf</CODE> sends its output to the port <VAR>port</VAR>.  <CODE>sprintf</CODE>
<CODE>string-set!</CODE>s locations of the non-constant string argument
<VAR>str</VAR> to the output characters.
</P>
<P>

Two extensions of <CODE>sprintf</CODE> return new strings.  If the first
argument is <CODE>#f</CODE>, then the returned string's length is as many
characters as specified by the <VAR>format</VAR> and data; if the first
argument is a non-negative integer <VAR>k</VAR>, then the length of the
returned string is also bounded by <VAR>k</VAR>.
</P>
<P>

The string <VAR>format</VAR> contains plain characters which are copied to
the output stream, and conversion specifications, each of which results
in fetching zero or more of the arguments <VAR>arg1</VAR> <small>...</small>.  The
results are undefined if there are an insufficient number of arguments
for the format.  If <VAR>format</VAR> is exhausted while some of the
<VAR>arg1</VAR> <small>...</small> arguments remain unused, the excess <VAR>arg1</VAR>
<small>...</small> arguments are ignored.
</P>
<P>

The conversion specifications in a format string have the form:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>% [ <VAR>flags</VAR> ] [ <VAR>width</VAR> ] [ . <VAR>precision</VAR> ] [ <VAR>type</VAR> ] <VAR>conversion</VAR>
</pre></td></tr></table><P>

An output conversion specifications consist of an initial `<SAMP>%</SAMP>'
character followed in sequence by:
</P>
<P>

<UL>
<LI>
Zero or more <EM>flag characters</EM> that modify the normal behavior of
the conversion specification.
<P>

</P>
<DL COMPACT>
<DT>`<SAMP>-</SAMP>'
<DD>Left-justify the result in the field.  Normally the result is
right-justified.
<P>

</P>
<DT>`<SAMP>+</SAMP>'
<DD>For the signed `<SAMP>%d</SAMP>' and `<SAMP>%i</SAMP>' conversions and all inexact
conversions, prefix a plus sign if the value is positive.
<P>

</P>
<DT>`<SAMP> </SAMP>'
<DD>For the signed `<SAMP>%d</SAMP>' and `<SAMP>%i</SAMP>' conversions, if the result
doesn't start with a plus or minus sign, prefix it with a space
character instead.  Since the `<SAMP>+</SAMP>' flag ensures that the result
includes a sign, this flag is ignored if both are specified.
<P>

</P>
<DT>`<SAMP>#</SAMP>'
<DD>For inexact conversions, `<SAMP>#</SAMP>' specifies that the result should
always include a decimal point, even if no digits follow it.  For the
`<SAMP>%g</SAMP>' and `<SAMP>%G</SAMP>' conversions, this also forces trailing zeros
after the decimal point to be printed where they would otherwise be
elided.
<P>

For the `<SAMP>%o</SAMP>' conversion, force the leading digit to be `<SAMP>0</SAMP>', as
if by increasing the precision.  For `<SAMP>%x</SAMP>' or `<SAMP>%X</SAMP>', prefix a
leading `<SAMP>0x</SAMP>' or `<SAMP>0X</SAMP>' (respectively) to the result.  This
doesn't do anything useful for the `<SAMP>%d</SAMP>', `<SAMP>%i</SAMP>', or `<SAMP>%u</SAMP>'
conversions.  Using this flag produces output which can be parsed by the
<CODE>scanf</CODE> functions with the `<SAMP>%i</SAMP>' conversion (see section <A HREF="slib_4.html#SEC60">4.3.3 Standard Formatted Input</A>).
</P>
<P>

</P>
<DT>`<SAMP>0</SAMP>'
<DD>Pad the field with zeros instead of spaces.  The zeros are placed after
any indication of sign or base.  This flag is ignored if the `<SAMP>-</SAMP>'
flag is also specified, or if a precision is specified for an exact
converson.
</DL>
<P>

</P>
<LI>
An optional decimal integer specifying the <EM>minimum field width</EM>.
If the normal conversion produces fewer characters than this, the field
is padded (with spaces or zeros per the `<SAMP>0</SAMP>' flag) to the specified
width.  This is a <EM>minimum</EM> width; if the normal conversion
produces more characters than this, the field is <EM>not</EM> truncated.
<A NAME="IDX221"></A>
<P>

Alternatively, if the field width is `<SAMP>*</SAMP>', the next argument in the
argument list (before the actual value to be printed) is used as the
field width.  The width value must be an integer.  If the value is
negative it is as though the `<SAMP>-</SAMP>' flag is set (see above) and the
absolute value is used as the field width.
</P>
<P>

</P>
<LI>
An optional <EM>precision</EM> to specify the number of digits to be
written for numeric conversions and the maximum field width for string
conversions.  The precision is specified by a period (`<SAMP>.</SAMP>') followed
optionally by a decimal integer (which defaults to zero if omitted).
<A NAME="IDX222"></A>
<P>

Alternatively, if the precision is `<SAMP>.*</SAMP>', the next argument in the
argument list (before the actual value to be printed) is used as the
precision.  The value must be an integer, and is ignored if negative.
If you specify `<SAMP>*</SAMP>' for both the field width and precision, the
field width argument precedes the precision argument.  The `<SAMP>.*</SAMP>'
precision is an enhancement.  C library versions may not accept this
syntax.
</P>
<P>

For the `<SAMP>%f</SAMP>', `<SAMP>%e</SAMP>', and `<SAMP>%E</SAMP>' conversions, the precision
specifies how many digits follow the decimal-point character.  The
default precision is <CODE>6</CODE>.  If the precision is explicitly <CODE>0</CODE>,
the decimal point character is suppressed.
</P>
<P>

For the `<SAMP>%g</SAMP>' and `<SAMP>%G</SAMP>' conversions, the precision specifies how
many significant digits to print.  Significant digits are the first
digit before the decimal point, and all the digits after it.  If the
precision is <CODE>0</CODE> or not specified for `<SAMP>%g</SAMP>' or `<SAMP>%G</SAMP>', it is
treated like a value of <CODE>1</CODE>.  If the value being printed cannot be
expressed accurately in the specified number of digits, the value is
rounded to the nearest number that fits.
</P>
<P>

For exact conversions, if a precision is supplied it specifies the
minimum number of digits to appear; leading zeros are produced if
necessary.  If a precision is not supplied, the number is printed with
as many digits as necessary.  Converting an exact `<SAMP>0</SAMP>' with an
explicit precision of zero produces no characters.
</P>
<P>

</P>
<LI>
An optional one of `<SAMP>l</SAMP>', `<SAMP>h</SAMP>' or `<SAMP>L</SAMP>', which is ignored for
numeric conversions.  It is an error to specify these modifiers for
non-numeric conversions.
<P>

</P>
<LI>
A character that specifies the conversion to be applied.
</UL>
<P>

<HR SIZE="6">
<A NAME="SEC57"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC56"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC58"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC54"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 4.3.2.1 Exact Conversions </H4>
<!--docid::SEC57::-->
<P>

</P>
<DL COMPACT>
<DT>`<SAMP>b</SAMP>', `<SAMP>B</SAMP>'
<DD>Print an integer as an unsigned binary number.
<P>

<EM>Note:</EM> `<SAMP>%b</SAMP>' and `<SAMP>%B</SAMP>' are SLIB extensions.
</P>
<P>

</P>
<DT>`<SAMP>d</SAMP>', `<SAMP>i</SAMP>'
<DD>Print an integer as a signed decimal number.  `<SAMP>%d</SAMP>' and `<SAMP>%i</SAMP>'
are synonymous for output, but are different when used with <CODE>scanf</CODE>
for input (see section <A HREF="slib_4.html#SEC60">4.3.3 Standard Formatted Input</A>).
<P>

</P>
<DT>`<SAMP>o</SAMP>'
<DD>Print an integer as an unsigned octal number.
<P>

</P>
<DT>`<SAMP>u</SAMP>'
<DD>Print an integer as an unsigned decimal number.
<P>

</P>
<DT>`<SAMP>x</SAMP>', `<SAMP>X</SAMP>'
<DD>Print an integer as an unsigned hexadecimal number.  `<SAMP>%x</SAMP>' prints
using the digits `<SAMP>0123456789abcdef</SAMP>'.  `<SAMP>%X</SAMP>' prints using the
digits `<SAMP>0123456789ABCDEF</SAMP>'.
</DL>
<P>

<HR SIZE="6">
<A NAME="SEC58"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC57"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC59"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC54"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 4.3.2.2 Inexact Conversions </H4>
<!--docid::SEC58::-->
<P>

</P>
<DL COMPACT>
<DT>`<SAMP>f</SAMP>'
<DD>Print a floating-point number in fixed-point notation.
<P>

</P>
<DT>`<SAMP>e</SAMP>', `<SAMP>E</SAMP>'
<DD>Print a floating-point number in exponential notation.  `<SAMP>%e</SAMP>' prints
`<SAMP>e</SAMP>' between mantissa and exponont.  `<SAMP>%E</SAMP>' prints `<SAMP>E</SAMP>'
between mantissa and exponont.
<P>

</P>
<DT>`<SAMP>g</SAMP>', `<SAMP>G</SAMP>'
<DD>Print a floating-point number in either fixed or exponential notation,
whichever is more appropriate for its magnitude.  Unless an `<SAMP>#</SAMP>'
flag has been supplied, trailing zeros after a decimal point will be
stripped off.  `<SAMP>%g</SAMP>' prints `<SAMP>e</SAMP>' between mantissa and exponont.
`<SAMP>%G</SAMP>' prints `<SAMP>E</SAMP>' between mantissa and exponent.
<P>

</P>
<DT>`<SAMP>k</SAMP>', `<SAMP>K</SAMP>'
<DD>Print a number like `<SAMP>%g</SAMP>', except that an SI prefix is output after
the number, which is scaled accordingly.  `<SAMP>%K</SAMP>' outputs a space
between number and prefix, `<SAMP>%k</SAMP>' does not.
<P>

</DL>
<P>

<HR SIZE="6">
<A NAME="SEC59"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC58"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC60"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC54"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 4.3.2.3 Other Conversions </H4>
<!--docid::SEC59::-->
<DL COMPACT>
<DT>`<SAMP>c</SAMP>'
<DD>Print a single character.  The `<SAMP>-</SAMP>' flag is the only one which can
be specified.  It is an error to specify a precision.
<P>

</P>
<DT>`<SAMP>s</SAMP>'
<DD>Print a string.  The `<SAMP>-</SAMP>' flag is the only one which can be
specified.  A precision specifies the maximum number of characters to
output; otherwise all characters in the string are output.
<P>

</P>
<DT>`<SAMP>a</SAMP>', `<SAMP>A</SAMP>'
<DD>Print a scheme expression.  The `<SAMP>-</SAMP>' flag left-justifies the output.
The `<SAMP>#</SAMP>' flag specifies that strings and characters should be quoted
as by <CODE>write</CODE> (which can be read using <CODE>read</CODE>); otherwise,
output is as <CODE>display</CODE> prints.  A precision specifies the maximum
number of characters to output; otherwise as many characters as needed
are output.
<P>

<EM>Note:</EM> `<SAMP>%a</SAMP>' and `<SAMP>%A</SAMP>' are SLIB extensions.
</P>
<P>

</P>
<DT>`<SAMP>%</SAMP>'
<DD>Print a literal `<SAMP>%</SAMP>' character.  No argument is consumed.  It is an
error to specify flags, field width, precision, or type modifiers with
`<SAMP>%%</SAMP>'.
</DL>
</DL>
<P>

<A NAME="Standard Formatted Input"></A>
<HR SIZE="6">
<A NAME="SEC60"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC59"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC61"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC54"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.3.3 Standard Formatted Input </H3>
<!--docid::SEC60::-->
<P>

<CODE>(require 'scanf)</CODE>
<A NAME="IDX223"></A>
</P>
<P>

<A NAME="IDX224"></A>
</P>
<DL>
<DT><U>Function:</U> <B>scanf-read-list</B> <I>format</I>
<DD><A NAME="IDX225"></A>
<DT><U>Function:</U> <B>scanf-read-list</B> <I>format port</I>
<DD><A NAME="IDX226"></A>
<DT><U>Function:</U> <B>scanf-read-list</B> <I>format string</I>
<DD></DL>
<P>

<A NAME="IDX227"></A>
</P>
<DL>
<DT><U>Macro:</U> <B>scanf</B> <I>format arg1 <small>...</small></I>
<DD><A NAME="IDX228"></A>
<DT><U>Macro:</U> <B>fscanf</B> <I>port format arg1 <small>...</small></I>
<DD><A NAME="IDX229"></A>
<DT><U>Macro:</U> <B>sscanf</B> <I>str format arg1 <small>...</small></I>
<DD><P>

Each function reads characters, interpreting them according to the
control string <VAR>format</VAR> argument.
</P>
<P>

<CODE>scanf-read-list</CODE> returns a list of the items specified as far as
the input matches <VAR>format</VAR>.  <CODE>scanf</CODE>, <CODE>fscanf</CODE>, and
<CODE>sscanf</CODE> return the number of items successfully matched and
stored.  <CODE>scanf</CODE>, <CODE>fscanf</CODE>, and <CODE>sscanf</CODE> also set the
location corresponding to <VAR>arg1</VAR> <small>...</small> using the methods:
</P>
<P>

</P>
<DL COMPACT>
<DT>symbol
<DD><CODE>set!</CODE>
<DT>car expression
<DD><CODE>set-car!</CODE>
<DT>cdr expression
<DD><CODE>set-cdr!</CODE>
<DT>vector-ref expression
<DD><CODE>vector-set!</CODE>
<DT>substring expression
<DD><CODE>substring-move-left!</CODE>
</DL>
<P>

The argument to a <CODE>substring</CODE> expression in <VAR>arg1</VAR> <small>...</small> must
be a non-constant string.  Characters will be stored starting at the
position specified by the second argument to <CODE>substring</CODE>.  The
number of characters stored will be limited by either the position
specified by the third argument to <CODE>substring</CODE> or the length of the
matched string, whichever is less.
</P>
<P>

The control string, <VAR>format</VAR>, contains conversion specifications and
other characters used to direct interpretation of input sequences.  The
control string contains:
</P>
<P>

<UL>
<LI>White-space characters (blanks, tabs, newlines, or formfeeds)
that cause input to be read (and discarded) up to the next
non-white-space character.
<P>

</P>
<LI>An ordinary character (not `<SAMP>%</SAMP>') that must match the next
character of the input stream.
<P>

</P>
<LI>Conversion specifications, consisting of the character `<SAMP>%</SAMP>', an
optional assignment suppressing character `<SAMP>*</SAMP>', an optional
numerical maximum-field width, an optional `<SAMP>l</SAMP>', `<SAMP>h</SAMP>' or
`<SAMP>L</SAMP>' which is ignored, and a conversion code.
<P>

</UL>
<P>

Unless the specification contains the `<SAMP>n</SAMP>' conversion character
(described below), a conversion specification directs the conversion of
the next input field.  The result of a conversion specification is
returned in the position of the corresponding argument points, unless
`<SAMP>*</SAMP>' indicates assignment suppression.  Assignment suppression
provides a way to describe an input field to be skipped.  An input field
is defined as a string of characters; it extends to the next
inappropriate character or until the field width, if specified, is
exhausted.
</P>
<P>

<BLOCKQUOTE>
<EM>Note:</EM> This specification of format strings differs from the
<CITE>ANSI C</CITE> and <CITE>POSIX</CITE> specifications.  In SLIB, white space
before an input field is not skipped unless white space appears before
the conversion specification in the format string.  In order to write
format strings which work identically with <CITE>ANSI C</CITE> and SLIB,
prepend whitespace to all conversion specifications except `<SAMP>[</SAMP>' and
`<SAMP>c</SAMP>'.
</BLOCKQUOTE>
<P>

The conversion code indicates the interpretation of the input field; For
a suppressed field, no value is returned.  The following conversion
codes are legal:
</P>
<P>

</P>
<DL COMPACT>

<DT>`<SAMP>%</SAMP>'
<DD>A single % is expected in the input at this point; no value is returned.
<P>

</P>
<DT>`<SAMP>d</SAMP>', `<SAMP>D</SAMP>'
<DD>A decimal integer is expected.
<P>

</P>
<DT>`<SAMP>u</SAMP>', `<SAMP>U</SAMP>'
<DD>An unsigned decimal integer is expected.
<P>

</P>
<DT>`<SAMP>o</SAMP>', `<SAMP>O</SAMP>'
<DD>An octal integer is expected.
<P>

</P>
<DT>`<SAMP>x</SAMP>', `<SAMP>X</SAMP>'
<DD>A hexadecimal integer is expected.
<P>

</P>
<DT>`<SAMP>i</SAMP>'
<DD>An integer is expected.  Returns the value of the next input item,
interpreted according to C conventions; a leading `<SAMP>0</SAMP>' implies
octal, a leading `<SAMP>0x</SAMP>' implies hexadecimal; otherwise, decimal is
assumed.
<P>

</P>
<DT>`<SAMP>n</SAMP>'
<DD>Returns the total number of bytes (including white space) read by
<CODE>scanf</CODE>.  No input is consumed by <CODE>%n</CODE>.
<P>

</P>
<DT>`<SAMP>f</SAMP>', `<SAMP>F</SAMP>', `<SAMP>e</SAMP>', `<SAMP>E</SAMP>', `<SAMP>g</SAMP>', `<SAMP>G</SAMP>'
<DD>A floating-point number is expected.  The input format for
floating-point numbers is an optionally signed string of digits,
possibly containing a radix character `<SAMP>.</SAMP>', followed by an optional
exponent field consisting of an `<SAMP>E</SAMP>' or an `<SAMP>e</SAMP>', followed by an
optional `<SAMP>+</SAMP>', `<SAMP>-</SAMP>', or space, followed by an integer.
<P>

</P>
<DT>`<SAMP>c</SAMP>', `<SAMP>C</SAMP>'
<DD><VAR>Width</VAR> characters are expected.  The normal skip-over-white-space
is suppressed in this case; to read the next non-space character, use
`<SAMP>%1s</SAMP>'.  If a field width is given, a string is returned; up to the
indicated number of characters is read.
<P>

</P>
<DT>`<SAMP>s</SAMP>', `<SAMP>S</SAMP>'
<DD>A character string is expected The input field is terminated by a
white-space character.  <CODE>scanf</CODE> cannot read a null string.
<P>

</P>
<DT>`<SAMP>[</SAMP>'
<DD>Indicates string data and the normal skip-over-leading-white-space is
suppressed.  The left bracket is followed by a set of characters, called
the scanset, and a right bracket; the input field is the maximal
sequence of input characters consisting entirely of characters in the
scanset.  `<SAMP>^</SAMP>', when it appears as the first character in the
scanset, serves as a complement operator and redefines the scanset as
the set of all characters not contained in the remainder of the scanset
string.  Construction of the scanset follows certain conventions.  A
range of characters may be represented by the construct first-last,
enabling `<SAMP>[0123456789]</SAMP>' to be expressed `<SAMP>[0-9]</SAMP>'.  Using this
convention, first must be lexically less than or equal to last;
otherwise, the dash stands for itself.  The dash also stands for itself
when it is the first or the last character in the scanset.  To include
the right square bracket as an element of the scanset, it must appear as
the first character (possibly preceded by a `<SAMP>^</SAMP>') of the scanset, in
which case it will not be interpreted syntactically as the closing
bracket.  At least one character must match for this conversion to
succeed.
</DL>
<P>

The <CODE>scanf</CODE> functions terminate their conversions at end-of-file,
at the end of the control string, or when an input character conflicts
with the control string.  In the latter case, the offending character is
left unread in the input stream.
</P>
</DL>
<P>

<A NAME="Programs and Arguments"></A>
<HR SIZE="6">
<A NAME="SEC61"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC60"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC62"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 4.4 Program and Arguments </H2>
<!--docid::SEC61::-->
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC62">4.4.1 Getopt</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Command Line option parsing</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC64">4.4.3 Command Line</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">A command line reader for Scheme shells</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC65">4.4.4 Parameter lists</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'parameters</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC66">4.4.5 Getopt Parameter lists</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'getopt-parameters</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC67">4.4.6 Filenames</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'glob or 'filename</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC68">4.4.7 Batch</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'batch</TD></TR>
</TABLE>
<P>

<A NAME="Getopt"></A>
<HR SIZE="6">
<A NAME="SEC62"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC61"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC63"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC61"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.4.1 Getopt </H3>
<!--docid::SEC62::-->
<P>

<CODE>(require 'getopt)</CODE>
<A NAME="IDX230"></A>
</P>
<P>

This routine implements Posix command line argument parsing.  Notice
that returning values through global variables means that <CODE>getopt</CODE>
is <EM>not</EM> reentrant.
</P>
<P>

Obedience to Posix format for the <CODE>getopt</CODE> calls sows confusion.
Passing <VAR>argc</VAR> and <VAR>argv</VAR> as arguments while referencing
<VAR>optind</VAR> as a global variable leads to strange behavior,
especially when the calls to <CODE>getopt</CODE> are buried in other
procedures.
</P>
<P>

Even in C, <VAR>argc</VAR> can be derived from <VAR>argv</VAR>; what purpose
does it serve beyond providing an opportunity for
<VAR>argv</VAR>/<VAR>argc</VAR> mismatch?  Just such a mismatch existed for
years in a SLIB <CODE>getopt--</CODE> example.
</P>
<P>

I have removed the <VAR>argc</VAR> and <VAR>argv</VAR> arguments to getopt
procedures; and replaced them with a global variable:
</P>
<P>

<A NAME="IDX231"></A>
</P>
<DL>
<DT><U>Variable:</U> <B>*argv*</B>
<DD>Define <VAR>*argv*</VAR> with a list of arguments before calling getopt
procedures.  If you don't want the first (0th) element to be ignored,
set <VAR>*optind*</VAR> to 0 (after requiring getopt).
</DL>
<P>

<A NAME="IDX232"></A>
</P>
<DL>
<DT><U>Variable:</U> <B>*optind*</B>
<DD>Is the index of the current element of the command line.  It is
initially one.  In order to parse a new command line or reparse an old
one, <VAR>*optind*</VAR> must be reset.
</DL>
<P>

<A NAME="IDX233"></A>
</P>
<DL>
<DT><U>Variable:</U> <B>*optarg*</B>
<DD>Is set by getopt to the (string) option-argument of the current option.
</DL>
<P>

<A NAME="IDX234"></A>
</P>
<DL>
<DT><U>Function:</U> <B>getopt</B> <I>optstring</I>
<DD>Returns the next option letter in <VAR>*argv*</VAR> (starting from
<CODE>(vector-ref argv *optind*)</CODE>) that matches a letter in
<VAR>optstring</VAR>.  <VAR>*argv*</VAR> is a vector or list of strings, the 0th
of which getopt usually ignores.  <VAR>optstring</VAR> is a string of
recognized option characters; if a character is followed by a colon,
the option takes an argument which may be immediately following it in
the string or in the next element of <VAR>*argv*</VAR>.
<P>

<VAR>*optind*</VAR> is the index of the next element of the <VAR>*argv*</VAR> vector
to be processed.  It is initialized to 1 by `<TT>getopt.scm</TT>', and
<CODE>getopt</CODE> updates it when it finishes with each element of
<VAR>*argv*</VAR>.
</P>
<P>

<CODE>getopt</CODE> returns the next option character from <VAR>*argv*</VAR> that
matches a character in <VAR>optstring</VAR>, if there is one that matches.
If the option takes an argument, <CODE>getopt</CODE> sets the variable
<VAR>*optarg*</VAR> to the option-argument as follows:
</P>
<P>

<UL>
<LI>
If the option was the last character in the string pointed to by an
element of <VAR>*argv*</VAR>, then <VAR>*optarg*</VAR> contains the next element
of <VAR>*argv*</VAR>, and <VAR>*optind*</VAR> is incremented by 2.  If the
resulting value of <VAR>*optind*</VAR> is greater than or equal to
<CODE>(length <VAR>*argv*</VAR>)</CODE>, this indicates a missing option
argument, and <CODE>getopt</CODE> returns an error indication.
<P>

</P>
<LI>
Otherwise, <VAR>*optarg*</VAR> is set to the string following the option
character in that element of <VAR>*argv*</VAR>, and <VAR>*optind*</VAR> is
incremented by 1.
</UL>
<P>

If, when <CODE>getopt</CODE> is called, the string <CODE>(vector-ref argv
*optind*)</CODE> either does not begin with the character <CODE>#\-</CODE> or is
just <CODE>&quot;-&quot;</CODE>, <CODE>getopt</CODE> returns <CODE>#f</CODE> without changing
<VAR>*optind*</VAR>.  If <CODE>(vector-ref argv *optind*)</CODE> is the string
<CODE>&quot;--&quot;</CODE>, <CODE>getopt</CODE> returns <CODE>#f</CODE> after incrementing
<VAR>*optind*</VAR>.
</P>
<P>

If <CODE>getopt</CODE> encounters an option character that is not contained in
<VAR>optstring</VAR>, it returns the question-mark <CODE>#\?</CODE> character.  If
it detects a missing option argument, it returns the colon character
<CODE>#\:</CODE> if the first character of <VAR>optstring</VAR> was a colon, or a
question-mark character otherwise.  In either case, <CODE>getopt</CODE> sets
the variable <VAR>getopt:opt</VAR> to the option character that caused the
error.
</P>
<P>

The special option <CODE>&quot;--&quot;</CODE> can be used to delimit the end of the
options; <CODE>#f</CODE> is returned, and <CODE>&quot;--&quot;</CODE> is skipped.
</P>
<P>

RETURN VALUE
</P>
<P>

<CODE>getopt</CODE> returns the next option character specified on the command
line.  A colon <CODE>#\:</CODE> is returned if <CODE>getopt</CODE> detects a missing
argument and the first character of <VAR>optstring</VAR> was a colon
<CODE>#\:</CODE>.
</P>
<P>

A question-mark <CODE>#\?</CODE> is returned if <CODE>getopt</CODE> encounters an
option character not in <VAR>optstring</VAR> or detects a missing argument
and the first character of <VAR>optstring</VAR> was not a colon <CODE>#\:</CODE>.
</P>
<P>

Otherwise, <CODE>getopt</CODE> returns <CODE>#f</CODE> when all command line options
have been parsed.
</P>
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>#! /usr/local/bin/scm
;;;This code is SCM specific.
(define argv (program-arguments))
(require 'getopt)
<A NAME="IDX235"></A>
(define opts &quot;:a:b:cd&quot;)
(let loop ((opt (getopt (length argv) argv opts)))
  (case opt
    ((#\a) (print &quot;option a: &quot; *optarg*))
    ((#\b) (print &quot;option b: &quot; *optarg*))
    ((#\c) (print &quot;option c&quot;))
    ((#\d) (print &quot;option d&quot;))
    ((#\?) (print &quot;error&quot; getopt:opt))
    ((#\:) (print &quot;missing arg&quot; getopt:opt))
    ((#f) (if (&lt; *optind* (length argv))
              (print &quot;argv[&quot; *optind* &quot;]=&quot;
                     (list-ref argv *optind*)))
          (set! *optind* (+ *optind* 1))))
  (if (&lt; *optind* (length argv))
      (loop (getopt (length argv) argv opts))))

(slib:exit)
</pre></td></tr></table></DL>
<P>

<HR SIZE="6">
<A NAME="SEC63"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC62"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC64"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC61"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.4.2 Getopt--- </H3>
<!--docid::SEC63::-->
<P>

<A NAME="IDX236"></A>
</P>
<DL>
<DT><U>Function:</U> <B><CODE>getopt--</CODE></B> <I>optstring</I>
<DD>The procedure <CODE>getopt--</CODE> is an extended version of <CODE>getopt</CODE>
which parses <EM>long option names</EM> of the form
`<SAMP>--hold-the-onions</SAMP>' and `<SAMP>--verbosity-level=extreme</SAMP>'.
<CODE>Getopt--</CODE> behaves as <CODE>getopt</CODE> except for non-empty
options beginning with `<SAMP>--</SAMP>'.
<P>

Options beginning with `<SAMP>--</SAMP>' are returned as strings rather than
characters.  If a value is assigned (using `<SAMP>=</SAMP>') to a long option,
<CODE>*optarg*</CODE> is set to the value.  The `<SAMP>=</SAMP>' and value are
not returned as part of the option string.
</P>
<P>

No information is passed to <CODE>getopt--</CODE> concerning which long
options should be accepted or whether such options can take arguments.
If a long option did not have an argument, <CODE>*optarg*</CODE> will be set
to <CODE>#f</CODE>.  The caller is responsible for detecting and reporting
errors.
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define opts &quot;:-:b:&quot;)
(define *argv* '(&quot;foo&quot; &quot;-b9&quot; &quot;--f1&quot; &quot;--2=&quot; &quot;--g3=35234.342&quot; &quot;--&quot;))
(define *optind* 1)
(define *optarg* #f)
(require 'qp)
<A NAME="IDX237"></A>(do ((i 5 (+ -1 i)))
    ((zero? i))
  (let ((opt (getopt-- opts)))
    (print *optind* opt *optarg*)))
-|
2 #\b &quot;9&quot;
3 &quot;f1&quot; #f
4 &quot;2&quot; &quot;&quot;
5 &quot;g3&quot; &quot;35234.342&quot;
5 #f &quot;35234.342&quot;
</pre></td></tr></table></DL>
<P>

<A NAME="Command Line"></A>
<HR SIZE="6">
<A NAME="SEC64"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC63"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC65"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC61"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.4.3 Command Line </H3>
<!--docid::SEC64::-->
<P>

<CODE>(require 'read-command)</CODE>
<A NAME="IDX238"></A>
</P>
<P>

<A NAME="IDX239"></A>
</P>
<DL>
<DT><U>Function:</U> <B>read-command</B> <I>port</I>
<DD><P>

<A NAME="IDX240"></A>
<DT><U>Function:</U> <B>read-command</B>
<DD><CODE>read-command</CODE> converts a <EM>command line</EM> into a list of strings
<A NAME="IDX241"></A>
<A NAME="IDX242"></A>
suitable for parsing by <CODE>getopt</CODE>.  The syntax of command lines
supported resembles that of popular <EM>shell</EM>s.  <CODE>read-command</CODE>
<A NAME="IDX243"></A>
updates <VAR>port</VAR> to point to the first character past the command
delimiter.
</P>
<P>

If an end of file is encountered in the input before any characters are
found that can begin an object or comment, then an end of file object is
returned.
</P>
<P>

The <VAR>port</VAR> argument may be omitted, in which case it defaults to the
value returned by <CODE>current-input-port</CODE>.
</P>
<P>

The fields into which the command line is split are delimited by
whitespace as defined by <CODE>char-whitespace?</CODE>.  The end of a command
is delimited by end-of-file or unescaped semicolon (<KBD>;</KBD>) or
<KBD>newline</KBD>.  Any character can be literally included in a field by
escaping it with a backslach (<KBD>\</KBD>).
</P>
<P>

The initial character and types of fields recognized are:
</P>
<DL COMPACT>
<DT>`<SAMP>\</SAMP>'
<DD>The next character has is taken literally and not interpreted as a field
delimiter.  If <KBD>\</KBD> is the last character before a <KBD>newline</KBD>,
that <KBD>newline</KBD> is just ignored.  Processing continues from the
characters after the <KBD>newline</KBD> as though the backslash and
<KBD>newline</KBD> were not there.
<DT>`<SAMP>&quot;</SAMP>'
<DD>The characters up to the next unescaped <KBD>&quot;</KBD> are taken literally,
according to [R4RS] rules for literal strings (see section `Strings' in <CITE>Revised(4) Scheme</CITE>).
<DT>`<SAMP>(</SAMP>', `<SAMP>%'</SAMP>'
<DD>One scheme expression is <CODE>read</CODE> starting with this character.  The
<CODE>read</CODE> expression is evaluated, converted to a string
(using <CODE>display</CODE>), and replaces the expression in the returned
field.
<DT>`<SAMP>;</SAMP>'
<DD>Semicolon delimits a command.  Using semicolons more than one command
can appear on a line.  Escaped semicolons and semicolons inside strings
do not delimit commands.
</DL>
<P>

The comment field differs from the previous fields in that it must be
the first character of a command or appear after whitespace in order to
be recognized.  <KBD>#</KBD> can be part of fields if these conditions are
not met.  For instance, <CODE>ab#c</CODE> is just the field ab#c.
</P>
<P>

</P>
<DL COMPACT>
<DT>`<SAMP>#</SAMP>'
<DD>Introduces a comment.  The comment continues to the end of the line on
which the semicolon appears.  Comments are treated as whitespace by
<CODE>read-dommand-line</CODE> and backslashes before <KBD>newline</KBD>s in
comments are also ignored.
</DL>
</DL>
<P>

<A NAME="IDX244"></A>
</P>
<DL>
<DT><U>Function:</U> <B>read-options-file</B> <I>filename</I>
<DD><P>

<CODE>read-options-file</CODE> converts an <EM>options file</EM> into a list of
<A NAME="IDX245"></A>
<A NAME="IDX246"></A>
strings suitable for parsing by <CODE>getopt</CODE>.  The syntax of options
files is the same as the syntax for command
lines, except that <KBD>newline</KBD>s do not terminate reading (only <KBD>;</KBD>
or end of file).
</P>
<P>

If an end of file is encountered before any characters are found that
can begin an object or comment, then an end of file object is returned.
</P>
</DL>
<P>

<A NAME="Parameter lists"></A>
<HR SIZE="6">
<A NAME="SEC65"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC64"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC66"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC61"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.4.4 Parameter lists </H3>
<!--docid::SEC65::-->
<P>

<CODE>(require 'parameters)</CODE>
<A NAME="IDX247"></A>
</P>
<P>

Arguments to procedures in scheme are distinguished from each other by
their position in the procedure call.  This can be confusing when a
procedure takes many arguments, many of which are not often used.
</P>
<P>

A <EM>parameter-list</EM> is a way of passing named information to a
procedure.  Procedures are also defined to set unused parameters to
default values, check parameters, and combine parameter lists.
</P>
<P>

A <VAR>parameter</VAR> has the form <CODE>(parameter-name value1
<small>...</small>)</CODE>.  This format allows for more than one value per
parameter-name.
</P>
<P>

A <VAR>parameter-list</VAR> is a list of <VAR>parameter</VAR>s, each with a
different <VAR>parameter-name</VAR>.
</P>
<P>

<A NAME="IDX248"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-parameter-list</B> <I>parameter-names</I>
<DD>Returns an empty parameter-list with slots for <VAR>parameter-names</VAR>.
</DL>
<P>

<A NAME="IDX249"></A>
</P>
<DL>
<DT><U>Function:</U> <B>parameter-list-ref</B> <I>parameter-list parameter-name</I>
<DD><VAR>parameter-name</VAR> must name a valid slot of <VAR>parameter-list</VAR>.
<CODE>parameter-list-ref</CODE> returns the value of parameter
<VAR>parameter-name</VAR> of <VAR>parameter-list</VAR>.
</DL>
<P>

<A NAME="IDX250"></A>
</P>
<DL>
<DT><U>Function:</U> <B>remove-parameter</B> <I>parameter-name parameter-list</I>
<DD>Removes the parameter <VAR>parameter-name</VAR> from <VAR>parameter-list</VAR>.
<CODE>remove-parameter</CODE> does not alter the argument
<VAR>parameter-list</VAR>.
<P>

If there are more than one <VAR>parameter-name</VAR> parameters, an error is
signaled.
</P>
</DL>
<P>

<A NAME="IDX251"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>adjoin-parameters!</B> <I>parameter-list parameter1 <small>...</small></I>
<DD>Returns <VAR>parameter-list</VAR> with <VAR>parameter1</VAR> <small>...</small> merged in.
</DL>
<P>

<A NAME="IDX252"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>parameter-list-expand</B> <I>expanders parameter-list</I>
<DD><VAR>expanders</VAR> is a list of procedures whose order matches the order of
the <VAR>parameter-name</VAR>s in the call to <CODE>make-parameter-list</CODE>
which created <VAR>parameter-list</VAR>.  For each non-false element of
<VAR>expanders</VAR> that procedure is mapped over the corresponding
parameter value and the returned parameter lists are merged into
<VAR>parameter-list</VAR>.
<P>

This process is repeated until <VAR>parameter-list</VAR> stops growing.  The
value returned from <CODE>parameter-list-expand</CODE> is unspecified.
</P>
</DL>
<P>

<A NAME="IDX253"></A>
</P>
<DL>
<DT><U>Function:</U> <B>fill-empty-parameters</B> <I>defaulters parameter-list</I>
<DD><VAR>defaulters</VAR> is a list of procedures whose order matches the order
of the <VAR>parameter-name</VAR>s in the call to <CODE>make-parameter-list</CODE>
which created <VAR>parameter-list</VAR>.  <CODE>fill-empty-parameters</CODE>
returns a new parameter-list with each empty parameter replaced with the
list returned by calling the corresponding <VAR>defaulter</VAR> with
<VAR>parameter-list</VAR> as its argument.
</DL>
<P>

<A NAME="IDX254"></A>
</P>
<DL>
<DT><U>Function:</U> <B>check-parameters</B> <I>checks parameter-list</I>
<DD><VAR>checks</VAR> is a list of procedures whose order matches the order of
the <VAR>parameter-name</VAR>s in the call to <CODE>make-parameter-list</CODE>
which created <VAR>parameter-list</VAR>.
<P>

<CODE>check-parameters</CODE> returns <VAR>parameter-list</VAR> if each <VAR>check</VAR>
of the corresponding <VAR>parameter-list</VAR> returns non-false.  If some
<VAR>check</VAR> returns <CODE>#f</CODE> a warning is signaled.
</P>
</DL>
<P>

In the following procedures <VAR>arities</VAR> is a list of symbols.  The
elements of <CODE>arities</CODE> can be:
</P>
<P>

</P>
<DL COMPACT>
<DT><CODE>single</CODE>
<DD>Requires a single parameter.
<DT><CODE>optional</CODE>
<DD>A single parameter or no parameter is acceptable.
<DT><CODE>boolean</CODE>
<DD>A single boolean parameter or zero parameters is acceptable.
<DT><CODE>nary</CODE>
<DD>Any number of parameters are acceptable.
<DT><CODE>nary1</CODE>
<DD>One or more of parameters are acceptable.
</DL>
<P>

<A NAME="IDX255"></A>
</P>
<DL>
<DT><U>Function:</U> <B>parameter-list-&gt;arglist</B> <I>positions arities parameter-list</I>
<DD>Returns <VAR>parameter-list</VAR> converted to an argument list.  Parameters
of <VAR>arity</VAR> type <CODE>single</CODE> and <CODE>boolean</CODE> are converted to
the single value associated with them.  The other <VAR>arity</VAR> types are
converted to lists of the value(s).
<P>

<VAR>positions</VAR> is a list of positive integers whose order matches the
order of the <VAR>parameter-name</VAR>s in the call to
<CODE>make-parameter-list</CODE> which created <VAR>parameter-list</VAR>.  The
integers specify in which argument position the corresponding parameter
should appear.
</P>
</DL>
<P>

<A NAME="Getopt Parameter lists"></A>
<HR SIZE="6">
<A NAME="SEC66"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC65"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC67"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC61"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.4.5 Getopt Parameter lists </H3>
<!--docid::SEC66::-->
<P>

<CODE>(require 'getopt-parameters)</CODE>
<A NAME="IDX256"></A>
</P>
<P>

<A NAME="IDX257"></A>
</P>
<DL>
<DT><U>Function:</U> <B>getopt-&gt;parameter-list</B> <I>optnames arities types aliases desc <small>...</small></I>
<DD><P>

Returns <VAR>*argv*</VAR> converted to a parameter-list.  <VAR>optnames</VAR> are
the parameter-names.  <VAR>arities</VAR> and <VAR>types</VAR> are lists of symbols
corresponding to <VAR>optnames</VAR>.
</P>
<P>

<VAR>aliases</VAR> is a list of lists of strings or integers paired with
elements of <VAR>optnames</VAR>.  Each one-character string will be treated
as a single `<SAMP>-</SAMP>' option by <CODE>getopt</CODE>.  Longer strings will be
treated as long-named options (see section <A HREF="slib_4.html#SEC62">getopt--</A>).
</P>
<P>

If the <VAR>aliases</VAR> association list has only strings as its
<CODE>car</CODE>s, then all the option-arguments after an option (and before
the next option) are adjoined to that option.
</P>
<P>

If the <VAR>aliases</VAR> association list has integers, then each (string)
option will take at most one option-argument.  Unoptioned arguments are
collected in a list.  A `<SAMP>-1</SAMP>' alias will take the last argument in
this list; `<SAMP>+1</SAMP>' will take the first argument in the list.  The
aliases -2 then +2; -3 then +3; <small>...</small> are tried so long as a positive
or negative consecutive alias is found and arguments remain in the list.
Finally a `<SAMP>0</SAMP>' alias, if found, absorbs any remaining arguments.
</P>
<P>

In all cases, if unclaimed arguments remain after processing, a warning
is signaled and #f is returned.
</P>
</DL>
<P>

<A NAME="IDX258"></A>
</P>
<DL>
<DT><U>Function:</U> <B>getopt-&gt;arglist</B> <I>optnames positions arities types defaulters checks aliases desc <small>...</small></I>
<DD><P>

Like <CODE>getopt-&gt;parameter-list</CODE>, but converts <VAR>*argv*</VAR> to an
argument-list as specified by <VAR>optnames</VAR>, <VAR>positions</VAR>,
<VAR>arities</VAR>, <VAR>types</VAR>, <VAR>defaulters</VAR>, <VAR>checks</VAR>, and
<VAR>aliases</VAR>.  If the options supplied violate the <VAR>arities</VAR> or
<VAR>checks</VAR> constraints, then a warning is signaled and #f is returned.
</P>
</DL>
These <CODE>getopt</CODE> functions can be used with SLIB relational
databases.  For an example, See section <A HREF="slib_6.html#SEC142">make-command-server</A>.
<P>

If errors are encountered while processing options, directions for using
the options (and argument strings <VAR>desc</VAR> <small>...</small>) are printed to
<CODE>current-error-port</CODE>.
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(begin
  (set! *optind* 1)
  (set! *argv* '(&quot;cmd&quot; &quot;-?&quot;)
  (getopt-&gt;parameter-list
   '(flag number symbols symbols string flag2 flag3 num2 num3)
   '(boolean optional nary1 nary single boolean boolean nary nary)
   '(boolean integer symbol symbol string boolean boolean integer integer)
   '((&quot;flag&quot; flag)
     (&quot;f&quot; flag)
     (&quot;Flag&quot; flag2)
     (&quot;B&quot; flag3)
     (&quot;optional&quot; number)
     (&quot;o&quot; number)
     (&quot;nary1&quot; symbols)
     (&quot;N&quot; symbols)
     (&quot;nary&quot; symbols)
     (&quot;n&quot; symbols)
     (&quot;single&quot; string)
     (&quot;s&quot; string)
     (&quot;a&quot; num2)
     (&quot;Abs&quot; num3))))
-|
Usage: cmd [OPTION ARGUMENT ...] ...

  -f, --flag
  -o, --optional=&lt;number&gt;
  -n, --nary=&lt;symbols&gt; ...
  -N, --nary1=&lt;symbols&gt; ...
  -s, --single=&lt;string&gt;
      --Flag
  -B
  -a        &lt;num2&gt; ...
      --Abs=&lt;num3&gt; ...

ERROR: getopt-&gt;parameter-list &quot;unrecognized option&quot; &quot;-?&quot;
</pre></td></tr></table><P>

<A NAME="Filenames"></A>
<HR SIZE="6">
<A NAME="SEC67"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC66"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC68"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC61"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.4.6 Filenames </H3>
<!--docid::SEC67::-->
<P>

<CODE>(require 'filename)</CODE> or <CODE>(require 'glob)</CODE>
<A NAME="IDX259"></A>
<A NAME="IDX260"></A>
</P>
<P>

<A NAME="IDX261"></A>
</P>
<DL>
<DT><U>Function:</U> <B>filename:match??</B> <I>pattern</I>
<DD><A NAME="IDX262"></A>
<DT><U>Function:</U> <B>filename:match-ci??</B> <I>pattern</I>
<DD><P>

Returns a predicate which returns a non-false value if its string argument
matches (the string) <VAR>pattern</VAR>, false otherwise.  Filename matching
is like
<A NAME="IDX263"></A>
<EM>glob</EM> expansion described the bash manpage, except that names
<A NAME="IDX264"></A>
beginning with `<SAMP>.</SAMP>' are matched and `<SAMP>/</SAMP>' characters are not
treated specially.
</P>
<P>

These functions interpret the following characters specially in
<VAR>pattern</VAR> strings:
</P>
<DL COMPACT>
<DT>`<SAMP>*</SAMP>'
<DD>Matches any string, including the null string.
<DT>`<SAMP>?</SAMP>'
<DD>Matches any single character.
<DT>`<SAMP>[<small>...</small>]</SAMP>'
<DD>Matches any one of the enclosed characters.  A pair of characters
separated by a minus sign (-) denotes a range; any character lexically
between those two characters, inclusive, is matched.  If the first
character following the `<SAMP>[</SAMP>' is a `<SAMP>!</SAMP>' or a `<SAMP>^</SAMP>' then any
character not enclosed is matched.  A `<SAMP>-</SAMP>' or `<SAMP>]</SAMP>' may be
matched by including it as the first or last character in the set.
</DL>
</DL>
<P>

<A NAME="IDX265"></A>
</P>
<DL>
<DT><U>Function:</U> <B>filename:substitute??</B> <I>pattern template</I>
<DD><A NAME="IDX266"></A>
<DT><U>Function:</U> <B>filename:substitute-ci??</B> <I>pattern template</I>
<DD><P>

Returns a function transforming a single string argument according to
glob patterns <VAR>pattern</VAR> and <VAR>template</VAR>.  <VAR>pattern</VAR> and
<VAR>template</VAR> must have the same number of wildcard specifications,
which need not be identical.  <VAR>pattern</VAR> and <VAR>template</VAR> may have
a different number of literal sections. If an argument to the function
matches <VAR>pattern</VAR> in the sense of <CODE>filename:match??</CODE> then it
returns a copy of <VAR>template</VAR> in which each wildcard specification is
replaced by the part of the argument matched by the corresponding
wildcard specification in <VAR>pattern</VAR>.  A <CODE>*</CODE> wildcard matches
the longest leftmost string possible.  If the argument does not match
<VAR>pattern</VAR> then false is returned.
</P>
<P>

<VAR>template</VAR> may be a function accepting the same number of string
arguments as there are wildcard specifications in <VAR>pattern</VAR>.  In
the case of a match the result of applying <VAR>template</VAR> to a list
of the substrings matched by wildcard specifications will be returned,
otherwise <VAR>template</VAR> will not be called and <CODE>#f</CODE> will be returned.
</P>
</DL>
<TABLE><tr><td>&nbsp;</td><td class=example><pre>((filename:substitute?? &quot;scm_[0-9]*.html&quot; &quot;scm5c4_??.htm&quot;)
 &quot;scm_10.html&quot;)
=> &quot;scm5c4_10.htm&quot;
((filename:substitute?? &quot;??&quot; &quot;beg?mid?end&quot;) &quot;AZ&quot;)
=> &quot;begAmidZend&quot;
((filename:substitute?? &quot;*na*&quot; &quot;?NA?&quot;) &quot;banana&quot;)
=> &quot;banaNA&quot;
((filename:substitute?? &quot;?*?&quot; (lambda (s1 s2 s3) (string-append s3 s1)))
 &quot;ABZ&quot;)
=> &quot;ZA&quot;
</pre></td></tr></table><P>

<A NAME="IDX267"></A>
</P>
<DL>
<DT><U>Function:</U> <B>replace-suffix</B> <I>str old new</I>
<DD><P>

<VAR>str</VAR> can be a string or a list of strings.  Returns a new string
(or strings) similar to <CODE>str</CODE> but with the suffix string <VAR>old</VAR>
removed and the suffix string <VAR>new</VAR> appended.  If the end of
<VAR>str</VAR> does not match <VAR>old</VAR>, an error is signaled.
</P>
</DL>
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(replace-suffix &quot;/usr/local/lib/slib/batch.scm&quot; &quot;.scm&quot; &quot;.c&quot;)
=> &quot;/usr/local/lib/slib/batch.c&quot;
</pre></td></tr></table><P>

<A NAME="IDX268"></A>
</P>
<DL>
<DT><U>Function:</U> <B>call-with-tmpnam</B> <I>proc k</I>
<DD><P>

<A NAME="IDX269"></A>
<DT><U>Function:</U> <B>call-with-tmpnam</B> <I>proc</I>
<DD>Calls <VAR>proc</VAR> with <VAR>k</VAR> arguments, strings returned by successive calls to
<CODE>tmpnam</CODE>.
If <VAR>proc</VAR> returns, then any files named by the arguments to <VAR>proc</VAR> are
deleted automatically and the value(s) yielded by the <VAR>proc</VAR> is(are)
returned.  <VAR>k</VAR> may be ommited, in which case it defaults to <CODE>1</CODE>.
</P>
<P>

<A NAME="IDX270"></A>
<DT><U>Function:</U> <B>call-with-tmpnam</B> <I>proc suffix1 <small>...</small></I>
<DD>Calls <VAR>proc</VAR> with strings returned by successive calls to <CODE>tmpnam</CODE>,
each with the corresponding <VAR>suffix</VAR> string appended.
If <VAR>proc</VAR> returns, then any files named by the arguments to <VAR>proc</VAR> are
deleted automatically and the value(s) yielded by the <VAR>proc</VAR> is(are)
returned.
</P>
</DL>
<P>

<A NAME="Batch"></A>
<HR SIZE="6">
<A NAME="SEC68"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC67"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC69"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC61"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.4.7 Batch </H3>
<!--docid::SEC68::-->
<P>

<CODE>(require 'batch)</CODE>
<A NAME="IDX271"></A>
</P>
<P>

The batch procedures provide a way to write and execute portable scripts
for a variety of operating systems.  Each <CODE>batch:</CODE> procedure takes
as its first argument a parameter-list (see section <A HREF="slib_4.html#SEC65">4.4.4 Parameter lists</A>).  This
parameter-list argument <VAR>parms</VAR> contains named associations.  Batch
currently uses 2 of these:
</P>
<P>

</P>
<DL COMPACT>
<DT><CODE>batch-port</CODE>
<DD>The port on which to write lines of the batch file.
<DT><CODE>batch-dialect</CODE>
<DD>The syntax of batch file to generate.  Currently supported are:
<UL>
<LI>
unix
<LI>
dos
<LI>
vms
<LI>
amigaos
<LI>
system
<LI>
*unknown*
</UL>
</DL>
<P>

`<TT>batch.scm</TT>' uses 2 enhanced relational tables
(see section <A HREF="slib_6.html#SEC142">6.1.1 Using Databases</A>) to store information linking the names of
<CODE>operating-system</CODE>s to <CODE>batch-dialect</CODE>es.
</P>
<P>

<A NAME="IDX272"></A>
</P>
<DL>
<DT><U>Function:</U> <B>batch:initialize!</B> <I>database</I>
<DD>Defines <CODE>operating-system</CODE> and <CODE>batch-dialect</CODE> tables and adds
the domain <CODE>operating-system</CODE> to the enhanced relational database
<VAR>database</VAR>.
</DL>
<P>

<A NAME="IDX273"></A>
</P>
<DL>
<DT><U>Variable:</U> <B>*operating-system*</B>
<DD>Is batch's best guess as to which operating-system it is running under.
<CODE>*operating-system*</CODE> is set to <CODE>(software-type)</CODE>
(see section <A HREF="slib_2.html#SEC15">2.2 Configuration</A>) unless <CODE>(software-type)</CODE> is <CODE>unix</CODE>,
in which case finer distinctions are made.
</DL>
<P>

<A NAME="IDX274"></A>
</P>
<DL>
<DT><U>Function:</U> <B>batch:call-with-output-script</B> <I>parms file proc</I>
<DD><VAR>proc</VAR> should be a procedure of one argument.  If <VAR>file</VAR> is an
output-port, <CODE>batch:call-with-output-script</CODE> writes an appropriate
header to <VAR>file</VAR> and then calls <VAR>proc</VAR> with <VAR>file</VAR> as the
only argument.  If <VAR>file</VAR> is a string,
<CODE>batch:call-with-output-script</CODE> opens a output-file of name
<VAR>file</VAR>, writes an appropriate header to <VAR>file</VAR>, and then calls
<VAR>proc</VAR> with the newly opened port as the only argument.  Otherwise,
<CODE>batch:call-with-output-script</CODE> acts as if it was called with the
result of <CODE>(current-output-port)</CODE> as its third argument.
</DL>
<P>

The rest of the <CODE>batch:</CODE> procedures write (or execute if
<CODE>batch-dialect</CODE> is <CODE>system</CODE>) commands to the batch port which
has been added to <VAR>parms</VAR> or <CODE>(copy-tree <VAR>parms</VAR>)</CODE> by the
code:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(adjoin-parameters! <VAR>parms</VAR> (list 'batch-port <VAR>port</VAR>))
</pre></td></tr></table><P>

<A NAME="IDX275"></A>
</P>
<DL>
<DT><U>Function:</U> <B>batch:command</B> <I>parms string1 string2 <small>...</small></I>
<DD>Calls <CODE>batch:try-command</CODE> (below) with arguments, but signals an
error if <CODE>batch:try-command</CODE> returns <CODE>#f</CODE>.
</DL>
<P>

These functions return a non-false value if the command was successfully
translated into the batch dialect and <CODE>#f</CODE> if not.  In the case of
the <CODE>system</CODE> dialect, the value is non-false if the operation
suceeded.
</P>
<P>

<A NAME="IDX276"></A>
</P>
<DL>
<DT><U>Function:</U> <B>batch:try-command</B> <I>parms string1 string2 <small>...</small></I>
<DD>Writes a command to the <CODE>batch-port</CODE> in <VAR>parms</VAR> which executes
the program named <VAR>string1</VAR> with arguments <VAR>string2</VAR> <small>...</small>.
</DL>
<P>

<A NAME="IDX277"></A>
</P>
<DL>
<DT><U>Function:</U> <B>batch:try-chopped-command</B> <I>parms arg1 arg2 <small>...</small> list</I>
<DD>breaks the last argument <VAR>list</VAR> into chunks small enough so that the
command:
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre><VAR>arg1</VAR> <VAR>arg2</VAR> <small>...</small> <VAR>chunk</VAR>
</pre></td></tr></table><P>

fits withing the platform's maximum command-line length.
</P>
<P>

<CODE>batch:try-chopped-command</CODE> calls <CODE>batch:try-command</CODE> with the
command and returns non-false only if the commands all fit and
<CODE>batch:try-command</CODE> of each command line returned non-false.
</P>
</DL>
<P>

<A NAME="IDX278"></A>
</P>
<DL>
<DT><U>Function:</U> <B>batch:run-script</B> <I>parms string1 string2 <small>...</small></I>
<DD>Writes a command to the <CODE>batch-port</CODE> in <VAR>parms</VAR> which executes
the batch script named <VAR>string1</VAR> with arguments <VAR>string2</VAR>
<small>...</small>.
<P>

<EM>Note:</EM> <CODE>batch:run-script</CODE> and <CODE>batch:try-command</CODE> are not the
same for some operating systems (VMS).
</P>
</DL>
<P>

<A NAME="IDX279"></A>
</P>
<DL>
<DT><U>Function:</U> <B>batch:comment</B> <I>parms line1 <small>...</small></I>
<DD>Writes comment lines <VAR>line1</VAR> <small>...</small> to the <CODE>batch-port</CODE> in
<VAR>parms</VAR>.
</DL>
<P>

<A NAME="IDX280"></A>
</P>
<DL>
<DT><U>Function:</U> <B>batch:lines-&gt;file</B> <I>parms file line1 <small>...</small></I>
<DD>Writes commands to the <CODE>batch-port</CODE> in <VAR>parms</VAR> which create a
file named <VAR>file</VAR> with contents <VAR>line1</VAR> <small>...</small>.
</DL>
<P>

<A NAME="IDX281"></A>
</P>
<DL>
<DT><U>Function:</U> <B>batch:delete-file</B> <I>parms file</I>
<DD>Writes a command to the <CODE>batch-port</CODE> in <VAR>parms</VAR> which deletes
the file named <VAR>file</VAR>.
</DL>
<P>

<A NAME="IDX282"></A>
</P>
<DL>
<DT><U>Function:</U> <B>batch:rename-file</B> <I>parms old-name new-name</I>
<DD>Writes a command to the <CODE>batch-port</CODE> in <VAR>parms</VAR> which renames
the file <VAR>old-name</VAR> to <VAR>new-name</VAR>.
</DL>
<P>

In addition, batch provides some small utilities very useful for writing
scripts:
</P>
<P>

<A NAME="IDX283"></A>
</P>
<DL>
<DT><U>Function:</U> <B>truncate-up-to</B> <I>path char</I>
<DD><A NAME="IDX284"></A>
<DT><U>Function:</U> <B>truncate-up-to</B> <I>path string</I>
<DD><A NAME="IDX285"></A>
<DT><U>Function:</U> <B>truncate-up-to</B> <I>path charlist</I>
<DD><VAR>path</VAR> can be a string or a list of strings.  Returns <VAR>path</VAR>
sans any prefixes ending with a character of the second argument.  This
can be used to derive a filename moved locally from elsewhere.
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(truncate-up-to &quot;/usr/local/lib/slib/batch.scm&quot; &quot;/&quot;)
=> &quot;batch.scm&quot;
</pre></td></tr></table></DL>
<P>

<A NAME="IDX286"></A>
</P>
<DL>
<DT><U>Function:</U> <B>string-join</B> <I>joiner string1 <small>...</small></I>
<DD>Returns a new string consisting of all the strings <VAR>string1</VAR> <small>...</small>
in order appended together with the string <VAR>joiner</VAR> between each
adjacent pair.
</DL>
<P>

<A NAME="IDX287"></A>
</P>
<DL>
<DT><U>Function:</U> <B>must-be-first</B> <I>list1 list2</I>
<DD>Returns a new list consisting of the elements of <VAR>list2</VAR> ordered so
that if some elements of <VAR>list1</VAR> are <CODE>equal?</CODE> to elements of
<VAR>list2</VAR>, then those elements will appear first and in the order of
<VAR>list1</VAR>.
</DL>
<P>

<A NAME="IDX288"></A>
</P>
<DL>
<DT><U>Function:</U> <B>must-be-last</B> <I>list1 list2</I>
<DD>Returns a new list consisting of the elements of <VAR>list1</VAR> ordered so
that if some elements of <VAR>list2</VAR> are <CODE>equal?</CODE> to elements of
<VAR>list1</VAR>, then those elements will appear last and in the order of
<VAR>list2</VAR>.
</DL>
<P>

<A NAME="IDX289"></A>
</P>
<DL>
<DT><U>Function:</U> <B>os-&gt;batch-dialect</B> <I>osname</I>
<DD>Returns its best guess for the <CODE>batch-dialect</CODE> to be used for the
operating-system named <VAR>osname</VAR>.  <CODE>os-&gt;batch-dialect</CODE> uses the
tables added to <VAR>database</VAR> by <CODE>batch:initialize!</CODE>.
</DL>
<P>

Here is an example of the use of most of batch's procedures:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(require 'databases)
<A NAME="IDX290"></A>(require 'parameters)
<A NAME="IDX291"></A>(require 'batch)
<A NAME="IDX292"></A>(require 'glob)
<A NAME="IDX293"></A>
(define batch (create-database #f 'alist-table))
(batch:initialize! batch)

(define my-parameters
  (list (list 'batch-dialect (os-&gt;batch-dialect *operating-system*))
        (list 'operating-system *operating-system*)
        (list 'batch-port (current-output-port)))) ;gets filled in later

(batch:call-with-output-script
 my-parameters
 &quot;my-batch&quot;
 (lambda (batch-port)
   (adjoin-parameters! my-parameters (list 'batch-port batch-port))
   (and
    (batch:comment my-parameters
                   &quot;================ Write file with C program.&quot;)
    (batch:rename-file my-parameters &quot;hello.c&quot; &quot;hello.c~&quot;)
    (batch:lines-&gt;file my-parameters &quot;hello.c&quot;
                       &quot;#include &lt;stdio.h&gt;&quot;
                       &quot;int main(int argc, char **argv)&quot;
                       &quot;{&quot;
                       &quot;  printf(\&quot;hello world\\n\&quot;);&quot;
                       &quot;  return 0;&quot;
                       &quot;}&quot; )
    (batch:command my-parameters &quot;cc&quot; &quot;-c&quot; &quot;hello.c&quot;)
    (batch:command my-parameters &quot;cc&quot; &quot;-o&quot; &quot;hello&quot;
                  (replace-suffix &quot;hello.c&quot; &quot;.c&quot; &quot;.o&quot;))
    (batch:command my-parameters &quot;hello&quot;)
    (batch:delete-file my-parameters &quot;hello&quot;)
    (batch:delete-file my-parameters &quot;hello.c&quot;)
    (batch:delete-file my-parameters &quot;hello.o&quot;)
    (batch:delete-file my-parameters &quot;my-batch&quot;)
    )))
</pre></td></tr></table><P>

Produces the file `<TT>my-batch</TT>':
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>#! /bin/sh
# &quot;my-batch&quot; script created by SLIB/batch Sun Oct 31 18:24:10 1999
# ================ Write file with C program.
mv -f hello.c hello.c~
rm -f hello.c
echo '#include &lt;stdio.h&gt;'&gt;&gt;hello.c
echo 'int main(int argc, char **argv)'&gt;&gt;hello.c
echo '{'&gt;&gt;hello.c
echo '  printf(&quot;hello world\n&quot;);'&gt;&gt;hello.c
echo '  return 0;'&gt;&gt;hello.c
echo '}'&gt;&gt;hello.c
cc -c hello.c
cc -o hello hello.o
hello
rm -f hello
rm -f hello.c
rm -f hello.o
rm -f my-batch
</pre></td></tr></table><P>

When run, `<TT>my-batch</TT>' prints:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>bash$ my-batch
mv: hello.c: No such file or directory
hello world
</pre></td></tr></table><P>

<A NAME="HTML"></A>
<HR SIZE="6">
<A NAME="SEC69"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC68"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC70"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 4.5 HTML </H2>
<!--docid::SEC69::-->
<P>

<CODE>(require 'html-form)</CODE>
<A NAME="IDX294"></A>
</P>
<P>

<A NAME="IDX295"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:atval</B> <I>txt</I>
<DD>Returns a string with character substitutions appropriate to
send <VAR>txt</VAR> as an <EM>attribute-value</EM>.
<A NAME="IDX296"></A>
</DL>
<P>

<A NAME="IDX297"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:plain</B> <I>txt</I>
<DD>Returns a string with character substitutions appropriate to
send <VAR>txt</VAR> as an <EM>plain-text</EM>.
<A NAME="IDX298"></A>
</DL>
<P>

<A NAME="IDX299"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:meta</B> <I>name content</I>
<DD>Returns a tag of meta-information suitable for passing as the
third argument to <CODE>html:head</CODE>.  The tag produced is `<SAMP>&lt;META
NAME=&quot;<VAR>name</VAR>&quot; CONTENT=&quot;<VAR>content</VAR>&quot;&gt;</SAMP>'.  The string or symbol <VAR>name</VAR> can be
`<SAMP>author</SAMP>', `<SAMP>copyright</SAMP>', `<SAMP>keywords</SAMP>', `<SAMP>description</SAMP>',
`<SAMP>date</SAMP>', `<SAMP>robots</SAMP>', <small>...</small>.
</DL>
<P>

<A NAME="IDX300"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:http-equiv</B> <I>name content</I>
<DD>Returns a tag of HTTP information suitable for passing as the
third argument to <CODE>html:head</CODE>.  The tag produced is `<SAMP>&lt;META
HTTP-EQUIV=&quot;<VAR>name</VAR>&quot; CONTENT=&quot;<VAR>content</VAR>&quot;&gt;</SAMP>'.  The string or symbol <VAR>name</VAR> can be
`<SAMP>Expires</SAMP>', `<SAMP>PICS-Label</SAMP>', `<SAMP>Content-Type</SAMP>',
`<SAMP>Refresh</SAMP>', <small>...</small>.
</DL>
<P>

<A NAME="IDX301"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:meta-refresh</B> <I>delay uri</I>
<DD><P>

<A NAME="IDX302"></A>
<DT><U>Function:</U> <B>html:meta-refresh</B> <I>delay</I>
<DD></P>
<P>

Returns a tag suitable for passing as the third argument to
<CODE>html:head</CODE>.  If <VAR>uri</VAR> argument is supplied, then <VAR>delay</VAR> seconds after
displaying the page with this tag, Netscape or IE browsers will fetch
and display <VAR>uri</VAR>.  Otherwise, <VAR>delay</VAR> seconds after displaying the page with
this tag, Netscape or IE browsers will fetch and redisplay this page.
</P>
</DL>
<P>

<A NAME="IDX303"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:head</B> <I>title backlink tags <small>...</small></I>
<DD><P>

<A NAME="IDX304"></A>
<DT><U>Function:</U> <B>html:head</B> <I>title backlink</I>
<DD></P>
<P>

<A NAME="IDX305"></A>
<DT><U>Function:</U> <B>html:head</B> <I>title</I>
<DD></P>
<P>

Returns header string for an HTML page named <VAR>title</VAR>.  If <VAR>backlink</VAR> is a string,
it is used verbatim between the `<SAMP>H1</SAMP>' tags; otherwise <VAR>title</VAR> is
used.  If string arguments <VAR>tags</VAR> ... are supplied, then they are
included verbatim within the <TT>&lt;HEAD&gt;</TT> section.
</P>
</DL>
<P>

<A NAME="IDX306"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:body</B> <I>body <small>...</small></I>
<DD>Returns HTML string to end a page.
</DL>
<P>

<A NAME="IDX307"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:pre</B> <I>line1 line <small>...</small></I>
<DD>Returns the strings <VAR>line1</VAR>, <VAR>lines</VAR> as <EM>PRE</EM>formmated plain text
<A NAME="IDX308"></A>
(rendered in fixed-width font).  Newlines are inserted between <VAR>line1</VAR>,
<VAR>lines</VAR>.  HTML tags (`<SAMP>&lt;tag&gt;</SAMP>') within <VAR>lines</VAR> will be visible verbatim.
</DL>
<P>

<A NAME="IDX309"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:comment</B> <I>line1 line <small>...</small></I>
<DD>Returns the strings <VAR>line1</VAR> as HTML comments.
</DL>
<HR SIZE="6">
<A NAME="SEC70"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC69"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC71"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 4.6 HTML Forms </H2>
<!--docid::SEC70::-->
<P>

<A NAME="IDX310"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:form</B> <I>method action body <small>...</small></I>
<DD>The symbol <VAR>method</VAR> is either <CODE>get</CODE>, <CODE>head</CODE>, <CODE>post</CODE>,
<CODE>put</CODE>, or <CODE>delete</CODE>.  The strings <VAR>body</VAR> form the body of the
form.  <CODE>html:form</CODE> returns the HTML <EM>form</EM>.
<A NAME="IDX311"></A>
</DL>
<P>

<A NAME="IDX312"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:hidden</B> <I>name value</I>
<DD>Returns HTML string which will cause <VAR>name</VAR>=<VAR>value</VAR> in form.
</DL>
<P>

<A NAME="IDX313"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:checkbox</B> <I>pname default</I>
<DD>Returns HTML string for check box.
</DL>
<P>

<A NAME="IDX314"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:text</B> <I>pname default size <small>...</small></I>
<DD>Returns HTML string for one-line text box.
</DL>
<P>

<A NAME="IDX315"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:text-area</B> <I>pname default-list</I>
<DD>Returns HTML string for multi-line text box.
</DL>
<P>

<A NAME="IDX316"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:select</B> <I>pname arity default-list foreign-values</I>
<DD>Returns HTML string for pull-down menu selector.
</DL>
<P>

<A NAME="IDX317"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:buttons</B> <I>pname arity default-list foreign-values</I>
<DD>Returns HTML string for any-of selector.
</DL>
<P>

<A NAME="IDX318"></A>
</P>
<DL>
<DT><U>Function:</U> <B>form:submit</B> <I>submit-label command</I>
<DD><P>

<A NAME="IDX319"></A>
<DT><U>Function:</U> <B>form:submit</B> <I>submit-label</I>
<DD></P>
<P>

The string or symbol <VAR>submit-label</VAR> appears on the button which submits the form.
If the optional second argument <VAR>command</VAR> is given, then <CODE>*command*=<VAR>command</VAR></CODE>
and <CODE>*button*=<VAR>submit-label</VAR></CODE> are set in the query.  Otherwise,
<CODE>*command*=<VAR>submit-label</VAR></CODE> is set in the query.
</P>
</DL>
<P>

<A NAME="IDX320"></A>
</P>
<DL>
<DT><U>Function:</U> <B>form:image</B> <I>submit-label image-src</I>
<DD>The <VAR>image-src</VAR> appears on the button which submits the form.
</DL>
<P>

<A NAME="IDX321"></A>
</P>
<DL>
<DT><U>Function:</U> <B>form:reset</B>
<DD>Returns a string which generates a <EM>reset</EM> button.
<A NAME="IDX322"></A>
</DL>
<P>

<A NAME="IDX323"></A>
</P>
<DL>
<DT><U>Function:</U> <B>form:element</B> <I>pname arity default-list foreign-values</I>
<DD>Returns a string which generates an INPUT element for the field
named <VAR>pname</VAR>.  The element appears in the created form with its
representation determined by its <VAR>arity</VAR> and domain.  For domains which
are foreign-keys:
<P>

</P>
<DL COMPACT>
<DT><CODE>single</CODE>
<DD>select menu
<DT><CODE>optional</CODE>
<DD>select menu
<DT><CODE>nary</CODE>
<DD>check boxes
<DT><CODE>nary1</CODE>
<DD>check boxes
</DL>
<P>

If the foreign-key table has a field named `<SAMP>visible-name</SAMP>', then
the contents of that field are the names visible to the user for
those choices.  Otherwise, the foreign-key itself is visible.
</P>
<P>

For other types of domains:
</P>
<P>

</P>
<DL COMPACT>
<DT><CODE>single</CODE>
<DD>text area
<DT><CODE>optional</CODE>
<DD>text area
<DT><CODE>boolean</CODE>
<DD>check box
<DT><CODE>nary</CODE>
<DD>text area
<DT><CODE>nary1</CODE>
<DD>text area
</DL>
</DL>
<P>

<A NAME="IDX324"></A>
</P>
<DL>
<DT><U>Function:</U> <B>form:delimited</B> <I>pname doc aliat arity default-list foreign-values</I>
<DD><P>

Returns a HTML string for a form element embedded in a line of a
delimited list.  Apply map <CODE>form:delimited</CODE> to the list returned by
<CODE>command-&gt;p-specs</CODE>.
</P>
</DL>
<P>

<A NAME="IDX325"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:delimited-list</B> <I>row <small>...</small></I>
<DD>Wraps its arguments with delimited-list (`<SAMP>DL</SAMP>' command.
</DL>
<P>

<A NAME="IDX326"></A>
</P>
<DL>
<DT><U>Function:</U> <B>get-foreign-choices</B> <I>tab</I>
<DD>Returns a list of the `<SAMP>visible-name</SAMP>' or first fields of
table <VAR>tab</VAR>.
</DL>
<P>

<A NAME="IDX327"></A>
</P>
<DL>
<DT><U>Function:</U> <B>command-&gt;p-specs</B> <I>rdb command-table command</I>
<DD><P>

The symbol <VAR>command-table</VAR> names a command table in the <VAR>rdb</VAR> relational database.
The symbol <VAR>command</VAR> names a key in <VAR>command-table</VAR>.
</P>
<P>

<CODE>command-&gt;p-specs</CODE> returns a list of lists of <VAR>pname</VAR>, <VAR>doc</VAR>, <VAR>aliat</VAR>,
<VAR>arity</VAR>, <VAR>default-list</VAR>, and <VAR>foreign-values</VAR>.  The
returned list has one element for each parameter of command <VAR>command</VAR>.
</P>
<P>

This example demonstrates how to create a HTML-form for the `<SAMP>build</SAMP>'
command.
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(require (in-vicinity (implementation-vicinity) &quot;build.scm&quot;))
(call-with-output-file &quot;buildscm.html&quot;
  (lambda (port)
    (display
     (string-append
      (html:head 'commands)
      (html:body
       (sprintf #f &quot;&lt;H2&gt;%s:&lt;/H2&gt;&lt;BLOCKQUOTE&gt;%s&lt;/BLOCKQUOTE&gt;\\n&quot;
                (html:plain 'build)
                (html:plain ((comtab 'get 'documentation) 'build)))
       (html:form
        'post
        (or &quot;http://localhost:8081/buildscm&quot; &quot;/cgi-bin/build.cgi&quot;)
        (apply html:delimited-list
               (apply map form:delimited
                      (command-&gt;p-specs build '*commands* 'build)))
        (form:submit 'build)
        (form:reset))))
     port)))
</pre></td></tr></table></DL>
<P>

<A NAME="HTML Tables"></A>
<HR SIZE="6">
<A NAME="SEC71"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC70"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC72"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 4.7 HTML Tables </H2>
<!--docid::SEC71::-->
<P>

<CODE>(require 'db-&gt;html)</CODE>
<A NAME="IDX328"></A>
</P>
<P>

<A NAME="IDX329"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:table</B> <I>options row <small>...</small></I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX330"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:caption</B> <I>caption align</I>
<DD><P>

<A NAME="IDX331"></A>
<DT><U>Function:</U> <B>html:caption</B> <I>caption</I>
<DD><VAR>align</VAR> can be `<SAMP>top</SAMP>' or `<SAMP>bottom</SAMP>'.
</P>
</DL>
<P>

<A NAME="IDX332"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:heading</B> <I>columns</I>
<DD>Outputs a heading row for the currently-started table.
</DL>
<P>

<A NAME="IDX333"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:href-heading</B> <I>columns uris</I>
<DD>Outputs a heading row with column-names <VAR>columns</VAR> linked to URIs <VAR>uris</VAR>.
</DL>
<P>

<A NAME="IDX334"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:linked-row-converter</B> <I>k foreigns</I>
<DD><P>

The positive integer <VAR>k</VAR> is the primary-key-limit (number of
primary-keys) of the table.  <VAR>foreigns</VAR> is a list of the filenames of
foreign-key field pages and #f for non foreign-key fields.
</P>
<P>

<CODE>html:linked-row-converter</CODE> returns a procedure taking a row for its single argument.  This
returned procedure returns the html string for that table row.
</P>
</DL>
<P>

<A NAME="IDX335"></A>
</P>
<DL>
<DT><U>Function:</U> <B>table-name-&gt;filename</B> <I>table-name</I>
<DD><P>

Returns the symbol <VAR>table-name</VAR> converted to a filename.
</P>
</DL>
<P>

<A NAME="IDX336"></A>
</P>
<DL>
<DT><U>Function:</U> <B>table-&gt;linked-html</B> <I>caption db table-name match-key1 <small>...</small></I>
<DD><P>

Returns HTML string for <VAR>db</VAR> table <VAR>table-name</VAR>.  Every foreign-key value is
linked to the page (of the table) defining that key.
</P>
<P>

The optional <VAR>match-key1</VAR> <small>...</small> arguments restrict actions to a subset of
the table.  See section <A HREF="slib_6.html#SEC147">match-key</A>.
</P>
</DL>
<P>

<A NAME="IDX337"></A>
</P>
<DL>
<DT><U>Function:</U> <B>table-&gt;linked-page</B> <I>db table-name index-filename arg <small>...</small></I>
<DD><P>

Returns a complete HTML page.  The string <VAR>index-filename</VAR> names the page which
refers to this one.
</P>
<P>

The optional <VAR>args</VAR> <small>...</small> arguments restrict actions to a subset of
the table.  See section <A HREF="slib_6.html#SEC147">match-key</A>.
</P>
</DL>
<P>

<A NAME="IDX338"></A>
</P>
<DL>
<DT><U>Function:</U> <B>catalog-&gt;html</B> <I>db caption arg <small>...</small></I>
<DD><P>

Returns HTML string for the catalog table of <VAR>db</VAR>.
</P>
</DL>
<HR SIZE="6">
<A NAME="SEC72"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC71"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC73"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.7.1 HTML editing tables </H3>
<!--docid::SEC72::-->
<P>

A client can modify one row of an editable table at a time.
For any change submitted, these routines check if that row has been
modified during the time the user has been editing the form.  If so,
an error page results.
</P>
<P>

The behavior of edited rows is:
</P>
<P>

<UL>
<LI>
If no fields are changed, then no change is made to the table.
<LI>
If the primary keys equal null-keys (parameter defaults), and no other
user has modified that row, then that row is deleted.
<LI>
If only primary keys are changed, there are non-key fields, and no
row with the new keys is in the table, then the old row is
deleted and one with the new keys is inserted.
<LI>
If only non-key fields are changed, and that row has not been
modified by another user, then the row is changed to reflect the
fields.
<LI>
If both keys and non-key fields are changed, and no row with the
new keys is in the table, then a row is created with the new
keys and fields.
<LI>
If fields are changed, all fields are primary keys, and no row with
the new keys is in the table, then a row is created with the new
keys.
</UL>
<P>

After any change to the table, a <CODE>sync-database</CODE> of the
database is performed.
</P>
<P>

<A NAME="IDX339"></A>
</P>
<DL>
<DT><U>Function:</U> <B>command:modify-table</B> <I>table-name null-keys update delete retrieve</I>
<DD><P>

<A NAME="IDX340"></A>
<DT><U>Function:</U> <B>command:modify-table</B> <I>table-name null-keys update delete</I>
<DD></P>
<P>

<A NAME="IDX341"></A>
<DT><U>Function:</U> <B>command:modify-table</B> <I>table-name null-keys update</I>
<DD></P>
<P>

<A NAME="IDX342"></A>
<DT><U>Function:</U> <B>command:modify-table</B> <I>table-name null-keys</I>
<DD></P>
<P>

Returns procedure (of <VAR>db</VAR>) which returns procedure to modify
row of <VAR>table-name</VAR>.  <VAR>null-keys</VAR> is the list of <EM>null</EM> keys indicating the row is
<A NAME="IDX343"></A>
to be deleted when any matches its corresponding primary key.
Optional arguments <VAR>update</VAR>, <VAR>delete</VAR>, and <VAR>retrieve</VAR> default to the <CODE>row:update</CODE>,
<CODE>row:delete</CODE>, and <CODE>row:retrieve</CODE> of <VAR>table-name</VAR> in <VAR>db</VAR>.
</P>
</DL>
<P>

<A NAME="IDX344"></A>
</P>
<DL>
<DT><U>Function:</U> <B>command:make-editable-table</B> <I>rdb table-name arg <small>...</small></I>
<DD>Given <VAR>table-name</VAR> in <VAR>rdb</VAR>, creates parameter and <CODE>*command*</CODE> tables
for editing one row of <VAR>table-name</VAR> at a time.  <CODE>command:make-editable-table</CODE> returns a procedure taking a
row argument which returns the HTML string for editing that row.
<P>

Optional <VAR>args</VAR> are expressions (lists) added to the call to
<CODE>command:modify-table</CODE>.
</P>
<P>

The domain name of a column determines the expected arity of the data
stored in that column.  Domain names ending in:
</P>
<P>

</P>
<DL COMPACT>
<DT>`<SAMP>*</SAMP>'
<DD>have arity `<SAMP>nary</SAMP>';
<DT>`<SAMP>+</SAMP>'
<DD>have arity `<SAMP>nary1</SAMP>'.
</DL>
</DL>
<P>

<A NAME="IDX345"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:editable-row-converter</B> <I>k names edit-point edit-converter</I>
<DD><P>

The positive integer <VAR>k</VAR> is the primary-key-limit (number of
primary-keys) of the table.  <VAR>names</VAR> is a list of the field-names.  <VAR>edit-point</VAR> is
the list of primary-keys denoting the row to edit (or #f).  <VAR>edit-converter</VAR> is the
procedure called with <VAR>k</VAR>, <VAR>names</VAR>, and the row to edit.
</P>
<P>

<CODE>html:editable-row-converter</CODE> returns a procedure taking a row for its single argument.  This
returned procedure returns the html string for that table row.
</P>
<P>

Each HTML table constructed using <CODE>html:editable-row-converter</CODE> has first <VAR>k</VAR> fields (typically
the primary key fields) of each row linked to a text encoding of these
fields (the result of calling <CODE>row-&gt;anchor</CODE>).  The page so
referenced typically allows the user to edit fields of that row.
</P>
</DL>
<HR SIZE="6">
<A NAME="SEC73"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC72"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC74"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.7.2 HTML databases </H3>
<!--docid::SEC73::-->
<P>

<A NAME="IDX346"></A>
</P>
<DL>
<DT><U>Function:</U> <B>db-&gt;html-files</B> <I>db dir index-filename caption</I>
<DD><VAR>db</VAR> must be a relational database.  <VAR>dir</VAR> must be #f or a
non-empty string naming an existing sub-directory of the current
directory.
<P>

<CODE>db-&gt;html-files</CODE> creates an html page for each table in the database <VAR>db</VAR> in the
sub-directory named <VAR>dir</VAR>, or the current directory if <VAR>dir</VAR> is #f.  The
top level page with the catalog of tables (captioned <VAR>caption</VAR>) is written
to a file named <VAR>index-filename</VAR>.
</P>
</DL>
<P>

<A NAME="IDX347"></A>
</P>
<DL>
<DT><U>Function:</U> <B>db-&gt;html-directory</B> <I>db dir index-filename</I>
<DD><P>

<A NAME="IDX348"></A>
<DT><U>Function:</U> <B>db-&gt;html-directory</B> <I>db dir</I>
<DD><VAR>db</VAR> must be a relational database.  <VAR>dir</VAR> must be a non-empty
string naming an existing sub-directory of the current directory or
one to be created.  The optional string <VAR>index-filename</VAR> names the filename of the
top page, which defaults to `<TT>index.html</TT>'.
</P>
<P>

<CODE>db-&gt;html-directory</CODE> creates sub-directory <VAR>dir</VAR> if neccessary, and calls
<CODE>(db-&gt;html-files <VAR>db</VAR> <VAR>dir</VAR> <VAR>index-filename</VAR> <VAR>dir</VAR>)</CODE>.  The `<SAMP>file:</SAMP>' URI of <VAR>index-filename</VAR> is
returned.
</P>
</DL>
<P>

<A NAME="IDX349"></A>
</P>
<DL>
<DT><U>Function:</U> <B>db-&gt;netscape</B> <I>db dir index-filename</I>
<DD><P>

<A NAME="IDX350"></A>
<DT><U>Function:</U> <B>db-&gt;netscape</B> <I>db dir</I>
<DD><CODE>db-&gt;netscape</CODE> is just like <CODE>db-&gt;html-directory</CODE>, but calls
<CODE>browse-url</CODE> with the uri for the top page after the
pages are created.
</P>
</DL>
<P>

<A NAME="HTTP and CGI"></A>
<HR SIZE="6">
<A NAME="SEC74"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC73"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC75"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 4.8 HTTP and CGI </H2>
<!--docid::SEC74::-->
<P>

<CODE>(require 'http)</CODE> or <CODE>(require 'cgi)</CODE>
<A NAME="IDX351"></A>
<A NAME="IDX352"></A>
</P>
<P>

<A NAME="IDX353"></A>
</P>
<DL>
<DT><U>Function:</U> <B>http:header</B> <I>alist</I>
<DD>Returns a string containing lines for each element of <VAR>alist</VAR>; the
<CODE>car</CODE> of which is followed by `<SAMP>: </SAMP>', then the <CODE>cdr</CODE>.
</DL>
<P>

<A NAME="IDX354"></A>
</P>
<DL>
<DT><U>Function:</U> <B>http:content</B> <I>alist body <small>...</small></I>
<DD>Returns the concatenation of strings <VAR>body</VAR> with the
<CODE>(http:header <VAR>alist</VAR>)</CODE> and the `<SAMP>Content-Length</SAMP>' prepended.
</DL>
<P>

<A NAME="IDX355"></A>
</P>
<DL>
<DT><U>Variable:</U> <B>*http:byline*</B>
<DD>String appearing at the bottom of error pages.
</DL>
<P>

<A NAME="IDX356"></A>
</P>
<DL>
<DT><U>Function:</U> <B>http:error-page</B> <I>status-code reason-phrase html-string <small>...</small></I>
<DD><VAR>status-code</VAR> and <VAR>reason-phrase</VAR> should be an integer and string as specified in
<CITE>RFC 2068</CITE>.  The returned page (string) will show the <VAR>status-code</VAR> and <VAR>reason-phrase</VAR>
and any additional <VAR>html-strings</VAR> <small>...</small>; with <VAR>*http:byline*</VAR> or SLIB's
default at the bottom.
</DL>
<P>

<A NAME="IDX357"></A>
</P>
<DL>
<DT><U>Function:</U> <B>http:forwarding-page</B> <I>title delay uri html-string <small>...</small></I>
<DD>The string or symbol <VAR>title</VAR> is the page title.  <VAR>delay</VAR> is a non-negative
integer.  The <VAR>html-strings</VAR> <small>...</small> are typically used to explain to the user why
this page is being forwarded.
<P>

<CODE>http:forwarding-page</CODE> returns an HTML string for a page which automatically forwards to
<VAR>uri</VAR> after <VAR>delay</VAR> seconds.  The returned page (string) contains any <VAR>html-strings</VAR>
<small>...</small> followed by a manual link to <VAR>uri</VAR>, in case the browser does not
forward automatically.
</P>
</DL>
<P>

<A NAME="IDX358"></A>
</P>
<DL>
<DT><U>Function:</U> <B>http:serve-query</B> <I>serve-proc input-port output-port</I>
<DD>reads the <EM>URI</EM> and <EM>query-string</EM> from <VAR>input-port</VAR>.  If the
<A NAME="IDX359"></A>
<A NAME="IDX360"></A>
query is a valid `<SAMP>&quot;POST&quot;</SAMP>' or `<SAMP>&quot;GET&quot;</SAMP>' query, then <CODE>http:serve-query</CODE> calls
<VAR>serve-proc</VAR> with three arguments, the <VAR>request-line</VAR>, <VAR>query-string</VAR>,
and <VAR>header-alist</VAR>.  Otherwise, <CODE>http:serve-query</CODE> calls <VAR>serve-proc</VAR> with the
<VAR>request-line</VAR>, #f, and <VAR>header-alist</VAR>.
<P>

If <VAR>serve-proc</VAR> returns a string, it is sent to <VAR>output-port</VAR>.  If <VAR>serve-proc</VAR> returns a list,
then an error page with number 525 and strings from the list.  If <VAR>serve-proc</VAR>
returns #f, then a `<SAMP>Bad Request</SAMP>' (400) page is sent to <VAR>output-port</VAR>.
</P>
<P>

Otherwise, <CODE>http:serve-query</CODE> replies (to <VAR>output-port</VAR>) with appropriate HTML describing the
problem.
</P>
</DL>
<P>

This example services HTTP queries from <VAR>port-number</VAR>:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>
(define socket (make-stream-socket AF_INET 0))
(and (socket:bind socket port-number) ; AF_INET INADDR_ANY
     (socket:listen socket 10)        ; Queue up to 10 requests.
     (dynamic-wind
         (lambda () #f)
         (lambda ()
           (do ((port (socket:accept socket) (socket:accept socket)))
               (#f)
             (let ((iport (duplicate-port port &quot;r&quot;))
                   (oport (duplicate-port port &quot;w&quot;)))
               (http:serve-query build:serve iport oport)
               (close-port iport)
               (close-port oport))
             (close-port port)))
         (lambda () (close-port socket))))
</pre></td></tr></table><P>

<A NAME="IDX361"></A>
</P>
<DL>
<DT><U>Function:</U> <B>cgi:serve-query</B> <I>serve-proc</I>
<DD>reads the <EM>URI</EM> and <EM>query-string</EM> from
<A NAME="IDX362"></A>
<A NAME="IDX363"></A>
<CODE>(current-input-port)</CODE>.  If the query is a valid `<SAMP>&quot;POST&quot;</SAMP>'
or `<SAMP>&quot;GET&quot;</SAMP>' query, then <CODE>cgi:serve-query</CODE> calls <VAR>serve-proc</VAR> with three arguments, the
<VAR>request-line</VAR>, <VAR>query-string</VAR>, and <VAR>header-alist</VAR>.
Otherwise, <CODE>cgi:serve-query</CODE> calls <VAR>serve-proc</VAR> with the <VAR>request-line</VAR>, #f, and
<VAR>header-alist</VAR>.
<P>

If <VAR>serve-proc</VAR> returns a string, it is sent to <CODE>(current-input-port)</CODE>.
If <VAR>serve-proc</VAR> returns a list, then an error page with number 525 and strings
from the list.  If <VAR>serve-proc</VAR> returns #f, then a `<SAMP>Bad Request</SAMP>' (400)
page is sent to <CODE>(current-input-port)</CODE>.
</P>
<P>

Otherwise, <CODE>cgi:serve-query</CODE> replies (to <CODE>(current-input-port)</CODE>) with
appropriate HTML describing the problem.
</P>
</DL>
<P>

<A NAME="IDX364"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-query-alist-command-server</B> <I>rdb command-table</I>
<DD><P>

<A NAME="IDX365"></A>
<DT><U>Function:</U> <B>make-query-alist-command-server</B> <I>rdb command-table #t</I>
<DD></P>
<P>

Returns a procedure of one argument.  When that procedure is called
with a <VAR>query-alist</VAR> (as returned by <CODE>uri:decode-query</CODE>, the
value of the `<SAMP>*command*</SAMP>' association will be the command invoked
in <VAR>command-table</VAR>.  If `<SAMP>*command*</SAMP>' is not in the <VAR>query-alist</VAR> then the
value of `<SAMP>*suggest*</SAMP>' is tried.  If neither name is in the
<VAR>query-alist</VAR>, then the literal value `<SAMP>*default*</SAMP>' is tried in
<VAR>command-table</VAR>.
</P>
<P>

If optional third argument is non-false, then the command is called
with just the parameter-list; otherwise, command is called with the
arguments described in its table.
</P>
</DL>
<P>

<A NAME="Parsing HTML"></A>
<HR SIZE="6">
<A NAME="SEC75"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC74"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC76"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 4.9 Parsing HTML </H2>
<!--docid::SEC75::-->
<P>

<CODE>(require 'html-for-each)</CODE>
<A NAME="IDX366"></A>
</P>
<P>

<A NAME="IDX367"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html-for-each</B> <I>file word-proc markup-proc white-proc newline-proc</I>
<DD><P>

<VAR>file</VAR> is an input port or a string naming an existing file containing
HTML text.
<VAR>word-proc</VAR> is a procedure of one argument or #f.
<VAR>markup-proc</VAR> is a procedure of one argument or #f.
<VAR>white-proc</VAR> is a procedure of one argument or #f.
<VAR>newline-proc</VAR> is a procedure of no arguments or #f.
</P>
<P>

<CODE>html-for-each</CODE> opens and reads characters from port <VAR>file</VAR> or the file named by
string <VAR>file</VAR>.  Sequential groups of characters are assembled into
strings which are either
</P>
<P>

<UL>
<LI>
enclosed by `<SAMP>&lt;</SAMP>' and `<SAMP>&gt;</SAMP>' (hypertext markups or comments);
<LI>
end-of-line;
<LI>
whitespace; or
<LI>
none of the above (words).
</UL>
<P>

Procedures are called according to these distinctions in order of
the string's occurrence in <VAR>file</VAR>.
</P>
<P>

<VAR>newline-proc</VAR> is called with no arguments for end-of-line <EM>not within a
markup or comment</EM>.
</P>
<P>

<VAR>white-proc</VAR> is called with strings of non-newline whitespace.
</P>
<P>

<VAR>markup-proc</VAR> is called with hypertext markup strings (including `<SAMP>&lt;</SAMP>' and
`<SAMP>&gt;</SAMP>').
</P>
<P>

<VAR>word-proc</VAR> is called with the remaining strings.
</P>
<P>

<CODE>html-for-each</CODE> returns an unspecified value.
</P>
</DL>
<P>

<A NAME="IDX368"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:read-title</B> <I>file limit</I>
<DD><P>

<A NAME="IDX369"></A>
<DT><U>Function:</U> <B>html:read-title</B> <I>file</I>
<DD><VAR>file</VAR> is an input port or a string naming an existing file containing
HTML text.  If supplied, <VAR>limit</VAR> must be an integer.  <VAR>limit</VAR> defaults to
1000.
</P>
<P>

<CODE>html:read-title</CODE> opens and reads HTML from port <VAR>file</VAR> or the file named by string <VAR>file</VAR>,
until reaching the (mandatory) `<SAMP>TITLE</SAMP>' field.  <CODE>html:read-title</CODE> returns the
title string with adjacent whitespaces collapsed to one space.  <CODE>html:read-title</CODE>
returns #f if the title field is empty, absent, if the first
character read from <VAR>file</VAR> is not `<SAMP>#\&lt;</SAMP>', or if the end of title is
not found within the first (approximately) <VAR>limit</VAR> words.
</P>
</DL>
<P>

<A NAME="IDX370"></A>
</P>
<DL>
<DT><U>Function:</U> <B>htm-fields</B> <I>htm</I>
<DD><P>

<VAR>htm</VAR> is a hypertext markup string.
</P>
<P>

If <VAR>htm</VAR> is a (hypertext) comment, then <CODE>htm-fields</CODE> returns #f.
Otherwise <CODE>htm-fields</CODE> returns the hypertext element symbol (created by
<CODE>string-ci-&gt;symbol</CODE>) consed onto an association list of the
attribute name-symbols and values.  Each value is a number or
string; or #t if the name had no value assigned within the markup.
</P>
</DL>
<P>

<A NAME="URI"></A>
<HR SIZE="6">
<A NAME="SEC76"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC75"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC78"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 4.10 URI </H2>
<!--docid::SEC76::-->
<P>

<CODE>(require 'uri)</CODE>
<A NAME="IDX371"></A>
</P>
<P>

Implements <EM>Uniform Resource Identifiers</EM> (URI) as
<A NAME="IDX372"></A>
described in RFC 2396.
</P>
<P>

<A NAME="IDX373"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-uri</B>
<DD><P>

<A NAME="IDX374"></A>
<DT><U>Function:</U> <B>make-uri</B> <I>fragment</I>
<DD></P>
<P>

<A NAME="IDX375"></A>
<DT><U>Function:</U> <B>make-uri</B> <I>query fragment</I>
<DD></P>
<P>

<A NAME="IDX376"></A>
<DT><U>Function:</U> <B>make-uri</B> <I>path query fragment</I>
<DD></P>
<P>

<A NAME="IDX377"></A>
<DT><U>Function:</U> <B>make-uri</B> <I>authority path query fragment</I>
<DD></P>
<P>

<A NAME="IDX378"></A>
<DT><U>Function:</U> <B>make-uri</B> <I>scheme authority path query fragment</I>
<DD></P>
<P>

Returns a Uniform Resource Identifier string from component arguments.
</P>
</DL>
<P>

<A NAME="IDX379"></A>
</P>
<DL>
<DT><U>Function:</U> <B>uri:make-path</B> <I>path</I>
<DD><P>

Returns a URI string combining the components of list <VAR>path</VAR>.
</P>
</DL>
<P>

<A NAME="IDX380"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:anchor</B> <I>name</I>
<DD>Returns a string which defines this location in the (HTML) file
as <VAR>name</VAR>.  The hypertext `<SAMP>&lt;A HREF=&quot;#<VAR>name</VAR>&quot;&gt;</SAMP>' will link to this point.
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(html:anchor &quot;(section 7)&quot;)
=>
&quot;&lt;A NAME=\&quot;(section%207)\&quot;&gt;&lt;/A&gt;&quot;
</pre></td></tr></table></DL>
<P>

<A NAME="IDX381"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:link</B> <I>uri highlighted</I>
<DD>Returns a string which links the <VAR>highlighted</VAR> text to <VAR>uri</VAR>.
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(html:link (make-uri &quot;(section 7)&quot;) &quot;section 7&quot;)
=>
&quot;&lt;A HREF=\&quot;#(section%207)\&quot;&gt;section 7&lt;/A&gt;&quot;
</pre></td></tr></table></DL>
<P>

<A NAME="IDX382"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:base</B> <I>uri</I>
<DD>Returns a string specifying the <EM>base</EM> <VAR>uri</VAR> of a document, for
<A NAME="IDX383"></A>
inclusion in the HEAD of the document (see section <A HREF="slib_4.html#SEC69">head</A>).
</DL>
<P>

<A NAME="IDX384"></A>
</P>
<DL>
<DT><U>Function:</U> <B>html:isindex</B> <I>prompt</I>
<DD>Returns a string specifying the search <VAR>prompt</VAR> of a document, for
inclusion in the HEAD of the document (see section <A HREF="slib_4.html#SEC69">head</A>).
</DL>
<P>

<A NAME="IDX385"></A>
</P>
<DL>
<DT><U>Function:</U> <B>uri-&gt;tree</B> <I>uri-reference base-tree</I>
<DD><P>

<A NAME="IDX386"></A>
<DT><U>Function:</U> <B>uri-&gt;tree</B> <I>uri-reference</I>
<DD></P>
<P>

Returns a list of 5 elements corresponding to the parts
(<VAR>scheme</VAR> <VAR>authority</VAR> <VAR>path</VAR> <VAR>query</VAR> <VAR>fragment</VAR>)
of string <VAR>uri-reference</VAR>.  Elements corresponding to absent parts are #f.
</P>
<P>

The <VAR>path</VAR> is a list of strings.  If the first string is empty,
then the path is absolute; otherwise relative.  The optional <VAR>base-tree</VAR> is a
tree as returned by <CODE>uri-&gt;tree</CODE>; and is used as the base address for relative
URIs.
</P>
<P>

If the <VAR>authority</VAR> component is a
<EM>Server-based Naming Authority</EM>, then it is a list of the
<A NAME="IDX387"></A>
<VAR>userinfo</VAR>, <VAR>host</VAR>, and <VAR>port</VAR> strings (or #f).  For other
types of <VAR>authority</VAR> components the <VAR>authority</VAR> will be a
string.
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(uri-&gt;tree &quot;http://www.ics.uci.edu/pub/ietf/uri/#Related&quot;)
=>
(http &quot;www.ics.uci.edu&quot; (&quot;&quot; &quot;pub&quot; &quot;ietf&quot; &quot;uri&quot; &quot;&quot;) #f &quot;Related&quot;)
</pre></td></tr></table></DL>
<P>

<A NAME="IDX388"></A>
</P>
<DL>
<DT><U>Function:</U> <B>uri:split-fields</B> <I>txt chr</I>
<DD><P>

Returns a list of <VAR>txt</VAR> split at each occurrence of <VAR>chr</VAR>.  <VAR>chr</VAR> does not
appear in the returned list of strings.
</P>
</DL>
<P>

<A NAME="IDX389"></A>
</P>
<DL>
<DT><U>Function:</U> <B>uri:decode-query</B> <I>query-string</I>
<DD>Converts a <EM>URI</EM> encoded <VAR>query-string</VAR> to a query-alist.
<A NAME="IDX390"></A>
</DL>
<P>

<CODE>uric:</CODE> prefixes indicate procedures dealing with
URI-components.
</P>
<P>

<A NAME="IDX391"></A>
</P>
<DL>
<DT><U>Function:</U> <B>uric:encode</B> <I>uri-component allows</I>
<DD>Returns a copy of the string <VAR>uri-component</VAR> in which all <EM>unsafe</EM> octets
<A NAME="IDX392"></A>
(as defined in RFC 2396) have been `<SAMP>%</SAMP>' <EM>escaped</EM>.
<A NAME="IDX393"></A>
<CODE>uric:decode</CODE> decodes strings encoded by <CODE>uric:encode</CODE>.
</DL>
<P>

<A NAME="IDX394"></A>
</P>
<DL>
<DT><U>Function:</U> <B>uric:decode</B> <I>uri-component</I>
<DD>Returns a copy of the string <VAR>uri-component</VAR> in which each `<SAMP>%</SAMP>' escaped
characters in <VAR>uri-component</VAR> is replaced with the character it encodes.  This
routine is useful for showing URI contents on error pages.
</DL>
<P>

<A NAME="IDX395"></A>
</P>
<DL>
<DT><U>Function:</U> <B>uri:path-&gt;keys</B> <I>path-list ptypes</I>
<DD><VAR>path-list</VAR> is a path-list as returned by <CODE>uri:split-fields</CODE>.  <CODE>uri:path-&gt;keys</CODE>
returns a list of items returned by <CODE>uri:decode-path</CODE>, coerced
to types <VAR>ptypes</VAR>.
</DL>
<A NAME="SEC77"></A>
<H3> File-system Locators and Predicates </H3>
<!--docid::SEC77::-->
<P>

<A NAME="IDX396"></A>
</P>
<DL>
<DT><U>Function:</U> <B>path-&gt;uri</B> <I>path</I>
<DD>Returns a URI-string for <VAR>path</VAR> on the local host.
</DL>
<P>

<A NAME="IDX397"></A>
</P>
<DL>
<DT><U>Function:</U> <B>absolute-uri?</B> <I>str</I>
<DD>Returns #t if <VAR>str</VAR> is an absolute-URI as indicated by a
syntactically valid (per RFC 2396) <EM>scheme</EM>; otherwise returns
<A NAME="IDX398"></A>
#f.
</DL>
<P>

<A NAME="IDX399"></A>
</P>
<DL>
<DT><U>Function:</U> <B>absolute-path?</B> <I>file-name</I>
<DD>Returns #t if <VAR>file-name</VAR> is a fully specified pathname (does not
depend on the current working directory); otherwise returns #f.
</DL>
<P>

<A NAME="IDX400"></A>
</P>
<DL>
<DT><U>Function:</U> <B>null-directory?</B> <I>str</I>
<DD>Returns #t if changing directory to <VAR>str</VAR> would leave the current
directory unchanged; otherwise returns #f.
</DL>
<P>

<A NAME="IDX401"></A>
</P>
<DL>
<DT><U>Function:</U> <B>glob-pattern?</B> <I>str</I>
<DD>Returns #t if the string <VAR>str</VAR> contains characters used for
specifying glob patterns, namely `<SAMP>*</SAMP>', `<SAMP>?</SAMP>', or `<SAMP>[</SAMP>'.
</DL>
Before RFC 2396, the <EM>File Transfer Protocol</EM> (FTP) served a
<A NAME="IDX402"></A>
similar purpose.
<P>

<A NAME="IDX403"></A>
</P>
<DL>
<DT><U>Function:</U> <B>parse-ftp-address</B> <I>uri</I>
<DD><P>

Returns a list of the decoded FTP <VAR>uri</VAR>; or #f if indecipherable.  FTP
<EM>Uniform Resource Locator</EM>, <EM>ange-ftp</EM>, and <EM>getit</EM>
<A NAME="IDX404"></A>
<A NAME="IDX405"></A>
<A NAME="IDX406"></A>
formats are handled.  The returned list has four elements which are
strings or #f:
</P>
<P>

<OL>
<LI>
username
<LI>
password
<LI>
remote-site
<LI>
remote-directory
</OL>
</DL>
<P>

<A NAME="Printing Scheme"></A>
<HR SIZE="6">
<A NAME="SEC78"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC76"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC79"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 4.11 Printing Scheme </H2>
<!--docid::SEC78::-->
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC79">4.11.1 Generic-Write</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'generic-write</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC80">4.11.2 Object-To-String</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'object-&gt;string</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC81">4.11.3 Pretty-Print</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'pretty-print, 'pprint-file</TD></TR>
</TABLE>
<P>

<A NAME="Generic-Write"></A>
<HR SIZE="6">
<A NAME="SEC79"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC78"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC80"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC78"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.11.1 Generic-Write </H3>
<!--docid::SEC79::-->
<P>

<CODE>(require 'generic-write)</CODE>
<A NAME="IDX407"></A>
</P>
<P>

<CODE>generic-write</CODE> is a procedure that transforms a Scheme data value
(or Scheme program expression) into its textual representation and
prints it.  The interface to the procedure is sufficiently general to
easily implement other useful formatting procedures such as pretty
printing, output to a string and truncated output.
</P>
<P>

<A NAME="IDX408"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>generic-write</B> <I>obj display? width output</I>
<DD><DL COMPACT>
<DT><VAR>obj</VAR>
<DD>Scheme data value to transform.
<DT><VAR>display?</VAR>
<DD>Boolean, controls whether characters and strings are quoted.
<DT><VAR>width</VAR>
<DD>Extended boolean, selects format:
<DL COMPACT>
<DT>#f
<DD>single line format
<DT>integer &gt; 0
<DD>pretty-print (value = max nb of chars per line)
</DL>
<DT><VAR>output</VAR>
<DD>Procedure of 1 argument of string type, called repeatedly with
successive substrings of the textual representation.  This procedure can
return <CODE>#f</CODE> to stop the transformation.
</DL>
<P>

The value returned by <CODE>generic-write</CODE> is undefined.
</P>
<P>

Examples:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(write obj) == (generic-write obj #f #f <VAR>display-string</VAR>)
(display obj) == (generic-write obj #t #f <VAR>display-string</VAR>)
</pre></td></tr></table>where
<TABLE><tr><td>&nbsp;</td><td class=example><pre><VAR>display-string</VAR> ==
(lambda (s) (for-each write-char (string-&gt;list s)) #t)
</pre></td></tr></table></DL>
<P>

<A NAME="Object-To-String"></A>
<HR SIZE="6">
<A NAME="SEC80"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC79"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC81"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC78"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.11.2 Object-To-String </H3>
<!--docid::SEC80::-->
<P>

<CODE>(require 'object-&gt;string)</CODE>
<A NAME="IDX409"></A>
</P>
<P>

<A NAME="IDX410"></A>
</P>
<DL>
<DT><U>Function:</U> <B>object-&gt;string</B> <I>obj</I>
<DD>Returns the textual representation of <VAR>obj</VAR> as a string.
</DL>
<P>

<A NAME="IDX411"></A>
</P>
<DL>
<DT><U>Function:</U> <B>object-&gt;limited-string</B> <I>obj limit</I>
<DD>Returns the textual representation of <VAR>obj</VAR> as a string of length
at most <VAR>limit</VAR>.
</DL>
<P>

<A NAME="Pretty-Print"></A>
<HR SIZE="6">
<A NAME="SEC81"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC80"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC82"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC78"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.11.3 Pretty-Print </H3>
<!--docid::SEC81::-->
<P>

<CODE>(require 'pretty-print)</CODE>
<A NAME="IDX412"></A>
</P>
<P>

<A NAME="IDX413"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>pretty-print</B> <I>obj</I>
<DD><A NAME="IDX414"></A>
<DT><U>Procedure:</U> <B>pretty-print</B> <I>obj port</I>
<DD><P>

<CODE>pretty-print</CODE>s <VAR>obj</VAR> on <VAR>port</VAR>.  If <VAR>port</VAR> is not
specified, <CODE>current-output-port</CODE> is used.
</P>
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(pretty-print '((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)))
   -| ((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))
</pre></td></tr></table></DL>
<P>

<A NAME="IDX415"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>pretty-print-&gt;string</B> <I>obj</I>
<DD><A NAME="IDX416"></A>
<DT><U>Procedure:</U> <B>pretty-print-&gt;string</B> <I>obj width</I>
<DD><P>

Returns the string of <VAR>obj</VAR> <CODE>pretty-print</CODE>ed in <VAR>width</VAR>
columns.  If <VAR>width</VAR> is not specified, <CODE>(output-port-width)</CODE> is
used.
</P>
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(pretty-print-&gt;string '((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)))
=>
&quot;((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))
&quot;
(pretty-print-&gt;string '((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))
                      16)
=>
&quot;((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))
&quot;
</pre></td></tr></table></DL>
<P>

<CODE>(require 'pprint-file)</CODE>
<A NAME="IDX417"></A>
</P>
<P>

<A NAME="IDX418"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>pprint-file</B> <I>infile</I>
<DD><A NAME="IDX419"></A>
<DT><U>Procedure:</U> <B>pprint-file</B> <I>infile outfile</I>
<DD>Pretty-prints all the code in <VAR>infile</VAR>.  If <VAR>outfile</VAR> is
specified, the output goes to <VAR>outfile</VAR>, otherwise it goes to
<CODE>(current-output-port)</CODE>.
</DL>
<P>

<A NAME="IDX420"></A>
</P>
<DL>
<DT><U>Function:</U> <B>pprint-filter-file</B> <I>infile proc outfile</I>
<DD><A NAME="IDX421"></A>
<DT><U>Function:</U> <B>pprint-filter-file</B> <I>infile proc</I>
<DD><VAR>infile</VAR> is a port or a string naming an existing file.  Scheme
source code expressions and definitions are read from the port (or file)
and <VAR>proc</VAR> is applied to them sequentially.
<P>

<VAR>outfile</VAR> is a port or a string.  If no <VAR>outfile</VAR> is specified
then <CODE>current-output-port</CODE> is assumed.  These expanded expressions
are then <CODE>pretty-print</CODE>ed to this port.
</P>
<P>

Whitepsace and comments (introduced by <CODE>;</CODE>) which are not part of
scheme expressions are reproduced in the output.  This procedure does
not affect the values returned by <CODE>current-input-port</CODE> and
<CODE>current-output-port</CODE>.
</P>
</DL>
<P>

<CODE>pprint-filter-file</CODE> can be used to pre-compile macro-expansion and
thus can reduce loading time.  The following will write into
`<TT>exp-code.scm</TT>' the result of expanding all defmacros in
`<TT>code.scm</TT>'.
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(require 'pprint-file)
<A NAME="IDX422"></A>(require 'defmacroexpand)
<A NAME="IDX423"></A>(defmacro:load &quot;my-macros.scm&quot;)
(pprint-filter-file &quot;code.scm&quot; defmacro:expand* &quot;exp-code.scm&quot;)
</pre></td></tr></table><P>

<A NAME="Time and Date"></A>
<HR SIZE="6">
<A NAME="SEC82"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC81"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC83"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 4.12 Time and Date </H2>
<!--docid::SEC82::-->
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC83">4.12.1 Time Zone</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC84">4.12.2 Posix Time</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'posix-time</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_4.html#SEC85">4.12.3 Common-Lisp Time</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'common-lisp-time</TD></TR>
</TABLE>
<P>

If <CODE>(provided? 'current-time)</CODE>:
</P>
<P>

The procedures <CODE>current-time</CODE>, <CODE>difftime</CODE>, and
<CODE>offset-time</CODE> deal with a <EM>calendar time</EM> datatype
<A NAME="IDX424"></A>
<A NAME="IDX425"></A>
which may or may not be disjoint from other Scheme datatypes.
</P>
<P>

<A NAME="IDX426"></A>
</P>
<DL>
<DT><U>Function:</U> <B>current-time</B>
<DD>Returns the time since 00:00:00 GMT, January 1, 1970, measured in
seconds.  Note that the reference time is different from the reference
time for <CODE>get-universal-time</CODE> in <A HREF="slib_4.html#SEC85">4.12.3 Common-Lisp Time</A>.
</DL>
<P>

<A NAME="IDX427"></A>
</P>
<DL>
<DT><U>Function:</U> <B>difftime</B> <I>caltime1 caltime0</I>
<DD>Returns the difference (number of seconds) between twe calendar times:
<VAR>caltime1</VAR> - <VAR>caltime0</VAR>.  <VAR>caltime0</VAR> may also be a number.
</DL>
<P>

<A NAME="IDX428"></A>
</P>
<DL>
<DT><U>Function:</U> <B>offset-time</B> <I>caltime offset</I>
<DD>Returns the calendar time of <VAR>caltime</VAR> offset by <VAR>offset</VAR> number
of seconds <CODE>(+ caltime offset)</CODE>.
</DL>
<P>

<A NAME="Time Zone"></A>
<HR SIZE="6">
<A NAME="SEC83"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC82"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC84"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC82"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.12.1 Time Zone </H3>
<!--docid::SEC83::-->
<P>

(require 'time-zone)
</P>
<P>

<A NAME="IDX429"></A>
</P>
<DL>
<DT><U>Data Format:</U> <B>TZ-string</B>
<DD><P>

POSIX standards specify several formats for encoding time-zone rules.
</P>
<P>

</P>
<DL COMPACT>
<DT><TT>:<I>&lt;pathname&gt;</I></TT>
<DD>If the first character of <I>&lt;pathname&gt;</I> is `<SAMP>/</SAMP>', then
<I>&lt;pathname&gt;</I> specifies the absolute pathname of a tzfile(5) format
time-zone file.  Otherwise, <I>&lt;pathname&gt;</I> is interpreted as a pathname
within <VAR>tzfile:vicinity</VAR> (/usr/lib/zoneinfo/) naming a tzfile(5)
format time-zone file.
<DT><TT><I>&lt;std&gt;</I><I>&lt;offset&gt;</I></TT>
<DD>The string <I>&lt;std&gt;</I> consists of 3 or more alphabetic characters.
<I>&lt;offset&gt;</I> specifies the time difference from GMT.  The <I>&lt;offset&gt;</I>
is positive if the local time zone is west of the Prime Meridian and
negative if it is east.  <I>&lt;offset&gt;</I> can be the number of hours or
hours and minutes (and optionally seconds) separated by `<SAMP>:</SAMP>'.  For
example, <CODE>-4:30</CODE>.
<DT><TT><I>&lt;std&gt;</I><I>&lt;offset&gt;</I><I>&lt;dst&gt;</I></TT>
<DD><I>&lt;dst&gt;</I> is the at least 3 alphabetic characters naming the local
daylight-savings-time.
<DT><TT><I>&lt;std&gt;</I><I>&lt;offset&gt;</I><I>&lt;dst&gt;</I><I>&lt;doffset&gt;</I></TT>
<DD><I>&lt;doffset&gt;</I> specifies the offset from the Prime Meridian when
daylight-savings-time is in effect.
</DL>
<P>

The non-tzfile formats can optionally be followed by transition times
specifying the day and time when a zone changes from standard to
daylight-savings and back again.
</P>
<P>

</P>
<DL COMPACT>
<DT><TT>,<I>&lt;date&gt;</I>/<I>&lt;time&gt;</I>,<I>&lt;date&gt;</I>/<I>&lt;time&gt;</I></TT>
<DD>The <I>&lt;time&gt;</I>s are specified like the <I>&lt;offset&gt;</I>s above, except that
leading `<SAMP>+</SAMP>' and `<SAMP>-</SAMP>' are not allowed.
<P>

Each <I>&lt;date&gt;</I> has one of the formats:
</P>
<P>

</P>
<DL COMPACT>
<DT><TT>J<I>&lt;day&gt;</I></TT>
<DD>specifies the Julian day with <I>&lt;day&gt;</I> between 1 and 365.  February 29
is never counted and cannot be referenced.
<DT><TT><I>&lt;day&gt;</I></TT>
<DD>This specifies the Julian day with n between 0 and 365.  February 29 is
counted in leap years and can be specified.
<DT><TT>M<I>&lt;month&gt;</I>.<I>&lt;week&gt;</I>.<I>&lt;day&gt;</I></TT>
<DD>This specifies day <I>&lt;day&gt;</I> (0 &lt;= <I>&lt;day&gt;</I> &lt;= 6) of week <I>&lt;week&gt;</I> (1
&lt;= <I>&lt;week&gt;</I> &lt;= 5) of month <I>&lt;month&gt;</I> (1 &lt;= <I>&lt;month&gt;</I> &lt;= 12).  Week
1 is the first week in which day d occurs and week 5 is the last week in
which day <I>&lt;day&gt;</I> occurs.  Day 0 is a Sunday.
</DL>
</DL>
<P>

</P>
</DL>
<P>

<A NAME="IDX430"></A>
</P>
<DL>
<DT><U>Data Type:</U> <B>time-zone</B>
<DD>is a datatype encoding how many hours from Greenwich Mean Time the local
time is, and the <EM>Daylight Savings Time</EM> rules for changing it.
</DL>
<P>

<A NAME="IDX431"></A>
</P>
<DL>
<DT><U>Function:</U> <B>time-zone</B> <I>TZ-string</I>
<DD>Creates and returns a time-zone object specified by the string
<VAR>TZ-string</VAR>.  If <CODE>time-zone</CODE> cannot interpret <VAR>TZ-string</VAR>,
<CODE>#f</CODE> is returned.
</DL>
<P>

<A NAME="IDX432"></A>
</P>
<DL>
<DT><U>Function:</U> <B>tz:params</B> <I>caltime tz</I>
<DD><VAR>tz</VAR> is a time-zone object.  <CODE>tz:params</CODE> returns a list of
three items:
<OL>
<LI>
An integer.  0 if standard time is in effect for timezone <VAR>tz</VAR> at
<VAR>caltime</VAR>; 1 if daylight savings time is in effect for timezone
<VAR>tz</VAR> at <VAR>caltime</VAR>.
<LI>
The number of seconds west of the Prime Meridian timezone <VAR>tz</VAR> is at
<VAR>caltime</VAR>.
<LI>
The name for timezone <VAR>tz</VAR> at <VAR>caltime</VAR>.
</OL>
<P>

<CODE>tz:params</CODE> is unaffected by the default timezone; inquiries can be
made of any timezone at any calendar time.
</P>
<P>

</P>
</DL>
<P>

<A NAME="IDX433"></A>
</P>
<DL>
<DT><U>Function:</U> <B>tz:std-offset</B> <I>tz</I>
<DD><VAR>tz</VAR> is a time-zone object.  <CODE>tz:std-offset</CODE> returns the
number of seconds west of the Prime Meridian timezone <VAR>tz</VAR> is.
<P>

</P>
</DL>
<P>

The rest of these procedures and variables are provided for POSIX
compatability.  Because of shared state they are not thread-safe.
</P>
<P>

<A NAME="IDX434"></A>
</P>
<DL>
<DT><U>Function:</U> <B>tzset</B>
<DD>Returns the default time-zone.
<P>

<A NAME="IDX435"></A>
<DT><U>Function:</U> <B>tzset</B> <I>tz</I>
<DD>Sets (and returns) the default time-zone to <VAR>tz</VAR>.
</P>
<P>

<A NAME="IDX436"></A>
<DT><U>Function:</U> <B>tzset</B> <I>TZ-string</I>
<DD>Sets (and returns) the default time-zone to that specified by
<VAR>TZ-string</VAR>.
</P>
<P>

<CODE>tzset</CODE> also sets the variables <VAR>*timezone*</VAR>, <VAR>daylight?</VAR>,
and <VAR>tzname</VAR>.  This function is automatically called by the time
conversion procedures which depend on the time zone (see section <A HREF="slib_4.html#SEC82">4.12 Time and Date</A>).
</P>
</DL>
<P>

<A NAME="IDX437"></A>
</P>
<DL>
<DT><U>Variable:</U> <B>*timezone*</B>
<DD>Contains the difference, in seconds, between Greenwich Mean Time and
local standard time (for example, in the U.S.  Eastern time zone (EST),
timezone is 5*60*60).  <CODE>*timezone*</CODE> is initialized by <CODE>tzset</CODE>.
</DL>
<P>

<A NAME="IDX438"></A>
</P>
<DL>
<DT><U>Variable:</U> <B>daylight?</B>
<DD>is <CODE>#t</CODE> if the default timezone has rules for <EM>Daylight Savings
Time</EM>.  <EM>Note:</EM> <VAR>daylight?</VAR> does not tell you when Daylight
Savings Time is in effect, just that the default zone sometimes has
Daylight Savings Time.
</DL>
<P>

<A NAME="IDX439"></A>
</P>
<DL>
<DT><U>Variable:</U> <B>tzname</B>
<DD>is a vector of strings.  Index 0 has the abbreviation for the standard
timezone; If <VAR>daylight?</VAR>, then index 1 has the abbreviation for the
Daylight Savings timezone.
</DL>
<P>

<A NAME="Posix Time"></A>
<HR SIZE="6">
<A NAME="SEC84"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC83"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC85"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC82"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.12.2 Posix Time </H3>
<!--docid::SEC84::-->
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(require 'posix-time)
<A NAME="IDX440"></A></pre></td></tr></table><P>

<A NAME="IDX441"></A>
</P>
<DL>
<DT><U>Data Type:</U> <B>Calendar-Time</B>
<DD><A NAME="IDX442"></A>
<A NAME="IDX443"></A>
is a datatype encapsulating time.
</DL>
<P>

<A NAME="IDX444"></A>
</P>
<DL>
<DT><U>Data Type:</U> <B>Coordinated Universal Time</B>
<DD><A NAME="IDX445"></A>
<A NAME="IDX446"></A>
(abbreviated <EM>UTC</EM>) is a vector of integers representing time:
<P>

<OL>
<LI>
 seconds (0 - 61)
<LI>
 minutes (0 - 59)
<LI>
 hours since midnight (0 - 23)
<LI>
 day of month (1 - 31)
<LI>
 month (0 - 11).  Note difference from <CODE>decode-universal-time</CODE>.
<LI>
 the number of years since 1900.  Note difference from
<CODE>decode-universal-time</CODE>.
<LI>
 day of week (0 - 6)
<LI>
 day of year (0 - 365)
<LI>
 1 for daylight savings, 0 for regular time
</OL>
</DL>
<P>

<A NAME="IDX447"></A>
</P>
<DL>
<DT><U>Function:</U> <B>gmtime</B> <I>caltime</I>
<DD>Converts the calendar time <VAR>caltime</VAR> to UTC and returns it.
<P>

<A NAME="IDX448"></A>
<DT><U>Function:</U> <B>localtime</B> <I>caltime tz</I>
<DD>Returns <VAR>caltime</VAR> converted to UTC relative to timezone <VAR>tz</VAR>.
</P>
<P>

<A NAME="IDX449"></A>
<DT><U>Function:</U> <B>localtime</B> <I>caltime</I>
<DD>converts the calendar time <VAR>caltime</VAR> to a vector of integers
expressed relative to the user's time zone.  <CODE>localtime</CODE> sets the
variable <VAR>*timezone*</VAR> with the difference between Coordinated
Universal Time (UTC) and local standard time in seconds
(see section <A HREF="slib_4.html#SEC83">tzset</A>).
</P>
<P>

</P>
</DL>
<P>

<A NAME="IDX450"></A>
</P>
<DL>
<DT><U>Function:</U> <B>gmktime</B> <I>univtime</I>
<DD>Converts a vector of integers in GMT Coordinated Universal Time (UTC)
format to a calendar time.
<P>

<A NAME="IDX451"></A>
<DT><U>Function:</U> <B>mktime</B> <I>univtime</I>
<DD>Converts a vector of integers in local Coordinated Universal Time (UTC)
format to a calendar time.
</P>
<P>

<A NAME="IDX452"></A>
<DT><U>Function:</U> <B>mktime</B> <I>univtime tz</I>
<DD>Converts a vector of integers in Coordinated Universal Time (UTC) format
(relative to time-zone <VAR>tz</VAR>)
to calendar time.
</P>
</DL>
<P>

<A NAME="IDX453"></A>
</P>
<DL>
<DT><U>Function:</U> <B>asctime</B> <I>univtime</I>
<DD>Converts the vector of integers <VAR>caltime</VAR> in Coordinated
Universal Time (UTC) format into a string of the form
<CODE>&quot;Wed Jun 30 21:49:08 1993&quot;</CODE>.
</DL>
<P>

<A NAME="IDX454"></A>
</P>
<DL>
<DT><U>Function:</U> <B>gtime</B> <I>caltime</I>
<DD><A NAME="IDX455"></A>
<DT><U>Function:</U> <B>ctime</B> <I>caltime</I>
<DD><A NAME="IDX456"></A>
<DT><U>Function:</U> <B>ctime</B> <I>caltime tz</I>
<DD>Equivalent to <CODE>(asctime (gmtime <VAR>caltime</VAR>))</CODE>,
<CODE>(asctime (localtime <VAR>caltime</VAR>))</CODE>, and
<CODE>(asctime (localtime <VAR>caltime</VAR> <VAR>tz</VAR>))</CODE>, respectively.
</DL>
<P>

<A NAME="Common-Lisp Time"></A>
<HR SIZE="6">
<A NAME="SEC85"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC84"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC86"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC82"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 4.12.3 Common-Lisp Time </H3>
<!--docid::SEC85::-->
<P>

<A NAME="IDX457"></A>
</P>
<DL>
<DT><U>Function:</U> <B>get-decoded-time</B>
<DD>Equivalent to <CODE>(decode-universal-time (get-universal-time))</CODE>.
</DL>
<P>

<A NAME="IDX458"></A>
</P>
<DL>
<DT><U>Function:</U> <B>get-universal-time</B>
<DD>Returns the current time as <EM>Universal Time</EM>, number of seconds
since 00:00:00 Jan 1, 1900 GMT.  Note that the reference time is
different from <CODE>current-time</CODE>.
</DL>
<P>

<A NAME="IDX459"></A>
</P>
<DL>
<DT><U>Function:</U> <B>decode-universal-time</B> <I>univtime</I>
<DD>Converts <VAR>univtime</VAR> to <EM>Decoded Time</EM> format.
Nine values are returned:
<OL>
<LI>
 seconds (0 - 61)
<LI>
 minutes (0 - 59)
<LI>
 hours since midnight
<LI>
 day of month
<LI>
 month (1 - 12).  Note difference from <CODE>gmtime</CODE> and <CODE>localtime</CODE>.
<LI>
 year (A.D.).  Note difference from <CODE>gmtime</CODE> and <CODE>localtime</CODE>.
<LI>
 day of week (0 - 6)
<LI>
 #t for daylight savings, #f otherwise
<LI>
 hours west of GMT (-24 - +24)
</OL>
<P>

Notice that the values returned by <CODE>decode-universal-time</CODE> do not
match the arguments to <CODE>encode-universal-time</CODE>.
</P>
</DL>
<P>

<A NAME="IDX460"></A>
</P>
<DL>
<DT><U>Function:</U> <B>encode-universal-time</B> <I>second minute hour date month year</I>
<DD><A NAME="IDX461"></A>
<DT><U>Function:</U> <B>encode-universal-time</B> <I>second minute hour date month year time-zone</I>
<DD>Converts the arguments in Decoded Time format to Universal Time format.
If <VAR>time-zone</VAR> is not specified, the returned time is adjusted for
daylight saving time.  Otherwise, no adjustment is performed.
<P>

Notice that the values returned by <CODE>decode-universal-time</CODE> do not
match the arguments to <CODE>encode-universal-time</CODE>.
</P>
</DL>
<P>

<A NAME="NCBI-DNA"></A>
<HR SIZE="6">
<A NAME="SEC86"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC85"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC87"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 4.13 NCBI-DNA </H2>
<!--docid::SEC86::-->
<P>

<A NAME="IDX462"></A>
</P>
<DL>
<DT><U>Function:</U> <B>ncbi:read-dna-sequence</B> <I>port</I>
<DD><P>

Reads the NCBI-format DNA sequence following the word `<SAMP>ORIGIN</SAMP>'
from <VAR>port</VAR>.
</P>
</DL>
<P>

<A NAME="IDX463"></A>
</P>
<DL>
<DT><U>Function:</U> <B>ncbi:read-file</B> <I>file</I>
<DD><P>

Reads the NCBI-format DNA sequence following the word `<SAMP>ORIGIN</SAMP>'
from <VAR>file</VAR>.
</P>
</DL>
<P>

<A NAME="IDX464"></A>
</P>
<DL>
<DT><U>Function:</U> <B>mrna&lt;-cdna</B> <I>str</I>
<DD><P>

Replaces `<SAMP>T</SAMP>' with `<SAMP>U</SAMP>' in <VAR>str</VAR>
</P>
</DL>
<P>

<A NAME="IDX465"></A>
</P>
<DL>
<DT><U>Function:</U> <B>codons&lt;-cdna</B> <I>cdna</I>
<DD><P>

Returns a list of three-letter symbol codons comprising the protein
sequence encoded by <VAR>cdna</VAR> starting with its first occurence of
`<SAMP>atg</SAMP>'.
</P>
</DL>
<P>

<A NAME="IDX466"></A>
</P>
<DL>
<DT><U>Function:</U> <B>protein&lt;-cdna</B> <I>cdna</I>
<DD><P>

Returns a list of three-letter symbols for the protein sequence
encoded by <VAR>cdna</VAR> starting with its first occurence of `<SAMP>atg</SAMP>'.
</P>
</DL>
<P>

<A NAME="IDX467"></A>
</P>
<DL>
<DT><U>Function:</U> <B>p&lt;-cdna</B> <I>cdna</I>
<DD><P>

Returns a string of one-letter amino acid codes for the protein
sequence encoded by <VAR>cdna</VAR> starting with its first occurence of
`<SAMP>atg</SAMP>'.
</P>
</DL>
<P>

These cDNA count routines provide a means to check the nucleotide
sequence with the `<SAMP>BASE COUNT</SAMP>' line preceding the sequence from
NCBI.
</P>
<P>

<A NAME="IDX468"></A>
</P>
<DL>
<DT><U>Function:</U> <B>cdna:base-count</B> <I>cdna</I>
<DD><P>

Returns a list of counts of `<SAMP>a</SAMP>', `<SAMP>c</SAMP>', `<SAMP>g</SAMP>', and
`<SAMP>t</SAMP>' occurrencing in <VAR>cdna</VAR>.
</P>
</DL>
<P>

<A NAME="IDX469"></A>
</P>
<DL>
<DT><U>Function:</U> <B>cdna:report-base-count</B> <I>cdna</I>
<DD><P>

Prints the counts of `<SAMP>a</SAMP>', `<SAMP>c</SAMP>', `<SAMP>g</SAMP>', and `<SAMP>t</SAMP>'
occurrencing in <VAR>cdna</VAR>.
</P>
</DL>
<P>

<A NAME="Schmooz"></A>
<HR SIZE="6">
<A NAME="SEC87"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC86"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 4.14 Schmooz </H2>
<!--docid::SEC87::-->
<P>

<A NAME="IDX470"></A>
<EM>Schmooz</EM> is a simple, lightweight markup language for interspersing
Texinfo documentation with Scheme source code.  Schmooz does not create
the top level Texinfo file; it creates `<SAMP>txi</SAMP>' files which can be
imported into the documentation using the Texinfo command
`<SAMP>@include</SAMP>'.
</P>
<P>

<A NAME="IDX471"></A>
<CODE>(require 'schmooz)</CODE> defines the function <CODE>schmooz</CODE>, which is
used to process files.  Files containing schmooz documentation should
not contain <CODE>(require 'schmooz)</CODE>.
</P>
<P>

<A NAME="IDX472"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>schmooz</B> <I>filename.scm <small>...</small></I>
<DD><VAR>Filename</VAR>.scm should be a string ending with `<SAMP>.scm</SAMP>' naming an
existing file containing Scheme source code.  <CODE>schmooz</CODE> extracts
top-level comments containing schmooz commands from <VAR>filename</VAR>.scm
and writes the converted Texinfo source to a file named
<VAR>filename</VAR>.txi.
<P>

<A NAME="IDX473"></A>
<DT><U>Procedure:</U> <B>schmooz</B> <I>filename.texi <small>...</small></I>
<DD><A NAME="IDX474"></A>
<DT><U>Procedure:</U> <B>schmooz</B> <I>filename.tex <small>...</small></I>
<DD><A NAME="IDX475"></A>
<DT><U>Procedure:</U> <B>schmooz</B> <I>filename.txi <small>...</small></I>
<DD><VAR>Filename</VAR> should be a string naming an existing file containing
Texinfo source code.  For every occurrence of the string `<SAMP>@include
<VAR>filename</VAR>.txi</SAMP>' within that file, <CODE>schmooz</CODE> calls itself with
the argument `<SAMP><VAR>filename</VAR>.scm</SAMP>'.
</P>
</DL>
<P>

Schmooz comments are distinguished (from non-schmooz comments) by their
first line, which must start with an at-sign (@) preceded by one or
more semicolons (<TT>;</TT>).  A schmooz comment ends at the first subsequent
line which does <EM>not</EM> start with a semicolon.  Currently schmooz
comments are recognized only at top level.
</P>
<P>

Schmooz comments are copied to the Texinfo output file with the leading
contiguous semicolons removed.  Certain character sequences starting
with at-sign are treated specially.  Others are copied unchanged.
</P>
<P>

A schmooz comment starting with `<SAMP>@body</SAMP>' must be followed by a
Scheme definition.  All comments between the `<SAMP>@body</SAMP>' line and
the definition will be included in a Texinfo definition, either
a `<SAMP>@defun</SAMP>' or a `<SAMP>@defvar</SAMP>', depending on whether a procedure
or a variable is being defined.
</P>
<P>

Within the text of that schmooz comment, at-sign
followed by `<SAMP>0</SAMP>' will be replaced by <CODE>@code{procedure-name}</CODE>
if the following definition is of a procedure; or
<CODE>@var{variable}</CODE> if defining a variable.
</P>
<P>

An at-sign followed by a non-zero digit will expand to the variable
citation of that numbered argument: `<SAMP>@var{argument-name}</SAMP>'.
</P>
<P>

If more than one definition follows a `<SAMP>@body</SAMP>' comment line
without an intervening blank or comment line, then those definitions
will be included in the same Texinfo definition using `<SAMP>@defvarx</SAMP>'
or `<SAMP>@defunx</SAMP>', depending on whether the first definition is of
a variable or of a procedure.
</P>
<P>

Schmooz can figure out whether a definition is of a procedure if
it is of the form:
</P>
<P>

`<SAMP>(define (&lt;identifier&gt; &lt;arg&gt; ...) &lt;expression&gt;)</SAMP>'
</P>
<P>

or if the left hand side of the definition is some form ending in
a lambda expression.  Obviously, it can be fooled.  In order to
force recognition of a procedure definition, start the documentation
with `<SAMP>@args</SAMP>' instead of `<SAMP>@body</SAMP>'.  `<SAMP>@args</SAMP>' should
be followed by the argument list of the function being defined,
which may be enclosed in parentheses and delimited by whitespace,
(as in Scheme), enclosed in braces and separated by commas, (as
in Texinfo), or consist of the remainder of the line, separated
by whitespace.
</P>
<P>

For example:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>;;@args arg1 args ...
;;@0 takes argument @1 and any number of @2
(define myfun (some-function-returning-magic))
</pre></td></tr></table><P>

Will result in:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>@defun myfun arg1 args @dots{}

@code{myfun} takes argument @var{arg1} and any number of @var{args}
@end defun
</pre></td></tr></table><P>

`<SAMP>@args</SAMP>' may also be useful for indicating optional arguments
by name.  If `<SAMP>@args</SAMP>' occurs inside a schmooz comment section,
rather than at the beginning, then it will generate a `<SAMP>@defunx</SAMP>'
line with the arguments supplied.
</P>
<P>

If the first at-sign in a schmooz comment is immediately followed by
whitespace, then the comment will be expanded to whatever follows that
whitespace.  If the at-sign is followed by a non-whitespace character
then the at-sign will be included as the first character of the expansion.
This feature is intended to make it easy to include Texinfo directives
in schmooz comments.
</P>
<P>

<A NAME="Mathematical Packages"></A>
<HR SIZE="6">
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_4.html#SEC45"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_5.html#SEC88"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<BR>
<FONT SIZE="-1">
This document was generated
by <I>Steve Langasek</I> on <I>January, 10 2005</I>
using <A HREF="http://texi2html.cvshome.org"><I>texi2html</I></A>
</FONT>

</BODY>
</HTML>