This file is indexed.

/usr/share/doc/slib/slib_4.html is in slib 3b1-3.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- This manual is for SLIB (version 3b1, June 2010),
the portable Scheme library.

Copyright C 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.  A
copy of the license is included in the section entitled "GNU Free
Documentation License."

 -->
<!-- Created on June 9, 2010 by texi2html 1.82
texi2html was 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.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>slib: 4. Textual Conversion Packages</title>

<meta name="description" content="slib: 4. Textual Conversion Packages">
<meta name="keywords" content="slib: 4. Textual Conversion Packages">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.82">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

<a name="Textual-Conversion-Packages"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="slib_3.html#Yasos-examples" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Precedence-Parsing" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib_3.html#Scheme-Syntax-Extension-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Textual-Conversion-Packages-1"></a>
<h1 class="chapter">4. Textual Conversion Packages</h1>

<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#Precedence-Parsing">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="#Format">4.2 Format (version 3.1)</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                      Common-Lisp Format
</td></tr>
<tr><td align="left" valign="top"><a href="#Standard-Formatted-I_002fO">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="#Programs-and-Arguments">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="#HTML">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="#HTML-Tables">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="#HTTP-and-CGI">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="#Parsing-HTML">4.9 Parsing HTML</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                &rsquo;html-for-each
</td></tr>
<tr><td align="left" valign="top"><a href="#URI">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="#Parsing-XML">4.11 Parsing XML</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                 &rsquo;parse-xml or &rsquo;ssax
</td></tr>
<tr><td align="left" valign="top"><a href="#Printing-Scheme">4.12 Printing Scheme</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">             Nicely
</td></tr>
<tr><td align="left" valign="top"><a href="#Time-and-Date">4.13 Time and Date</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">               
</td></tr>
<tr><td align="left" valign="top"><a href="#NCBI_002dDNA">4.14 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="#Schmooz">4.15 Schmooz</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                     Documentation markup for Scheme programs
</td></tr>
</table>

<hr size="6">
<a name="Precedence-Parsing"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Precedence-Parsing-Overview" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Precedence-Parsing-1"></a>
<h2 class="section">4.1 Precedence Parsing</h2>

<p><code>(require 'precedence-parse)</code> or <code>(require 'parse)</code>
<a name="index-parse"></a>
<a name="index-precedence"></a>
</p>
<p>This package implements:
</p>
<ul>
<li>
a Pratt style precedence parser;
</li><li>
a <em>tokenizer</em> which congeals tokens according to assigned classes of
constituent characters;
</li><li>
procedures giving direct control of parser rulesets;
</li><li>
procedures for higher level specification of rulesets.
</li></ul>

<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#Precedence-Parsing-Overview">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="#Rule-Types">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="#Ruleset-Definition-and-Use">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="#Token-definition">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="#Nud-and-Led-Definition">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="#Grammar-Rule-Definition">4.1.6 Grammar Rule Definition</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">     
</td></tr>
</table>

<hr size="6">
<a name="Precedence-Parsing-Overview"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Precedence-Parsing" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Rule-Types" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Precedence-Parsing" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Precedence-Parsing-Overview-1"></a>
<h3 class="subsection">4.1.1 Precedence Parsing Overview</h3>

<p>This package offers improvements over previous parsers.
</p>
<ul>
<li>
Common computer language constructs are concisely specified.
</li><li>
Grammars can be changed dynamically.  Operators can be assigned
different meanings within a lexical context.
</li><li>
Rulesets don&rsquo;t need compilation.  Grammars can be changed incrementally.
</li><li>
Operator precedence is specified by integers.
</li><li>
All possibilities of bad input are handled <a name="DOCF4" href="slib_fot.html#FOOT4">(4)</a> and return as much structure as was
parsed when the error occured; The symbol <code>?</code> is substituted for
missing input.
</li></ul>

<a name="index-binding-power"></a>
<p>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>
<a name="index-syntax-tree"></a>
<p>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://swiss.csail.mit.edu/~jaffer/JACAL">http://swiss.csail.mit.edu/~jaffer/JACAL</a>) uses
<tt>precedence-parse</tt>.  Its grammar definitions in the file
&lsquo;<tt>jacal/English.scm</tt>&rsquo; can serve as examples of use.
</p>

<hr size="6">
<a name="Rule-Types"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Precedence-Parsing-Overview" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Ruleset-Definition-and-Use" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Precedence-Parsing" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Rule-Types-1"></a>
<h3 class="subsection">4.1.2 Rule Types</h3>

<p>Here are the higher-level syntax types and an example of each.
Precedence considerations are omitted for clarity.
See <a href="#Grammar-Rule-Definition">Grammar Rule Definition</a> for full details.
</p><dl>
<dt><a name="index-nofix"></a><u>Grammar:</u> <b>nofix</b><i> bye exit</i></dt>
<dd><table><tr><td>&nbsp;</td><td><pre class="example">bye
</pre></td></tr></table>
<p>calls the function <code>exit</code> with no arguments.
</p></dd></dl>
<dl>
<dt><a name="index-prefix"></a><u>Grammar:</u> <b>prefix</b><i> - negate</i></dt>
<dd><table><tr><td>&nbsp;</td><td><pre class="example">- 42
</pre></td></tr></table>
<p>Calls the function <code>negate</code> with the argument <code>42</code>.
</p></dd></dl>
<dl>
<dt><a name="index-infix"></a><u>Grammar:</u> <b>infix</b><i> - difference</i></dt>
<dd><table><tr><td>&nbsp;</td><td><pre class="example">x - y
</pre></td></tr></table>
<p>Calls the function <code>difference</code> with arguments <code>x</code> and <code>y</code>.
</p></dd></dl>
<dl>
<dt><a name="index-nary"></a><u>Grammar:</u> <b>nary</b><i> + sum</i></dt>
<dd><table><tr><td>&nbsp;</td><td><pre class="example">x + y + z
</pre></td></tr></table>
<p>Calls the function <code>sum</code> with arguments <code>x</code>, <code>y</code>, and
<code>y</code>.
</p></dd></dl>
<dl>
<dt><a name="index-postfix"></a><u>Grammar:</u> <b>postfix</b><i> ! factorial</i></dt>
<dd><table><tr><td>&nbsp;</td><td><pre class="example">5 !
</pre></td></tr></table>
<p>Calls the function <code>factorial</code> with the argument <code>5</code>.
</p></dd></dl>
<dl>
<dt><a name="index-prestfix"></a><u>Grammar:</u> <b>prestfix</b><i> set set!</i></dt>
<dd><table><tr><td>&nbsp;</td><td><pre class="example">set foo bar
</pre></td></tr></table>
<p>Calls the function <code>set!</code> with the arguments <code>foo</code> and
<code>bar</code>.
</p></dd></dl>
<dl>
<dt><a name="index-commentfix"></a><u>Grammar:</u> <b>commentfix</b><i> /* */</i></dt>
<dd><table><tr><td>&nbsp;</td><td><pre class="example">/* almost any text here */
</pre></td></tr></table>
<p>Ignores the comment delimited by <code>/*</code> and <code>*/</code>.
</p></dd></dl>
<dl>
<dt><a name="index-matchfix"></a><u>Grammar:</u> <b>matchfix</b><i> { list }</i></dt>
<dd><table><tr><td>&nbsp;</td><td><pre class="example">{0, 1, 2}
</pre></td></tr></table>
<p>Calls the function <code>list</code> with the arguments <code>0</code>, <code>1</code>,
and <code>2</code>.
</p></dd></dl>
<dl>
<dt><a name="index-inmatchfix"></a><u>Grammar:</u> <b>inmatchfix</b><i> ( funcall )</i></dt>
<dd><table><tr><td>&nbsp;</td><td><pre class="example">f(x, y)
</pre></td></tr></table>
<p>Calls the function <code>funcall</code> with the arguments <code>f</code>, <code>x</code>,
and <code>y</code>.
</p></dd></dl>
<dl>
<dt><a name="index-delim"></a><u>Grammar:</u> <b>delim</b><i> ;</i></dt>
<dd><table><tr><td>&nbsp;</td><td><pre class="example">set foo bar;
</pre></td></tr></table>
<p>delimits the extent of the restfix operator <code>set</code>.
</p></dd></dl>


<hr size="6">
<a name="Ruleset-Definition-and-Use"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Rule-Types" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Token-definition" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Precedence-Parsing" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Ruleset-Definition-and-Use-1"></a>
<h3 class="subsection">4.1.3 Ruleset Definition and Use</h3>

<dl>
<dt><a name="index-_002asyn_002ddefs_002a"></a><u>Variable:</u> <b>*syn-defs*</b></dt>
<dd><p>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>.
</p></dd></dl>

<dl>
<dt><a name="index-_002asyn_002dignore_002dwhitespace_002a"></a><u>Constant:</u> <b>*syn-ignore-whitespace*</b></dt>
<dd><p>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>
</p></dd></dl>

<p>In order to start defining a grammar, either
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(set! *syn-defs* '())
</pre></td></tr></table>
<p>or
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(set! *syn-defs* *syn-ignore-whitespace*)
</pre></td></tr></table>

<dl>
<dt><a name="index-prec_003adefine_002dgrammar"></a><u>Function:</u> <b>prec:define-grammar</b><i> rule1 &hellip;</i></dt>
<dd><p>Appends <var>rule1</var> &hellip; to <var>*syn-defs*</var>.
<code>prec:define-grammar</code> is used to define both the character classes
and rules for tokens.
</p></dd></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>
<table><tr><td>&nbsp;</td><td><pre class="example">(define my-ruleset *syn-defs*)
</pre></td></tr></table>

<dl>
<dt><a name="index-prec_003aparse"></a><u>Function:</u> <b>prec:parse</b><i> ruleset delim</i></dt>
<dt><a name="index-prec_003aparse-1"></a><u>Function:</u> <b>prec:parse</b><i> ruleset delim port</i></dt>
<dd><p>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>
<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 symbol 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="index-current_002dinput_002dport"></a>
</p></dd></dl>


<hr size="6">
<a name="Token-definition"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Ruleset-Definition-and-Use" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Nud-and-Led-Definition" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Precedence-Parsing" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Token-definition-1"></a>
<h3 class="subsection">4.1.4 Token definition</h3>

<dl>
<dt><a name="index-tok_003achar_002dgroup"></a><u>Function:</u> <b>tok:char-group</b><i> group chars chars-proc</i></dt>
<dd><p>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>
<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></dd></dl>

<p>The following convenient constants are provided for use with
<code>tok:char-group</code>.
</p>
<dl>
<dt><a name="index-tok_003adecimal_002ddigits"></a><u>Constant:</u> <b>tok:decimal-digits</b></dt>
<dd><p>Is the string <code>&quot;0123456789&quot;</code>.
</p></dd></dl>
<dl>
<dt><a name="index-tok_003aupper_002dcase"></a><u>Constant:</u> <b>tok:upper-case</b></dt>
<dd><p>Is the string consisting of all upper-case letters
(&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;).
</p></dd></dl>
<dl>
<dt><a name="index-tok_003alower_002dcase"></a><u>Constant:</u> <b>tok:lower-case</b></dt>
<dd><p>Is the string consisting of all lower-case letters
(&quot;abcdefghijklmnopqrstuvwxyz&quot;).
</p></dd></dl>
<dl>
<dt><a name="index-tok_003awhitespaces"></a><u>Constant:</u> <b>tok:whitespaces</b></dt>
<dd><p>Is the string consisting of all characters between 0 and 255 for which
<code>char-whitespace?</code> returns true.
</p></dd></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>
<dl>
<dt><a name="index-tok_003abump_002dcolumn"></a><u>Function:</u> <b>tok:bump-column</b><i> pos port</i></dt>
<dd><p>Adds <var>pos</var> to the current-column for input-port <var>port</var>.
</p></dd></dl>


<hr size="6">
<a name="Nud-and-Led-Definition"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Token-definition" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Grammar-Rule-Definition" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Precedence-Parsing" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Nud-and-Led-Definition-1"></a>
<h3 class="subsection">4.1.5 Nud and Led Definition</h3>

<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="index-Null-Denotation_002c-nud"></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="index-Left-Denotation_002c-led"></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>
<blockquote><p>Pratt, V. R.
Top Down Operator Precendence.
<cite>SIGACT/SIGPLAN Symposium on Principles of Programming Languages</cite>,
Boston, 1973, pages 41-51
</p></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>
<dl>
<dt><a name="index-prec_003amake_002dnud"></a><u>Function:</u> <b>prec:make-nud</b><i> tk sop arg1 &hellip;</i></dt>
<dd><p>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> &hellip; as its arguments; the resulting value is incorporated
into the expression being built.  Otherwise, <code>(list <var>sop</var>
<var>arg1</var> &hellip;)</code> is incorporated.
</p></dd></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>
<dl>
<dt><a name="index-prec_003amake_002dled"></a><u>Function:</u> <b>prec:make-led</b><i> tk sop arg1 &hellip;</i></dt>
<dd><p>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>
&hellip; as its arguments; the resulting value is incorporated into the
expression being built.  Otherwise, <var>left</var> is incorporated.
</p></dd></dl>

<p>If no LED has been defined for a token, and <var>left</var> is set, the
parser issues a warning.
</p>
<hr size="6">
<a name="Grammar-Rule-Definition"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Nud-and-Led-Definition" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Format" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Precedence-Parsing" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Grammar-Rule-Definition-1"></a>
<h3 class="subsection">4.1.6 Grammar Rule Definition</h3>

<p>Here are procedures for defining rules for the syntax types introduced
in <a href="#Precedence-Parsing-Overview">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, &hellip;, 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>
<dl>
<dt><a name="index-prec_003adelim"></a><u>Function:</u> <b>prec:delim</b><i> tk</i></dt>
<dd><p>Returns a rule specifying that <var>tk</var> should not be returned from
parsing; i.e. <var>tk</var>&rsquo;s function is purely syntactic.  The end-of-file
is always treated as a delimiter.
</p></dd></dl>

<dl>
<dt><a name="index-prec_003anofix"></a><u>Function:</u> <b>prec:nofix</b><i> tk sop</i></dt>
<dd><p>Returns a rule specifying the following actions take place when <var>tk</var>
is parsed:
</p><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.
</li></ul>
</dd></dl>

<dl>
<dt><a name="index-prec_003aprefix"></a><u>Function:</u> <b>prec:prefix</b><i> tk sop bp rule1 &hellip;</i></dt>
<dd><p>Returns a rule specifying the following actions take place when <var>tk</var>
is parsed:
</p><ul>
<li>
The rules <var>rule1</var> &hellip; augment and, in case of conflict, override
rules currently in effect.
</li><li>
<code>prec:parse1</code> is called with binding-power <var>bp</var>.
</li><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><li>
The ruleset in effect before <var>tk</var> was parsed is restored;
<var>rule1</var> &hellip; are forgotten.
</li></ul>
</dd></dl>

<dl>
<dt><a name="index-prec_003ainfix"></a><u>Function:</u> <b>prec:infix</b><i> tk sop lbp bp rule1 &hellip;</i></dt>
<dd><p>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:
</p><ul>
<li>
The rules <var>rule1</var> &hellip; augment and, in case of conflict, override
rules currently in effect.
</li><li>
One expression is parsed with binding-power <var>lbp</var>.  If instead a
delimiter is encountered, a warning is issued.
</li><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><li>
The ruleset in effect before <var>tk</var> was parsed is restored;
<var>rule1</var> &hellip; are forgotten.
</li></ul>
</dd></dl>

<dl>
<dt><a name="index-prec_003anary"></a><u>Function:</u> <b>prec:nary</b><i> tk sop bp</i></dt>
<dd><p>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:
</p><ul>
<li>
Expressions are parsed with binding-power <var>bp</var> as far as they are
interleaved with the token <var>tk</var>.
</li><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></ul>
</dd></dl>

<dl>
<dt><a name="index-prec_003apostfix"></a><u>Function:</u> <b>prec:postfix</b><i> tk sop lbp</i></dt>
<dd><p>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:
</p><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.
</li></ul>
</dd></dl>

<dl>
<dt><a name="index-prec_003aprestfix"></a><u>Function:</u> <b>prec:prestfix</b><i> tk sop bp rule1 &hellip;</i></dt>
<dd><p>Returns a rule specifying the following actions take place when <var>tk</var>
is parsed:
</p><ul>
<li>
The rules <var>rule1</var> &hellip; augment and, in case of conflict, override
rules currently in effect.
</li><li>
Expressions are parsed with binding-power <var>bp</var> until a delimiter is
reached.
</li><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><li>
The ruleset in effect before <var>tk</var> was parsed is restored;
<var>rule1</var> &hellip; are forgotten.
</li></ul>
</dd></dl>

<dl>
<dt><a name="index-prec_003acommentfix"></a><u>Function:</u> <b>prec:commentfix</b><i> tk stp match rule1 &hellip;</i></dt>
<dd><p>Returns rules specifying the following actions take place when <var>tk</var>
is parsed:
</p><ul>
<li>
The rules <var>rule1</var> &hellip; augment and, in case of conflict, override
rules currently in effect.
</li><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><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><li>
The ruleset in effect before <var>tk</var> was parsed is restored;
<var>rule1</var> &hellip; are forgotten.
</li></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></dd></dl>

<dl>
<dt><a name="index-prec_003amatchfix"></a><u>Function:</u> <b>prec:matchfix</b><i> tk sop sep match rule1 &hellip;</i></dt>
<dd><p>Returns a rule specifying the following actions take place when <var>tk</var>
is parsed:
</p><ul>
<li>
The rules <var>rule1</var> &hellip; augment and, in case of conflict, override
rules currently in effect.
</li><li>
A rule declaring the token <var>match</var> a delimiter takes effect.
</li><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><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><li>
The ruleset in effect before <var>tk</var> was parsed is restored;
<var>rule1</var> &hellip; are forgotten.
</li></ul>
</dd></dl>

<dl>
<dt><a name="index-prec_003ainmatchfix"></a><u>Function:</u> <b>prec:inmatchfix</b><i> tk sop sep match lbp rule1 &hellip;</i></dt>
<dd><p>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:
</p><ul>
<li>
The rules <var>rule1</var> &hellip; augment and, in case of conflict, override
rules currently in effect.
</li><li>
A rule declaring the token <var>match</var> a delimiter takes effect.
</li><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><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><li>
The ruleset in effect before <var>tk</var> was parsed is restored;
<var>rule1</var> &hellip; are forgotten.
</li></ul>
</dd></dl>


<hr size="6">
<a name="Format"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Grammar-Rule-Definition" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Format-Interface" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Format-_0028version-3_002e1_0029"></a>
<h2 class="section">4.2 Format (version 3.1)</h2>

<p>&lt;A NAME=&quot;format&quot;&gt;&lt;/A&gt;
<code>(require 'format)</code> or <code>(require 'srfi-28)</code>
<a name="index-format"></a>
</p>


<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#Format-Interface">4.2.1 Format Interface</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">            
</td></tr>
<tr><td align="left" valign="top"><a href="#Format-Specification">4.2.2 Format Specification (Format version 3.1)</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">        
</td></tr>
</table>

<hr size="6">
<a name="Format-Interface"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Format" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Format-Specification" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Format" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Format-Interface-1"></a>
<h3 class="subsection">4.2.1 Format Interface</h3>

<dl>
<dt><a name="index-format-1"></a><u>Function:</u> <b>format</b><i> destination format-string . arguments</i></dt>
<dd><p>An almost complete implementation of Common LISP format description
according to the CL reference book <cite>Common LISP</cite> from Guy L.
Steele, Digital Press.  Backward compatible to most of the available
Scheme format implementations.
</p>
<p>Returns <code>#t</code>, <code>#f</code> or a string; has side effect of printing
according to <var>format-string</var>.  If <var>destination</var> is <code>#t</code>,
the output is to the current output port and <code>#t</code> is returned.  If
<var>destination</var> is <code>#f</code>, a formatted string is returned as the
result of the call.  NEW: If <var>destination</var> is a string,
<var>destination</var> is regarded as the format string; <var>format-string</var> is
then the first argument and the output is returned as a string. If
<var>destination</var> is a number, the output is to the current error port
if available by the implementation. Otherwise <var>destination</var> must be
an output port and <code>#t</code> is returned.
</p>
<p><var>format-string</var> must be a string.  In case of a formatting error
format returns <code>#f</code> and prints a message on the current output or
error port.  Characters are output as if the string were output by the
<code>display</code> function with the exception of those prefixed by a tilde
(~).  For a detailed description of the <var>format-string</var> syntax
please consult a Common LISP format reference manual.  For a test suite
to verify this format implementation load &lsquo;<tt>formatst.scm</tt>&rsquo;. Please
send bug reports to <code>lutzeb@cs.tu-berlin.de</code>.
</p>
<p>Note: <code>format</code> is not reentrant, i.e. only one <code>format</code>-call
may be executed at a time.
</p>
</dd></dl>

<hr size="6">
<a name="Format-Specification"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Format-Interface" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Implemented-CL-Format-Control-Directives" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Format" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Format-Specification-_0028Format-version-3_002e1_0029"></a>
<h3 class="subsection">4.2.2 Format Specification (Format version 3.1)</h3>

<p>Please consult a Common LISP format reference manual for a detailed
description of the format string syntax.  For a demonstration of the
implemented directives see &lsquo;<tt>formatst.scm</tt>&rsquo;.
</p>
<p>This implementation supports directive parameters and modifiers
(<code>:</code> and <code>@</code> characters). Multiple parameters must be
separated by a comma (<code>,</code>).  Parameters can be numerical parameters
(positive or negative), character parameters (prefixed by a quote
character (<code>'</code>), variable parameters (<code>v</code>), number of rest
arguments parameter (<code>#</code>), empty and default parameters.  Directive
characters are case independent. The general form of a directive
is:
</p>
<p><var>directive</var> ::= ~{<var>directive-parameter</var>,}[:][@]<var>directive-character</var>
</p>
<p><var>directive-parameter</var> ::= [ [-|+]{0-9}+ | &rsquo;<var>character</var> | v | # ]
</p>

<hr size="6">
<a name="Implemented-CL-Format-Control-Directives"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Format-Specification" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Not-Implemented-CL-Format-Control-Directives" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Format-Specification" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h4 class="subsubsection">4.2.2.1 Implemented CL Format Control Directives</h4>

<p>Documentation syntax: Uppercase characters represent the corresponding
control directive characters. Lowercase characters represent control
directive parameter descriptions.
</p>
<dl compact="compact">
<dt> <code>~A</code></dt>
<dd><p>Any (print as <code>display</code> does).
</p><dl compact="compact">
<dt> <code>~@A</code></dt>
<dd><p>left pad.
</p></dd>
<dt> <code>~<var>mincol</var>,<var>colinc</var>,<var>minpad</var>,<var>padchar</var>A</code></dt>
<dd><p>full padding.
</p></dd>
</dl>
</dd>
<dt> <code>~S</code></dt>
<dd><p>S-expression (print as <code>write</code> does).
</p><dl compact="compact">
<dt> <code>~@S</code></dt>
<dd><p>left pad.
</p></dd>
<dt> <code>~<var>mincol</var>,<var>colinc</var>,<var>minpad</var>,<var>padchar</var>S</code></dt>
<dd><p>full padding.
</p></dd>
</dl>
</dd>
<dt> <code>~D</code></dt>
<dd><p>Decimal.
</p><dl compact="compact">
<dt> <code>~@D</code></dt>
<dd><p>print number sign always.
</p></dd>
<dt> <code>~:D</code></dt>
<dd><p>print comma separated.
</p></dd>
<dt> <code>~<var>mincol</var>,<var>padchar</var>,<var>commachar</var>D</code></dt>
<dd><p>padding.
</p></dd>
</dl>
</dd>
<dt> <code>~X</code></dt>
<dd><p>Hexadecimal.
</p><dl compact="compact">
<dt> <code>~@X</code></dt>
<dd><p>print number sign always.
</p></dd>
<dt> <code>~:X</code></dt>
<dd><p>print comma separated.
</p></dd>
<dt> <code>~<var>mincol</var>,<var>padchar</var>,<var>commachar</var>X</code></dt>
<dd><p>padding.
</p></dd>
</dl>
</dd>
<dt> <code>~O</code></dt>
<dd><p>Octal.
</p><dl compact="compact">
<dt> <code>~@O</code></dt>
<dd><p>print number sign always.
</p></dd>
<dt> <code>~:O</code></dt>
<dd><p>print comma separated.
</p></dd>
<dt> <code>~<var>mincol</var>,<var>padchar</var>,<var>commachar</var>O</code></dt>
<dd><p>padding.
</p></dd>
</dl>
</dd>
<dt> <code>~B</code></dt>
<dd><p>Binary.
</p><dl compact="compact">
<dt> <code>~@B</code></dt>
<dd><p>print number sign always.
</p></dd>
<dt> <code>~:B</code></dt>
<dd><p>print comma separated.
</p></dd>
<dt> <code>~<var>mincol</var>,<var>padchar</var>,<var>commachar</var>B</code></dt>
<dd><p>padding.
</p></dd>
</dl>
</dd>
<dt> <code>~<var>n</var>R</code></dt>
<dd><p>Radix <var>n</var>.
</p><dl compact="compact">
<dt> <code>~<var>n</var>,<var>mincol</var>,<var>padchar</var>,<var>commachar</var>R</code></dt>
<dd><p>padding.
</p></dd>
</dl>
</dd>
<dt> <code>~@R</code></dt>
<dd><p>print a number as a Roman numeral.
</p></dd>
<dt> <code>~:@R</code></dt>
<dd><p>print a number as an &ldquo;old fashioned&rdquo; Roman numeral.
</p></dd>
<dt> <code>~:R</code></dt>
<dd><p>print a number as an ordinal English number.
</p></dd>
<dt> <code>~R</code></dt>
<dd><p>print a number as a cardinal English number.
</p></dd>
<dt> <code>~P</code></dt>
<dd><p>Plural.
</p><dl compact="compact">
<dt> <code>~@P</code></dt>
<dd><p>prints <code>y</code> and <code>ies</code>.
</p></dd>
<dt> <code>~:P</code></dt>
<dd><p>as <code>~P but jumps 1 argument backward.</code>
</p></dd>
<dt> <code>~:@P</code></dt>
<dd><p>as <code>~@P but jumps 1 argument backward.</code>
</p></dd>
</dl>
</dd>
<dt> <code>~C</code></dt>
<dd><p>Character.
</p><dl compact="compact">
<dt> <code>~@C</code></dt>
<dd><p>prints a character as the reader can understand it (i.e. <code>#\</code> prefixing).
</p></dd>
<dt> <code>~:C</code></dt>
<dd><p>prints a character as emacs does (eg. <code>^C</code> for ASCII 03).
</p></dd>
</dl>
</dd>
<dt> <code>~F</code></dt>
<dd><p>Fixed-format floating-point (prints a flonum like <var>mmm.nnn</var>).
</p><dl compact="compact">
<dt> <code>~<var>width</var>,<var>digits</var>,<var>scale</var>,<var>overflowchar</var>,<var>padchar</var>F</code></dt>
<dt> <code>~@F</code></dt>
<dd><p>If the number is positive a plus sign is printed.
</p></dd>
</dl>
</dd>
<dt> <code>~E</code></dt>
<dd><p>Exponential floating-point (prints a flonum like <var>mmm.nnn</var><code>E</code><var>ee</var>).
</p><dl compact="compact">
<dt> <code>~<var>width</var>,<var>digits</var>,<var>exponentdigits</var>,<var>scale</var>,<var>overflowchar</var>,<var>padchar</var>,<var>exponentchar</var>E</code></dt>
<dt> <code>~@E</code></dt>
<dd><p>If the number is positive a plus sign is printed.
</p></dd>
</dl>
</dd>
<dt> <code>~G</code></dt>
<dd><p>General floating-point (prints a flonum either fixed or exponential).
</p><dl compact="compact">
<dt> <code>~<var>width</var>,<var>digits</var>,<var>exponentdigits</var>,<var>scale</var>,<var>overflowchar</var>,<var>padchar</var>,<var>exponentchar</var>G</code></dt>
<dt> <code>~@G</code></dt>
<dd><p>If the number is positive a plus sign is printed.
</p></dd>
</dl>
</dd>
<dt> <code>~$</code></dt>
<dd><p>Dollars floating-point (prints a flonum in fixed with signs separated).
</p><dl compact="compact">
<dt> <code>~<var>digits</var>,<var>scale</var>,<var>width</var>,<var>padchar</var>$</code></dt>
<dt> <code>~@$</code></dt>
<dd><p>If the number is positive a plus sign is printed.
</p></dd>
<dt> <code>~:@$</code></dt>
<dd><p>A sign is always printed and appears before the padding.
</p></dd>
<dt> <code>~:$</code></dt>
<dd><p>The sign appears before the padding.
</p></dd>
</dl>
</dd>
<dt> <code>~%</code></dt>
<dd><p>Newline.
</p><dl compact="compact">
<dt> <code>~<var>n</var>%</code></dt>
<dd><p>print <var>n</var> newlines.
</p></dd>
</dl>
</dd>
<dt> <code>~&amp;</code></dt>
<dd><p>print newline if not at the beginning of the output line.
</p><dl compact="compact">
<dt> <code>~<var>n</var>&amp;</code></dt>
<dd><p>prints <code>~&amp;</code> and then <var>n-1</var> newlines.
</p></dd>
</dl>
</dd>
<dt> <code>~|</code></dt>
<dd><p>Page Separator.
</p><dl compact="compact">
<dt> <code>~<var>n</var>|</code></dt>
<dd><p>print <var>n</var> page separators.
</p></dd>
</dl>
</dd>
<dt> <code>~~</code></dt>
<dd><p>Tilde.
</p><dl compact="compact">
<dt> <code>~<var>n</var>~</code></dt>
<dd><p>print <var>n</var> tildes.
</p></dd>
</dl>
</dd>
<dt> <code>~</code>&lt;newline&gt;</dt>
<dd><p>Continuation Line.
</p><dl compact="compact">
<dt> <code>~:</code>&lt;newline&gt;</dt>
<dd><p>newline is ignored, white space left.
</p></dd>
<dt> <code>~@</code>&lt;newline&gt;</dt>
<dd><p>newline is left, white space ignored.
</p></dd>
</dl>
</dd>
<dt> <code>~T</code></dt>
<dd><p>Tabulation.
</p><dl compact="compact">
<dt> <code>~@T</code></dt>
<dd><p>relative tabulation.
</p></dd>
<dt> <code>~<var>colnum,colinc</var>T</code></dt>
<dd><p>full tabulation.
</p></dd>
</dl>
</dd>
<dt> <code>~?</code></dt>
<dd><p>Indirection (expects indirect arguments as a list).
</p><dl compact="compact">
<dt> <code>~@?</code></dt>
<dd><p>extracts indirect arguments from format arguments.
</p></dd>
</dl>
</dd>
<dt> <code>~(<var>str</var>~)</code></dt>
<dd><p>Case conversion (converts by <code>string-downcase</code>).
</p><dl compact="compact">
<dt> <code>~:(<var>str</var>~)</code></dt>
<dd><p>converts by <code>string-capitalize</code>.
</p></dd>
<dt> <code>~@(<var>str</var>~)</code></dt>
<dd><p>converts by <code>string-capitalize-first</code>.
</p></dd>
<dt> <code>~:@(<var>str</var>~)</code></dt>
<dd><p>converts by <code>string-upcase</code>.
</p></dd>
</dl>
</dd>
<dt> <code>~*</code></dt>
<dd><p>Argument Jumping (jumps 1 argument forward).
</p><dl compact="compact">
<dt> <code>~<var>n</var>*</code></dt>
<dd><p>jumps <var>n</var> arguments forward.
</p></dd>
<dt> <code>~:*</code></dt>
<dd><p>jumps 1 argument backward.
</p></dd>
<dt> <code>~<var>n</var>:*</code></dt>
<dd><p>jumps <var>n</var> arguments backward.
</p></dd>
<dt> <code>~@*</code></dt>
<dd><p>jumps to the 0th argument.
</p></dd>
<dt> <code>~<var>n</var>@*</code></dt>
<dd><p>jumps to the <var>n</var>th argument (beginning from 0)
</p></dd>
</dl>
</dd>
<dt> <code>~[<var>str0</var>~;<var>str1</var>~;...~;<var>strn</var>~]</code></dt>
<dd><p>Conditional Expression (numerical clause conditional).
</p><dl compact="compact">
<dt> <code>~<var>n</var>[</code></dt>
<dd><p>take argument from <var>n</var>.
</p></dd>
<dt> <code>~@[</code></dt>
<dd><p>true test conditional.
</p></dd>
<dt> <code>~:[</code></dt>
<dd><p>if-else-then conditional.
</p></dd>
<dt> <code>~;</code></dt>
<dd><p>clause separator.
</p></dd>
<dt> <code>~:;</code></dt>
<dd><p>default clause follows.
</p></dd>
</dl>
</dd>
<dt> <code>~{<var>str</var>~}</code></dt>
<dd><p>Iteration (args come from the next argument (a list)). Iteration
bounding is controlled by configuration variables
<var>format:iteration-bounded</var> and <var>format:max-iterations</var>.
With both variables default, a maximum of 100 iterations will be
performed.
</p><dl compact="compact">
<dt> <code>~<var>n</var>{</code></dt>
<dd><p>at most <var>n</var> iterations.
</p></dd>
<dt> <code>~:{</code></dt>
<dd><p>args from next arg (a list of lists).
</p></dd>
<dt> <code>~@{</code></dt>
<dd><p>args from the rest of arguments.
</p></dd>
<dt> <code>~:@{</code></dt>
<dd><p>args from the rest args (lists).
</p></dd>
</dl>
</dd>
<dt> <code>~^</code></dt>
<dd><p>Up and out.
</p><dl compact="compact">
<dt> <code>~<var>n</var>^</code></dt>
<dd><p>aborts if <var>n</var> = 0
</p></dd>
<dt> <code>~<var>n</var>,<var>m</var>^</code></dt>
<dd><p>aborts if <var>n</var> = <var>m</var>
</p></dd>
<dt> <code>~<var>n</var>,<var>m</var>,<var>k</var>^</code></dt>
<dd><p>aborts if <var>n</var> &lt;= <var>m</var> &lt;= <var>k</var>
</p></dd>
</dl>
</dd>
</dl>


<hr size="6">
<a name="Not-Implemented-CL-Format-Control-Directives"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Implemented-CL-Format-Control-Directives" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Extended_002c-Replaced-and-Additional-Control-Directives" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Format-Specification" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h4 class="subsubsection">4.2.2.2 Not Implemented CL Format Control Directives</h4>

<dl compact="compact">
<dt> <code>~:A</code></dt>
<dd><p>print <code>#f</code> as an empty list (see below).
</p></dd>
<dt> <code>~:S</code></dt>
<dd><p>print <code>#f</code> as an empty list (see below).
</p></dd>
<dt> <code>~&lt;~&gt;</code></dt>
<dd><p>Justification.
</p></dd>
<dt> <code>~:^</code></dt>
<dd><p>(sorry I don&rsquo;t understand its semantics completely)
</p></dd>
</dl>


<hr size="6">
<a name="Extended_002c-Replaced-and-Additional-Control-Directives"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Not-Implemented-CL-Format-Control-Directives" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Configuration-Variables" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Format-Specification" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h4 class="subsubsection">4.2.2.3 Extended, Replaced and Additional Control Directives</h4>

<dl compact="compact">
<dt> <code>~<var>mincol</var>,<var>padchar</var>,<var>commachar</var>,<var>commawidth</var>D</code></dt>
<dt> <code>~<var>mincol</var>,<var>padchar</var>,<var>commachar</var>,<var>commawidth</var>X</code></dt>
<dt> <code>~<var>mincol</var>,<var>padchar</var>,<var>commachar</var>,<var>commawidth</var>O</code></dt>
<dt> <code>~<var>mincol</var>,<var>padchar</var>,<var>commachar</var>,<var>commawidth</var>B</code></dt>
<dt> <code>~<var>n</var>,<var>mincol</var>,<var>padchar</var>,<var>commachar</var>,<var>commawidth</var>R</code></dt>
<dd><p><var>commawidth</var> is the number of characters between two comma characters.
</p></dd>
</dl>

<dl compact="compact">
<dt> <code>~I</code></dt>
<dd><p>print a R4RS complex number as <code>~F~@Fi</code> with passed parameters for
<code>~F</code>.
</p></dd>
<dt> <code>~Y</code></dt>
<dd><p>Pretty print formatting of an argument for scheme code lists.
</p></dd>
<dt> <code>~K</code></dt>
<dd><p>Same as <code>~?.</code>
</p></dd>
<dt> <code>~!</code></dt>
<dd><p>Flushes the output if format <var>destination</var> is a port.
</p></dd>
<dt> <code>~_</code></dt>
<dd><p>Print a <code>#\space</code> character
</p><dl compact="compact">
<dt> <code>~<var>n</var>_</code></dt>
<dd><p>print <var>n</var> <code>#\space</code> characters.
</p></dd>
</dl>
</dd>
<dt> <code>~/</code></dt>
<dd><p>Print a <code>#\tab</code> character
</p><dl compact="compact">
<dt> <code>~<var>n</var>/</code></dt>
<dd><p>print <var>n</var> <code>#\tab</code> characters.
</p></dd>
</dl>
</dd>
<dt> <code>~<var>n</var>C</code></dt>
<dd><p>Takes <var>n</var> as an integer representation for a character. No arguments
are consumed. <var>n</var> is converted to a character by
<code>integer-&gt;char</code>.  <var>n</var> must be a positive decimal number.
</p></dd>
<dt> <code>~:S</code></dt>
<dd><p>Print out readproof.  Prints out internal objects represented as
<code>#&lt;...&gt;</code> as strings <code>&quot;#&lt;...&gt;&quot;</code> so that the format output can always
be processed by <code>read</code>.

</p></dd>
<dt> <code>~:A</code></dt>
<dd><p>Print out readproof.  Prints out internal objects represented as
<code>#&lt;...&gt;</code> as strings <code>&quot;#&lt;...&gt;&quot;</code> so that the format output can always
be processed by <code>read</code>.
</p></dd>
<dt> <code>~Q</code></dt>
<dd><p>Prints information and a copyright notice on the format implementation.
</p><dl compact="compact">
<dt> <code>~:Q</code></dt>
<dd><p>prints format version.
</p></dd>
</dl>

</dd>
<dt> <code>~F, ~E, ~G, ~$</code></dt>
<dd><p>may also print number strings, i.e. passing a number as a string and
format it accordingly.
</p></dd>
</dl>

<hr size="6">
<a name="Configuration-Variables"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Extended_002c-Replaced-and-Additional-Control-Directives" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Compatibility-With-Other-Format-Implementations" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Format-Specification" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h4 class="subsubsection">4.2.2.4 Configuration Variables</h4>

<p>Format has some configuration variables at the beginning of
&lsquo;<tt>format.scm</tt>&rsquo; to suit the systems and users needs. There should be
no modification necessary for the configuration that comes with SLIB.
If modification is desired the variable should be set after the format
code is loaded. Format detects automatically if the running scheme
system implements floating point numbers and complex numbers.
</p>
<dl compact="compact">
<dt> <var>format:symbol-case-conv</var></dt>
<dd><p>Symbols are converted by <code>symbol-&gt;string</code> so the case type of the
printed symbols is implementation dependent.
<code>format:symbol-case-conv</code> is a one arg closure which is either
<code>#f</code> (no conversion), <code>string-upcase</code>, <code>string-downcase</code>
or <code>string-capitalize</code>. (default <code>#f</code>)
</p>
</dd>
<dt> <var>format:iobj-case-conv</var></dt>
<dd><p>As <var>format:symbol-case-conv</var> but applies for the representation of
implementation internal objects. (default <code>#f</code>)
</p>
</dd>
<dt> <var>format:expch</var></dt>
<dd><p>The character prefixing the exponent value in <code>~E</code> printing. (default
<code>#\E</code>)
</p>
</dd>
<dt> <var>format:iteration-bounded</var></dt>
<dd><p>When <code>#t</code>, a <code>~{...~}</code> control will iterate no more than the
number of times specified by <var>format:max-iterations</var> regardless of
the number of iterations implied by modifiers and arguments.
When <code>#f</code>, a <code>~{...~}</code> control will iterate the number of
times implied by modifiers and arguments, unless termination is forced
by language or system limitations. (default <code>#t</code>)
</p>
</dd>
<dt> <var>format:max-iterations</var></dt>
<dd><p>The maximum number of iterations performed by a <code>~{...~}</code> control.
Has effect only when <var>format:iteration-bounded</var> is <code>#t</code>.
(default 100)
</p>
</dd>
</dl>

<hr size="6">
<a name="Compatibility-With-Other-Format-Implementations"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Configuration-Variables" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Standard-Formatted-I_002fO" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Format-Specification" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h4 class="subsubsection">4.2.2.5 Compatibility With Other Format Implementations</h4>

<dl compact="compact">
<dt> SLIB format 2.x:</dt>
<dd><p>See &lsquo;<tt>format.doc</tt>&rsquo;.
</p>
</dd>
<dt> SLIB format 1.4:</dt>
<dd><p>Downward compatible except for padding support and <code>~A</code>, <code>~S</code>,
<code>~P</code>, <code>~X</code> uppercase printing.  SLIB format 1.4 uses C-style
<code>printf</code> padding support which is completely replaced by the CL
<code>format</code> padding style.
</p>
</dd>
<dt> MIT C-Scheme 7.1:</dt>
<dd><p>Downward compatible except for <code>~</code>, which is not documented
(ignores all characters inside the format string up to a newline
character).  (7.1 implements <code>~a</code>, <code>~s</code>,
~<var>newline</var>, <code>~~</code>, <code>~%</code>, numerical and variable
parameters and <code>:/@</code> modifiers in the CL sense).
</p>
</dd>
<dt> Elk 1.5/2.0:</dt>
<dd><p>Downward compatible except for <code>~A</code> and <code>~S</code> which print in
uppercase.  (Elk implements <code>~a</code>, <code>~s</code>, <code>~~</code>, and
<code>~%</code> (no directive parameters or modifiers)).
</p>
</dd>
<dt> Scheme-&gt;C 01nov91:</dt>
<dd><p>Downward compatible except for an optional destination parameter: S2C
accepts a format call without a destination which returns a formatted
string. This is equivalent to a #f destination in S2C. (S2C implements
<code>~a</code>, <code>~s</code>, <code>~c</code>, <code>~%</code>, and <code>~~</code> (no directive
parameters or modifiers)).
</p>
</dd>
</dl>

<p>This implementation of format is solely useful in the SLIB context
because it requires other components provided by SLIB.
</p>

<hr size="6">
<a name="Standard-Formatted-I_002fO"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Compatibility-With-Other-Format-Implementations" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#stdio" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Standard-Formatted-I_002fO-1"></a>
<h2 class="section">4.3 Standard Formatted I/O</h2>

<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#Standard-Formatted-Output">4.3.2 Standard Formatted Output</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">   &rsquo;printf
</td></tr>
<tr><td align="left" valign="top"><a href="#Standard-Formatted-Input">4.3.3 Standard Formatted Input</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">    &rsquo;scanf
</td></tr>
</table>

<hr size="6">
<a name="stdio"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Standard-Formatted-I_002fO" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Standard-Formatted-Output" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Standard-Formatted-I_002fO" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">4.3.1 stdio</h3>

<p><code>(require 'stdio)</code>
<a name="index-stdio"></a>
</p>
<p><code>require</code>s <code>printf</code> and <code>scanf</code> and additionally defines
the symbols:
</p>
<dl>
<dt><a name="index-stdin"></a><u>Variable:</u> <b>stdin</b></dt>
<dd><p>Defined to be <code>(current-input-port)</code>.
</p></dd></dl>
<dl>
<dt><a name="index-stdout"></a><u>Variable:</u> <b>stdout</b></dt>
<dd><p>Defined to be <code>(current-output-port)</code>.
</p></dd></dl>
<dl>
<dt><a name="index-stderr"></a><u>Variable:</u> <b>stderr</b></dt>
<dd><p>Defined to be <code>(current-error-port)</code>.
</p></dd></dl>


<hr size="6">
<a name="Standard-Formatted-Output"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#stdio" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Exact-Conversions" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Standard-Formatted-I_002fO" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Standard-Formatted-Output-1"></a>
<h3 class="subsection">4.3.2 Standard Formatted Output</h3>

<p>&lt;A NAME=&quot;printf&quot;&gt;&lt;/A&gt;
<code>(require 'printf)</code>
<a name="index-printf"></a>
</p>
<dl>
<dt><a name="index-printf-1"></a><u>Procedure:</u> <b>printf</b><i> format arg1 &hellip;</i></dt>
<dt><a name="index-fprintf"></a><u>Procedure:</u> <b>fprintf</b><i> port format arg1 &hellip;</i></dt>
<dt><a name="index-sprintf"></a><u>Procedure:</u> <b>sprintf</b><i> str format arg1 &hellip;</i></dt>
<dt><a name="index-sprintf-1"></a><u>Procedure:</u> <b>sprintf</b><i> #f format arg1 &hellip;</i></dt>
<dt><a name="index-sprintf-2"></a><u>Procedure:</u> <b>sprintf</b><i> k format arg1 &hellip;</i></dt>
<dd>
<p>Each function converts, formats, and outputs its <var>arg1</var> &hellip;
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&rsquo;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> &hellip;.  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> &hellip; arguments remain unused, the excess <var>arg1</var>
&hellip; arguments are ignored.
</p>
<p>The conversion specifications in a format string have the form:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">% <span class="roman">[</span> <var>flags</var> <span class="roman">]</span> <span class="roman">[</span> <var>width</var> <span class="roman">]</span> <span class="roman">[</span> . <var>precision</var> <span class="roman">]</span> <span class="roman">[</span> <var>type</var> <span class="roman">]</span> <var>conversion</var>
</pre></td></tr></table>

<p>An output conversion specifications consist of an initial &lsquo;<samp>%</samp>&rsquo;
character followed in sequence by:
</p>
<ul>
<li>
Zero or more <em>flag characters</em> that modify the normal behavior of
the conversion specification.

<dl compact="compact">
<dt> &lsquo;<samp>-</samp>&rsquo;</dt>
<dd><p>Left-justify the result in the field.  Normally the result is
right-justified.
</p>
</dd>
<dt> &lsquo;<samp>+</samp>&rsquo;</dt>
<dd><p>For the signed &lsquo;<samp>%d</samp>&rsquo; and &lsquo;<samp>%i</samp>&rsquo; conversions and all inexact
conversions, prefix a plus sign if the value is positive.
</p>
</dd>
<dt> &lsquo;<samp> </samp>&rsquo;</dt>
<dd><p>For the signed &lsquo;<samp>%d</samp>&rsquo; and &lsquo;<samp>%i</samp>&rsquo; conversions, if the result
doesn&rsquo;t start with a plus or minus sign, prefix it with a space
character instead.  Since the &lsquo;<samp>+</samp>&rsquo; flag ensures that the result
includes a sign, this flag is ignored if both are specified.
</p>
</dd>
<dt> &lsquo;<samp>#</samp>&rsquo;</dt>
<dd><p>For inexact conversions, &lsquo;<samp>#</samp>&rsquo; specifies that the result should
always include a decimal point, even if no digits follow it.  For the
&lsquo;<samp>%g</samp>&rsquo; and &lsquo;<samp>%G</samp>&rsquo; conversions, this also forces trailing zeros
after the decimal point to be printed where they would otherwise be
elided.
</p>
<p>For the &lsquo;<samp>%o</samp>&rsquo; conversion, force the leading digit to be &lsquo;<samp>0</samp>&rsquo;, as
if by increasing the precision.  For &lsquo;<samp>%x</samp>&rsquo; or &lsquo;<samp>%X</samp>&rsquo;, prefix a
leading &lsquo;<samp>0x</samp>&rsquo; or &lsquo;<samp>0X</samp>&rsquo; (respectively) to the result.  This
doesn&rsquo;t do anything useful for the &lsquo;<samp>%d</samp>&rsquo;, &lsquo;<samp>%i</samp>&rsquo;, or &lsquo;<samp>%u</samp>&rsquo;
conversions.  Using this flag produces output which can be parsed by the
<code>scanf</code> functions with the &lsquo;<samp>%i</samp>&rsquo; conversion
(see section <a href="#Standard-Formatted-Input">Standard Formatted Input</a>).
</p>

</dd>
<dt> &lsquo;<samp>0</samp>&rsquo;</dt>
<dd><p>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 &lsquo;<samp>-</samp>&rsquo;
flag is also specified, or if a precision is specified for an exact
converson.
</p></dd>
</dl>

</li><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 &lsquo;<samp>0</samp>&rsquo; 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="index-minimum-field-width-_0028printf_0029"></a>

<p>Alternatively, if the field width is &lsquo;<samp>*</samp>&rsquo;, 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 &lsquo;<samp>-</samp>&rsquo; flag is set (see above) and the
absolute value is used as the field width.
</p>
</li><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 (&lsquo;<samp>.</samp>&rsquo;) followed
optionally by a decimal integer (which defaults to zero if omitted).
<a name="index-precision-_0028printf_0029"></a>

<p>Alternatively, if the precision is &lsquo;<samp>.*</samp>&rsquo;, 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 &lsquo;<samp>*</samp>&rsquo; for both the field width and precision, the
field width argument precedes the precision argument.  The &lsquo;<samp>.*</samp>&rsquo;
precision is an enhancement.  C library versions may not accept this
syntax.
</p>
<p>For the &lsquo;<samp>%f</samp>&rsquo;, &lsquo;<samp>%e</samp>&rsquo;, and &lsquo;<samp>%E</samp>&rsquo; 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 &lsquo;<samp>%g</samp>&rsquo; and &lsquo;<samp>%G</samp>&rsquo; 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 &lsquo;<samp>%g</samp>&rsquo; or &lsquo;<samp>%G</samp>&rsquo;, 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 &lsquo;<samp>0</samp>&rsquo; with an
explicit precision of zero produces no characters.
</p>
</li><li>
An optional one of &lsquo;<samp>l</samp>&rsquo;, &lsquo;<samp>h</samp>&rsquo; or &lsquo;<samp>L</samp>&rsquo;, which is ignored for
numeric conversions.  It is an error to specify these modifiers for
non-numeric conversions.

</li><li>
A character that specifies the conversion to be applied.
</li></ul>

</dd></dl>
<hr size="6">
<a name="Exact-Conversions"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Standard-Formatted-Output" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Inexact-Conversions" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Standard-Formatted-Output" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h4 class="subsubsection">4.3.2.1 Exact Conversions</h4>

<dl compact="compact">
<dt> &lsquo;<samp>b</samp>&rsquo;, &lsquo;<samp>B</samp>&rsquo;</dt>
<dd><p>Print an integer as an unsigned binary number.
</p>
<p><em>Note:</em> &lsquo;<samp>%b</samp>&rsquo; and &lsquo;<samp>%B</samp>&rsquo; are SLIB extensions.
</p>

</dd>
<dt> &lsquo;<samp>d</samp>&rsquo;, &lsquo;<samp>i</samp>&rsquo;</dt>
<dd><p>Print an integer as a signed decimal number.  &lsquo;<samp>%d</samp>&rsquo; and &lsquo;<samp>%i</samp>&rsquo;
are synonymous for output, but are different when used with <code>scanf</code>
for input (see section <a href="#Standard-Formatted-Input">Standard Formatted Input</a>).
</p>
</dd>
<dt> &lsquo;<samp>o</samp>&rsquo;</dt>
<dd><p>Print an integer as an unsigned octal number.
</p>
</dd>
<dt> &lsquo;<samp>u</samp>&rsquo;</dt>
<dd><p>Print an integer as an unsigned decimal number.
</p>
</dd>
<dt> &lsquo;<samp>x</samp>&rsquo;, &lsquo;<samp>X</samp>&rsquo;</dt>
<dd><p>Print an integer as an unsigned hexadecimal number.  &lsquo;<samp>%x</samp>&rsquo; prints
using the digits &lsquo;<samp>0123456789abcdef</samp>&rsquo;.  &lsquo;<samp>%X</samp>&rsquo; prints using the
digits &lsquo;<samp>0123456789ABCDEF</samp>&rsquo;.
</p></dd>
</dl>

<hr size="6">
<a name="Inexact-Conversions"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Exact-Conversions" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Other-Conversions" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Standard-Formatted-Output" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h4 class="subsubsection">4.3.2.2 Inexact Conversions</h4>

<dl compact="compact">
<dt> &lsquo;<samp>f</samp>&rsquo;</dt>
<dd><p>Print a floating-point number in fixed-point notation.
</p>
</dd>
<dt> &lsquo;<samp>e</samp>&rsquo;, &lsquo;<samp>E</samp>&rsquo;</dt>
<dd><p>Print a floating-point number in exponential notation.  &lsquo;<samp>%e</samp>&rsquo; prints
&lsquo;<samp>e</samp>&rsquo; between mantissa and exponont.  &lsquo;<samp>%E</samp>&rsquo; prints &lsquo;<samp>E</samp>&rsquo;
between mantissa and exponont.
</p>
</dd>
<dt> &lsquo;<samp>g</samp>&rsquo;, &lsquo;<samp>G</samp>&rsquo;</dt>
<dd><p>Print a floating-point number in either fixed or exponential notation,
whichever is more appropriate for its magnitude.  Unless an &lsquo;<samp>#</samp>&rsquo;
flag has been supplied, trailing zeros after a decimal point will be
stripped off.  &lsquo;<samp>%g</samp>&rsquo; prints &lsquo;<samp>e</samp>&rsquo; between mantissa and exponont.
&lsquo;<samp>%G</samp>&rsquo; prints &lsquo;<samp>E</samp>&rsquo; between mantissa and exponent.
</p>
</dd>
<dt> &lsquo;<samp>k</samp>&rsquo;, &lsquo;<samp>K</samp>&rsquo;</dt>
<dd><p>Print a number like &lsquo;<samp>%g</samp>&rsquo;, except that an SI prefix is output
after the number, which is scaled accordingly.  &lsquo;<samp>%K</samp>&rsquo; outputs a
dot between number and prefix, &lsquo;<samp>%k</samp>&rsquo; does not.
</p>
</dd>
</dl>

<hr size="6">
<a name="Other-Conversions"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Inexact-Conversions" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Standard-Formatted-Input" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Standard-Formatted-Output" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h4 class="subsubsection">4.3.2.3 Other Conversions</h4>
<dl compact="compact">
<dt> &lsquo;<samp>c</samp>&rsquo;</dt>
<dd><p>Print a single character.  The &lsquo;<samp>-</samp>&rsquo; flag is the only one which can
be specified.  It is an error to specify a precision.
</p>
</dd>
<dt> &lsquo;<samp>s</samp>&rsquo;</dt>
<dd><p>Print a string.  The &lsquo;<samp>-</samp>&rsquo; 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>
</dd>
<dt> &lsquo;<samp>a</samp>&rsquo;, &lsquo;<samp>A</samp>&rsquo;</dt>
<dd><p>Print a scheme expression.  The &lsquo;<samp>-</samp>&rsquo; flag left-justifies the output.
The &lsquo;<samp>#</samp>&rsquo; 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>
<p><em>Note:</em> &lsquo;<samp>%a</samp>&rsquo; and &lsquo;<samp>%A</samp>&rsquo; are SLIB extensions.
</p>



</dd>
<dt> &lsquo;<samp>%</samp>&rsquo;</dt>
<dd><p>Print a literal &lsquo;<samp>%</samp>&rsquo; character.  No argument is consumed.  It is an
error to specify flags, field width, precision, or type modifiers with
&lsquo;<samp>%%</samp>&rsquo;.
</p></dd>
</dl>
@end deffn


<hr size="6">
<a name="Standard-Formatted-Input"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Other-Conversions" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Programs-and-Arguments" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Standard-Formatted-I_002fO" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Standard-Formatted-Input-1"></a>
<h3 class="subsection">4.3.3 Standard Formatted Input</h3>

<p><code>(require 'scanf)</code>
<a name="index-scanf"></a>
</p>
<dl>
<dt><a name="index-scanf_002dread_002dlist"></a><u>Function:</u> <b>scanf-read-list</b><i> format</i></dt>
<dt><a name="index-scanf_002dread_002dlist-1"></a><u>Function:</u> <b>scanf-read-list</b><i> format port</i></dt>
<dt><a name="index-scanf_002dread_002dlist-2"></a><u>Function:</u> <b>scanf-read-list</b><i> format string</i></dt>
</dl>

<dl>
<dt><a name="index-scanf-1"></a><u>Macro:</u> <b>scanf</b><i> format arg1 &hellip;</i></dt>
<dt><a name="index-fscanf"></a><u>Macro:</u> <b>fscanf</b><i> port format arg1 &hellip;</i></dt>
<dt><a name="index-sscanf"></a><u>Macro:</u> <b>sscanf</b><i> str format arg1 &hellip;</i></dt>
<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> &hellip; using the methods:
</p>
<dl compact="compact">
<dt> symbol</dt>
<dd><p><code>set!</code>
</p></dd>
<dt> car expression</dt>
<dd><p><code>set-car!</code>
</p></dd>
<dt> cdr expression</dt>
<dd><p><code>set-cdr!</code>
</p></dd>
<dt> vector-ref expression</dt>
<dd><p><code>vector-set!</code>
</p></dd>
<dt> substring expression</dt>
<dd><p><code>substring-move-left!</code>
</p></dd>
</dl>

<p>The argument to a <code>substring</code> expression in <var>arg1</var> &hellip; 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>
<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.

</li><li> An ordinary character (not &lsquo;<samp>%</samp>&rsquo;) that must match the next
character of the input stream.

</li><li> Conversion specifications, consisting of the character &lsquo;<samp>%</samp>&rsquo;, an
optional assignment suppressing character &lsquo;<samp>*</samp>&rsquo;, an optional
numerical maximum-field width, an optional &lsquo;<samp>l</samp>&rsquo;, &lsquo;<samp>h</samp>&rsquo; or
&lsquo;<samp>L</samp>&rsquo; which is ignored, and a conversion code.


</li></ul>

<p>Unless the specification contains the &lsquo;<samp>n</samp>&rsquo; 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
&lsquo;<samp>*</samp>&rsquo; 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>
<blockquote><p><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 &lsquo;<samp>[</samp>&rsquo; and
&lsquo;<samp>c</samp>&rsquo;.
</p></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>
<dl compact="compact">
<dt> &lsquo;<samp>%</samp>&rsquo;</dt>
<dd><p>A single % is expected in the input at this point; no value is returned.
</p>
</dd>
<dt> &lsquo;<samp>d</samp>&rsquo;, &lsquo;<samp>D</samp>&rsquo;</dt>
<dd><p>A decimal integer is expected.
</p>
</dd>
<dt> &lsquo;<samp>u</samp>&rsquo;, &lsquo;<samp>U</samp>&rsquo;</dt>
<dd><p>An unsigned decimal integer is expected.
</p>
</dd>
<dt> &lsquo;<samp>o</samp>&rsquo;, &lsquo;<samp>O</samp>&rsquo;</dt>
<dd><p>An octal integer is expected.
</p>
</dd>
<dt> &lsquo;<samp>x</samp>&rsquo;, &lsquo;<samp>X</samp>&rsquo;</dt>
<dd><p>A hexadecimal integer is expected.
</p>
</dd>
<dt> &lsquo;<samp>i</samp>&rsquo;</dt>
<dd><p>An integer is expected.  Returns the value of the next input item,
interpreted according to C conventions; a leading &lsquo;<samp>0</samp>&rsquo; implies
octal, a leading &lsquo;<samp>0x</samp>&rsquo; implies hexadecimal; otherwise, decimal is
assumed.
</p>
</dd>
<dt> &lsquo;<samp>n</samp>&rsquo;</dt>
<dd><p>Returns the total number of bytes (including white space) read by
<code>scanf</code>.  No input is consumed by <code>%n</code>.
</p>
</dd>
<dt> &lsquo;<samp>f</samp>&rsquo;, &lsquo;<samp>F</samp>&rsquo;, &lsquo;<samp>e</samp>&rsquo;, &lsquo;<samp>E</samp>&rsquo;, &lsquo;<samp>g</samp>&rsquo;, &lsquo;<samp>G</samp>&rsquo;</dt>
<dd><p>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 &lsquo;<samp>.</samp>&rsquo;, followed by an optional
exponent field consisting of an &lsquo;<samp>E</samp>&rsquo; or an &lsquo;<samp>e</samp>&rsquo;, followed by an
optional &lsquo;<samp>+</samp>&rsquo;, &lsquo;<samp>-</samp>&rsquo;, or space, followed by an integer.
</p>
</dd>
<dt> &lsquo;<samp>c</samp>&rsquo;, &lsquo;<samp>C</samp>&rsquo;</dt>
<dd><p><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
&lsquo;<samp>%1s</samp>&rsquo;.  If a field width is given, a string is returned; up to the
indicated number of characters is read.
</p>
</dd>
<dt> &lsquo;<samp>s</samp>&rsquo;, &lsquo;<samp>S</samp>&rsquo;</dt>
<dd><p>A character string is expected The input field is terminated by a
white-space character.  <code>scanf</code> cannot read a null string.
</p>
</dd>
<dt> &lsquo;<samp>[</samp>&rsquo;</dt>
<dd><p>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.  &lsquo;<samp>^</samp>&rsquo;, 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 &lsquo;<samp>[0123456789]</samp>&rsquo; to be expressed &lsquo;<samp>[0-9]</samp>&rsquo;.  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 &lsquo;<samp>^</samp>&rsquo;) 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.
</p></dd>
</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></dd></dl>


<hr size="6">
<a name="Programs-and-Arguments"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Standard-Formatted-Input" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Getopt" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Program-and-Arguments"></a>
<h2 class="section">4.4 Program and Arguments</h2>

<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#Getopt">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="#Command-Line">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="#Parameter-lists">4.4.4 Parameter lists</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">             &rsquo;parameters
</td></tr>
<tr><td align="left" valign="top"><a href="#Getopt-Parameter-lists">4.4.5 Getopt Parameter lists</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">      &rsquo;getopt-parameters
</td></tr>
<tr><td align="left" valign="top"><a href="#Filenames">4.4.6 Filenames</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                   &rsquo;filename
</td></tr>
<tr><td align="left" valign="top"><a href="#Batch">4.4.7 Batch</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                       &rsquo;batch
</td></tr>
</table>

<hr size="6">
<a name="Getopt"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Programs-and-Arguments" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Getopt_002d_002d_002d" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Programs-and-Arguments" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Getopt-1"></a>
<h3 class="subsection">4.4.1 Getopt</h3>

<p><code>(require 'getopt)</code>
<a name="index-getopt"></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>
<dl>
<dt><a name="index-_002aargv_002a"></a><u>Variable:</u> <b>*argv*</b></dt>
<dd><p>Define <var>*argv*</var> with a list of arguments before calling getopt
procedures.  If you don&rsquo;t want the first (0th) element to be ignored,
set <var>*optind*</var> to 0 (after requiring getopt).
</p></dd></dl>

<dl>
<dt><a name="index-_002aoptind_002a"></a><u>Variable:</u> <b>*optind*</b></dt>
<dd><p>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.
</p></dd></dl>

<dl>
<dt><a name="index-_002aoptarg_002a"></a><u>Variable:</u> <b>*optarg*</b></dt>
<dd><p>Is set by getopt to the (string) option-argument of the current option.
</p></dd></dl>

<dl>
<dt><a name="index-getopt-1"></a><u>Function:</u> <b>getopt</b><i> optstring</i></dt>
<dd><p>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>
<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 &lsquo;<tt>getopt.scm</tt>&rsquo;, 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>
<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.

</li><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.
</li></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:
</p><table><tr><td>&nbsp;</td><td><pre class="lisp">#! /usr/local/bin/scm
(require 'program-arguments)
(require 'getopt)
(define argv (program-arguments))
<a name="index-getopt-2"></a><a name="index-program_002darguments"></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>
</dd></dl>

<hr size="6">
<a name="Getopt_002d_002d_002d"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Getopt" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Command-Line" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Programs-and-Arguments" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">4.4.2 Getopt&mdash;</h3>

<dl>
<dt><a name="index-getopt_002d_002d"></a><u>Function:</u> <b><code>getopt--</code></b><i> optstring</i></dt>
<dd><p>The procedure <code>getopt--</code> is an extended version of <code>getopt</code>
which parses <em>long option names</em> of the form
&lsquo;<samp>--hold-the-onions</samp>&rsquo; and &lsquo;<samp>--verbosity-level=extreme</samp>&rsquo;.
<code>Getopt--</code> behaves as <code>getopt</code> except for non-empty
options beginning with &lsquo;<samp>--</samp>&rsquo;.
</p>
<p>Options beginning with &lsquo;<samp>--</samp>&rsquo; are returned as strings rather than
characters.  If a value is assigned (using &lsquo;<samp>=</samp>&rsquo;) to a long option,
<code>*optarg*</code> is set to the value.  The &lsquo;<samp>=</samp>&rsquo; 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>
<table><tr><td>&nbsp;</td><td><pre class="example">(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="index-qp"></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>
</dd></dl>


<hr size="6">
<a name="Command-Line"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Getopt_002d_002d_002d" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Parameter-lists" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Programs-and-Arguments" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Command-Line-1"></a>
<h3 class="subsection">4.4.3 Command Line</h3>

<p><code>(require 'read-command)</code>
<a name="index-read_002dcommand"></a>
</p>

<dl>
<dt><a name="index-read_002dcommand-1"></a><u>Function:</u> <b>read-command</b><i> port</i></dt>
<dt><a name="index-read_002dcommand-2"></a><u>Function:</u> <b>read-command</b></dt>
<dd><p><code>read-command</code> converts a <em>command line</em> into a list of strings
<a name="index-command-line"></a>
<a name="index-command-line-1"></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="index-shell"></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 (&lt;;&gt;) or
&lt;newline&gt;.  Any character can be literally included in a field by
escaping it with a backslach (&lt;\&gt;).
</p>
<p>The initial character and types of fields recognized are:
</p><dl compact="compact">
<dt> &lsquo;<samp>\</samp>&rsquo;</dt>
<dd><p>The next character has is taken literally and not interpreted as a field
delimiter.  If &lt;\&gt; is the last character before a &lt;newline&gt;,
that &lt;newline&gt; is just ignored.  Processing continues from the
characters after the &lt;newline&gt; as though the backslash and
&lt;newline&gt; were not there.
</p></dd>
<dt> &lsquo;<samp>&quot;</samp>&rsquo;</dt>
<dd><p>The characters up to the next unescaped &lt;&quot;&gt; are taken literally,
according to [R4RS] rules for literal strings
(see <a href="../r4rs/Strings.html#Strings">(r4rs)Strings</a> section &lsquo;Strings&rsquo; in <cite>Revised(4) Scheme</cite>).
</p></dd>
<dt> &lsquo;<samp>(</samp>&rsquo;, &lsquo;<samp>%'</samp>&rsquo;</dt>
<dd><p>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.
</p></dd>
<dt> &lsquo;<samp>;</samp>&rsquo;</dt>
<dd><p>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.
</p></dd>
</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.  &lt;#&gt; can be part of fields if these conditions are
not met.  For instance, <code>ab#c</code> is just the field ab#c.
</p>
<dl compact="compact">
<dt> &lsquo;<samp>#</samp>&rsquo;</dt>
<dd><p>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 &lt;newline&gt;s in
comments are also ignored.
</p></dd>
</dl>
</dd></dl>


<dl>
<dt><a name="index-read_002doptions_002dfile"></a><u>Function:</u> <b>read-options-file</b><i> filename</i></dt>
<dd>
<p><code>read-options-file</code> converts an <em>options file</em> into a list of
<a name="index-options-file"></a>
<a name="index-options-file-1"></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 &lt;newline&gt;s do not terminate reading (only &lt;;&gt;
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></dd></dl>



<hr size="6">
<a name="Parameter-lists"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Command-Line" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Getopt-Parameter-lists" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Programs-and-Arguments" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Parameter-lists-1"></a>
<h3 class="subsection">4.4.4 Parameter lists</h3>

<p><code>(require 'parameters)</code>
<a name="index-parameters"></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>(<span class="roman">parameter-name</span> <span class="roman">value1</span>
&hellip;)</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>
<dl>
<dt><a name="index-make_002dparameter_002dlist"></a><u>Function:</u> <b>make-parameter-list</b><i> parameter-names</i></dt>
<dd><p>Returns an empty parameter-list with slots for <var>parameter-names</var>.
</p></dd></dl>

<dl>
<dt><a name="index-parameter_002dlist_002dref"></a><u>Function:</u> <b>parameter-list-ref</b><i> parameter-list parameter-name</i></dt>
<dd><p><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>.
</p></dd></dl>

<dl>
<dt><a name="index-remove_002dparameter"></a><u>Function:</u> <b>remove-parameter</b><i> parameter-name parameter-list</i></dt>
<dd><p>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>
<p>If there are more than one <var>parameter-name</var> parameters, an error is
signaled.
</p></dd></dl>

<dl>
<dt><a name="index-adjoin_002dparameters_0021"></a><u>Procedure:</u> <b>adjoin-parameters!</b><i> parameter-list parameter1 &hellip;</i></dt>
<dd><p>Returns <var>parameter-list</var> with <var>parameter1</var> &hellip; merged in.
</p></dd></dl>

<dl>
<dt><a name="index-parameter_002dlist_002dexpand"></a><u>Procedure:</u> <b>parameter-list-expand</b><i> expanders parameter-list</i></dt>
<dd><p><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>
<p>This process is repeated until <var>parameter-list</var> stops growing.  The
value returned from <code>parameter-list-expand</code> is unspecified.
</p></dd></dl>

<dl>
<dt><a name="index-fill_002dempty_002dparameters"></a><u>Function:</u> <b>fill-empty-parameters</b><i> defaulters parameter-list</i></dt>
<dd><p><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.
</p></dd></dl>

<dl>
<dt><a name="index-check_002dparameters"></a><u>Function:</u> <b>check-parameters</b><i> checks parameter-list</i></dt>
<dd><p><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>
<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></dd></dl>

<p>In the following procedures <var>arities</var> is a list of symbols.  The
elements of <code>arities</code> can be:
</p>
<dl compact="compact">
<dt> <code>single</code></dt>
<dd><p>Requires a single parameter.
</p></dd>
<dt> <code>optional</code></dt>
<dd><p>A single parameter or no parameter is acceptable.
</p></dd>
<dt> <code>boolean</code></dt>
<dd><p>A single boolean parameter or zero parameters is acceptable.
</p></dd>
<dt> <code>nary</code></dt>
<dd><p>Any number of parameters are acceptable.
</p></dd>
<dt> <code>nary1</code></dt>
<dd><p>One or more of parameters are acceptable.
</p></dd>
</dl>

<dl>
<dt><a name="index-parameter_002dlist_002d_003earglist"></a><u>Function:</u> <b>parameter-list-&gt;arglist</b><i> positions arities parameter-list</i></dt>
<dd><p>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>
<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></dd></dl>


<hr size="6">
<a name="Getopt-Parameter-lists"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Parameter-lists" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Filenames" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Programs-and-Arguments" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Getopt-Parameter-lists-1"></a>
<h3 class="subsection">4.4.5 Getopt Parameter lists</h3>

<p><code>(require 'getopt-parameters)</code>
<a name="index-getopt_002dparameters"></a>
</p>

<dl>
<dt><a name="index-getopt_002d_003eparameter_002dlist"></a><u>Function:</u> <b>getopt-&gt;parameter-list</b><i> optnames arities types aliases desc &hellip;</i></dt>
<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 &lsquo;<samp>-</samp>&rsquo; option by <code>getopt</code>.  Longer strings will be
treated as long-named options (see section <a href="#Getopt">getopt&ndash;</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 &lsquo;<samp>-1</samp>&rsquo; alias will take the last argument in
this list; &lsquo;<samp>+1</samp>&rsquo; will take the first argument in the list.  The
aliases -2 then +2; -3 then +3; &hellip; are tried so long as a positive
or negative consecutive alias is found and arguments remain in the list.
Finally a &lsquo;<samp>0</samp>&rsquo; 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></dd></dl>


<dl>
<dt><a name="index-getopt_002d_003earglist"></a><u>Function:</u> <b>getopt-&gt;arglist</b><i> optnames positions arities types defaulters checks aliases desc &hellip;</i></dt>
<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></dd></dl>

<p>These <code>getopt</code> functions can be used with SLIB relational
databases.  For an example, See section <a href="slib_6.html#Using-Databases">make-command-server</a>.
</p>
<p>If errors are encountered while processing options, directions for using
the options (and argument strings <var>desc</var> &hellip;) are printed to
<code>current-error-port</code>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(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>


<hr size="6">
<a name="Filenames"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Getopt-Parameter-lists" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Batch" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Programs-and-Arguments" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Filenames-1"></a>
<h3 class="subsection">4.4.6 Filenames</h3>

<a name="index-glob"></a>
<p><code>(require 'filename)</code>
<a name="index-filename"></a>
<a name="index-glob-1"></a>
</p>

<dl>
<dt><a name="index-filename_003amatch_003f_003f"></a><u>Function:</u> <b>filename:match??</b><i> pattern</i></dt>
<dt><a name="index-filename_003amatch_002dci_003f_003f"></a><u>Function:</u> <b>filename:match-ci??</b><i> pattern</i></dt>
<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="index-glob-2"></a>
<em>glob</em> expansion described the bash manpage, except that names
<a name="index-glob-3"></a>
beginning with &lsquo;<samp>.</samp>&rsquo; are matched and &lsquo;<samp>/</samp>&rsquo; characters are not
treated specially.
</p>
<p>These functions interpret the following characters specially in
<var>pattern</var> strings:
</p><dl compact="compact">
<dt> &lsquo;<samp>*</samp>&rsquo;</dt>
<dd><p>Matches any string, including the null string.
</p></dd>
<dt> &lsquo;<samp>?</samp>&rsquo;</dt>
<dd><p>Matches any single character.
</p></dd>
<dt> &lsquo;<samp>[&hellip;]</samp>&rsquo;</dt>
<dd><p>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 &lsquo;<samp>[</samp>&rsquo; is a &lsquo;<samp>!</samp>&rsquo; or a &lsquo;<samp>^</samp>&rsquo; then any
character not enclosed is matched.  A &lsquo;<samp>-</samp>&rsquo; or &lsquo;<samp>]</samp>&rsquo; may be
matched by including it as the first or last character in the set.
</p></dd>
</dl>
</dd></dl>


<dl>
<dt><a name="index-filename_003asubstitute_003f_003f"></a><u>Function:</u> <b>filename:substitute??</b><i> pattern template</i></dt>
<dt><a name="index-filename_003asubstitute_002dci_003f_003f"></a><u>Function:</u> <b>filename:substitute-ci??</b><i> pattern template</i></dt>
<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></dd></dl>

<table><tr><td>&nbsp;</td><td><pre class="example">((filename:substitute?? &quot;scm_[0-9]*.html&quot; &quot;scm5c4_??.htm&quot;)
 &quot;scm_10.html&quot;)
&rArr; &quot;scm5c4_10.htm&quot;
((filename:substitute?? &quot;??&quot; &quot;beg?mid?end&quot;) &quot;AZ&quot;)
&rArr; &quot;begAmidZend&quot;
((filename:substitute?? &quot;*na*&quot; &quot;?NA?&quot;) &quot;banana&quot;)
&rArr; &quot;banaNA&quot;
((filename:substitute?? &quot;?*?&quot; (lambda (s1 s2 s3) (string-append s3 s1)))
 &quot;ABZ&quot;)
&rArr; &quot;ZA&quot;
</pre></td></tr></table>


<dl>
<dt><a name="index-replace_002dsuffix"></a><u>Function:</u> <b>replace-suffix</b><i> str old new</i></dt>
<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></dd></dl>

<table><tr><td>&nbsp;</td><td><pre class="example">(replace-suffix &quot;/usr/local/lib/slib/batch.scm&quot; &quot;.scm&quot; &quot;.c&quot;)
&rArr; &quot;/usr/local/lib/slib/batch.c&quot;
</pre></td></tr></table>


<dl>
<dt><a name="index-call_002dwith_002dtmpnam"></a><u>Function:</u> <b>call-with-tmpnam</b><i> proc k</i></dt>
<dt><a name="index-call_002dwith_002dtmpnam-1"></a><u>Function:</u> <b>call-with-tmpnam</b><i> proc</i></dt>
<dd><p>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>

</dd><dt><a name="index-call_002dwith_002dtmpnam-2"></a><u>Function:</u> <b>call-with-tmpnam</b><i> proc suffix1 &hellip;</i></dt>
<dd><p>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></dd></dl>



<hr size="6">
<a name="Batch"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Filenames" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#HTML" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Programs-and-Arguments" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Batch-1"></a>
<h3 class="subsection">4.4.7 Batch</h3>

<p><code>(require 'batch)</code>
<a name="index-batch"></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="#Parameter-lists">Parameter lists</a>).  This
parameter-list argument <var>parms</var> contains named associations.  Batch
currently uses 2 of these:
</p>
<dl compact="compact">
<dt> <code>batch-port</code></dt>
<dd><p>The port on which to write lines of the batch file.
</p></dd>
<dt> <code>batch-dialect</code></dt>
<dd><p>The syntax of batch file to generate.  Currently supported are:
</p><ul>
<li>
unix
</li><li>
dos
</li><li>
vms
</li><li>
amigaos
</li><li>
system
</li><li>
*unknown*
</li></ul>
</dd>
</dl>

<p>The &lsquo;<samp>batch</samp>&rsquo; module uses 2 enhanced relational tables
(see section <a href="slib_6.html#Using-Databases">Using Databases</a>) to store information linking the names of
<code>operating-system</code>s to <code>batch-dialect</code>es.
</p>
<dl>
<dt><a name="index-batch_003ainitialize_0021"></a><u>Function:</u> <b>batch:initialize!</b><i> database</i></dt>
<dd><p>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>.
</p></dd></dl>

<dl>
<dt><a name="index-_002aoperating_002dsystem_002a"></a><u>Variable:</u> <b>*operating-system*</b></dt>
<dd><p>Is batch&rsquo;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#Configuration">Configuration</a>) unless <code>(software-type)</code> is <code>unix</code>,
in which case finer distinctions are made.
</p></dd></dl>

<dl>
<dt><a name="index-batch_003acall_002dwith_002doutput_002dscript"></a><u>Function:</u> <b>batch:call-with-output-script</b><i> parms file proc</i></dt>
<dd><p><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.
</p></dd></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>
<table><tr><td>&nbsp;</td><td><pre class="example">(adjoin-parameters! <var>parms</var> (list 'batch-port <var>port</var>))
</pre></td></tr></table>

<dl>
<dt><a name="index-batch_003acommand"></a><u>Function:</u> <b>batch:command</b><i> parms string1 string2 &hellip;</i></dt>
<dd><p>Calls <code>batch:try-command</code> (below) with arguments, but signals an
error if <code>batch:try-command</code> returns <code>#f</code>.
</p></dd></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>
<dl>
<dt><a name="index-batch_003atry_002dcommand"></a><u>Function:</u> <b>batch:try-command</b><i> parms string1 string2 &hellip;</i></dt>
<dd><p>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> &hellip;.
</p></dd></dl>

<dl>
<dt><a name="index-batch_003atry_002dchopped_002dcommand"></a><u>Function:</u> <b>batch:try-chopped-command</b><i> parms arg1 arg2 &hellip; list</i></dt>
<dd><p>breaks the last argument <var>list</var> into chunks small enough so that the
command:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example"><var>arg1</var> <var>arg2</var> &hellip; <var>chunk</var>
</pre></td></tr></table>

<p>fits withing the platform&rsquo;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></dd></dl>

<dl>
<dt><a name="index-batch_003arun_002dscript"></a><u>Function:</u> <b>batch:run-script</b><i> parms string1 string2 &hellip;</i></dt>
<dd><p>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>
&hellip;.
</p>
<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></dd></dl>

<dl>
<dt><a name="index-batch_003acomment"></a><u>Function:</u> <b>batch:comment</b><i> parms line1 &hellip;</i></dt>
<dd><p>Writes comment lines <var>line1</var> &hellip; to the <code>batch-port</code> in
<var>parms</var>.
</p></dd></dl>

<dl>
<dt><a name="index-batch_003alines_002d_003efile"></a><u>Function:</u> <b>batch:lines-&gt;file</b><i> parms file line1 &hellip;</i></dt>
<dd><p>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> &hellip;.
</p></dd></dl>

<dl>
<dt><a name="index-batch_003adelete_002dfile"></a><u>Function:</u> <b>batch:delete-file</b><i> parms file</i></dt>
<dd><p>Writes a command to the <code>batch-port</code> in <var>parms</var> which deletes
the file named <var>file</var>.
</p></dd></dl>

<dl>
<dt><a name="index-batch_003arename_002dfile"></a><u>Function:</u> <b>batch:rename-file</b><i> parms old-name new-name</i></dt>
<dd><p>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>.
</p></dd></dl>

<p>In addition, batch provides some small utilities very useful for writing
scripts:
</p>
<dl>
<dt><a name="index-truncate_002dup_002dto"></a><u>Function:</u> <b>truncate-up-to</b><i> path char</i></dt>
<dt><a name="index-truncate_002dup_002dto-1"></a><u>Function:</u> <b>truncate-up-to</b><i> path string</i></dt>
<dt><a name="index-truncate_002dup_002dto-2"></a><u>Function:</u> <b>truncate-up-to</b><i> path charlist</i></dt>
<dd><p><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><pre class="example">(truncate-up-to &quot;/usr/local/lib/slib/batch.scm&quot; &quot;/&quot;)
&rArr; &quot;batch.scm&quot;
</pre></td></tr></table>
</dd></dl>

<dl>
<dt><a name="index-string_002djoin"></a><u>Function:</u> <b>string-join</b><i> joiner string1 &hellip;</i></dt>
<dd><p>Returns a new string consisting of all the strings <var>string1</var> &hellip;
in order appended together with the string <var>joiner</var> between each
adjacent pair.
</p></dd></dl>

<dl>
<dt><a name="index-must_002dbe_002dfirst"></a><u>Function:</u> <b>must-be-first</b><i> list1 list2</i></dt>
<dd><p>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>.
</p></dd></dl>

<dl>
<dt><a name="index-must_002dbe_002dlast"></a><u>Function:</u> <b>must-be-last</b><i> list1 list2</i></dt>
<dd><p>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>.
</p></dd></dl>

<dl>
<dt><a name="index-os_002d_003ebatch_002ddialect"></a><u>Function:</u> <b>os-&gt;batch-dialect</b><i> osname</i></dt>
<dd><p>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>.
</p></dd></dl>

<p>Here is an example of the use of most of batch&rsquo;s procedures:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(require 'databases)
<a name="index-databases"></a>(require 'parameters)
<a name="index-parameters-1"></a>(require 'batch)
<a name="index-batch-1"></a>(require 'filename)
<a name="index-filename-1"></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 &lsquo;<tt>my-batch</tt>&rsquo;:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">#! /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, &lsquo;<tt>my-batch</tt>&rsquo; prints:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">bash$ my-batch
mv: hello.c: No such file or directory
hello world
</pre></td></tr></table>


<hr size="6">
<a name="HTML"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Batch" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#HTML-Forms" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="HTML-1"></a>
<h2 class="section">4.5 HTML</h2>

<p><code>(require 'html-form)</code>
<a name="index-html_002dform"></a>
</p>

<dl>
<dt><a name="index-html_003aatval"></a><u>Function:</u> <b>html:atval</b><i> txt</i></dt>
<dd><p>Returns a string with character substitutions appropriate to
send <var>txt</var> as an <em>attribute-value</em>.
<a name="index-attribute_002dvalue"></a>
</p></dd></dl>


<dl>
<dt><a name="index-html_003aplain"></a><u>Function:</u> <b>html:plain</b><i> txt</i></dt>
<dd><p>Returns a string with character substitutions appropriate to
send <var>txt</var> as an <em>plain-text</em>.
<a name="index-plain_002dtext"></a>
</p></dd></dl>


<dl>
<dt><a name="index-html_003ameta"></a><u>Function:</u> <b>html:meta</b><i> name content</i></dt>
<dd><p>Returns a tag of meta-information suitable for passing as the
third argument to <code>html:head</code>.  The tag produced is &lsquo;<samp>&lt;META
NAME=&quot;<var>name</var>&quot; CONTENT=&quot;<var>content</var>&quot;&gt;</samp>&rsquo;.  The string or symbol <var>name</var> can be
&lsquo;<samp>author</samp>&rsquo;, &lsquo;<samp>copyright</samp>&rsquo;, &lsquo;<samp>keywords</samp>&rsquo;, &lsquo;<samp>description</samp>&rsquo;,
&lsquo;<samp>date</samp>&rsquo;, &lsquo;<samp>robots</samp>&rsquo;, &hellip;.
</p></dd></dl>


<dl>
<dt><a name="index-html_003ahttp_002dequiv"></a><u>Function:</u> <b>html:http-equiv</b><i> name content</i></dt>
<dd><p>Returns a tag of HTTP information suitable for passing as the
third argument to <code>html:head</code>.  The tag produced is &lsquo;<samp>&lt;META
HTTP-EQUIV=&quot;<var>name</var>&quot; CONTENT=&quot;<var>content</var>&quot;&gt;</samp>&rsquo;.  The string or symbol <var>name</var> can be
&lsquo;<samp>Expires</samp>&rsquo;, &lsquo;<samp>PICS-Label</samp>&rsquo;, &lsquo;<samp>Content-Type</samp>&rsquo;,
&lsquo;<samp>Refresh</samp>&rsquo;, &hellip;.
</p></dd></dl>


<dl>
<dt><a name="index-html_003ameta_002drefresh"></a><u>Function:</u> <b>html:meta-refresh</b><i> delay uri</i></dt>
<dt><a name="index-html_003ameta_002drefresh-1"></a><u>Function:</u> <b>html:meta-refresh</b><i> delay</i></dt>
<dd>
<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></dd></dl>


<dl>
<dt><a name="index-html_003ahead"></a><u>Function:</u> <b>html:head</b><i> title backlink tags &hellip;</i></dt>
<dt><a name="index-html_003ahead-1"></a><u>Function:</u> <b>html:head</b><i> title backlink</i></dt>
<dt><a name="index-html_003ahead-2"></a><u>Function:</u> <b>html:head</b><i> title</i></dt>
<dd>
<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 &lsquo;<samp>H1</samp>&rsquo; 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></dd></dl>


<dl>
<dt><a name="index-html_003abody"></a><u>Function:</u> <b>html:body</b><i> body &hellip;</i></dt>
<dd><p>Returns HTML string to end a page.
</p></dd></dl>


<dl>
<dt><a name="index-html_003apre"></a><u>Function:</u> <b>html:pre</b><i> line1 line &hellip;</i></dt>
<dd><p>Returns the strings <var>line1</var>, <var>lines</var> as <em>PRE</em>formmated plain text
<a name="index-PRE"></a>
(rendered in fixed-width font).  Newlines are inserted between <var>line1</var>,
<var>lines</var>.  HTML tags (&lsquo;<samp>&lt;tag&gt;</samp>&rsquo;) within <var>lines</var> will be visible verbatim.
</p></dd></dl>


<dl>
<dt><a name="index-html_003acomment"></a><u>Function:</u> <b>html:comment</b><i> line1 line &hellip;</i></dt>
<dd><p>Returns the strings <var>line1</var> as HTML comments.
</p></dd></dl>

<hr size="6">
<a name="HTML-Forms"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#HTML" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#HTML-Tables" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section">4.6 HTML Forms</h2>


<dl>
<dt><a name="index-html_003aform"></a><u>Function:</u> <b>html:form</b><i> method action body &hellip;</i></dt>
<dd><p>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="index-form"></a>
</p></dd></dl>


<dl>
<dt><a name="index-html_003ahidden"></a><u>Function:</u> <b>html:hidden</b><i> name value</i></dt>
<dd><p>Returns HTML string which will cause <var>name</var>=<var>value</var> in form.
</p></dd></dl>


<dl>
<dt><a name="index-html_003acheckbox"></a><u>Function:</u> <b>html:checkbox</b><i> pname default</i></dt>
<dd><p>Returns HTML string for check box.
</p></dd></dl>


<dl>
<dt><a name="index-html_003atext"></a><u>Function:</u> <b>html:text</b><i> pname default size &hellip;</i></dt>
<dd><p>Returns HTML string for one-line text box.
</p></dd></dl>


<dl>
<dt><a name="index-html_003atext_002darea"></a><u>Function:</u> <b>html:text-area</b><i> pname default-list</i></dt>
<dd><p>Returns HTML string for multi-line text box.
</p></dd></dl>


<dl>
<dt><a name="index-html_003aselect"></a><u>Function:</u> <b>html:select</b><i> pname arity default-list foreign-values</i></dt>
<dd><p>Returns HTML string for pull-down menu selector.
</p></dd></dl>


<dl>
<dt><a name="index-html_003abuttons"></a><u>Function:</u> <b>html:buttons</b><i> pname arity default-list foreign-values</i></dt>
<dd><p>Returns HTML string for any-of selector.
</p></dd></dl>


<dl>
<dt><a name="index-form_003asubmit"></a><u>Function:</u> <b>form:submit</b><i> submit-label command</i></dt>
<dt><a name="index-form_003asubmit-1"></a><u>Function:</u> <b>form:submit</b><i> submit-label</i></dt>
<dd>
<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></dd></dl>


<dl>
<dt><a name="index-form_003aimage"></a><u>Function:</u> <b>form:image</b><i> submit-label image-src</i></dt>
<dd><p>The <var>image-src</var> appears on the button which submits the form.
</p></dd></dl>


<dl>
<dt><a name="index-form_003areset"></a><u>Function:</u> <b>form:reset</b></dt>
<dd><p>Returns a string which generates a <em>reset</em> button.
<a name="index-reset"></a>
</p></dd></dl>


<dl>
<dt><a name="index-form_003aelement"></a><u>Function:</u> <b>form:element</b><i> pname arity default-list foreign-values</i></dt>
<dd><p>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>
<dl compact="compact">
<dt> <code>single</code></dt>
<dd><p>select menu
</p></dd>
<dt> <code>optional</code></dt>
<dd><p>select menu
</p></dd>
<dt> <code>nary</code></dt>
<dd><p>check boxes
</p></dd>
<dt> <code>nary1</code></dt>
<dd><p>check boxes
</p></dd>
</dl>

<p>If the foreign-key table has a field named &lsquo;<samp>visible-name</samp>&rsquo;, 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>
<dl compact="compact">
<dt> <code>single</code></dt>
<dd><p>text area
</p></dd>
<dt> <code>optional</code></dt>
<dd><p>text area
</p></dd>
<dt> <code>boolean</code></dt>
<dd><p>check box
</p></dd>
<dt> <code>nary</code></dt>
<dd><p>text area
</p></dd>
<dt> <code>nary1</code></dt>
<dd><p>text area
</p></dd>
</dl>
</dd></dl>


<dl>
<dt><a name="index-form_003adelimited"></a><u>Function:</u> <b>form:delimited</b><i> pname doc aliat arity default-list foreign-values</i></dt>
<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></dd></dl>


<dl>
<dt><a name="index-html_003adelimited_002dlist"></a><u>Function:</u> <b>html:delimited-list</b><i> row &hellip;</i></dt>
<dd><p>Wraps its arguments with delimited-list (&lsquo;<samp>DL</samp>&rsquo; command.
</p></dd></dl>


<dl>
<dt><a name="index-get_002dforeign_002dchoices"></a><u>Function:</u> <b>get-foreign-choices</b><i> tab</i></dt>
<dd><p>Returns a list of the &lsquo;<samp>visible-name</samp>&rsquo; or first fields of
table <var>tab</var>.
</p></dd></dl>


<dl>
<dt><a name="index-command_002d_003ep_002dspecs"></a><u>Function:</u> <b>command-&gt;p-specs</b><i> rdb command-table command</i></dt>
<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 &lsquo;<samp>build</samp>&rsquo;
command.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(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>
</dd></dl>



<hr size="6">
<a name="HTML-Tables"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#HTML-Forms" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#HTML-editing-tables" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="HTML-Tables-1"></a>
<h2 class="section">4.7 HTML Tables</h2>

<p><code>(require 'db-&gt;html)</code>
<a name="index-db_002d_003ehtml"></a>
</p>

<dl>
<dt><a name="index-html_003atable"></a><u>Function:</u> <b>html:table</b><i> options row &hellip;</i></dt>
</dl>


<dl>
<dt><a name="index-html_003acaption"></a><u>Function:</u> <b>html:caption</b><i> caption align</i></dt>
<dt><a name="index-html_003acaption-1"></a><u>Function:</u> <b>html:caption</b><i> caption</i></dt>
<dd><p><var>align</var> can be &lsquo;<samp>top</samp>&rsquo; or &lsquo;<samp>bottom</samp>&rsquo;.
</p></dd></dl>


<dl>
<dt><a name="index-html_003aheading"></a><u>Function:</u> <b>html:heading</b><i> columns</i></dt>
<dd><p>Outputs a heading row for the currently-started table.
</p></dd></dl>


<dl>
<dt><a name="index-html_003ahref_002dheading"></a><u>Function:</u> <b>html:href-heading</b><i> columns uris</i></dt>
<dd><p>Outputs a heading row with column-names <var>columns</var> linked to URIs <var>uris</var>.
</p></dd></dl>


<dl>
<dt><a name="index-html_003alinked_002drow_002dconverter"></a><u>Function:</u> <b>html:linked-row-converter</b><i> k foreigns</i></dt>
<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></dd></dl>


<dl>
<dt><a name="index-table_002dname_002d_003efilename"></a><u>Function:</u> <b>table-name-&gt;filename</b><i> table-name</i></dt>
<dd>
<p>Returns the symbol <var>table-name</var> converted to a filename.
</p></dd></dl>


<dl>
<dt><a name="index-table_002d_003elinked_002dhtml"></a><u>Function:</u> <b>table-&gt;linked-html</b><i> caption db table-name match-key1 &hellip;</i></dt>
<dd>
<p>Returns HTML string for <var>db</var> table <var>table-name</var> chopped into 50-row HTML tables.
Every foreign-key value is linked to the page (of the table)
defining that key.
</p>
<p>The optional <var>match-key1</var> &hellip; arguments restrict actions to a subset of
the table.  See section <a href="slib_6.html#Table-Operations">match-key</a>.
</p></dd></dl>


<dl>
<dt><a name="index-table_002d_003elinked_002dpage"></a><u>Function:</u> <b>table-&gt;linked-page</b><i> db table-name index-filename arg &hellip;</i></dt>
<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> &hellip; arguments restrict actions to a subset of
the table.  See section <a href="slib_6.html#Table-Operations">match-key</a>.
</p></dd></dl>


<dl>
<dt><a name="index-catalog_002d_003ehtml"></a><u>Function:</u> <b>catalog-&gt;html</b><i> db caption arg &hellip;</i></dt>
<dd>
<p>Returns HTML string for the catalog table of <var>db</var>.
</p></dd></dl>

<hr size="6">
<a name="HTML-editing-tables"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#HTML-Tables" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#HTML-databases" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#HTML-Tables" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">4.7.1 HTML editing tables</h3>

<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>
<ul>
<li>
If no fields are changed, then no change is made to the table.
</li><li>
If the primary keys equal null-keys (parameter defaults), and no other
user has modified that row, then that row is deleted.
</li><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><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><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><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.
</li></ul>

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

<dl>
<dt><a name="index-command_003amodify_002dtable"></a><u>Function:</u> <b>command:modify-table</b><i> table-name null-keys update delete retrieve</i></dt>
<dt><a name="index-command_003amodify_002dtable-1"></a><u>Function:</u> <b>command:modify-table</b><i> table-name null-keys update delete</i></dt>
<dt><a name="index-command_003amodify_002dtable-2"></a><u>Function:</u> <b>command:modify-table</b><i> table-name null-keys update</i></dt>
<dt><a name="index-command_003amodify_002dtable-3"></a><u>Function:</u> <b>command:modify-table</b><i> table-name null-keys</i></dt>
<dd>
<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="index-null"></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></dd></dl>


<dl>
<dt><a name="index-command_003amake_002deditable_002dtable"></a><u>Function:</u> <b>command:make-editable-table</b><i> rdb table-name arg &hellip;</i></dt>
<dd><p>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>
<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>
<dl compact="compact">
<dt> &lsquo;<samp>*</samp>&rsquo;</dt>
<dd><p>have arity &lsquo;<samp>nary</samp>&rsquo;;
</p></dd>
<dt> &lsquo;<samp>+</samp>&rsquo;</dt>
<dd><p>have arity &lsquo;<samp>nary1</samp>&rsquo;.
</p></dd>
</dl>
</dd></dl>


<dl>
<dt><a name="index-html_003aeditable_002drow_002dconverter"></a><u>Function:</u> <b>html:editable-row-converter</b><i> k names edit-point edit-converter</i></dt>
<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></dd></dl>

<hr size="6">
<a name="HTML-databases"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#HTML-editing-tables" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#HTTP-and-CGI" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#HTML-Tables" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">4.7.2 HTML databases</h3>


<dl>
<dt><a name="index-db_002d_003ehtml_002dfiles"></a><u>Function:</u> <b>db-&gt;html-files</b><i> db dir index-filename caption</i></dt>
<dd><p><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>
<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></dd></dl>


<dl>
<dt><a name="index-db_002d_003ehtml_002ddirectory"></a><u>Function:</u> <b>db-&gt;html-directory</b><i> db dir index-filename</i></dt>
<dt><a name="index-db_002d_003ehtml_002ddirectory-1"></a><u>Function:</u> <b>db-&gt;html-directory</b><i> db dir</i></dt>
<dd><p><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 &lsquo;<tt>index.html</tt>&rsquo;.
</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 &lsquo;<samp>file:</samp>&rsquo; URI of <var>index-filename</var> is
returned.
</p></dd></dl>


<dl>
<dt><a name="index-db_002d_003enetscape"></a><u>Function:</u> <b>db-&gt;netscape</b><i> db dir index-filename</i></dt>
<dt><a name="index-db_002d_003enetscape-1"></a><u>Function:</u> <b>db-&gt;netscape</b><i> db dir</i></dt>
<dd><p><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></dd></dl>



<hr size="6">
<a name="HTTP-and-CGI"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#HTML-databases" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Parsing-HTML" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="HTTP-and-CGI-1"></a>
<h2 class="section">4.8 HTTP and CGI</h2>

<p><code>(require 'http)</code> or <code>(require 'cgi)</code>
<a name="index-http"></a>
<a name="index-cgi"></a>
</p>

<dl>
<dt><a name="index-http_003aheader"></a><u>Function:</u> <b>http:header</b><i> alist</i></dt>
<dd><p>Returns a string containing lines for each element of <var>alist</var>; the
<code>car</code> of which is followed by &lsquo;<samp>: </samp>&rsquo;, then the <code>cdr</code>.
</p></dd></dl>


<dl>
<dt><a name="index-http_003acontent"></a><u>Function:</u> <b>http:content</b><i> alist body &hellip;</i></dt>
<dd><p>Returns the concatenation of strings <var>body</var> with the
<code>(http:header <var>alist</var>)</code> and the &lsquo;<samp>Content-Length</samp>&rsquo; prepended.
</p></dd></dl>


<dl>
<dt><a name="index-_002ahttp_003abyline_002a"></a><u>Variable:</u> <b>*http:byline*</b></dt>
<dd><p>String appearing at the bottom of error pages.
</p></dd></dl>

<dl>
<dt><a name="index-http_003aerror_002dpage"></a><u>Function:</u> <b>http:error-page</b><i> status-code reason-phrase html-string &hellip;</i></dt>
<dd><p><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> &hellip;; with <var>*http:byline*</var> or SLIB&rsquo;s
default at the bottom.
</p></dd></dl>


<dl>
<dt><a name="index-http_003aforwarding_002dpage"></a><u>Function:</u> <b>http:forwarding-page</b><i> title dly uri html-string &hellip;</i></dt>
<dd><p>The string or symbol <var>title</var> is the page title.  <var>dly</var> is a non-negative
integer.  The <var>html-strings</var> &hellip; are typically used to explain to the user why
this page is being forwarded.
</p>
<p><code>http:forwarding-page</code> returns an HTML string for a page which automatically forwards to
<var>uri</var> after <var>dly</var> seconds.  The returned page (string) contains any <var>html-strings</var>
&hellip; followed by a manual link to <var>uri</var>, in case the browser does not
forward automatically.
</p></dd></dl>


<dl>
<dt><a name="index-http_003aserve_002dquery"></a><u>Function:</u> <b>http:serve-query</b><i> serve-proc input-port output-port</i></dt>
<dd><p>reads the <em>URI</em> and <em>query-string</em> from <var>input-port</var>.  If the
<a name="index-URI"></a>
<a name="index-query_002dstring"></a>
query is a valid &lsquo;<samp>&quot;POST&quot;</samp>&rsquo; or &lsquo;<samp>&quot;GET&quot;</samp>&rsquo; 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>
<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 &lsquo;<samp>Bad Request</samp>&rsquo; (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></dd></dl>



<p>This example services HTTP queries from <var>port-number</var>:
</p><table><tr><td>&nbsp;</td><td><pre class="example">
(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>


<dl>
<dt><a name="index-cgi_003aserve_002dquery"></a><u>Function:</u> <b>cgi:serve-query</b><i> serve-proc</i></dt>
<dd><p>reads the <em>URI</em> and <em>query-string</em> from
<a name="index-URI-1"></a>
<a name="index-query_002dstring-1"></a>
<code>(current-input-port)</code>.  If the query is a valid &lsquo;<samp>&quot;POST&quot;</samp>&rsquo;
or &lsquo;<samp>&quot;GET&quot;</samp>&rsquo; 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>
<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 &lsquo;<samp>Bad Request</samp>&rsquo; (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></dd></dl>


<dl>
<dt><a name="index-make_002dquery_002dalist_002dcommand_002dserver"></a><u>Function:</u> <b>make-query-alist-command-server</b><i> rdb command-table</i></dt>
<dt><a name="index-make_002dquery_002dalist_002dcommand_002dserver-1"></a><u>Function:</u> <b>make-query-alist-command-server</b><i> rdb command-table #t</i></dt>
<dd>
<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 &lsquo;<samp>*command*</samp>&rsquo; association will be the command invoked
in <var>command-table</var>.  If &lsquo;<samp>*command*</samp>&rsquo; is not in the <var>query-alist</var> then the
value of &lsquo;<samp>*suggest*</samp>&rsquo; is tried.  If neither name is in the
<var>query-alist</var>, then the literal value &lsquo;<samp>*default*</samp>&rsquo; 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></dd></dl>



<hr size="6">
<a name="Parsing-HTML"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#HTTP-and-CGI" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#URI" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Parsing-HTML-1"></a>
<h2 class="section">4.9 Parsing HTML</h2>

<p><code>(require 'html-for-each)</code>
<a name="index-html_002dfor_002deach"></a>
</p>

<dl>
<dt><a name="index-html_002dfor_002deach-1"></a><u>Function:</u> <b>html-for-each</b><i> file word-proc markup-proc white-proc newline-proc</i></dt>
<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>
<ul>
<li>
enclosed by &lsquo;<samp>&lt;</samp>&rsquo; and &lsquo;<samp>&gt;</samp>&rsquo; (hypertext markups or comments);
</li><li>
end-of-line;
</li><li>
whitespace; or
</li><li>
none of the above (words).
</li></ul>

<p>Procedures are called according to these distinctions in order of
the string&rsquo;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 &lsquo;<samp>&lt;</samp>&rsquo; and
&lsquo;<samp>&gt;</samp>&rsquo;).
</p>
<p><var>word-proc</var> is called with the remaining strings.
</p>
<p><code>html-for-each</code> returns an unspecified value.
</p></dd></dl>


<dl>
<dt><a name="index-html_003aread_002dtitle"></a><u>Function:</u> <b>html:read-title</b><i> file limit</i></dt>
<dt><a name="index-html_003aread_002dtitle-1"></a><u>Function:</u> <b>html:read-title</b><i> file</i></dt>
<dd><p><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) &lsquo;<samp>TITLE</samp>&rsquo; 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 &lsquo;<samp>#\&lt;</samp>&rsquo;, or if the end of title is
not found within the first (approximately) <var>limit</var> words.
</p></dd></dl>


<dl>
<dt><a name="index-htm_002dfields"></a><u>Function:</u> <b>htm-fields</b><i> htm</i></dt>
<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></dd></dl>



<hr size="6">
<a name="URI"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Parsing-HTML" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Parsing-XML" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="URI-1"></a>
<h2 class="section">4.10 URI</h2>

<p><code>(require 'uri)</code>
<a name="index-uri"></a>
</p>
<p>Implements <em>Uniform Resource Identifiers</em> (URI) as
<a name="index-Uniform-Resource-Identifiers"></a>
described in RFC 2396.
</p>

<dl>
<dt><a name="index-make_002duri"></a><u>Function:</u> <b>make-uri</b></dt>
<dt><a name="index-make_002duri-1"></a><u>Function:</u> <b>make-uri</b><i> fragment</i></dt>
<dt><a name="index-make_002duri-2"></a><u>Function:</u> <b>make-uri</b><i> query fragment</i></dt>
<dt><a name="index-make_002duri-3"></a><u>Function:</u> <b>make-uri</b><i> path query fragment</i></dt>
<dt><a name="index-make_002duri-4"></a><u>Function:</u> <b>make-uri</b><i> authority path query fragment</i></dt>
<dt><a name="index-make_002duri-5"></a><u>Function:</u> <b>make-uri</b><i> scheme authority path query fragment</i></dt>
<dd>
<p>Returns a Uniform Resource Identifier string from component arguments.
</p></dd></dl>


<dl>
<dt><a name="index-uri_003amake_002dpath"></a><u>Function:</u> <b>uri:make-path</b><i> path</i></dt>
<dd>
<p>Returns a URI string combining the components of list <var>path</var>.
</p></dd></dl>


<dl>
<dt><a name="index-html_003aanchor"></a><u>Function:</u> <b>html:anchor</b><i> name</i></dt>
<dd><p>Returns a string which defines this location in the (HTML) file
as <var>name</var>.  The hypertext &lsquo;<samp>&lt;A HREF=&quot;#<var>name</var>&quot;&gt;</samp>&rsquo; will link to this point.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(html:anchor &quot;(section 7)&quot;)
&rArr;
&quot;&lt;A NAME=\&quot;(section%207)\&quot;&gt;&lt;/A&gt;&quot;
</pre></td></tr></table>
</dd></dl>


<dl>
<dt><a name="index-html_003alink"></a><u>Function:</u> <b>html:link</b><i> uri highlighted</i></dt>
<dd><p>Returns a string which links the <var>highlighted</var> text to <var>uri</var>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(html:link (make-uri &quot;(section 7)&quot;) &quot;section 7&quot;)
&rArr;
&quot;&lt;A HREF=\&quot;#(section%207)\&quot;&gt;section 7&lt;/A&gt;&quot;
</pre></td></tr></table>
</dd></dl>


<dl>
<dt><a name="index-html_003abase"></a><u>Function:</u> <b>html:base</b><i> uri</i></dt>
<dd><p>Returns a string specifying the <em>base</em> <var>uri</var> of a document, for
<a name="index-base"></a>
inclusion in the HEAD of the document (see section <a href="#HTML">head</a>).
</p></dd></dl>


<dl>
<dt><a name="index-html_003aisindex"></a><u>Function:</u> <b>html:isindex</b><i> prompt</i></dt>
<dd><p>Returns a string specifying the search <var>prompt</var> of a document, for
inclusion in the HEAD of the document (see section <a href="#HTML">head</a>).
</p></dd></dl>


<dl>
<dt><a name="index-uri_002d_003etree"></a><u>Function:</u> <b>uri-&gt;tree</b><i> uri-reference base-tree</i></dt>
<dt><a name="index-uri_002d_003etree-1"></a><u>Function:</u> <b>uri-&gt;tree</b><i> uri-reference</i></dt>
<dd>
<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="index-Server_002dbased-Naming-Authority"></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>
<table><tr><td>&nbsp;</td><td><pre class="example">(uri-&gt;tree &quot;http://www.ics.uci.edu/pub/ietf/uri/#Related&quot;)
&rArr;
(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>
</dd></dl>


<dl>
<dt><a name="index-uri_003asplit_002dfields"></a><u>Function:</u> <b>uri:split-fields</b><i> txt chr</i></dt>
<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></dd></dl>


<dl>
<dt><a name="index-uri_003adecode_002dquery"></a><u>Function:</u> <b>uri:decode-query</b><i> query-string</i></dt>
<dd><p>Converts a <em>URI</em> encoded <var>query-string</var> to a query-alist.
<a name="index-URI-2"></a>
</p></dd></dl>


<p><code>uric:</code> prefixes indicate procedures dealing with
URI-components.
</p>

<dl>
<dt><a name="index-uric_003aencode"></a><u>Function:</u> <b>uric:encode</b><i> uri-component allows</i></dt>
<dd><p>Returns a copy of the string <var>uri-component</var> in which all <em>unsafe</em> octets
<a name="index-unsafe"></a>
(as defined in RFC 2396) have been &lsquo;<samp>%</samp>&rsquo; <em>escaped</em>.
<a name="index-escaped"></a>
<code>uric:decode</code> decodes strings encoded by <code>uric:encode</code>.
</p></dd></dl>


<dl>
<dt><a name="index-uric_003adecode"></a><u>Function:</u> <b>uric:decode</b><i> uri-component</i></dt>
<dd><p>Returns a copy of the string <var>uri-component</var> in which each &lsquo;<samp>%</samp>&rsquo; 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.
</p></dd></dl>


<dl>
<dt><a name="index-uri_003apath_002d_003ekeys"></a><u>Function:</u> <b>uri:path-&gt;keys</b><i> path-list ptypes</i></dt>
<dd><p><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>.
</p></dd></dl>

<a name="File_002dsystem-Locators-and-Predicates"></a>
<h3 class="subheading">File-system Locators and Predicates</h3>


<dl>
<dt><a name="index-path_002d_003euri"></a><u>Function:</u> <b>path-&gt;uri</b><i> path</i></dt>
<dd><p>Returns a URI-string for <var>path</var> on the local host.
</p></dd></dl>


<dl>
<dt><a name="index-absolute_002duri_003f"></a><u>Function:</u> <b>absolute-uri?</b><i> str</i></dt>
<dd><p>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="index-scheme"></a>
#f.
</p></dd></dl>


<dl>
<dt><a name="index-absolute_002dpath_003f"></a><u>Function:</u> <b>absolute-path?</b><i> file-name</i></dt>
<dd><p>Returns #t if <var>file-name</var> is a fully specified pathname (does not
depend on the current working directory); otherwise returns #f.
</p></dd></dl>


<dl>
<dt><a name="index-null_002ddirectory_003f"></a><u>Function:</u> <b>null-directory?</b><i> str</i></dt>
<dd><p>Returns #t if changing directory to <var>str</var> would leave the current
directory unchanged; otherwise returns #f.
</p></dd></dl>


<dl>
<dt><a name="index-glob_002dpattern_003f"></a><u>Function:</u> <b>glob-pattern?</b><i> str</i></dt>
<dd><p>Returns #t if the string <var>str</var> contains characters used for
specifying glob patterns, namely &lsquo;<samp>*</samp>&rsquo;, &lsquo;<samp>?</samp>&rsquo;, or &lsquo;<samp>[</samp>&rsquo;.
</p></dd></dl>

<p>Before RFC 2396, the <em>File Transfer Protocol</em> (FTP) served a
<a name="index-File-Transfer-Protocol"></a>
similar purpose.
</p>

<dl>
<dt><a name="index-parse_002dftp_002daddress"></a><u>Function:</u> <b>parse-ftp-address</b><i> uri</i></dt>
<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="index-Uniform-Resource-Locator"></a>
<a name="index-ange_002dftp"></a>
<a name="index-getit"></a>
formats are handled.  The returned list has four elements which are
strings or #f:
</p>
<ol>
<li>
username
</li><li>
password
</li><li>
remote-site
</li><li>
remote-directory
</li></ol>
</dd></dl>



<hr size="6">
<a name="Parsing-XML"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#URI" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#String-Glue" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Parsing-XML-1"></a>
<h2 class="section">4.11 Parsing XML</h2>

<p><code>(require 'xml-parse)</code> or <code>(require 'ssax)</code>
</p>
<p>The XML standard document referred to in this module is<br>
<a href="http://www.w3.org/TR/1998/REC-xml-19980210.html">http://www.w3.org/TR/1998/REC-xml-19980210.html</a>.
</p>
<p>The present frameworks fully supports the XML Namespaces
Recommendation<br>
<a href="http://www.w3.org/TR/REC-xml-names">http://www.w3.org/TR/REC-xml-names</a>.
</p>
<hr size="6">
<a name="String-Glue"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Parsing-XML" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Character-and-Token-Functions" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Parsing-XML" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">4.11.1 String Glue</h3>


<dl>
<dt><a name="index-ssax_003areverse_002dcollect_002dstr"></a><u>Function:</u> <b>ssax:reverse-collect-str</b><i> list-of-frags</i></dt>
<dd>

<p>Given the list of fragments (some of which are text strings),
reverse the list and concatenate adjacent text strings.  If
LIST-OF-FRAGS has zero or one element, the result of the procedure
is <code>equal?</code> to its argument.
</p></dd></dl>


<dl>
<dt><a name="index-ssax_003areverse_002dcollect_002dstr_002ddrop_002dws"></a><u>Function:</u> <b>ssax:reverse-collect-str-drop-ws</b><i> list-of-frags</i></dt>
<dd>

<p>Given the list of fragments (some of which are text strings),
reverse the list and concatenate adjacent text strings while
dropping &quot;unsignificant&quot; whitespace, that is, whitespace in front,
behind and between elements.  The whitespace that is included in
character data is not affected.
</p>
<p>Use this procedure to &quot;intelligently&quot; drop &quot;insignificant&quot;
whitespace in the parsed SXML.  If the strict compliance with the
XML Recommendation regarding the whitespace is desired, use the
<code>ssax:reverse-collect-str</code> procedure instead.
</p></dd></dl>

<hr size="6">
<a name="Character-and-Token-Functions"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#String-Glue" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Data-Types" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Parsing-XML" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">4.11.2 Character and Token Functions</h3>

<p>The following functions either skip, or build and return tokens,
according to inclusion or delimiting semantics.  The list of
characters to expect, include, or to break at may vary from one
invocation of a function to another.  This allows the functions to
easily parse even context-sensitive languages.
</p>
<p>Exceptions are mentioned specifically.  The list of expected
characters (characters to skip until, or break-characters) may
include an EOF &quot;character&quot;, which is coded as symbol *eof*
</p>
<p>The input stream to parse is specified as a PORT, which is the last
argument.
</p>

<dl>
<dt><a name="index-ssax_003aassert_002dcurrent_002dchar"></a><u>Function:</u> <b>ssax:assert-current-char</b><i> char-list string port</i></dt>
<dd>

<p>Reads a character from the <var>port</var> and looks it up in the
<var>char-list</var> of expected characters.  If the read character was
found among expected, it is returned.  Otherwise, the
procedure writes a message using <var>string</var> as a comment
and quits.
</p></dd></dl>


<dl>
<dt><a name="index-ssax_003askip_002dwhile"></a><u>Function:</u> <b>ssax:skip-while</b><i> char-list port</i></dt>
<dd>

<p>Reads characters from the <var>port</var> and disregards them, as long as they
are mentioned in the <var>char-list</var>.  The first character (which may be EOF)
peeked from the stream that is <em>not</em> a member of the <var>char-list</var> is
returned.
</p></dd></dl>


<dl>
<dt><a name="index-ssax_003ainit_002dbuffer"></a><u>Function:</u> <b>ssax:init-buffer</b></dt>
<dd>

<p>Returns an initial buffer for <code>ssax:next-token*</code> procedures.
<code>ssax:init-buffer</code> may allocate a new buffer at each invocation.
</p></dd></dl>


<dl>
<dt><a name="index-ssax_003anext_002dtoken"></a><u>Function:</u> <b>ssax:next-token</b><i> prefix-char-list break-char-list comment-string port</i></dt>
<dd>

<p>Skips any number of the prefix characters (members of the <var>prefix-char-list</var>), if
any, and reads the sequence of characters up to (but not including)
a break character, one of the <var>break-char-list</var>.
</p>
<p>The string of characters thus read is returned.  The break character
is left on the input stream.  <var>break-char-list</var> may include the symbol <code>*eof*</code>;
otherwise, EOF is fatal, generating an error message including a
specified <var>comment-string</var>.
</p></dd></dl>

<p><code>ssax:next-token-of</code> is similar to <code>ssax:next-token</code>
except that it implements an inclusion rather than delimiting
semantics.
</p>

<dl>
<dt><a name="index-ssax_003anext_002dtoken_002dof"></a><u>Function:</u> <b>ssax:next-token-of</b><i> inc-charset port</i></dt>
<dd>

<p>Reads characters from the <var>port</var> that belong to the list of characters
<var>inc-charset</var>.  The reading stops at the first character which is not a member
of the set.  This character is left on the stream.  All the read
characters are returned in a string.
</p>

</dd><dt><a name="index-ssax_003anext_002dtoken_002dof-1"></a><u>Function:</u> <b>ssax:next-token-of</b><i> pred port</i></dt>
<dd>
<p>Reads characters from the <var>port</var> for which <var>pred</var> (a procedure of
one argument) returns non-#f.  The reading stops at the first
character for which <var>pred</var> returns #f.  That character is left
on the stream.  All the results of evaluating of <var>pred</var> up to #f
are returned in a string.
</p>
<p><var>pred</var> is a procedure that takes one argument (a character or
the EOF object) and returns a character or #f.  The returned
character does not have to be the same as the input argument to the
<var>pred</var>.  For example,
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(ssax:next-token-of (lambda (c)
                      (cond ((eof-object? c) #f)
                            ((char-alphabetic? c) (char-downcase c))
                            (else #f)))
                    (current-input-port))
</pre></td></tr></table>

<p>will try to read an alphabetic token from the current input port,
and return it in lower case.
</p></dd></dl>


<dl>
<dt><a name="index-ssax_003aread_002dstring"></a><u>Function:</u> <b>ssax:read-string</b><i> len port</i></dt>
<dd>

<p>Reads <var>len</var> characters from the <var>port</var>, and returns them in a string.  If
EOF is encountered before <var>len</var> characters are read, a shorter string
will be returned.
</p></dd></dl>

<hr size="6">
<a name="Data-Types"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Character-and-Token-Functions" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Low_002dLevel-Parsers-and-Scanners" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Parsing-XML" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">4.11.3 Data Types</h3>

<dl compact="compact">
<dt> <code>TAG-KIND</code></dt>
<dd>
<p>A symbol &lsquo;<samp>START</samp>&rsquo;, &lsquo;<samp>END</samp>&rsquo;, &lsquo;<samp>PI</samp>&rsquo;, &lsquo;<samp>DECL</samp>&rsquo;,
&lsquo;<samp>COMMENT</samp>&rsquo;, &lsquo;<samp>CDSECT</samp>&rsquo;, or &lsquo;<samp>ENTITY-REF</samp>&rsquo; that identifies
a markup token
</p>
</dd>
<dt> <code>UNRES-NAME</code></dt>
<dd>
<p>a name (called GI in the XML Recommendation) as given in an XML
document for a markup token: start-tag, PI target, attribute name.
If a GI is an NCName, UNRES-NAME is this NCName converted into a
Scheme symbol.  If a GI is a QName, &lsquo;<samp>UNRES-NAME</samp>&rsquo; is a pair of
symbols: <code>(<var>PREFIX</var> . <var>LOCALPART</var>)</code>.
</p>
</dd>
<dt> <code>RES-NAME</code></dt>
<dd>
<p>An expanded name, a resolved version of an &lsquo;<samp>UNRES-NAME</samp>&rsquo;.  For
an element or an attribute name with a non-empty namespace URI,
&lsquo;<samp>RES-NAME</samp>&rsquo; is a pair of symbols,
<code>(<var>URI-SYMB</var> . <var>LOCALPART</var>)</code>.
Otherwise, it&rsquo;s a single symbol.
</p>
</dd>
<dt> <code>ELEM-CONTENT-MODEL</code></dt>
<dd>
<p>A symbol:
</p><dl compact="compact">
<dt> &lsquo;<samp>ANY</samp>&rsquo;</dt>
<dd><p>anything goes, expect an END tag.
</p></dd>
<dt> &lsquo;<samp>EMPTY-TAG</samp>&rsquo;</dt>
<dd><p>no content, and no END-tag is coming
</p></dd>
<dt> &lsquo;<samp>EMPTY</samp>&rsquo;</dt>
<dd><p>no content, expect the END-tag as the next token
</p></dd>
<dt> &lsquo;<samp>PCDATA</samp>&rsquo;</dt>
<dd><p>expect character data only, and no children elements
</p></dd>
<dt> &lsquo;<samp>MIXED</samp>&rsquo;</dt>
<dt> &lsquo;<samp>ELEM-CONTENT</samp>&rsquo;</dt>
</dl>

</dd>
<dt> <code>URI-SYMB</code></dt>
<dd>
<p>A symbol representing a namespace URI &ndash; or other symbol chosen by
the user to represent URI.  In the former case, <code>URI-SYMB</code> is
created by %-quoting of bad URI characters and converting the
resulting string into a symbol.
</p>
</dd>
<dt> <code>NAMESPACES</code></dt>
<dd>
<p>A list representing namespaces in effect.  An element of the list
has one of the following forms:
</p>
<dl compact="compact">
<dt> <code>(<var>prefix</var> <var>uri-symb</var> . <var>uri-symb</var>) or</code></dt>
<dt> <code>(<var>prefix</var> <var>user-prefix</var> . <var>uri-symb</var>)</code></dt>
<dd><p><var>user-prefix</var> is a symbol chosen by the user to represent the URI.
</p>
</dd>
<dt> <code>(#f <var>user-prefix</var> . <var>uri-symb</var>)</code></dt>
<dd><p>Specification of the user-chosen prefix and a URI-SYMBOL.
</p>
</dd>
<dt> <code>(*DEFAULT* <var>user-prefix</var> . <var>uri-symb</var>)</code></dt>
<dd><p>Declaration of the default namespace
</p>
</dd>
<dt> <code>(*DEFAULT* #f . #f)</code></dt>
<dd><p>Un-declaration of the default namespace.  This notation
represents overriding of the previous declaration
</p>
</dd>
</dl>

<p>A NAMESPACES list may contain several elements for the same <var>prefix</var>.
The one closest to the beginning of the list takes effect.
</p>
</dd>
<dt> <code>ATTLIST</code></dt>
<dd>
<p>An ordered collection of (<var>NAME</var> . <var>VALUE</var>) pairs, where
<var>NAME</var> is a RES-NAME or an UNRES-NAME.  The collection is an ADT.
</p>
</dd>
<dt> <code>STR-HANDLER</code></dt>
<dd>
<p>A procedure of three arguments: <var>string1</var> <var>string2</var>
<var>seed</var> returning a new <var>seed</var>.  The procedure is supposed to
handle a chunk of character data <var>string1</var> followed by a chunk
of character data <var>string2</var>.  <var>string2</var> is a short string,
often &lsquo;<samp>&quot;\n&quot;</samp>&rsquo; and even &lsquo;<samp>&quot;&quot;</samp>&rsquo;.
</p>
</dd>
<dt> <code>ENTITIES</code></dt>
<dd><p>An assoc list of pairs:
</p><table><tr><td>&nbsp;</td><td><pre class="lisp">   (<var>named-entity-name</var> . <var>named-entity-body</var>)
</pre></td></tr></table>

<p>where <var>named-entity-name</var> is a symbol under which the entity was
declared, <var>named-entity-body</var> is either a string, or (for an
external entity) a thunk that will return an input port (from which
the entity can be read).  <var>named-entity-body</var> may also be #f.
This is an indication that a <var>named-entity-name</var> is currently
being expanded.  A reference to this <var>named-entity-name</var> will be
an error: violation of the WFC nonrecursion.
</p>
</dd>
<dt> <code>XML-TOKEN</code></dt>
<dd>
<p>This record represents a markup, which is, according to the XML
Recommendation, &quot;takes the form of start-tags, end-tags,
empty-element tags, entity references, character references,
comments, CDATA section delimiters, document type declarations, and
processing instructions.&quot;
</p>
<dl compact="compact">
<dt> kind</dt>
<dd><p>a TAG-KIND
</p></dd>
<dt> head</dt>
<dd><p>an UNRES-NAME.  For XML-TOKENs of kinds &rsquo;COMMENT and &rsquo;CDSECT, the
head is #f.
</p></dd>
</dl>

<p>For example,
</p><table><tr><td>&nbsp;</td><td><pre class="example">&lt;P&gt;                   =&gt; kind=START,      head=P
&lt;/P&gt;                  =&gt; kind=END,        head=P
&lt;BR/&gt;                 =&gt; kind=EMPTY-EL,   head=BR
&lt;!DOCTYPE OMF ...&gt;    =&gt; kind=DECL,       head=DOCTYPE
&lt;?xml version=&quot;1.0&quot;?&gt; =&gt; kind=PI,         head=xml
&amp;my-ent;              =&gt; kind=ENTITY-REF, head=my-ent
</pre></td></tr></table>

<p>Character references are not represented by xml-tokens as these
references are transparently resolved into the corresponding
characters.
</p>
</dd>
<dt> <code>XML-DECL</code></dt>
<dd>
<p>The record represents a datatype of an XML document: the list of
declared elements and their attributes, declared notations, list of
replacement strings or loading procedures for parsed general
entities, etc.  Normally an XML-DECL record is created from a DTD or
an XML Schema, although it can be created and filled in in many
other ways (e.g., loaded from a file).
</p>
<dl compact="compact">
<dt> <var>elems</var></dt>
<dd><p>an (assoc) list of decl-elem or #f.  The latter instructs
the parser to do no validation of elements and attributes.
</p>
</dd>
<dt> <var>decl-elem</var></dt>
<dd><p>declaration of one element:
</p>
<p><code>(<var>elem-name</var> <var>elem-content</var> <var>decl-attrs</var>)</code>
</p>
<p><var>elem-name</var> is an UNRES-NAME for the element.
</p>
<p><var>elem-content</var> is an ELEM-CONTENT-MODEL.
</p>
<p><var>decl-attrs</var> is an <code>ATTLIST</code>, of
<code>(<var>attr-name</var> . <var>value</var>)</code> associations.
</p>
<p>This element can declare a user procedure to handle parsing of an
element (e.g., to do a custom validation, or to build a hash of IDs
as they&rsquo;re encountered).
</p>
</dd>
<dt> <var>decl-attr</var></dt>
<dd><p>an element of an <code>ATTLIST</code>, declaration of one attribute:
</p>
<p><code>(<var>attr-name</var> <var>content-type</var> <var>use-type</var> <var>default-value</var>)</code>
</p>
<p><var>attr-name</var> is an UNRES-NAME for the declared attribute.
</p>
<p><var>content-type</var> is a symbol: <code>CDATA</code>, <code>NMTOKEN</code>,
<code>NMTOKENS</code>, &hellip; or a list of strings for the enumerated
type.
</p>
<p><var>use-type</var> is a symbol: <code>REQUIRED</code>, <code>IMPLIED</code>, or
<code>FIXED</code>.
</p>
<p><var>default-value</var> is a string for the default value, or #f if not
given.
</p>
</dd>
</dl>

</dd>
</dl>

<hr size="6">
<a name="Low_002dLevel-Parsers-and-Scanners"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Data-Types" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Mid_002dLevel-Parsers-and-Scanners" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Parsing-XML" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">4.11.4 Low-Level Parsers and Scanners</h3>

<p>These procedures deal with primitive lexical units (Names,
whitespaces, tags) and with pieces of more generic productions.
Most of these parsers must be called in appropriate context.  For
example, <code>ssax:complete-start-tag</code> must be called only when the
start-tag has been detected and its GI has been read.
</p>

<dl>
<dt><a name="index-ssax_003askip_002ds"></a><u>Function:</u> <b>ssax:skip-s</b><i> port</i></dt>
<dd>

<p>Skip the S (whitespace) production as defined by
</p><table><tr><td>&nbsp;</td><td><pre class="example">[3] S ::= (#x20 | #x09 | #x0D | #x0A)
</pre></td></tr></table>

<p><code>ssax:skip-s</code> returns the first not-whitespace character it encounters while
scanning the <var>port</var>.  This character is left on the input stream.
</p></dd></dl>


<dl>
<dt><a name="index-ssax_003aread_002dncname"></a><u>Function:</u> <b>ssax:read-ncname</b><i> port</i></dt>
<dd>

<p>Read a NCName starting from the current position in the <var>port</var> and
return it as a symbol.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">[4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':'
                 | CombiningChar | Extender
[5] Name ::= (Letter | '_' | ':') (NameChar)*
</pre></td></tr></table>

<p>This code supports the XML Namespace Recommendation REC-xml-names,
which modifies the above productions as follows:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">[4] NCNameChar ::= Letter | Digit | '.' | '-' | '_'
                      | CombiningChar | Extender
[5] NCName ::= (Letter | '_') (NCNameChar)*
</pre></td></tr></table>

<p>As the Rec-xml-names says,
</p>
<blockquote><p>&quot;An XML document conforms to this specification if all other tokens
[other than element types and attribute names] in the document which
are required, for XML conformance, to match the XML production for
Name, match this specification&rsquo;s production for NCName.&quot;
</p></blockquote>

<p>Element types and attribute names must match the production QName,
defined below.
</p></dd></dl>


<dl>
<dt><a name="index-ssax_003aread_002dqname"></a><u>Function:</u> <b>ssax:read-qname</b><i> port</i></dt>
<dd>

<p>Read a (namespace-) Qualified Name, QName, from the current position
in <var>port</var>; and return an UNRES-NAME.
</p>
<p>From REC-xml-names:
</p><table><tr><td>&nbsp;</td><td><pre class="example">[6] QName ::= (Prefix ':')? LocalPart
[7] Prefix ::= NCName
[8] LocalPart ::= NCName
</pre></td></tr></table>
</dd></dl>


<dl>
<dt><a name="index-ssax_003aread_002dmarkup_002dtoken"></a><u>Function:</u> <b>ssax:read-markup-token</b><i> port</i></dt>
<dd>

<p>This procedure starts parsing of a markup token.  The current
position in the stream must be &lsquo;<samp>&lt;</samp>&rsquo;.  This procedure scans
enough of the input stream to figure out what kind of a markup token
it is seeing.  The procedure returns an XML-TOKEN structure
describing the token.  Note, generally reading of the current markup
is not finished!  In particular, no attributes of the start-tag
token are scanned.
</p>
<p>Here&rsquo;s a detailed break out of the return values and the position in
the PORT when that particular value is returned:
</p>
<dl compact="compact">
<dt> PI-token</dt>
<dd>
<p>only PI-target is read.  To finish the Processing-Instruction and
disregard it, call <code>ssax:skip-pi</code>.  <code>ssax:read-attributes</code>
may be useful as well (for PIs whose content is attribute-value
pairs).
</p>
</dd>
<dt> END-token</dt>
<dd>
<p>The end tag is read completely; the current position is right after
the terminating &lsquo;<samp>&gt;</samp>&rsquo; character.
</p>
</dd>
<dt> COMMENT</dt>
<dd>
<p>is read and skipped completely.  The current position is right after
&lsquo;<samp>--&gt;</samp>&rsquo; that terminates the comment.
</p>
</dd>
<dt> CDSECT</dt>
<dd>
<p>The current position is right after &lsquo;<samp>&lt;!CDATA[</samp>&rsquo;.  Use
<code>ssax:read-cdata-body</code> to read the rest.
</p>
</dd>
<dt> DECL</dt>
<dd>
<p>We have read the keyword (the one that follows &lsquo;<samp>&lt;!</samp>&rsquo;)
identifying this declaration markup.  The current position is after
the keyword (usually a whitespace character)
</p>
</dd>
<dt> START-token</dt>
<dd>
<p>We have read the keyword (GI) of this start tag.  No attributes are
scanned yet.  We don&rsquo;t know if this tag has an empty content either.
Use <code>ssax:complete-start-tag</code> to finish parsing of the token.
</p>
</dd>
</dl>
</dd></dl>


<dl>
<dt><a name="index-ssax_003askip_002dpi"></a><u>Function:</u> <b>ssax:skip-pi</b><i> port</i></dt>
<dd>

<p>The current position is inside a PI.  Skip till the rest of the PI
</p></dd></dl>


<dl>
<dt><a name="index-ssax_003aread_002dpi_002dbody_002das_002dstring"></a><u>Function:</u> <b>ssax:read-pi-body-as-string</b><i> port</i></dt>
<dd>

<p>The current position is right after reading the PITarget.  We read
the body of PI and return is as a string.  The port will point to
the character right after &lsquo;<samp>?&gt;</samp>&rsquo; combination that terminates PI.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">[16] PI ::= '&lt;?' PITarget (S (Char* - (Char* '?&gt;' Char*)))? '?&gt;'
</pre></td></tr></table>
</dd></dl>


<dl>
<dt><a name="index-ssax_003askip_002dinternal_002ddtd"></a><u>Function:</u> <b>ssax:skip-internal-dtd</b><i> port</i></dt>
<dd>

<p>The current pos in the port is inside an internal DTD subset (e.g.,
after reading &lsquo;<samp>#\[</samp>&rsquo; that begins an internal DTD subset) Skip
until the &lsquo;<samp>]&gt;</samp>&rsquo; combination that terminates this DTD.
</p></dd></dl>


<dl>
<dt><a name="index-ssax_003aread_002dcdata_002dbody"></a><u>Function:</u> <b>ssax:read-cdata-body</b><i> port str-handler seed</i></dt>
<dd>

<p>This procedure must be called after we have read a string
&lsquo;<samp>&lt;![CDATA[</samp>&rsquo; that begins a CDATA section.  The current position
must be the first position of the CDATA body.  This function reads
<em>lines</em> of the CDATA body and passes them to a <var>str-handler</var>, a character
data consumer.
</p>
<p><var>str-handler</var> is a procedure taking arguments: <var>string1</var>, <var>string2</var>,
and <var>seed</var>.  The first <var>string1</var> argument to <var>str-handler</var> never
contains a newline; the second <var>string2</var> argument often will.
On the first invocation of <var>str-handler</var>, <var>seed</var> is the one passed to <code>ssax:read-cdata-body</code> as the
third argument.  The result of this first invocation will be passed
as the <var>seed</var> argument to the second invocation of the line
consumer, and so on.  The result of the last invocation of the <var>str-handler</var> is
returned by the <code>ssax:read-cdata-body</code>.  Note a similarity to the fundamental <em>fold</em>
<a name="index-fold"></a>
iterator.
</p>
<p>Within a CDATA section all characters are taken at their face value,
with three exceptions:
</p><ul>
<li>
CR, LF, and CRLF are treated as line delimiters, and passed
as a single &lsquo;<samp>#\newline</samp>&rsquo; to <var>str-handler</var>

</li><li>
&lsquo;<samp>]]&gt;</samp>&rsquo; combination is the end of the CDATA section.
&lsquo;<samp>&amp;gt;</samp>&rsquo; is treated as an embedded &lsquo;<samp>&gt;</samp>&rsquo; character.

</li><li>
&lsquo;<samp>&amp;lt;</samp>&rsquo; and &lsquo;<samp>&amp;amp;</samp>&rsquo; are not specially recognized (and are
not expanded)!

</li></ul>
</dd></dl>


<dl>
<dt><a name="index-ssax_003aread_002dchar_002dref"></a><u>Function:</u> <b>ssax:read-char-ref</b><i> port</i></dt>
<dd>

<table><tr><td>&nbsp;</td><td><pre class="example">[66]  CharRef ::=  '&amp;#' [0-9]+ ';'
                 | '&amp;#x' [0-9a-fA-F]+ ';'
</pre></td></tr></table>

<p>This procedure must be called after we we have read &lsquo;<samp>&amp;#</samp>&rsquo; that
introduces a char reference.  The procedure reads this reference and
returns the corresponding char.  The current position in PORT will
be after the &lsquo;<samp>;</samp>&rsquo; that terminates the char reference.
</p>
<p>Faults detected:<br>
WFC: XML-Spec.html#wf-Legalchar
</p>
<p>According to Section <cite>4.1 Character and Entity References</cite>
of the XML Recommendation:
</p>
<blockquote><p>&quot;[Definition: A character reference refers to a specific character
in the ISO/IEC 10646 character set, for example one not directly
accessible from available input devices.]&quot;
</p></blockquote>

</dd></dl>


<dl>
<dt><a name="index-ssax_003ahandle_002dparsed_002dentity"></a><u>Function:</u> <b>ssax:handle-parsed-entity</b><i> port name entities content-handler str-handler seed</i></dt>
<dd>

<p>Expands and handles a parsed-entity reference.
</p>
<p><var>name</var> is a symbol, the name of the parsed entity to expand.
<var>content-handler</var> is a procedure of arguments <var>port</var>, <var>entities</var>, and
<var>seed</var> that returns a seed.
<var>str-handler</var> is called if the entity in question is a pre-declared entity.
</p>
<p><code>ssax:handle-parsed-entity</code> returns the result returned by <var>content-handler</var> or <var>str-handler</var>.
</p>
<p>Faults detected:<br>
WFC: XML-Spec.html#wf-entdeclared<br>
WFC: XML-Spec.html#norecursion
</p></dd></dl>


<dl>
<dt><a name="index-attlist_002dadd"></a><u>Function:</u> <b>attlist-add</b><i> attlist name-value</i></dt>
<dd>

<p>Add a <var>name-value</var> pair to the existing <var>attlist</var>, preserving its sorted ascending
order; and return the new list.  Return #f if a pair with the same
name already exists in <var>attlist</var>
</p></dd></dl>


<dl>
<dt><a name="index-attlist_002dremove_002dtop"></a><u>Function:</u> <b>attlist-remove-top</b><i> attlist</i></dt>
<dd>

<p>Given an non-null <var>attlist</var>, return a pair of values: the top and the rest.
</p></dd></dl>


<dl>
<dt><a name="index-ssax_003aread_002dattributes"></a><u>Function:</u> <b>ssax:read-attributes</b><i> port entities</i></dt>
<dd>

<p>This procedure reads and parses a production <em>Attribute</em>.
<a name="index-Attribute"></a>
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">[41] Attribute ::= Name Eq AttValue
[10] AttValue ::=  '&quot;' ([^&lt;&amp;&quot;] | Reference)* '&quot;'
                | &quot;'&quot; ([^&lt;&amp;'] | Reference)* &quot;'&quot;
[25] Eq ::= S? '=' S?
</pre></td></tr></table>

<p>The procedure returns an ATTLIST, of Name (as UNRES-NAME), Value (as
string) pairs.  The current character on the <var>port</var> is a non-whitespace
character that is not an NCName-starting character.
</p>
<p>Note the following rules to keep in mind when reading an
<em>AttValue</em>:
<a name="index-AttValue"></a>
</p><blockquote><p>Before the value of an attribute is passed to the application or
checked for validity, the XML processor must normalize it as
follows:
</p>
<ul>
<li>
A character reference is processed by appending the referenced
character to the attribute value.

</li><li>
An entity reference is processed by recursively processing the
replacement text of the entity.  The named entities &lsquo;<samp>amp</samp>&rsquo;,
&lsquo;<samp>lt</samp>&rsquo;, &lsquo;<samp>gt</samp>&rsquo;, &lsquo;<samp>quot</samp>&rsquo;, and &lsquo;<samp>apos</samp>&rsquo; are pre-declared.

</li><li>
A whitespace character (#x20, #x0D, #x0A, #x09) is processed by
appending #x20 to the normalized value, except that only a single
#x20 is appended for a &quot;#x0D#x0A&quot; sequence that is part of an
external parsed entity or the literal entity value of an internal
parsed entity.

</li><li>
Other characters are processed by appending them to the normalized
value.

</li></ul>

</blockquote>

<p>Faults detected:<br>
WFC: XML-Spec.html#CleanAttrVals<br>
WFC: XML-Spec.html#uniqattspec
</p></dd></dl>


<dl>
<dt><a name="index-ssax_003aresolve_002dname"></a><u>Function:</u> <b>ssax:resolve-name</b><i> port unres-name namespaces apply-default-ns?</i></dt>
<dd>

<p>Convert an <var>unres-name</var> to a RES-NAME, given the appropriate <var>namespaces</var> declarations.
The last parameter, <var>apply-default-ns?</var>, determines if the default namespace applies
(for instance, it does not for attribute names).
</p>
<p>Per REC-xml-names/#nsc-NSDeclared, the &quot;xml&quot; prefix is considered
pre-declared and bound to the namespace name
&quot;http://www.w3.org/XML/1998/namespace&quot;.
</p>
<p><code>ssax:resolve-name</code> tests for the namespace constraints:<br>
<a href="http://www.w3.org/TR/REC-xml-names/#nsc-NSDeclared">http://www.w3.org/TR/REC-xml-names/#nsc-NSDeclared</a>
</p></dd></dl>


<dl>
<dt><a name="index-ssax_003acomplete_002dstart_002dtag"></a><u>Function:</u> <b>ssax:complete-start-tag</b><i> tag port elems entities namespaces</i></dt>
<dd>

<p>Complete parsing of a start-tag markup.  <code>ssax:complete-start-tag</code> must be called after the
start tag token has been read.  <var>tag</var> is an UNRES-NAME.  <var>elems</var> is an
instance of the ELEMS slot of XML-DECL; it can be #f to tell the
function to do <em>no</em> validation of elements and their
attributes.
</p>
<p><code>ssax:complete-start-tag</code> returns several values:
</p><ul>
<li> ELEM-GI:
a RES-NAME.
</li><li> ATTRIBUTES:
element&rsquo;s attributes, an ATTLIST of (RES-NAME . STRING) pairs.
The list does NOT include xmlns attributes.
</li><li> NAMESPACES:
the input list of namespaces amended with namespace
(re-)declarations contained within the start-tag under parsing
</li><li> ELEM-CONTENT-MODEL
</li></ul>

<p>On exit, the current position in <var>port</var> will be the first character
after &lsquo;<samp>&gt;</samp>&rsquo; that terminates the start-tag markup.
</p>
<p>Faults detected:<br>
VC: XML-Spec.html#enum<br>
VC: XML-Spec.html#RequiredAttr<br>
VC: XML-Spec.html#FixedAttr<br>
VC: XML-Spec.html#ValueType<br>
WFC: XML-Spec.html#uniqattspec (after namespaces prefixes are resolved)<br>
VC: XML-Spec.html#elementvalid<br>
WFC: REC-xml-names/#dt-NSName
</p>
<p><em>Note</em>: although XML Recommendation does not explicitly say it,
xmlns and xmlns: attributes don&rsquo;t have to be declared (although they
can be declared, to specify their default value).
</p></dd></dl>


<dl>
<dt><a name="index-ssax_003aread_002dexternal_002did"></a><u>Function:</u> <b>ssax:read-external-id</b><i> port</i></dt>
<dd>

<p>Parses an ExternalID production:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">[75] ExternalID ::= 'SYSTEM' S SystemLiteral
                  | 'PUBLIC' S PubidLiteral S SystemLiteral
[11] SystemLiteral ::= ('&quot;' [^&quot;]* '&quot;') | (&quot;'&quot; [^']* &quot;'&quot;)
[12] PubidLiteral ::=  '&quot;' PubidChar* '&quot;'
                     | &quot;'&quot; (PubidChar - &quot;'&quot;)* &quot;'&quot;
[13] PubidChar ::=  #x20 | #x0D | #x0A | [a-zA-Z0-9]
                         | [-'()+,./:=?;!*#@$_%]
</pre></td></tr></table>

<p>Call <code>ssax:read-external-id</code> when an ExternalID is expected; that is, the current
character must be either #\S or #\P that starts correspondingly a
SYSTEM or PUBLIC token.  <code>ssax:read-external-id</code> returns the <var>SystemLiteral</var> as a
string.  A <var>PubidLiteral</var> is disregarded if present.
</p></dd></dl>

<hr size="6">
<a name="Mid_002dLevel-Parsers-and-Scanners"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Low_002dLevel-Parsers-and-Scanners" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#High_002dlevel-Parsers" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Parsing-XML" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">4.11.5 Mid-Level Parsers and Scanners</h3>

<p>These procedures parse productions corresponding to the whole
(document) entity or its higher-level pieces (prolog, root element,
etc).
</p>

<dl>
<dt><a name="index-ssax_003ascan_002dmisc"></a><u>Function:</u> <b>ssax:scan-misc</b><i> port</i></dt>
<dd>

<p>Scan the Misc production in the context:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">[1]  document ::=  prolog element Misc*
[22] prolog ::= XMLDecl? Misc* (doctypedec l Misc*)?
[27] Misc ::= Comment | PI |  S
</pre></td></tr></table>

<p>Call <code>ssax:scan-misc</code> in the prolog or epilog contexts.  In these contexts,
whitespaces are completely ignored.  The return value from <code>ssax:scan-misc</code> is
either a PI-token, a DECL-token, a START token, or *EOF*.  Comments
are ignored and not reported.
</p></dd></dl>


<dl>
<dt><a name="index-ssax_003aread_002dchar_002ddata"></a><u>Function:</u> <b>ssax:read-char-data</b><i> port expect-eof? str-handler iseed</i></dt>
<dd>

<p>Read the character content of an XML document or an XML element.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">[43] content ::=
(element | CharData | Reference | CDSect | PI | Comment)*
</pre></td></tr></table>

<p>To be more precise, <code>ssax:read-char-data</code> reads CharData, expands CDSect and character
entities, and skips comments.  <code>ssax:read-char-data</code> stops at a named reference, EOF,
at the beginning of a PI, or a start/end tag.
</p>
<p><var>expect-eof?</var> is a boolean indicating if EOF is normal; i.e., the character
data may be terminated by the EOF.  EOF is normal while processing a
parsed entity.
</p>
<p><var>iseed</var> is an argument passed to the first invocation of <var>str-handler</var>.
</p>
<p><code>ssax:read-char-data</code> returns two results: <var>seed</var> and <var>token</var>.  The <var>seed</var>
is the result of the last invocation of <var>str-handler</var>, or the original <var>iseed</var> if <var>str-handler</var>
was never called.
</p>
<p><var>token</var> can be either an eof-object (this can happen only if <var>expect-eof?</var>
was #t), or:
</p><ul>
<li>
an xml-token describing a START tag or an END-tag;
For a start token, the caller has to finish reading it.

</li><li>
an xml-token describing the beginning of a PI.  It&rsquo;s up to an
application to read or skip through the rest of this PI;

</li><li>
an xml-token describing a named entity reference.

</li></ul>

<p>CDATA sections and character references are expanded inline and
never returned.  Comments are silently disregarded.
</p>
<p>As the XML Recommendation requires, all whitespace in character data
must be preserved.  However, a CR character (#x0D) must be
disregarded if it appears before a LF character (#x0A), or replaced
by a #x0A character otherwise.  See Secs. 2.10 and 2.11 of the XML
Recommendation.  See also the canonical XML Recommendation.
</p></dd></dl>


<dl>
<dt><a name="index-ssax_003aassert_002dtoken"></a><u>Function:</u> <b>ssax:assert-token</b><i> token kind gi error-cont</i></dt>
<dd>

<p>Make sure that <var>token</var> is of anticipated <var>kind</var> and has anticipated <var>gi</var>.  Note
that the <var>gi</var> argument may actually be a pair of two symbols,
Namespace-URI or the prefix, and of the localname.  If the assertion
fails, <var>error-cont</var> is evaluated by passing it three arguments: <var>token</var> <var>kind</var> <var>gi</var>.  The
result of <var>error-cont</var> is returned.
</p></dd></dl>

<hr size="6">
<a name="High_002dlevel-Parsers"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Mid_002dLevel-Parsers-and-Scanners" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Parsing-XML-to-SXML" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Parsing-XML" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">4.11.6 High-level Parsers</h3>

<p>These procedures are to instantiate a SSAX parser.  A user can
instantiate the parser to do the full validation, or no validation,
or any particular validation.  The user specifies which PI he wants
to be notified about.  The user tells what to do with the parsed
character and element data.  The latter handlers determine if the
parsing follows a SAX or a DOM model.
</p>

<dl>
<dt><a name="index-ssax_003amake_002dpi_002dparser"></a><u>Function:</u> <b>ssax:make-pi-parser</b><i> my-pi-handlers</i></dt>
<dd>

<p>Create a parser to parse and process one Processing Element (PI).
</p>
<p><var>my-pi-handlers</var> is an association list of pairs
<code>(<var>pi-tag</var> . <var>pi-handler</var>)</code> where <var>pi-tag</var> is an
NCName symbol, the PI target; and <var>pi-handler</var> is a procedure
taking arguments <var>port</var>, <var>pi-tag</var>, and <var>seed</var>.
</p>
<p><var>pi-handler</var> should read the rest of the PI up to and including
the combination &lsquo;<samp>?&gt;</samp>&rsquo; that terminates the PI.  The handler
should return a new seed.  One of the <var>pi-tag</var>s may be the
symbol <code>*DEFAULT*</code>.  The corresponding handler will handle PIs
that no other handler will.  If the *DEFAULT* <var>pi-tag</var> is not
specified, <code>ssax:make-pi-parser</code> will assume the default handler that skips the body of
the PI.
</p>
<p><code>ssax:make-pi-parser</code> returns a procedure of arguments <var>port</var>, <var>pi-tag</var>, and
<var>seed</var>; that will parse the current PI according to <var>my-pi-handlers</var>.
</p></dd></dl>


<dl>
<dt><a name="index-ssax_003amake_002delem_002dparser"></a><u>Function:</u> <b>ssax:make-elem-parser</b><i> my-new-level-seed my-finish-element my-char-data-handler my-pi-handlers</i></dt>
<dd>

<p>Create a parser to parse and process one element, including its
character content or children elements.  The parser is typically
applied to the root element of a document.
</p>
<dl compact="compact">
<dt> <var>my-new-level-seed</var></dt>
<dd><p>is a procedure taking arguments:
</p>
<p><var>elem-gi</var> <var>attributes</var> <var>namespaces</var> <var>expected-content</var> <var>seed</var>
</p>
<p>where <var>elem-gi</var> is a RES-NAME of the element about to be
processed.
</p>
<p><var>my-new-level-seed</var> is to generate the seed to be passed to handlers that process the
content of the element.
</p>
</dd>
<dt> <var>my-finish-element</var></dt>
<dd><p>is a procedure taking arguments:
</p>
<p><var>elem-gi</var> <var>attributes</var> <var>namespaces</var> <var>parent-seed</var> <var>seed</var>
</p>
<p><var>my-finish-element</var> is called when parsing of <var>elem-gi</var> is finished.
The <var>seed</var> is the result from the last content parser (or
from <var>my-new-level-seed</var> if the element has the empty content).
<var>parent-seed</var> is the same seed as was passed to <var>my-new-level-seed</var>.
<var>my-finish-element</var> is to generate a seed that will be the result
of the element parser.
</p>
</dd>
<dt> <var>my-char-data-handler</var></dt>
<dd><p>is a STR-HANDLER as described in Data Types above.
</p>
</dd>
<dt> <var>my-pi-handlers</var></dt>
<dd><p>is as described for <code>ssax:make-pi-handler</code> above.
</p>
</dd>
</dl>

<p>The generated parser is a procedure taking arguments:
</p>
<p><var>start-tag-head</var> <var>port</var> <var>elems</var> <var>entities</var> <var>namespaces</var> <var>preserve-ws?</var> <var>seed</var>
</p>
<p>The procedure must be called after the start tag token has been
read.  <var>start-tag-head</var> is an UNRES-NAME from the start-element
tag.  ELEMS is an instance of ELEMS slot of XML-DECL.
</p>
<p>Faults detected:<br>
VC: XML-Spec.html#elementvalid<br>
WFC: XML-Spec.html#GIMatch
</p></dd></dl>


<dl>
<dt><a name="index-ssax_003amake_002dparser"></a><u>Function:</u> <b>ssax:make-parser</b><i> user-handler-tag user-handler &hellip;</i></dt>
<dd>

<p>Create an XML parser, an instance of the XML parsing framework.
This will be a SAX, a DOM, or a specialized parser depending on the
supplied user-handlers.
</p>
<p><code>ssax:make-parser</code> takes an even number of arguments; <var>user-handler-tag</var> is a symbol that identifies
a procedure (or association list for <code>PROCESSING-INSTRUCTIONS</code>)
(<var>user-handler</var>) that follows the tag.  Given below are tags and signatures of
the corresponding procedures.  Not all tags have to be specified.
If some are omitted, reasonable defaults will apply.
</p>
<dl compact="compact">
<dt> &lsquo;<samp>DOCTYPE</samp>&rsquo;</dt>
<dd><p>handler-procedure: <var>port</var> <var>docname</var> <var>systemid</var> <var>internal-subset?</var> <var>seed</var>
</p>
<p>If <var>internal-subset?</var> is #t, the current position in the port is
right after we have read &lsquo;<samp>[</samp>&rsquo; that begins the internal DTD
subset.  We must finish reading of this subset before we return (or
must call <code>skip-internal-dtd</code> if we aren&rsquo;t interested in
reading it).  <var>port</var> at exit must be at the first symbol after
the whole DOCTYPE declaration.
</p>
<p>The handler-procedure must generate four values:
</p><blockquote><p><var>elems</var> <var>entities</var> <var>namespaces</var> <var>seed</var>
</p></blockquote>

<p><var>elems</var> is as defined for the ELEMS slot of XML-DECL.  It may be
#f to switch off validation.  <var>namespaces</var> will typically
contain <var>user-prefix</var>es for selected <var>uri-symb</var>s.  The
default handler-procedure skips the internal subset, if any, and
returns <code>(values #f '() '() seed)</code>.
</p>
</dd>
<dt> &lsquo;<samp>UNDECL-ROOT</samp>&rsquo;</dt>
<dd><p>procedure: <var>elem-gi</var> <var>seed</var>
</p>
<p>where <var>elem-gi</var> is an UNRES-NAME of the root element.  This
procedure is called when an XML document under parsing contains
<em>no</em> DOCTYPE declaration.
</p>
<p>The handler-procedure, as a DOCTYPE handler procedure above,
must generate four values:
</p><blockquote><p><var>elems</var> <var>entities</var> <var>namespaces</var> <var>seed</var>
</p></blockquote>

<p>The default handler-procedure returns (values #f &rsquo;() &rsquo;() seed)
</p>
</dd>
<dt> &lsquo;<samp>DECL-ROOT</samp>&rsquo;</dt>
<dd><p>procedure: <var>elem-gi</var> <var>seed</var>
</p>
<p>where <var>elem-gi</var> is an UNRES-NAME of the root element.  This
procedure is called when an XML document under parsing does contains
the DOCTYPE declaration.  The handler-procedure must generate a new
<var>seed</var> (and verify that the name of the root element matches the
doctype, if the handler so wishes).  The default handler-procedure
is the identity function.
</p>
</dd>
<dt> &lsquo;<samp>NEW-LEVEL-SEED</samp>&rsquo;</dt>
<dd><p>procedure: see ssax:make-elem-parser, my-new-level-seed
</p>
</dd>
<dt> &lsquo;<samp>FINISH-ELEMENT</samp>&rsquo;</dt>
<dd><p>procedure: see ssax:make-elem-parser, my-finish-element
</p>
</dd>
<dt> &lsquo;<samp>CHAR-DATA-HANDLER</samp>&rsquo;</dt>
<dd><p>procedure: see ssax:make-elem-parser, my-char-data-handler
</p>
</dd>
<dt> &lsquo;<samp>PROCESSING-INSTRUCTIONS</samp>&rsquo;</dt>
<dd><p>association list as is passed to <code>ssax:make-pi-parser</code>.
The default value is &rsquo;()
</p>
</dd>
</dl>

<p>The generated parser is a procedure of arguments <var>port</var> and
<var>seed</var>.
</p>
<p>This procedure parses the document prolog and then exits to an
element parser (created by <code>ssax:make-elem-parser</code>) to handle
the rest.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">[1]  document ::=  prolog element Misc*
[22] prolog ::= XMLDecl? Misc* (doctypedec | Misc*)?
[27] Misc ::= Comment | PI |  S
[28] doctypedecl ::=  '&lt;!DOCTYPE' S Name (S ExternalID)? S?
              ('[' (markupdecl | PEReference | S)* ']' S?)? '&gt;'
[29] markupdecl ::= elementdecl | AttlistDecl
                     | EntityDecl
                     | NotationDecl | PI
                     | Comment
</pre></td></tr></table>
</dd></dl>

<hr size="6">
<a name="Parsing-XML-to-SXML"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#High_002dlevel-Parsers" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Printing-Scheme" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Parsing-XML" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">4.11.7 Parsing XML to SXML</h3>


<dl>
<dt><a name="index-ssax_003axml_002d_003esxml"></a><u>Function:</u> <b>ssax:xml-&gt;sxml</b><i> port namespace-prefix-assig</i></dt>
<dd>

<p>This is an instance of the SSAX parser that returns an SXML
representation of the XML document to be read from <var>port</var>.  <var>namespace-prefix-assig</var> is a list
of <code>(<var>user-prefix</var> . <var>uri-string</var>)</code> that assigns
<var>user-prefix</var>es to certain namespaces identified by particular
<var>uri-string</var>s.  It may be an empty list.  <code>ssax:xml-&gt;sxml</code> returns an SXML
tree.  The port points out to the first character after the root
element.
</p></dd></dl>



<hr size="6">
<a name="Printing-Scheme"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Parsing-XML-to-SXML" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Generic_002dWrite" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Printing-Scheme-1"></a>
<h2 class="section">4.12 Printing Scheme</h2>

<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#Generic_002dWrite">4.12.1 Generic-Write</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">               &rsquo;generic-write
</td></tr>
<tr><td align="left" valign="top"><a href="#Object_002dTo_002dString">4.12.2 Object-To-String</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">            &rsquo;object-&gt;string
</td></tr>
<tr><td align="left" valign="top"><a href="#Pretty_002dPrint">4.12.3 Pretty-Print</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                &rsquo;pretty-print, &rsquo;pprint-file
</td></tr>
</table>

<hr size="6">
<a name="Generic_002dWrite"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Printing-Scheme" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Object_002dTo_002dString" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Printing-Scheme" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Generic_002dWrite-1"></a>
<h3 class="subsection">4.12.1 Generic-Write</h3>

<p><code>(require 'generic-write)</code>
<a name="index-generic_002dwrite"></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>
<dl>
<dt><a name="index-generic_002dwrite-1"></a><u>Procedure:</u> <b>generic-write</b><i> obj display? width output</i></dt>
<dd><dl compact="compact">
<dt> <var>obj</var></dt>
<dd><p>Scheme data value to transform.
</p></dd>
<dt> <var>display?</var></dt>
<dd><p>Boolean, controls whether characters and strings are quoted.
</p></dd>
<dt> <var>width</var></dt>
<dd><p>Extended boolean, selects format:
</p><dl compact="compact">
<dt> #f</dt>
<dd><p>single line format
</p></dd>
<dt> integer &gt; 0</dt>
<dd><p>pretty-print (value = max nb of chars per line)
</p></dd>
</dl>
</dd>
<dt> <var>output</var></dt>
<dd><p>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.
</p></dd>
</dl>

<p>The value returned by <code>generic-write</code> is undefined.
</p>
<p>Examples:
</p><table><tr><td>&nbsp;</td><td><pre class="lisp">(write obj) &equiv; (generic-write obj #f #f <var>display-string</var>)
(display obj) &equiv; (generic-write obj #t #f <var>display-string</var>)
</pre></td></tr></table>
<p>where
</p><table><tr><td>&nbsp;</td><td><pre class="lisp"><var>display-string</var> &equiv;
(lambda (s) (for-each write-char (string-&gt;list s)) #t)
</pre></td></tr></table>
</dd></dl>


<hr size="6">
<a name="Object_002dTo_002dString"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Generic_002dWrite" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Pretty_002dPrint" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Printing-Scheme" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Object_002dTo_002dString-1"></a>
<h3 class="subsection">4.12.2 Object-To-String</h3>

<p><code>(require 'object-&gt;string)</code>
<a name="index-object_002d_003estring"></a>
</p>

<dl>
<dt><a name="index-object_002d_003estring-1"></a><u>Function:</u> <b>object-&gt;string</b><i> obj</i></dt>
<dd><p>Returns the textual representation of <var>obj</var> as a string.
</p></dd></dl>


<dl>
<dt><a name="index-object_002d_003elimited_002dstring"></a><u>Function:</u> <b>object-&gt;limited-string</b><i> obj limit</i></dt>
<dd><p>Returns the textual representation of <var>obj</var> as a string of length
at most <var>limit</var>.
</p></dd></dl>



<hr size="6">
<a name="Pretty_002dPrint"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Object_002dTo_002dString" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Time-and-Date" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Printing-Scheme" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Pretty_002dPrint-1"></a>
<h3 class="subsection">4.12.3 Pretty-Print</h3>

<p><code>(require 'pretty-print)</code>
<a name="index-pretty_002dprint"></a>
</p>
<dl>
<dt><a name="index-pretty_002dprint-1"></a><u>Procedure:</u> <b>pretty-print</b><i> obj</i></dt>
<dt><a name="index-pretty_002dprint-2"></a><u>Procedure:</u> <b>pretty-print</b><i> obj port</i></dt>
<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:
</p><table><tr><td>&nbsp;</td><td><pre class="example">(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>
</dd></dl>

<dl>
<dt><a name="index-pretty_002dprint_002d_003estring"></a><u>Procedure:</u> <b>pretty-print-&gt;string</b><i> obj</i></dt>
<dt><a name="index-pretty_002dprint_002d_003estring-1"></a><u>Procedure:</u> <b>pretty-print-&gt;string</b><i> obj width</i></dt>
<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:
</p><table><tr><td>&nbsp;</td><td><pre class="example">(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)))
&rArr;
&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><pre class="example">(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)
&rArr;
&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>
</dd></dl>


<p><code>(require 'pprint-file)</code>
<a name="index-pprint_002dfile"></a>
</p>
<dl>
<dt><a name="index-pprint_002dfile-1"></a><u>Procedure:</u> <b>pprint-file</b><i> infile</i></dt>
<dt><a name="index-pprint_002dfile-2"></a><u>Procedure:</u> <b>pprint-file</b><i> infile outfile</i></dt>
<dd><p>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>.
</p></dd></dl>

<dl>
<dt><a name="index-pprint_002dfilter_002dfile"></a><u>Function:</u> <b>pprint-filter-file</b><i> infile proc outfile</i></dt>
<dt><a name="index-pprint_002dfilter_002dfile-1"></a><u>Function:</u> <b>pprint-filter-file</b><i> infile proc</i></dt>
<dd><p><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>
<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></dd></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
&lsquo;<tt>exp-code.scm</tt>&rsquo; the result of expanding all defmacros in
&lsquo;<tt>code.scm</tt>&rsquo;.
</p><table><tr><td>&nbsp;</td><td><pre class="lisp">(require 'pprint-file)
<a name="index-pprint_002dfile-3"></a>(require 'defmacroexpand)
<a name="index-defmacroexpand-1"></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>


<hr size="6">
<a name="Time-and-Date"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Pretty_002dPrint" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Time-Zone" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Time-and-Date-1"></a>
<h2 class="section">4.13 Time and Date</h2>

<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#Time-Zone">4.13.1 Time Zone</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                   
</td></tr>
<tr><td align="left" valign="top"><a href="#Posix-Time">4.13.2 Posix Time</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                  &rsquo;posix-time
</td></tr>
<tr><td align="left" valign="top"><a href="#Common_002dLisp-Time">4.13.3 Common-Lisp Time</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">            &rsquo;common-lisp-time
</td></tr>
<tr><td align="left" valign="top"><a href="#Time-Infrastructure">4.13.4 Time Infrastructure</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">         
</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="index-time"></a>
<a name="index-calendar-time"></a>
which may or may not be disjoint from other Scheme datatypes.
</p>
<dl>
<dt><a name="index-current_002dtime"></a><u>Function:</u> <b>current-time</b></dt>
<dd><p>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="#Common_002dLisp-Time">Common-Lisp Time</a>.
</p></dd></dl>

<dl>
<dt><a name="index-difftime"></a><u>Function:</u> <b>difftime</b><i> caltime1 caltime0</i></dt>
<dd><p>Returns the difference (number of seconds) between twe calendar times:
<var>caltime1</var> - <var>caltime0</var>.  <var>caltime0</var> may also be a number.
</p></dd></dl>

<dl>
<dt><a name="index-offset_002dtime"></a><u>Function:</u> <b>offset-time</b><i> caltime offset</i></dt>
<dd><p>Returns the calendar time of <var>caltime</var> offset by <var>offset</var> number
of seconds <code>(+ caltime offset)</code>.
</p></dd></dl>


<hr size="6">
<a name="Time-Zone"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Time-and-Date" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Posix-Time" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Time-and-Date" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Time-Zone-1"></a>
<h3 class="subsection">4.13.1 Time Zone</h3>

<p>(require &rsquo;time-zone)
</p>
<dl>
<dt><a name="index-TZ_002dstring"></a><u>Data Format:</u> <b>TZ-string</b></dt>
<dd>
<p>POSIX standards specify several formats for encoding time-zone rules.
</p>
<dl compact="compact">
<dt> <tt>:<i>&lt;pathname&gt;</i></tt></dt>
<dd><p>If the first character of <i>&lt;pathname&gt;</i> is &lsquo;<samp>/</samp>&rsquo;, 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.
</p></dd>
<dt> <tt><i>&lt;std&gt;</i><i>&lt;offset&gt;</i></tt></dt>
<dd><p>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 &lsquo;<samp>:</samp>&rsquo;.  For
example, <code>-4:30</code>.
</p></dd>
<dt> <tt><i>&lt;std&gt;</i><i>&lt;offset&gt;</i><i>&lt;dst&gt;</i></tt></dt>
<dd><p><i>&lt;dst&gt;</i> is the at least 3 alphabetic characters naming the local
daylight-savings-time.
</p></dd>
<dt> <tt><i>&lt;std&gt;</i><i>&lt;offset&gt;</i><i>&lt;dst&gt;</i><i>&lt;doffset&gt;</i></tt></dt>
<dd><p><i>&lt;doffset&gt;</i> specifies the offset from the Prime Meridian when
daylight-savings-time is in effect.
</p></dd>
</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>
<dl compact="compact">
<dt> <tt>,<i>&lt;date&gt;</i>/<i>&lt;time&gt;</i>,<i>&lt;date&gt;</i>/<i>&lt;time&gt;</i></tt></dt>
<dd><p>The <i>&lt;time&gt;</i>s are specified like the <i>&lt;offset&gt;</i>s above, except that
leading &lsquo;<samp>+</samp>&rsquo; and &lsquo;<samp>-</samp>&rsquo; are not allowed.
</p>
<p>Each <i>&lt;date&gt;</i> has one of the formats:
</p>
<dl compact="compact">
<dt> <tt>J<i>&lt;day&gt;</i></tt></dt>
<dd><p>specifies the Julian day with <i>&lt;day&gt;</i> between 1 and 365.  February 29
is never counted and cannot be referenced.
</p></dd>
<dt> <tt><i>&lt;day&gt;</i></tt></dt>
<dd><p>This specifies the Julian day with n between 0 and 365.  February 29 is
counted in leap years and can be specified.
</p></dd>
<dt> <tt>M<i>&lt;month&gt;</i>.<i>&lt;week&gt;</i>.<i>&lt;day&gt;</i></tt></dt>
<dd><p>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.
</p></dd>
</dl>
</dd>
</dl>

</dd></dl>

<dl>
<dt><a name="index-time_002dzone"></a><u>Data Type:</u> <b>time-zone</b></dt>
<dd><p>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.
</p></dd></dl>

<dl>
<dt><a name="index-time_002dzone-1"></a><u>Function:</u> <b>time-zone</b><i> TZ-string</i></dt>
<dd><p>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.
</p></dd></dl>

<dl>
<dt><a name="index-tz_003aparams"></a><u>Function:</u> <b>tz:params</b><i> caltime tz</i></dt>
<dd><p><var>tz</var> is a time-zone object.  <code>tz:params</code> returns a list of
three items:
</p><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><li>
The number of seconds west of the Prime Meridian timezone <var>tz</var> is at
<var>caltime</var>.
</li><li>
The name for timezone <var>tz</var> at <var>caltime</var>.
</li></ol>

<p><code>tz:params</code> is unaffected by the default timezone; inquiries can be
made of any timezone at any calendar time.
</p>
</dd></dl>

<dl>
<dt><a name="index-tz_003astd_002doffset"></a><u>Function:</u> <b>tz:std-offset</b><i> tz</i></dt>
<dd><p><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>
</dd></dl>

<p>The rest of these procedures and variables are provided for POSIX
compatability.  Because of shared state they are not thread-safe.
</p>
<dl>
<dt><a name="index-tzset"></a><u>Function:</u> <b>tzset</b></dt>
<dd><p>Returns the default time-zone.
</p>
</dd><dt><a name="index-tzset-1"></a><u>Function:</u> <b>tzset</b><i> tz</i></dt>
<dd><p>Sets (and returns) the default time-zone to <var>tz</var>.
</p>
</dd><dt><a name="index-tzset-2"></a><u>Function:</u> <b>tzset</b><i> TZ-string</i></dt>
<dd><p>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="#Time-and-Date">Time and Date</a>).
</p></dd></dl>

<dl>
<dt><a name="index-_002atimezone_002a"></a><u>Variable:</u> <b>*timezone*</b></dt>
<dd><p>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>.
</p></dd></dl>

<dl>
<dt><a name="index-daylight_003f"></a><u>Variable:</u> <b>daylight?</b></dt>
<dd><p>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.
</p></dd></dl>

<dl>
<dt><a name="index-tzname"></a><u>Variable:</u> <b>tzname</b></dt>
<dd><p>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.
</p></dd></dl>


<hr size="6">
<a name="Posix-Time"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Time-Zone" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Common_002dLisp-Time" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Time-and-Date" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Posix-Time-1"></a>
<h3 class="subsection">4.13.2 Posix Time</h3>

<table><tr><td>&nbsp;</td><td><pre class="example">(require 'posix-time)
<a name="index-posix_002dtime"></a></pre></td></tr></table>

<dl>
<dt><a name="index-Calendar_002dTime"></a><u>Data Type:</u> <b>Calendar-Time</b></dt>
<dd><a name="index-calendar-time-1"></a>
<a name="index-caltime"></a>
<p>is a datatype encapsulating time.
</p></dd></dl>

<dl>
<dt><a name="index-Coordinated-Universal-Time"></a><u>Data Type:</u> <b>Coordinated Universal Time</b></dt>
<dd><a name="index-Coordinated-Universal-Time-1"></a>
<a name="index-UTC"></a>
<p>(abbreviated <em>UTC</em>) is a vector of integers representing time:
</p>
<ol>
<li>
 seconds (0 - 61)
</li><li>
 minutes (0 - 59)
</li><li>
 hours since midnight (0 - 23)
</li><li>
 day of month (1 - 31)
</li><li>
 month (0 - 11).  Note difference from <code>decode-universal-time</code>.
</li><li>
 the number of years since 1900.  Note difference from
<code>decode-universal-time</code>.
</li><li>
 day of week (0 - 6)
</li><li>
 day of year (0 - 365)
</li><li>
 1 for daylight savings, 0 for regular time
</li></ol>
</dd></dl>

<dl>
<dt><a name="index-gmtime"></a><u>Function:</u> <b>gmtime</b><i> caltime</i></dt>
<dd><p>Converts the calendar time <var>caltime</var> to UTC and returns it.
</p>
</dd><dt><a name="index-localtime"></a><u>Function:</u> <b>localtime</b><i> caltime tz</i></dt>
<dd><p>Returns <var>caltime</var> converted to UTC relative to timezone <var>tz</var>.
</p>
</dd><dt><a name="index-localtime-1"></a><u>Function:</u> <b>localtime</b><i> caltime</i></dt>
<dd><p>converts the calendar time <var>caltime</var> to a vector of integers
expressed relative to the user&rsquo;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="#Time-Zone">tzset</a>).
</p>
</dd></dl>

<dl>
<dt><a name="index-gmktime"></a><u>Function:</u> <b>gmktime</b><i> univtime</i></dt>
<dd><p>Converts a vector of integers in GMT Coordinated Universal Time (UTC)
format to a calendar time.
</p>
</dd><dt><a name="index-mktime"></a><u>Function:</u> <b>mktime</b><i> univtime</i></dt>
<dd><p>Converts a vector of integers in local Coordinated Universal Time (UTC)
format to a calendar time.
</p>
</dd><dt><a name="index-mktime-1"></a><u>Function:</u> <b>mktime</b><i> univtime tz</i></dt>
<dd><p>Converts a vector of integers in Coordinated Universal Time (UTC) format
(relative to time-zone <var>tz</var>)
to calendar time.
</p></dd></dl>

<dl>
<dt><a name="index-asctime"></a><u>Function:</u> <b>asctime</b><i> univtime</i></dt>
<dd><p>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>.
</p></dd></dl>

<dl>
<dt><a name="index-gtime"></a><u>Function:</u> <b>gtime</b><i> caltime</i></dt>
<dt><a name="index-ctime"></a><u>Function:</u> <b>ctime</b><i> caltime</i></dt>
<dt><a name="index-ctime-1"></a><u>Function:</u> <b>ctime</b><i> caltime tz</i></dt>
<dd><p>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.
</p></dd></dl>


<hr size="6">
<a name="Common_002dLisp-Time"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Posix-Time" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Time-Infrastructure" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Time-and-Date" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Common_002dLisp-Time-1"></a>
<h3 class="subsection">4.13.3 Common-Lisp Time</h3>

<dl>
<dt><a name="index-get_002ddecoded_002dtime"></a><u>Function:</u> <b>get-decoded-time</b></dt>
<dd><p>Equivalent to <code>(decode-universal-time (get-universal-time))</code>.
</p></dd></dl>

<dl>
<dt><a name="index-get_002duniversal_002dtime"></a><u>Function:</u> <b>get-universal-time</b></dt>
<dd><p>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>.
</p></dd></dl>

<dl>
<dt><a name="index-decode_002duniversal_002dtime"></a><u>Function:</u> <b>decode-universal-time</b><i> univtime</i></dt>
<dd><p>Converts <var>univtime</var> to <em>Decoded Time</em> format.
Nine values are returned:
</p><ol>
<li>
 seconds (0 - 61)
</li><li>
 minutes (0 - 59)
</li><li>
 hours since midnight
</li><li>
 day of month
</li><li>
 month (1 - 12).  Note difference from <code>gmtime</code> and <code>localtime</code>.
</li><li>
 year (A.D.).  Note difference from <code>gmtime</code> and <code>localtime</code>.
</li><li>
 day of week (0 - 6)
</li><li>
 #t for daylight savings, #f otherwise
</li><li>
 hours west of GMT (-24 - +24)
</li></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></dd></dl>

<dl>
<dt><a name="index-encode_002duniversal_002dtime"></a><u>Function:</u> <b>encode-universal-time</b><i> second minute hour date month year</i></dt>
<dt><a name="index-encode_002duniversal_002dtime-1"></a><u>Function:</u> <b>encode-universal-time</b><i> second minute hour date month year time-zone</i></dt>
<dd><p>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>
<p>Notice that the values returned by <code>decode-universal-time</code> do not
match the arguments to <code>encode-universal-time</code>.
</p></dd></dl>


<hr size="6">
<a name="Time-Infrastructure"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Common_002dLisp-Time" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#NCBI_002dDNA" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Time-and-Date" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Time-Infrastructure-1"></a>
<h3 class="subsection">4.13.4 Time Infrastructure</h3>

<p><code>(require 'time-core)</code>
</p>
<dl>
<dt><a name="index-time_003agmtime"></a><u>Function:</u> <b>time:gmtime</b><i> tm</i></dt>
<dt><a name="index-time_003ainvert"></a><u>Function:</u> <b>time:invert</b><i> decoder target</i></dt>
<dt><a name="index-time_003asplit"></a><u>Function:</u> <b>time:split</b><i> t tm_isdst tm_gmtoff tm_zone</i></dt>
</dl>

<p><code>(require 'tzfile)</code>
</p>
<dl>
<dt><a name="index-tzfile_003aread"></a><u>Function:</u> <b>tzfile:read</b><i> path</i></dt>
</dl>


<hr size="6">
<a name="NCBI_002dDNA"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Time-Infrastructure" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Schmooz" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="NCBI_002dDNA-1"></a>
<h2 class="section">4.14 NCBI-DNA</h2>

<p><code>(require 'ncbi-dma)</code>
<a name="index-ncbi_002ddma"></a>
</p>

<dl>
<dt><a name="index-ncbi_003aread_002ddna_002dsequence"></a><u>Function:</u> <b>ncbi:read-dna-sequence</b><i> port</i></dt>
<dd>
<p>Reads the NCBI-format DNA sequence following the word &lsquo;<samp>ORIGIN</samp>&rsquo;
from <var>port</var>.
</p></dd></dl>


<dl>
<dt><a name="index-ncbi_003aread_002dfile"></a><u>Function:</u> <b>ncbi:read-file</b><i> file</i></dt>
<dd>
<p>Reads the NCBI-format DNA sequence following the word &lsquo;<samp>ORIGIN</samp>&rsquo;
from <var>file</var>.
</p></dd></dl>


<dl>
<dt><a name="index-mrna_003c_002dcdna"></a><u>Function:</u> <b>mrna&lt;-cdna</b><i> str</i></dt>
<dd>
<p>Replaces &lsquo;<samp>T</samp>&rsquo; with &lsquo;<samp>U</samp>&rsquo; in <var>str</var>
</p></dd></dl>


<dl>
<dt><a name="index-codons_003c_002dcdna"></a><u>Function:</u> <b>codons&lt;-cdna</b><i> cdna</i></dt>
<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
&lsquo;<samp>atg</samp>&rsquo;.
</p></dd></dl>


<dl>
<dt><a name="index-protein_003c_002dcdna"></a><u>Function:</u> <b>protein&lt;-cdna</b><i> cdna</i></dt>
<dd>
<p>Returns a list of three-letter symbols for the protein sequence
encoded by <var>cdna</var> starting with its first occurence of &lsquo;<samp>atg</samp>&rsquo;.
</p></dd></dl>


<dl>
<dt><a name="index-p_003c_002dcdna"></a><u>Function:</u> <b>p&lt;-cdna</b><i> cdna</i></dt>
<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
&lsquo;<samp>atg</samp>&rsquo;.
</p></dd></dl>


<p>These cDNA count routines provide a means to check the nucleotide
sequence with the &lsquo;<samp>BASE COUNT</samp>&rsquo; line preceding the sequence from
NCBI.
</p>

<dl>
<dt><a name="index-cdna_003abase_002dcount"></a><u>Function:</u> <b>cdna:base-count</b><i> cdna</i></dt>
<dd>
<p>Returns a list of counts of &lsquo;<samp>a</samp>&rsquo;, &lsquo;<samp>c</samp>&rsquo;, &lsquo;<samp>g</samp>&rsquo;, and
&lsquo;<samp>t</samp>&rsquo; occurrencing in <var>cdna</var>.
</p></dd></dl>


<dl>
<dt><a name="index-cdna_003areport_002dbase_002dcount"></a><u>Function:</u> <b>cdna:report-base-count</b><i> cdna</i></dt>
<dd>
<p>Prints the counts of &lsquo;<samp>a</samp>&rsquo;, &lsquo;<samp>c</samp>&rsquo;, &lsquo;<samp>g</samp>&rsquo;, and &lsquo;<samp>t</samp>&rsquo;
occurrencing in <var>cdna</var>.
</p></dd></dl>



<hr size="6">
<a name="Schmooz"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#NCBI_002dDNA" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Schmooz-1"></a>
<h2 class="section">4.15 Schmooz</h2>


<a name="index-schmooz"></a>
<p><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 &lsquo;<samp>txi</samp>&rsquo; files which can be
imported into the documentation using the Texinfo command
&lsquo;<samp>@include</samp>&rsquo;.
</p>
<a name="index-schmooz-1"></a>
<p><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>
<dl>
<dt><a name="index-schmooz-2"></a><u>Procedure:</u> <b>schmooz</b><i> filename<span class="roman">.scm</span> &hellip;</i></dt>
<dd><p><var>Filename</var>.scm should be a string ending with &lsquo;<samp>.scm</samp>&rsquo; 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>
</dd><dt><a name="index-schmooz-3"></a><u>Procedure:</u> <b>schmooz</b><i> filename<span class="roman">.texi</span> &hellip;</i></dt>
<dt><a name="index-schmooz-4"></a><u>Procedure:</u> <b>schmooz</b><i> filename<span class="roman">.tex</span> &hellip;</i></dt>
<dt><a name="index-schmooz-5"></a><u>Procedure:</u> <b>schmooz</b><i> filename<span class="roman">.txi</span> &hellip;</i></dt>
<dd><p><var>Filename</var> should be a string naming an existing file containing
Texinfo source code.  For every occurrence of the string &lsquo;<samp>@include
<var>filename</var>.txi</samp>&rsquo; within that file, <code>schmooz</code> calls itself with
the argument &lsquo;<samp><var>filename</var>.scm</samp>&rsquo;.
</p></dd></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 &lsquo;<samp>@body</samp>&rsquo; must be followed by a
Scheme definition.  All comments between the &lsquo;<samp>@body</samp>&rsquo; line and
the definition will be included in a Texinfo definition, either
a &lsquo;<samp>@defun</samp>&rsquo; or a &lsquo;<samp>@defvar</samp>&rsquo;, depending on whether a procedure
or a variable is being defined.
</p>
<p>Within the text of that schmooz comment, at-sign
followed by &lsquo;<samp>0</samp>&rsquo; 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: &lsquo;<samp>@var{argument-name}</samp>&rsquo;.
</p>
<p>If more than one definition follows a &lsquo;<samp>@body</samp>&rsquo; comment line
without an intervening blank or comment line, then those definitions
will be included in the same Texinfo definition using &lsquo;<samp>@defvarx</samp>&rsquo;
or &lsquo;<samp>@defunx</samp>&rsquo;, 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>&lsquo;<samp>(define (&lt;identifier&gt; &lt;arg&gt; ...) &lt;expression&gt;)</samp>&rsquo;
</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 &lsquo;<samp>@args</samp>&rsquo; instead of &lsquo;<samp>@body</samp>&rsquo;.  &lsquo;<samp>@args</samp>&rsquo; 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>
<table><tr><td>&nbsp;</td><td><pre class="example">;;@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>
<table><tr><td>&nbsp;</td><td><pre class="example">@defun myfun arg1 args @dots{}

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

<p>&lsquo;<samp>@args</samp>&rsquo; may also be useful for indicating optional arguments
by name.  If &lsquo;<samp>@args</samp>&rsquo; occurs inside a schmooz comment section,
rather than at the beginning, then it will generate a &lsquo;<samp>@defunx</samp>&rsquo;
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>

<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Textual-Conversion-Packages" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="slib_5.html#Mathematical-Packages" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="slib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="slib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="slib_10.html#Procedure-and-Macro-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="slib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
 <font size="-1">
  This document was generated by <em>root</em> on <em>June 9, 2010</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.82</em></a>.
 </font>
 <br>

</p>
</body>
</html>