File: yabasic.htm

package info (click to toggle)
yabasic 2.715-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,332 kB
  • ctags: 1,518
  • sloc: ansic: 11,053; sh: 7,617; perl: 260; makefile: 57
file content (3044 lines) | stat: -rw-r--r-- 213,394 bytes parent folder | download
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>Description of yabasic</title>
<meta name="CREATED" content="19990404;14483900">
<meta name="CHANGEDBY" content="Marc-Oliver Ihm">
<meta name="CHANGED" content="19990404;14542300">
<meta name="author" content="Marc-Oliver Ihm">
<meta name="generator" content="Namo WebEditor v3.0">
<style asd="asd"><!--

.code { font-family:'Courier New',monospace; margin-left: 36; }

--></style>
</head>

<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">

<div align="center"><table border="0" cellpadding="4" cellspacing="8">
    <tr>
        <td valign="top"><p><a name="Description of yabasic"><font face="Arial"
             size="7" color="#400040"><strong><em>Yabasic</em></strong></font></a><font
             face="Arial" color="#400040"><em><br> </em></font><font face="Arial"
             size="2" color="#400040"><strong>Yet another Basic</strong></font><font
             face="Arial" size="2"><strong> for Unix and Windows</strong></font></td>
        <td align="right" valign="bottom"><p><font face="Arial" size="5"><strong>Version 
            2.71</strong></font><font face="Arial" size="1"><strong><br> </strong></font></td>
    </tr>
    <tr>
        <td valign="top"><table border cellpadding="2" cellspacing="0" width="100%">
                <tr>
                    <td bgcolor="#99CCCC"><p align="center"><a href="#Unix"><font
                         face="Arial" size="4" color="black"><strong>Yabasic 
                        under Unix</strong></font></a></td>
                </tr>
                <tr>
                    <td bgcolor="#FFFFCC"><ul type="disc">
                            <li><a href="#Invocation, unix"><font face="Arial">Invocation,</font></a><font
                             face="Arial"> </font><a href="#Options, Unix"><font
                             face="Arial">Options</font></a> 
                            <li><a href="#Setting defaults, Unix"><font face="Arial">Setting 
                            Defaults</font></a> 
                        </ul></td>
                </tr>
            </table></td>
        <td valign="top"><table border cellpadding="2" cellspacing="0" width="100%">
                <tr>
                    <td bgcolor="#99CCCC"><p align="center"><a href="#Windows 95"><font
                         face="Arial" size="4" color="black"><strong>Yabasic 
                        under Windows</strong></font></a></td>
                </tr>
                <tr>
                    <td bgcolor="#FFFFCC"><ul type="disc">
                            <li><a href="#Invocation, windows"><font face="Arial">Invocation,</font></a><font
                             face="Arial"> </font><a href="#Options, Windows"><font
                             face="Arial">Options</font></a> 
                            <li><a href="#Setting defaults, Windows"><font face="Arial">Setting 
                            Defaults</font></a> 
                        </ul></td>
                </tr>
            </table></td>
    </tr>
    <tr>
        <td valign="top" colspan="2"><table border cellpadding="2" cellspacing="0"
             width="100%">
                <tr>
                    <td colspan="2" bgcolor="#99CCCC"><p align="center"><a href="#Yabasic described by examples"><font
                         face="Arial" size="4" color="black"><strong>Yabasic 
                        by examples</strong></font></a></td>
                </tr>
                <tr>
                    <td bgcolor="#FFFFCC"><ul type="disc">
                            <li><a href="#A simple Program"><font face="Arial">A 
                            simple Program with </font></a><a href="#A simple Program"><font
                             face="Arial"><strong>input</strong></font></a><a href="#A simple Program"><font
                             face="Arial"> and </font></a><a href="#A simple Program"><font
                             face="Arial"><strong>print</strong></font></a> 
                            
                            <li><a href="#Arithmetic"><font face="Arial">Arithmetic</font></a><font
                             face="Arial">: </font><a href="#Operators"><font
                             face="Arial">Operators</font></a><font face="Arial"> 
                            and </font><a href="#Functions"><font face="Arial">Functions</font></a> 
                            
                            <li><a href="#Making decisions"><font face="Arial">Making 
                            decisions: The if-statement</font></a> <font face="Arial">and 
                            the select-statement</font> 
                            <li><a href="#Strings and loops"><font face="Arial">Strings 
                            and loops</font></a><font face="Arial"> (</font><a href="#for-next-loop"><font
                             face="Arial">for</font></a><font face="Arial">, 
                            </font><a href="#repeat-while"><font face="Arial">repeat</font></a><font
                             face="Arial">, </font><a href="#repeat-while"><font
                             face="Arial">while</font></a><font face="Arial"> 
                            and </font><a href="#repeat-while"><font face="Arial">do</font></a><font
                             face="Arial">)</font> 
                            <li><a href="#User defined functions"><font face="Arial">User 
                            defined subroutines</font></a><font face="Arial">, 
                            <br> </font><a href="#Defining subroutines at runtime"><font
                             face="Arial">defining subs at runtime</font></a><font
                             face="Arial"> and </font><a href="#Libraries"><font
                             face="Arial">libraries</font></a> 
                            <li><a href="#Graphics and printing"><font face="Arial">Graphics, 
                            printing</font></a> <font face="Arial">and </font><a href="#Bitmaps"><font
                             face="Arial">Bitmaps</font></a> 
                        </ul></td>
                    <td valign="top" bgcolor="#FFFFCC"><ul type="disc">
                            <li><a href="#Data and Arrays"><font face="Arial">Data 
                            and Arrays</font></a><font face="Arial"> and </font><a href="#More on Arrays"><font
                             face="Arial">More on Arrays</font></a> 
                            <li><a href="#Files and more on input"><font face="Arial">Files 
                            and more on input</font></a> 
                            <li><a href="#Calling the Operating System"><font
                             face="Arial">Interaction with the Operating System</font></a> 
                            
                            <li><a href="#Peek and Poke"><font face="Arial">Peek 
                            and Poke</font></a> 
                            <li><a href="#More on print"><font face="Arial">Advanced 
                            Printing: Positions, </font></a><font face="Arial"><br> 
                            </font><a href="#More on print"><font face="Arial">Formats 
                            and Colour</font></a> 
                            <li><a href="#Loose Ends"><font face="Arial">Loose 
                            Ends</font></a> 
                        </ul></td>
                </tr>
            </table></td>
    </tr>
    <tr>
        <td valign="top" rowspan="2"><table border cellpadding="2" cellspacing="0"
             width="100%" bgcolor="#99CCCC">
                <tr>
                    <td bgcolor="#99CCCC"><p align="center"><a href="#Index"><font
                         face="Arial" size="4" color="black"><strong>Index</strong></font></a></td>
                </tr>
                <tr>
                    <td valign="top" bgcolor="#FFFFCC"><ul type="disc">
                            <li><a href="#Index of keywords"><font face="Arial">Index 
                            of Keywords</font></a> 
                            <li><a href="#Index of concepts"><font face="Arial">Index 
                            of Concepts</font></a> 
                        </ul></td>
                </tr>
            </table></td>
        <td valign="top"><table border cellpadding="2" cellspacing="0" width="100%">
                <tr>
                    <td bgcolor="#99CCCC"><p align="center"><a href="#internals"><font
                         face="Arial" size="4" color="black"><strong>Background</strong></font></a></td>
                </tr>
            </table></td>
    </tr>
    <tr>
        <td valign="top"><table border cellpadding="2" cellspacing="0" width="100%">
                <tr>
                    <td bgcolor="#99CCCC"><p align="center"><a href="#copy"><font
                         face="Arial" size="4" color="black"><strong>Copyright</strong></font></a><a href="#copy"><font
                         face="Arial" color="black"> </font></a></td>
                </tr>
                <tr>
                    <td valign="top" bgcolor="#FFFFCC"><p><font face="Arial">Choose 
                        between the </font><a href="http://www.yabasic.de/artistic.htm"><font
                         face="Arial">Artistic License</font></a><font face="Arial"> 
                        and <br> the </font><a href="http://www.yabasic.de/gpl.htm"><font
                         face="Arial">Gnu General Public License</font></a><font
                         face="Arial">.</font></td>
                </tr>
            </table></td>
    </tr>
</table></div>
<p><font face="Arial">This document describes the </font><font face="Arial"><strong>features</strong></font><font
 face="Arial"> of yabasic. In short, yabasic implements the most common (and 
simple) elements of the basic-language, plus some graphic facilities; anyone, 
who has ever written basic-programs should feel at home.</font></p>
<p><font face="Arial">This page covers all the features of yabasic, you don't 
need any other text to learn it. In fact, there is </font><font face="Arial"><strong>no</strong></font><font
 face="Arial"> other text about yabasic, neither a unix-man-page nor a Windows-helpfile.</font></p>
<p><font face="Arial">This text doesn't teach basic from scratch, it rather 
assumes </font><font face="Arial"><strong>some experience</strong></font><font
 face="Arial"> with the basic-programming-language.</font></p>
<p><hr width="449"> </p>
<h1><a name="Unix"><font face="Arial">Unix</font></a></h1>
<h2><a name="Invocation, unix"><font face="Arial">Invocation</font></a></h2>
<p><font face="Arial">There are three way to start yabasic:</font> 
<table border="0" cellpadding="2">
    <tr>
        <td valign="top"><p><font face="Arial"><strong>1.</strong></font></td>
        <td valign="top"><p><font face="Arial">You may write your basic-program 
            to a file (e.g. </font><font face="Arial"><strong>foo.yab</strong></font><font
             face="Arial">) and call yabasic with this file as an argument:<br> 
            </font><font face="Arial"><strong>yabasic foo.yab<br> </strong></font><font
             face="Arial">this will make yabasic execute your program.</font></td>
    </tr>
    <tr>
        <td valign="top"><p><font face="Arial"><strong>2.</strong></font></td>
        <td valign="top"><p><font face="Arial">You may start you yabasic without 
            any filename. Typing<br> </font><font face="Arial"><strong>yabasic</strong></font><font
             face="Arial"><br> makes yabasic start and prompt for commands to 
            execute; after you have typed in your code, press </font><font face="Arial"><strong>RETURN</strong></font><font
             face="Arial"> twice and yabasic will execute your commands. This 
            behavior allows yabasic to be used as some sort of fancy desktop 
            calculator.</font></td>
    </tr>
    <tr>
        <td valign="top"><p><font face="Arial"><strong>3.</strong></font></td>
        <td valign="top"><p><font face="Arial">You may put your program into 
            a file and insert this text as the </font><font face="Arial"><strong>very 
            first line</strong></font><font face="Arial">:</font><font face="Arial"><strong><br> 
            #!/usr/bin/yabasic</strong></font><font face="Arial"><br> This is 
            only an example and you should substitute for </font><font face="Arial"><strong>/usr/bin/yabasic</strong></font><font
             face="Arial"> the full pathname of yabasic on your computer. Yabasic 
            will treat the line starting with </font><font face="Arial"><strong>#!</strong></font><font
             face="Arial"> as a comment, but Unix will invoke yabasic to execute 
            this program.</font></td>
    </tr>
</table>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h2><a name="Options, Unix"><font face="Arial">Options</font></a></h2>
<dl>
    <dt><font face="Arial"><strong>-h</strong></font> 
    <dd><font face="Arial">Prints out a short help message; </font><font face="Arial"><strong>-help</strong></font><font
     face="Arial"> or </font><font face="Arial"><strong>-?</strong></font><font
     face="Arial"> are accepted as well. </font>
    <dt><font face="Arial"><strong>-fg </strong></font><font face="Arial" size="4"><strong><em><var>foreground-color</var></em></strong></font><font
     size="4"> </font>
    <dd><font face="Arial">Sets the foreground color for graphics. The usual 
    X colornames like </font><font face="Arial"><em>red, green</em></font><font
     face="Arial"> are accepted.</font> 
    <dt><font face="Arial"><strong>-bg </strong></font><font face="Arial" size="4"><strong><em><var>background-color</var></em></strong></font><font
     face="Arial" size="4"><strong> </strong></font>
    <dd><font face="Arial">Sets the background color. </font>
    <dt><font face="Arial"><strong>-geometry </strong></font><font face="Arial"
     size="4"><strong><em><var>geometry-string</var></em></strong></font><font
     face="Arial" size="4"><strong> </strong></font>
    <dd><font face="Arial">The usual X geometry-string will work (e.g. </font><font
     face="Arial"><strong>+10+10</strong></font><font face="Arial">), but any 
    window size will be ignored.</font> 
    <dt><font face="Arial"><strong>-display </strong></font><font face="Arial"
     size="4"><strong><em><var>Name-of-Display</var></em></strong></font><font
     face="Arial" size="4"><strong> </strong></font>
    <dd><font face="Arial">Name of the Display, where the window should appear. 
    </font>
    <dt><font face="Arial"><strong>-font</strong></font><font face="Arial" size="4"><strong> 
    </strong></font><font face="Arial" size="4"><strong><em><var>Name-of-font</var></em></strong></font><font
     size="4"> </font>
    <dd><font face="Arial">Name of the font, which will be used for graphics 
    text. </font>
    <dt><font face="Arial"><strong>-execute</strong></font><font face="Arial"
     size="4"><strong> </strong></font><font face="Arial" size="4"><strong><i>Yabasic-Commands</i></strong></font> 
    
    <dd>Execute specified commands right away. 
    <dt><font face="Arial"><strong>-i</strong></font> 
    <dd><a name="infolevel"><font face="Arial">Sets the initial infolevel. This 
    controls the amount of information one gets about the progress of program 
    execution, Every level contains all lower levels (e.g. </font></a><a name="infolevel"><font
     face="Arial"><strong>w</strong></font></a><a name="infolevel"><font face="Arial"> 
    contains </font></a><a name="infolevel"><font face="Arial"><strong>f</strong></font></a><a
     name="infolevel"><font face="Arial"> and </font></a><a name="infolevel"><font
     face="Arial"><strong>e</strong></font></a><a name="infolevel"><font face="Arial">) 
    and can be one of: </font></a>
    <dl>
        <dt><font face="Arial"><strong>d </strong></font>
        <dd><font face="Arial">Set the infolevel to </font><font face="Arial"><strong><em>debug</em></strong></font><font
         face="Arial"><em> </em></font><font face="Arial">: This gives detailed 
        debugging information; much more output than you'd probably like to 
        read. </font>
        <dt><font face="Arial"><strong>n</strong></font> 
        <dd><font face="Arial"><strong><em>note</em></strong></font><font face="Arial"><em> 
        </em></font><font face="Arial">: Useful information; e.g. about execution 
        time and memory consumption. </font>
        <dt><font face="Arial"><strong>w</strong></font><font face="Arial"> 
        </font>
        <dd><font face="Arial"><strong><em>warning</em></strong></font><font
         face="Arial"><em> </em></font><font face="Arial">: Gives you warnings, 
        that something has gone wrong (e.g. division by zero); nevertheless 
        execution proceeds. </font>
        <dt><font face="Arial"><strong>e</strong></font><font face="Arial"> 
        </font>
        <dd><font face="Arial"><strong><em>error</em></strong></font><font face="Arial"><em> 
        </em></font><font face="Arial">: A serious error (e.g. an array boundary 
        violation) has occurred, stopping the program. </font>
        <dt><font face="Arial"><strong>f</strong></font><font face="Arial"> 
        </font>
        <dd><font face="Arial"><strong><em>fatal</em></strong></font><font face="Arial"><em> 
        </em></font><font face="Arial">: Something has gone wrong and cannot 
        be fixed; the interpreter exits immediately. This happens most often 
        in the course of an arithmetic fault (floating point exception) but 
        can also be a sign of an internal error within yabasic. </font>
    </dl>
    <dd><font face="Arial">The default infolevel is </font><font face="Arial"><strong>w</strong></font><font
     face="Arial">. </font>
    <dt><font face="Arial"><strong>-licence</strong></font> 
    <dd><font face="Arial">This makes yabasic print out its copyleft; have a 
    look and you will see, that almost anything is allowed.</font> 
    <dt><font face="Arial"><strong>-doc </strong></font><font face="Arial"><strong><em>name</em></strong></font> 
    
    <dd><font face="Arial">Prints the embedded documentation of the given yabasic 
    program or library</font> 
    <dt><b>-librarypath </b><b><i>path</i></b> 
    <dl>
        <dt>Changes the directory where yabasic searches any library which is 
        not found in the current directory. 
    </dl>
    <dd>&nbsp; 
    <dt>&nbsp; 
    <dt><a href="#Description of yabasic"><font face="Arial">Back to table of 
    contents ...</font></a> 
    <dd><hr width="454"> 
</dl>
<h2><a name="Setting defaults, Unix"><font face="Arial">Setting defaults</font></a></h2>
<p><font face="Arial">The colors, text-font and the window position should be 
set on the </font><a href="#options"><font face="Arial">command-line </font></a><font
 face="Arial">, or specified in the users resource file (this is usually the 
file</font><font face="Arial"><strong> .Xresources</strong></font><font face="Arial"> 
in your home-directory); e.g.: </font>
<dl>
    <dd><font face="Arial">yabasic*foreground: blue</font> 
    <pre><font face="Arial">yabasic*background: gold</font>
<font face="Arial">yabasic*geometry: +10+10</font>
<font face="Arial">yabasic*font: 9x15</font></pre>
</dl>
<p><font face="Arial">This sets the foreground of the graphics-window to blue, 
the background to gold, the window will appear at position 10,10 and the text-font 
will be 9x15.</font></p>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h1><a name="Windows 95"><font face="Arial">Windows</font></a></h1>
<h2><a name="Invocation, windows"><font face="Arial">Invocation</font></a></h2>
<p><font face="Arial">After you have run the setup program, yabasic can be invoked 
in three ways: </font>
<table border="0" cellpadding="2">
    <tr>
        <td valign="top"><p><font face="Arial"><strong>1.</strong></font></td>
        <td><p><font face="Arial">Choose &quot;</font><font face="Arial"><strong>yabasic</strong></font><font
             face="Arial">&quot; from the start-menu: Yabasic will come up with 
            a console window and wait for a program to be typed in right away. 
            </font></td>
    </tr>
    <tr>
        <td valign="top"><p><font face="Arial"><strong>2.</strong></font></td>
        <td><p><font face="Arial">Click with the right mousebutton on your desktop. 
            Choose &quot;</font><font face="Arial"><strong>new</strong></font><font
             face="Arial">&quot; from the context-menu that appears; this will 
            create a new icon on your desktop. The context-menu of this icon 
            has three entries &quot;</font><font face="Arial"><strong>Execute</strong></font><font
             face="Arial">&quot;, &quot;</font><font face="Arial"><strong>Edit</strong></font><font
             face="Arial">&quot; and &quot;</font><font face="Arial"><strong>View 
            docu</strong></font><font face="Arial">&quot; (which shows the embedded 
            documentation, if any); a double-click executes the program.</font></td>
    </tr>
    <tr>
        <td valign="top"><p><font face="Arial"><strong>3.</strong></font></td>
        <td><p><font face="Arial">Create a file containing your yabasic-program. 
            This file should have the extension &quot;</font><font face="Arial"><strong>.yab</strong></font><font
             face="Arial">&quot;. Double-click on this file then invokes yabasic, 
            to execute your program. </font></td>
    </tr>
</table>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h2><a name="Options, Windows"><font face="Arial">Options</font></a></h2>
<dl>
    <dt><font face="Arial"><strong>-h </strong></font>
    <dd><font face="Arial">Prints out a short help message; </font><font face="Arial"><strong>-help</strong></font><font
     face="Arial"> or </font><font face="Arial"><strong>-?</strong></font><font
     face="Arial"> are accepted as well. </font>
    <dt><font face="Arial"><strong>-geometry </strong></font><font face="Arial"
     size="4"><strong><em><var>geometry-string</var></em></strong></font><font
     face="Arial" size="4"> </font>
    <dd><font face="Arial">E.g. </font><font face="Arial"><strong>+20+10</strong></font><font
     face="Arial"> will place the graphic-window 10 pixels below and 20 pixels 
    left of the upper left corner of the screen.</font> 
    <dt><font face="Arial"><strong>-font </strong></font><font face="Arial" size="4"><strong><em><var>Name-of-font</var></em></strong></font><font
     size="4"> </font>
    <dd><font face="Arial">Name of the font which will be used for graphics 
    text. Can be any of: <br> </font><font face="Arial"><strong>decorative, 
    dontcare, modern, roman, script, swiss</strong></font><font face="Arial"> 
    <br> You can append (without space) a fontsize to any of these identifiers, 
    i.e. </font><font face="Arial"><strong>swiss30</strong></font><font face="Arial"> 
    chooses a swiss font, 30 pixels high.</font> 
    <dt><font face="Arial"><strong>-execute</strong></font><font face="Arial"
     size="4"><strong> </strong></font><font face="Arial" size="4"><strong><i>Yabasic-Commands</i></strong></font> 
    
    <dd>Execute specified commands right away. 
    <dt><font face="Arial"><strong>-i</strong></font> 
    <dd><a name="infolevel1"><font face="Arial">Sets the initial infolevel. 
    This controls the amount of information one gets about the progress of program 
    execution, Every level contains all lower levels (e.g. </font></a><a name="infolevel1"><font
     face="Arial"><strong>w</strong></font></a><a name="infolevel1"><font face="Arial"> 
    contains </font></a><a name="infolevel1"><font face="Arial"><strong>f</strong></font></a><a
     name="infolevel1"><font face="Arial"> and </font></a><a name="infolevel1"><font
     face="Arial"><strong>e</strong></font></a><a name="infolevel1"><font face="Arial">) 
    and can be one of: </font></a>
    <dl>
        <dt><font face="Arial"><strong>d </strong></font>
        <dd><font face="Arial">Set the inoflevel to </font><font face="Arial"><strong><em>debug</em></strong></font><font
         face="Arial"><em> </em></font><font face="Arial">: This gives detailed 
        debugging information; much more output than you'd probably like to 
        read. </font>
        <dt><font face="Arial"><strong>n</strong></font> 
        <dd><font face="Arial"><strong><em>note</em></strong></font><font face="Arial"><em> 
        </em></font><font face="Arial">: Useful information; e.g. about execution 
        time and memory consumption. </font>
        <dt><font face="Arial"><strong>w</strong></font><font face="Arial"> 
        </font>
        <dd><font face="Arial"><strong><em>warning</em></strong></font><font
         face="Arial"><em> </em></font><font face="Arial">: Gives you warnings, 
        that something has gone wrong (e.g. division by zero); nevertheless 
        execution proceeds. </font>
        <dt><font face="Arial"><strong>e</strong></font><font face="Arial"> 
        </font>
        <dd><font face="Arial"><strong><em>error</em></strong></font><font face="Arial"><em> 
        </em></font><font face="Arial">: A serious error (e.g. an array boundary 
        violation) has occurred, stopping the program. </font>
        <dt><font face="Arial"><strong>f</strong></font><font face="Arial"> 
        </font>
        <dd><font face="Arial"><strong><em>fatal</em></strong></font><font face="Arial"><em> 
        </em></font><font face="Arial">: Something has gone wrong and cannot 
        be fixed; the interpreter exits immediately. This happens most often 
        in the course of an arithmetic fault (floating point exception) but 
        can also be a sign of an internal error within yabasic. </font>
    </dl>
    <dd><font face="Arial">The default infolevel is </font><font face="Arial"><strong>w</strong></font><font
     face="Arial">. </font>
    <dt><font face="Arial"><strong>-licence</strong></font> 
    <dd><font face="Arial">This makes yabasic print out its copyleft; have a 
    look and you will see, that almost anything is allowed.</font> 
    <dt><font face="Arial"><strong>-doc </strong></font><font face="Arial"><strong><em>name</em></strong></font> 
    
    <dd><font face="Arial">Prints the embedded documentation of the given yabasic 
    program or library.</font> 
    <dt>&nbsp; <b>-librarypath </b><b><i>path</i></b> 
    <dl>
        <dt>Changes the directory where yabasic searches any library which is 
        not found in the current directory. 
    </dl>
    <dd>&nbsp; 
</dl>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h2><a name="Setting defaults, Windows"><font face="Arial">Setting defaults</font></a></h2>
<p><font face="Arial">To choose the default-values for graphic-font, fontsize 
and window position, you have to edit the registry.</font></p>
<p><font face="Arial">Yabasic stores its defaults under:</font> 
<dl>
    <dd><font face="Arial">HKEY_LOCAL_MACHINE/SOFTWARE/Yabasic</font> 
</dl>
<p><font face="Arial">You may edit the subkeys &quot;font&quot; and &quot;geometry&quot;; 
these subkeys accept the same values as the corresponding </font><a href="#Options, Windows"><font
 face="Arial">command line options</font></a><font face="Arial"> </font><font
 face="Arial"><strong>-font</strong></font><font face="Arial"> and </font><font
 face="Arial"><strong>-geometry</strong></font><font face="Arial">. Command 
line options take precedence over registry defaults.</font></p>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h1><a name="Yabasic described by examples"><font face="Arial">Yabasic explained 
by examples</font></a></h1>
<h2><a name="A simple Program"><font face="Arial">A simple Program</font></a></h2>
<p><font face="Arial">This is the first example:</font> 
<dl>
    <dd><font face="Arial">REM this is the first yabasic-program</font> 
    <pre><font face="Arial">input &quot;Enter two numbers:&quot; a,b</font>
<font face="Arial">print a,&quot;+&quot;,b,&quot;=&quot;,a+b</font>
<font face="Arial">print &quot;Please enter your Name:&quot;;</font>
<font face="Arial">INPUT a$</font>
<font face="Arial">print &quot;Hello &quot;,a$,&quot; !&quot;</font></pre>
</dl>
<p><font face="Arial">This program produces the following output (user input 
is displayed like </font><font face="Arial"><strong><em><u>this</u></em></strong></font><font
 face="Arial">):</font> 
<dl>
    <dd><font face="Arial">Enter two numbers: </font><font face="Arial"><u>2 
    3</u></font> 
    <pre><font face="Arial">2+3=5</font>
<font face="Arial">Please enter your Name: </font><font face="Arial"><u>Bill</u></font>
<font face="Arial">Hello Bill !</font></pre>
</dl>
<p><font face="Arial">This simple program contains three different commands:</font> 

<dl>
    <dt><a name="REM"><font face="Arial"><strong>REM</strong></font></a><a name="REM"> 
    </a>
    <dd><font face="Arial">The </font><font face="Arial"><strong>REM</strong></font><font
     face="Arial">-statement introduces comments; everything after </font><font
     face="Arial"><strong>REM</strong></font><font face="Arial"> up to the end 
    of the line is ignored.</font> 
    <dt><a name="input"><font face="Arial"><strong>input</strong></font></a><a
     name="input"> </a>
    <dd><font face="Arial">This statement reads one or more variables from the 
    user. The optional prompt-string after the </font><font face="Arial"><strong>input</strong></font><font
     face="Arial">-statement (&quot;</font><font face="Arial"><strong>Enter 
    a number:</strong></font><font face="Arial">&quot;) is printed on the terminal 
    prior to reading any input. Note that there is no semicolon after this prompt-string. 
    To learn more about, how input chops a line into pieces you may refer to 
    the section </font><a href="#More on input"><font face="Arial">More on Input</font></a><font
     face="Arial">. To learn, how to read input from the keyboard without delay, 
    check out </font><a href="#Getting a key from the keyboard"><font face="Arial">Getting 
    a key from the keyboard</font></a><font face="Arial">.</font> 
    <dt><a name="print"><font face="Arial"><strong>print</strong></font></a><a
     name="print"> </a>
    <dd><font face="Arial">The print-statement writes all its arguments to the 
    screen; after writing its last argument, </font><font face="Arial"><strong>print</strong></font><font
     face="Arial"> goes to the next line (as in </font><font face="Arial"><strong>print 
    &quot;Hello &quot;,a$,&quot; !&quot;</strong></font><font face="Arial">); 
    to avoid this automatic newline, place a semicolon (</font><font face="Arial"><strong>;</strong></font><font
     face="Arial">) after the last argument (as in </font><font face="Arial"><strong>print 
    &quot;Please enter your Name:&quot;;</strong></font><font face="Arial">). 
    To insert a tabulator instead of the automatic newline append a colon (</font><font
     face="Arial"><strong>,</strong></font><font face="Arial">), e.g.</font><font
     face="Arial"><strong> print &quot;Please enter your Name:&quot;,</strong></font><font
     face="Arial"> . Note that print can be abbreviated with a single question 
    mark (?). If you want to print (or input) at a specific location, you may 
    go to the section </font><a href="#Printing at a Random Position"><font face="Arial">Prining 
    on your Screen</font></a><font face="Arial">.</font> 
</dl>
<p><font face="Arial">Furthermore some general properties of yabasic should 
be noted:</font> 
<dl>
    <dt><a name="Case"><font face="Arial"><strong>Case</strong></font></a><a
     name="Case"> </a>
    <dd><font face="Arial">Commands can be entered in any case: </font><font
     face="Arial"><strong>input</strong></font><font face="Arial"> is the same 
    as </font><font face="Arial"><strong>INPUT</strong></font><font face="Arial"> 
    and even as </font><font face="Arial"><strong>InPUt. This applies to every 
    command in yabasic but not to variables, i.e. a$ and A$ are different variables.</strong></font> 
    
    <dt><a name="Variables"><font face="Arial"><strong>Variables</strong></font></a><a
     name="Variables"> </a>
    <dd><font face="Arial">Variable names are case sensitive (i.e. types of 
    variables: </font><font face="Arial"><strong>a$</strong></font><font face="Arial"> 
    and </font><font face="Arial"><strong>A$</strong></font><font face="Arial"> 
    are different) and can be of any length. There are two sorts of variables:</font> 
    
    <dt>&nbsp; 
    <dl>
        <dt><font face="Arial">String variables</font> 
        <dd><font face="Arial">e.g. </font><font face="Arial"><strong>a$</strong></font><font
         face="Arial">, </font><font face="Arial"><strong>b12$</strong></font><font
         face="Arial"> or </font><font face="Arial"><strong>VeryLongName$</strong></font><font
         face="Arial"> may contain strings of any length. String variables always 
        have a Dollar-sign (</font><font face="Arial"><strong>$</strong></font><font
         face="Arial">) as the last character of their names.</font> 
        <dt><font face="Arial">Numerical variables</font> 
        <dd><font face="Arial">e.g. </font><font face="Arial"><strong>a</strong></font><font
         face="Arial">, </font><font face="Arial"><strong>c3po</strong></font><font
         face="Arial"> or </font><font face="Arial"><strong>ThisIsAnEvenLongerName</strong></font><font
         face="Arial"> contain real numbers like 2, -1.3, 15.3e44 or 0.</font> 
        
    </dl>
    <dd><font face="Arial">Variables (with the exception of arrays) need not 
    be declared, their initial values are &quot;&quot; (for string variables) 
    and 0.0 (for numerical variables).</font> 
</dl>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h2><a name="Arithmetic"><font face="Arial">Arithmetic</font></a></h2>
<h3><a name="Operators"><font face="Arial">Operators</font></a></h3>
<p><font face="Arial">Yabasic has five arithmetic operators: </font><font face="Arial"><strong>+</strong></font><font
 face="Arial"> (addition), </font><font face="Arial"><strong>-</strong></font><font
 face="Arial"> (subtraction), </font><font face="Arial"><strong>*</strong></font><font
 face="Arial"> (multiplication), </font><font face="Arial"><strong>/ </strong></font><font
 face="Arial">(division) and </font><font face="Arial"><strong>^</strong></font><font
 face="Arial"> (power); they all behave as expected, i.e. this line of code</font> 

<dl>
    <dd><font face="Arial">print 1+2,2*3,4/2,2^3</font> 
</dl>
<p><font face="Arial">produces this line of output:</font> 
<dl>
    <dd><font face="Arial">3 6 2 8</font> 
</dl>
<p><font face="Arial">Note that the power operator (</font><font face="Arial"><strong>^</strong></font><font
 face="Arial">) handles fractional powers: </font><font face="Arial"><strong>8^(1/3)</strong></font><font
 face="Arial"> gives </font><font face="Arial"><strong>2</strong></font><font
 face="Arial"> as a result.</font></p>
<h3><a name="Functions"><font face="Arial">Functions</font></a></h3>
<p><font face="Arial">This section demonstrates and explains the arithmetic 
functions of yabasic.</font> 
<dl>
    <dt><a name="Trigonometric functions:"><font face="Arial"><strong>Trigonometric 
    functions:</strong></font></a><a name="Trigonometric functions:"> </a>
    <dd><font face="Arial">There are 6 trigonometric functions:</font> 
    <dl>
        <dd><font face="Arial"><strong>print sin(1.0),cos(pi),tan(3) <br> print 
        asin(0.5),acos(0.7) <br> print atan(2),atan(1,2)</strong></font><font
         face="Arial"> </font>
    </dl>
    <dd><font face="Arial">These lines produce this output:</font> 
    <dl>
        <dd><font face="Arial"><strong>0.841471 -1 -0.142547 <br> 0.523599 0.795399 
        <br> 1.10715 0.463648</strong></font><font face="Arial"> </font>
    </dl>
    <dd><font face="Arial">As you can see yabasic can calculate sine, cosine, 
    tangent and their inverses. And, if you have an eye for trigonometry, you 
    may have noticed that all these functions expect their argument in radians; 
    to facilitate the transformation from degrees to radians (</font><font face="Arial"><strong>radian=degree*pi/180</strong></font><font
     face="Arial">), there is a predefined variable named </font><font face="Arial"><strong>pi</strong></font><font
     face="Arial"> (or </font><font face="Arial"><strong>PI</strong></font><font
     face="Arial">) which has an initial value of 3.14159.</font> 
    <dd><font face="Arial">Finally note that the </font><font face="Arial"><strong>atan()</strong></font><font
     face="Arial">-function comes in </font><font face="Arial"><strong>two flavors</strong></font><font
     face="Arial">: Called with a single argument (e.g. </font><font face="Arial"><strong>atan(2)</strong></font><font
     face="Arial">) </font><font face="Arial"><strong>atan()</strong></font><font
     face="Arial">returns a value between -pi/2 ... +pi/2. Called with two arguments 
    (e.g. </font><font face="Arial"><strong>atan(2,-1)</strong></font><font face="Arial">) 
    </font><font face="Arial"><strong>atan()</strong></font><font face="Arial"> 
    returns a value between -pi and +pi; (This can be useful e.g. when transforming 
    from cartesian to polar coordinates).</font> 
    <dt><a name="Exponentiation:"><font face="Arial"><strong>Exponentiation:</strong></font></a><a
     name="Exponentiation:"> </a>
    <dd><font face="Arial">The </font><font face="Arial"><strong>exp()</strong></font><font
     face="Arial"> functions comes with its inverse. the </font><font face="Arial"><strong>log()</strong></font><font
     face="Arial">-function:</font><font face="Arial"><strong> <br> print exp(1),log(2),log(euler) 
    <br> log()</strong></font><font face="Arial"> and </font><font face="Arial"><strong>exp()</strong></font><font
     face="Arial"> operate with the base e (=2.17828), which comes as a predefined 
    variable named </font><font face="Arial"><strong>euler</strong></font><font
     face="Arial">. Knowing this you won't be surprised to get the following 
    output:<br> </font><font face="Arial"><strong>2.71828 0.693147 1</strong></font> 
    
    <dt><a name="Integer and fractional parts:"><font face="Arial"><strong>Integer 
    and fractional parts:</strong></font></a><a name="Integer and fractional parts:"> 
    </a>
    <dd><font face="Arial">The functions</font><font face="Arial"><strong> int() 
    </strong></font><font face="Arial">and</font><font face="Arial"><strong> 
    frac() </strong></font><font face="Arial">split their argument at the decimal 
    point:<br> </font><font face="Arial"><strong>print int(2.34),frac(2.34) 
    </strong></font><font face="Arial">produces: </font><font face="Arial"><strong>2 
    0.34</strong></font> 
    <dt><a name="Absolut values and signum"><font face="Arial"><strong>Absolut 
    values and signum</strong></font></a><a name="Absolut values and signum"> 
    </a>
    <dd><font face="Arial">The</font><font face="Arial"><strong> abs() </strong></font><font
     face="Arial">and</font><font face="Arial"><strong> sig() </strong></font><font
     face="Arial">functions return the absolute value and the signum of their 
    arguments:<br> </font><font face="Arial"><strong>print abs(-2.34),abs(2.34),sig(-2.34),sig(0),sig(2.34) 
    </strong></font><font face="Arial">produces:</font><font face="Arial"><strong> 
    2.34 2.34 -1 0 1</strong></font> 
    <dt><a name="Remainder"><font face="Arial"><strong>Remainder</strong></font></a><a
     name="Remainder"> </a>
    <dd><font face="Arial">To get the remainder of a division employ the </font><font
     face="Arial"><strong>mod()</strong></font><font face="Arial">-function; 
    e.g. </font><font face="Arial"><strong>mod(11,4)</strong></font><font face="Arial"> 
    produces </font><font face="Arial"><strong>3</strong></font><font face="Arial">, 
    because when dividing 11 by 4 you get 2 and a remainder of 3.</font> 
    <dt><a name="Minimum and Maximum:"><font face="Arial"><strong>Minimum and 
    Maximum:</strong></font></a><a name="Minimum and Maximum:"> </a>
    <dd><font face="Arial">Return the lower and higher value of their two arguments:<br> 
    </font><font face="Arial"><strong>print min(2,3),max(2,3) </strong></font><font
     face="Arial">gives: </font><font face="Arial"><strong>2 3</strong></font> 
    
    <dt><a name="The square root"><font face="Arial"><strong>Square root and 
    square:</strong></font></a><a name="The square root"> </a>
    <dd><font face="Arial">The square root is calculated by </font><font face="Arial"><strong>sqrt()</strong></font><font
     face="Arial">, the square by</font><font face="Arial"><strong> sqr()</strong></font><font
     face="Arial">: </font><font face="Arial"><strong><br> print sqrt(2),sqr(2) 
    </strong></font><font face="Arial">gives </font><font face="Arial"><strong>1.41421 
    4</strong></font> 
    <dt><a name="hex"><font face="Arial"><strong>Hexadecimal and binary numbers:</strong></font></a><a
     name="hex"> </a>
    <dd><font face="Arial">To convert a decimal number to hex and vice versa, 
    use </font><font face="Arial"><strong>hex$()</strong></font><font face="Arial"> 
    and </font><font face="Arial"><strong>dec()</strong></font><font face="Arial">:<br> 
    </font><font face="Arial"><strong>print hex$(255),&quot; is &quot;,dec(&quot;ff&quot;)</strong></font><font
     face="Arial"> gives </font><font face="Arial"><strong>ff is 255</strong></font> 
    
    <dd><font face="Arial">Binary numbers can be converted quite similar to 
    decimal: </font><font face="Arial"><b>bin$(8)</b></font><font face="Arial"> 
    returns &quot;100&quot; and </font><font face="Arial"><b>dec(&quot;100&quot;,2)</b></font><font
     face="Arial"> will return 8. Note, that you need to supply the base (here: 
    2) with the dec()-function if it is different from the default value 16.</font> 
    
    <dt><a name="Random numbers"><font face="Arial"><strong>Random numbers:</strong></font></a><a
     name="Random numbers"> </a>
    <dd><font face="Arial">are returned by the </font><font face="Arial"><strong>ran()</strong></font><font
     face="Arial">-function; this function comes in </font><font face="Arial"><strong>two 
    flavours</strong></font><font face="Arial">: Called without arguments (e.g. 
    </font><font face="Arial"><strong>print ran()</strong></font><font face="Arial">) 
    you will get a random number between 0 and 1. Called with a single argument 
    (e.g. </font><font face="Arial"><strong>print ran(2)</strong></font><font
     face="Arial">) you will get a random number between 0 and the supplied 
    argument.<br> The </font><font face="Arial"><strong>ran()</strong></font><font
     face="Arial">-function of yabasic uses the </font><font face="Arial"><strong>ran()</strong></font><font
     face="Arial">-function of the C standard library, so you had better not 
    expect too much randomness ...</font> 
    <dt><a name="Bitmanipulation:"><font face="Arial"><b>Bitmanipulation:</b></font></a><font
     face="Arial"> </font>
    <dd><font face="Arial">You may use the bitwise operations </font><font face="Arial"><b>and()</b></font><font
     face="Arial">, </font><font face="Arial"><b>or()</b></font><font face="Arial">, 
    </font><font face="Arial"><b>eor()</b></font><font face="Arial"> (which 
    might be written as </font><font face="Arial"><b>xor()</b></font><font face="Arial">) 
    like this: </font>
    <dd><font face="Arial"><b>print and(10,7),or(9,3),eor(15,4)</b></font><font
     face="Arial"> </font>
    <dd><font face="Arial">Which will give you</font><font face="Arial"><b> 
    2 11 11 </b></font><font face="Arial">as a result. Note however, that yabasic 
    has </font><font face="Arial"><b>no not()</b></font><font face="Arial"> 
    operation; this is due to the way, yabasic treats numbers (there are no 
    real integers). However, the same result can easily be achieved by using 
    </font><font face="Arial"><b>eor()</b></font><font face="Arial"> with an 
    argument of all ones (in binary): </font><font face="Arial"><b>eor(255,123)</b></font><font
     face="Arial"> </font><font face="Arial"><b>eor(65535,266)</b></font><font
     face="Arial"> are examples. </font>
</dl>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h2><a name="Making decisions"><font face="Arial">Making decisions: The </font></a><a
 name="Making decisions"><font face="Arial"><strong>if</strong></font></a><a
 name="Making decisions"><font face="Arial">-statement</font></a></h2>
<p><font face="Arial">To make decisions you have to use the </font><font face="Arial"><strong>if</strong></font><font
 face="Arial">-statement:</font></p>
<blockquote><pre><font face="Arial">input &quot;Please enter a number&quot; a</font>
<font face="Arial">if (a&gt;10) then </font>
<font face="Arial">  print &quot;Your number is bigger than 10&quot;</font>
<font face="Arial">elsif (a&gt;5) then </font>
<font face="Arial">  print &quot;Your number is bigger than 5  but less or equal 10&quot;</font>
<font face="Arial">else</font>
<font face="Arial">  print &quot;Your number is less or equal 5&quot;</font>
<font face="Arial">endif</font></pre></blockquote>
<p><font face="Arial">As you can see, the condition has to be enclosed in parentheses 
(...). The </font><font face="Arial"><strong>else</strong></font><font face="Arial"> 
and the </font><font face="Arial"><strong>elsif</strong></font><font face="Arial">-part 
of the </font><font face="Arial"><strong>if</strong></font><font face="Arial">-statement 
are optional and can be omitted, as in this example:</font></p>
<blockquote><pre><font face="Arial">input &quot;Please enter a number&quot; a </font>
<font face="Arial">if (a&gt;10 and a&lt;20) then </font>
<font face="Arial">  print &quot;bigger than 10&quot;:print &quot;but less than 20&quot;</font>
<font face="Arial">fi</font></pre></blockquote>
<p><a name="Note that endif"><font face="Arial">Note that </font></a><a name="Note that endif"><font
 face="Arial"><strong>endif</strong></font></a><a name="Note that endif"><font
 face="Arial"> can be written as </font></a><a name="Note that endif"><font face="Arial"><strong>fi</strong></font></a><a
 name="Note that endif"><font face="Arial"> too. </font></a></p>
<p><font face="Arial">Just in case you want to write even less, you may try:</font></p>
<blockquote><pre><font face="Arial">input &quot;Please enter a number&quot; a</font>
<font face="Arial">if (a&gt;10 and a&lt;20) print &quot;bigger than 10 &quot;:print &quot;but less than 20&quot;</font></pre></blockquote>
<p><font face="Arial">Note, that </font><font face="Arial"><strong>then</strong></font><font
 face="Arial"> and </font><font face="Arial"><strong>endif</strong></font><font
 face="Arial"> (or</font><font face="Arial"><strong> fi</strong></font><font
 face="Arial">) have been omitted; As you might expect, both </font><font face="Arial"><b>print</b></font><font
 face="Arial">-statements are executed or not, depending on the condition. Note 
however, that previous versions of yabasic behaved differently (and quite counterintuitive) 
in this respect.</font></p>
<p><font face="Arial">Next, have a look at the condition </font><font face="Arial"><strong>(a&gt;10 
and a&lt;20)</strong></font><font face="Arial"> of the </font><font face="Arial"><strong>if</strong></font><font
 face="Arial">-statement:</font> 
<dl>
    <dt><a name="Conditions"><font face="Arial"><strong>Conditions:</strong></font></a><a
     name="Conditions"> </a>
    <dd><font face="Arial">Numbers or arithmetic expressions can be compared 
    with the usual relational operators: </font><font face="Arial"><strong>=</strong></font><font
     face="Arial"> (equal), </font><font face="Arial"><strong>&lt;&gt;</strong></font><font
     face="Arial"> (not equal), </font><font face="Arial"><strong>&lt;</strong></font><font
     face="Arial"> (less than), </font><font face="Arial"><strong>&lt;=</strong></font><font
     face="Arial"> (less or equal), </font><font face="Arial"><strong>&gt;</strong></font><font
     face="Arial"> (greater than) and </font><font face="Arial"><strong>&gt;= 
    </strong></font><font face="Arial">(greater or equal).<br> Strings can be 
    compared with just the same set of operators, where characters are ordered 
    according to the ascii-charset; e.g. </font><font face="Arial"><strong>(&quot;a&quot;&lt;&quot;b&quot;)</strong></font><font
     face="Arial"> is true (because </font><font face="Arial"><strong>&quot;a&quot;</strong></font><font
     face="Arial"> precedes </font><font face="Arial"><strong>&quot;b&quot;</strong></font><font
     face="Arial"> within the ascii-charset) and likewise </font><font face="Arial"><strong>(&quot;a&quot;=&quot;b&quot;)</strong></font><font
     face="Arial"> is false.<br> More than one comparison can be combined with 
    parentheses </font><font face="Arial"><strong>()</strong></font><font face="Arial"> 
    and these keywords: </font><font face="Arial"><strong>or</strong></font><font
     face="Arial">, </font><font face="Arial"><strong>and</strong></font><font
     face="Arial">, </font><font face="Arial"><strong>not</strong></font><font
     face="Arial">; Note that </font><font face="Arial"><strong>not</strong></font><font
     face="Arial"> precedes </font><font face="Arial"><strong>and</strong></font><font
     face="Arial">, which in turn precedes </font><font face="Arial"><strong>or</strong></font><font
     face="Arial"> (in the same way as </font><font face="Arial"><strong>*</strong></font><font
     face="Arial"> precedes </font><font face="Arial"><strong>+</strong></font><font
     face="Arial"> within arithmetic expressions).<br> <br> There are some other 
    statements, which can be used within a condition:</font> 
    <ul type="disc">
        <li><font face="Arial">you may use an </font><a href="#Opening a file"><font
         face="Arial">open</font></a><font face="Arial">-statement as a condition 
        to check, if it has been successful.</font> 
        <li><a href="#End of File"><font face="Arial">eof()</font></a><font face="Arial"> 
        checks, if a file contains more input.</font> 
        <dl>
            <dt><a href="#Globbing"><font face="Arial">glob$()</font></a><font
             face="Arial"> checks, if its first argument matches the pattern 
            supplied as the second argument.</font> 
        </dl>
    </ul>
    <p><font face="Arial">For Convenience you may store the result of a comparison 
    within a variable and retrieve it later:</font></p>
    <ul>
        <pre><font face="Arial">input &quot;Please enter a number between 1 and 10: &quot; a</font>
<font face="Arial">okay=(a&gt;=1 and a&lt;=10)</font>
<font face="Arial">if (not okay) print &quot;autsch !&quot;</font></pre>
    </ul>
    <p><font face="Arial">The result of the comparison is stored within the 
    variable okay which is simply queried within the if-statement.</font></p>
    <p><a name="true and false"><font face="Arial">The above </font></a><font
     face="Arial">example can be rewritten, showing the special constants TRUE 
    and FALSE:</font></p>
    <ul>
        <pre><font face="Arial">input &quot;Please enter a number between 1 and 10: &quot; a</font>
<font face="Arial">if (a&gt;=1 and a&lt;=10) then okay=TRUE : else okay=FALSE : fi</font>
<font face="Arial">if (not okay) print &quot;autsch !&quot;</font></pre>
    </ul>
    <dt><a name="Multiple commands on one line"><font face="Arial"><strong>Multiple 
    commands on one line</strong></font></a><a name="Multiple commands on one line"> 
    </a>
    <dd><font face="Arial">Note that more than one command can appear on one 
    line, as in </font><font face="Arial"><strong><br> print &quot;bigger than 
    10&quot;:print &quot;but less than 20&quot;<br> </strong></font><font face="Arial">as 
    long as you separate them with colons (:).</font> 
    <dd>&nbsp; 
    <dt><a name="switch"><font face="Arial"><b>Comparing with many values</b></font></a> 
    
    <dd><font face="Arial">Sometimes you may want to test an expression against 
    many different values, e.g.: while processing user-input:</font> 
    <pre class="code"><font face="Arial">input &quot;Please enter your choice&quot; a$</font></pre>
    <pre><font face="Arial">switch a$:</font>
<font face="Arial">  case &quot;q&quot;:end</font>
<font face="Arial">  case &quot;?&quot;:case &quot;h&quot;: print &quot;Sorry, no help available&quot; :break</font>
<font face="Arial">  case &quot;p&quot;: print &quot;Howdy !&quot;</font>
<font face="Arial">end switch</font></pre>
    <p><font face="Arial">This program checks its input (in the variable </font><font
     face="Arial"><b>a$</b></font><font face="Arial">) against many different 
    values, reacting accordingly. Of course you may do this with an </font><font
     face="Arial"><b>if</b></font><font face="Arial">-statement, but it would 
    be much harder to understand.</font></p>
    <p><font face="Arial">Note finally, that you may just as well </font><font
     face="Arial"><b>switch</b></font><font face="Arial"> on arithmetic expressions.</font></p>
</dl>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h2><a name="Strings and loops"><font face="Arial">Strings and loops</font></a></h2>
<p><font face="Arial">Basic has always been simple and strong in string-processing; 
and yabasic also tries to continue in this tradition:</font> 
<dl>
    <dd><font face="Arial">input &quot;Please enter a word&quot; a$ </font>
    <pre><font face="Arial">for a=len(a$) to 1 step -1:print mid$(a$,a,1);:next a </font>
<font face="Arial">print &quot; is &quot;,a$,&quot; reversed !&quot;</font></pre>
</dl>
<p><font face="Arial">If you try this program, you will get this output:</font> 

<dl>
    <dd><font face="Arial">Please enter a word: </font><font face="Arial"><u>hello</u></font> 
    
    <pre><font face="Arial">olleh is hello reversed !</font></pre>
    <dt><a name="for-next-loop"><font face="Arial"><strong>for-next-loops</strong></font></a><a
     name="for-next-loop"> </a>
    <dd><font face="Arial">The heart of the above program is the for-loop: everything 
    from </font><font face="Arial"><strong>for</strong></font><font face="Arial"> 
    to </font><font face="Arial"><strong>next</strong></font><font face="Arial"> 
    is repeated, while the variable (</font><font face="Arial"><strong>a</strong></font><font
     face="Arial">) goes from its initial value </font><font face="Arial"><strong>len(a$)</strong></font><font
     face="Arial"> to its final value </font><font face="Arial"><strong>1</strong></font><font
     face="Arial">. As you might have anticipated, </font><font face="Arial"><strong>len(a$)</strong></font><font
     face="Arial"> returns the length of its string-argument.<br> Note the </font><font
     face="Arial"><strong>step</strong></font><font face="Arial">-clause: the 
    number after </font><font face="Arial"><strong>step</strong></font><font
     face="Arial"> (here: </font><font face="Arial"><strong>-1</strong></font><font
     face="Arial">) is added to </font><font face="Arial"><strong>a</strong></font><font
     face="Arial"> after every repetition; in the example the </font><font face="Arial"><strong>step</strong></font><font
     face="Arial">-clause makes </font><font face="Arial"><strong>a</strong></font><font
     face="Arial"> go down with every iteration. If you omit the step-clause, 
    </font><font face="Arial"><strong>step 1</strong></font><font face="Arial"> 
    is assumed. Finally note, that you can leave the for next loop </font><font
     face="Arial"><strong>at any time</strong></font><font face="Arial"> by 
    simple </font><font face="Arial"><strong>goto</strong></font><font face="Arial">. 
    You may put the for-loop to some offbeat usage; e.g. </font><font face="Arial"><strong>for 
    a=1 to 100 step a:print a:next a</strong></font><font face="Arial"> prints 
    the powers off 2 up to 64.</font> 
    <dt><a name="repeat-while"><font face="Arial"><strong>repeat-until</strong></font></a><a
     name="repeat-while"><font face="Arial"> loop, </font></a><a name="repeat-while"><font
     face="Arial"><strong>while-wend </strong></font></a><font face="Arial">loop 
    and </font><font face="Arial"><b>do-loop</b></font><font face="Arial"><b> 
    </b></font><font face="Arial">loop</font> 
    <dd><font face="Arial">Of course this for-loop can be reformulated as </font><font
     face="Arial"><strong>repeat-until, while-wend</strong></font><font face="Arial"> 
    or </font><font face="Arial"><b>do-</b></font><font face="Arial"><b><strong>loop</strong></b></font><font
     face="Arial">:</font> 
    <pre class="code"><font face="Arial">input &quot;Please enter a word&quot; a$</font> </pre>
    <pre><font face="Arial">a=len(a$):repeat print mid$(a$,a,1);:a=a-1 until(a=0)</font>
<font face="Arial">print &quot; is &quot;,a$,&quot; reversed !&quot;<br></font>
<font face="Arial">&nbsp;</font>
<font face="Arial">input &quot;Please enter a word&quot; a$</font> 
<font face="Arial">a=len(a$):while(a&gt;0) print mid$(a$,a,1);:a=a-1 wend</font>
<font face="Arial">print &quot; is &quot;,a$,&quot; reversed !&quot;<br></font>
&nbsp;
<font face="Arial">input &quot;Please enter a word&quot; a$</font> 
<font face="Arial">a=len(a$):do: print mid$(a$,a,1);:a=a-1:if (a=0) then break fi: loop</font>
<font face="Arial">print &quot; is &quot;,a$,&quot; reversed !&quot;&nbsp;</font></pre>
    <dd><font face="Arial">All these loops produce the same result (as long 
    as you input at least one character !).</font> 
    <dt><a name="break and continue"><font face="Arial"><b>break</b></font></a><a
     name="break and continue"><font face="Arial"> and </font></a><a name="break and continue"><font
     face="Arial"><b>continue</b></font></a> 
    <dd><font face="Arial">The last example also shows the break-statement, 
    which can be used to break out of any loop:</font> 
    <dd>&nbsp; 
    <pre class="code"><font face="Arial">do</font></pre>
    <pre><font face="Arial">  a$=inkey$</font>
<font face="Arial">  if (a$=&quot;q&quot;) break</font>
<font face="Arial">  if (a$=&quot; &quot;) continue</font>
<font face="Arial">  print a$</font>
<font face="Arial">  loop</font>
&nbsp;</pre>
    <p><font face="Arial">The above example reads characters from the keyboard 
    and prints them to screen; however: If you enter &quot;q&quot; the loop 
    is terminated (by the </font><font face="Arial"><b>break</b></font><font
     face="Arial">-statement) and if you enter &quot; &quot; (space) the loop 
    starts all over without printing (caused by the </font><font face="Arial"><b>continue</b></font><font
     face="Arial">-statement)</font></p>
</dl>
<p><font face="Arial">Within the for-next-loop above the string-functions </font><font
 face="Arial"><strong>len()</strong></font><font face="Arial"> and </font><font
 face="Arial"><strong>mid$()</strong></font><font face="Arial"> are applied, 
but there are many more string functions:</font> 
<dl>
    <dt><a name="Getting pieces out of a string:"><font face="Arial"><strong>Getting 
    pieces out of a string:</strong></font></a><a name="Getting pieces out of a string:"> 
    </a>
    <dd><font face="Arial">There are three functions which give back parts of 
    a string:<br> </font><font face="Arial"><strong>a$=&quot;123456&quot;<br> 
    print left$(a$,2),&quot;-&quot;,mid$(a$,2,3),&quot;-&quot;,right$(a$,3)</strong></font><font
     face="Arial"><br> gives you the following output:<br> </font><font face="Arial"><strong>12-234-456<br> 
    </strong></font><font face="Arial">As you see </font><font face="Arial"><strong>left$()</strong></font><font
     face="Arial"> cuts off as many characters as specified by its second argument 
    from the left of your string. </font><font face="Arial"><strong>right$()</strong></font><font
     face="Arial"> cuts from the right, and </font><font face="Arial"><strong>mid$()</strong></font><font
     face="Arial"> cuts in the middle, where the second argument is the starting 
    point and the third one is the length of the string to be cut out; if you 
    omit the third argument, </font><font face="Arial"><b>mid$()</b></font><font
     face="Arial"> returns everything up to the end of the string: </font><font
     face="Arial"><b>mid$(&quot;Hallo&quot;,2)</b></font><font face="Arial"> 
    returns &quot;allo&quot;.<br> Furthermore </font><font face="Arial"><strong>mid$()</strong></font><font
     face="Arial"> and its friends can even be used to selectively change parts 
    of a string:<br> </font><font face="Arial"><strong>a$=&quot;123456&quot;:left$(a$,2)=&quot;abcd&quot;:print 
    a$<br> </strong></font><font face="Arial">results in<br> </font><font face="Arial"><strong>ab3456<br> 
    </strong></font><font face="Arial">As you see only the two leftmost characters 
    are changed (even though the string </font><font face="Arial"><strong>&quot;abcd&quot;</strong></font><font
     face="Arial"> contains four characters); the same can be done with </font><font
     face="Arial"><strong>mid$()</strong></font><font face="Arial"> or </font><font
     face="Arial"><strong>right$()</strong></font><font face="Arial">. Note 
    that assigning to left$()/right$()/mid$() will never change the length of 
    the string.</font> 
    <dt><a name="strings to numbers (and reverse):"><font face="Arial"><strong>strings 
    to numbers (and reverse):</strong></font></a><a name="strings to numbers (and reverse):"> 
    </a>
    <dd><font face="Arial">The function </font><font face="Arial"><strong>str$()</strong></font><font
     face="Arial">converts its numeric argument to a string: <br> </font><font
     face="Arial"><strong>print str$(12)</strong></font><font face="Arial"> 
    gives the string &quot;</font><font face="Arial"><strong>12</strong></font><font
     face="Arial">&quot; as a result. The formatting of the number can be influenced 
    by an optional second argument: </font><font face="Arial"><strong>print 
    str$(12.123455,&quot;##.##&quot;)</strong></font><font face="Arial"> returns 
    the string </font><font face="Arial"><strong>12.12</strong></font><font face="Arial">. 
    The second argument has the same effect as the format of the </font><a href="#print using"><font
     face="Arial">print using</font></a><font face="Arial"> statement.<br> Just 
    the opposite is done by the function </font><font face="Arial"><strong>val()</strong></font><font
     face="Arial">: </font><font face="Arial"><strong>print 2+val(&quot;23&quot;)</strong></font><font
     face="Arial"> gives </font><font face="Arial"><strong>25</strong></font><font
     face="Arial"> as a result, whereas </font><font face="Arial"><strong>print 
    val(&quot;e2&quot;)</strong></font><font face="Arial"> delivers </font><font
     face="Arial"><strong>0</strong></font><font face="Arial"> (because </font><font
     face="Arial"><strong>&quot;e2&quot;</strong></font><font face="Arial"> 
    is not a valid number).</font> 
    <dt><a name="The Ascii-Charset:"><font face="Arial"><strong>The ascii-charset:</strong></font></a><a
     name="The Ascii-Charset:"> </a>
    <dd><font face="Arial">yabasic offers two functions to work with the ascii-charset. 
    </font><font face="Arial"><strong>asc()</strong></font><font face="Arial"> 
    gives you a specific ascii-character: </font><font face="Arial"><strong>print 
    asc(&quot;e&quot;)</strong></font><font face="Arial"> gives 101 as a result, 
    because the character </font><font face="Arial"><strong>&quot;e&quot;</strong></font><font
     face="Arial"> has position </font><font face="Arial"><strong>101</strong></font><font
     face="Arial"> within the ascii-charset. Likewise the function </font><font
     face="Arial"><strong>chr$()</strong></font><font face="Arial"> returns 
    the ascii-char for a given position within the charset, e.g. </font><font
     face="Arial"><strong>chr$(98)</strong></font><font face="Arial"> returns 
    </font><font face="Arial"><strong>&quot;b&quot;</strong></font><font face="Arial">.</font> 
    
    <dt><a name="Escape-sequences"><font face="Arial"><strong>Escape-sequences</strong></font></a><a
     name="Escape-sequences"> </a>
    <dd><font face="Arial">Nevertheless you won't use </font><font face="Arial"><strong>chr$()</strong></font><font
     face="Arial"> as often as you might think, because the most important nonprintable 
    characters can be constructed using escape-sequences with the </font><font
     face="Arial"><strong>\</strong></font><font face="Arial">-character: You 
    might use </font><font face="Arial"><strong>\n</strong></font><font face="Arial"> 
    instead of </font><font face="Arial"><strong>chr$(10)</strong></font><font
     face="Arial"> wherever you want to use the newline-character.</font> 
    <dd><font face="Arial">Finally escape sequences of the form \x</font><font
     face="Arial"><i>HEX</i></font><font face="Arial"> allow to encode arbitrary 
    characters: E.g. \x012 returns the character chr$(18). Note that \x requires 
    a hexadecimal number; and hexadecimal 12 is the same as decimal 18.</font> 
    
    <dd><font face="Arial">The following table lists all escape sequences of 
    yabasic (of course, these are just the sequences known within the C-language):</font> 
    
    <dd>&nbsp; 
    <dd><table border cellpadding="2">
            <tr>
                <td><p align="center"><font face="Arial"><strong>Escape-sequence</strong></font></td>
            <td><p><font face="Arial"><strong>Resulting Char</strong></font></td>
        </tr>
        <tr>
            <td><p align="center"><font face="Arial"><strong>\n</strong></font></td>
            <td><p><font face="Arial">newline</font></td>
        </tr>
        <tr>
            <td><p align="center"><font face="Arial"><strong>\t</strong></font></td>
            <td><p><font face="Arial">tabulator</font></td>
        </tr>
        <tr>
            <td><p align="center"><font face="Arial"><strong>\v</strong></font></td>
            <td><p><font face="Arial">vertical tabulator</font></td>
        </tr>
        <tr>
            <td><p align="center"><font face="Arial"><strong>\b</strong></font></td>
            <td><p><font face="Arial">backspace</font></td>
        </tr>
        <tr>
            <td><p align="center"><font face="Arial"><strong>\r</strong></font></td>
            <td><p><font face="Arial">carriage return</font></td>
        </tr>
        <tr>
            <td><p align="center"><font face="Arial"><strong>\f</strong></font></td>
            <td><p><font face="Arial">formfeed</font></td>
        </tr>
        <tr>
            <td><p align="center"><font face="Arial"><strong>\a</strong></font></td>
            <td><p><font face="Arial">alert</font></td>
        </tr>
        <tr>
            <td><p align="center"><font face="Arial"><strong>\\</strong></font></td>
            <td><p><font face="Arial">backslash</font></td>
        </tr>
        <tr>
            <td><p align="center"><font face="Arial"><strong>\`</strong></font></td>
            <td><p><font face="Arial">single quote</font></td>
        </tr>
        <tr>
            <td><p align="center"><font face="Arial"><strong>\&quot;</strong></font></td>
            <td><p><font face="Arial">double quote</font></td>
        </tr>
    </table>
    <dd><font face="Arial"><br> These escape sequences are replaced within every 
    pair of doublequotes (</font><font face="Arial"><strong>&quot;&quot;</strong></font><font
     face="Arial">), i.e. within literal strings; user input read with the</font><font
     face="Arial"><strong> input</strong></font><font face="Arial">-statement 
    is not affected in any way.<br> Finally note, that escape sequences have 
    a profound impact, when specifying </font><a href="#Specifying Window-pathnames"><font
     face="Arial">Window-pathnames</font></a><font face="Arial">.</font> 
    <dd>&nbsp; 
</dl>
<p><font face="Arial">Here is another example which introduces the rest of yabasic's 
string-functions:</font> </p>
<ul>
    <pre><font face="Arial"> &nbsp;label again&nbsp;</font>
<font face="Arial">  print &quot;Please enter a string containing the word \&quot;yabasic\&quot;&quot; </font>
<font face="Arial">  input a$ </font>
<font face="Arial">  if (instr(lower$(a$),&quot;yabasic&quot;)&lt;&gt;0) then</font>
<font face="Arial">    gosub thanx </font>
<font face="Arial">  else </font>
<font face="Arial">    print &quot;No, please try again !&quot; </font>
<font face="Arial">  endif </font>
<font face="Arial">goto loop </font>
<font face="Arial">label thanx </font>
<font face="Arial">print &quot;Thanks a lot !&quot; </font>
<font face="Arial">return</font></pre>
</ul>
<p><font face="Arial">If you run this program you will receive the following 
output:</font> 
<dl>
    <dd><font face="Arial">Please enter a string containing the word &quot;yabasic&quot; 
    </font>
    <pre><font face="Arial">?</font><font face="Arial"><u>thequickbrownfox</u></font>
<font face="Arial">No, please try again ! </font>
<font face="Arial">Please enter a string containing the word &quot;yabasic&quot; </font>
<font face="Arial">?</font><font face="Arial"><u>jumpedyabasicoverthelazydog</u></font>
<font face="Arial">Thanx.</font></pre>
    <dt><a name="Marking locations in a program"><font face="Arial"><strong>Marking 
    locations in a program</strong></font></a><a name="Marking locations in a program"> 
    </a>
    <dd><font face="Arial">The first line in the example-program (</font><font
     face="Arial"><strong>label loop</strong></font><font face="Arial">) is 
    a label: As yabasic has no line-numbers, you need labels to mark a specific 
    location within your program. You can compose labels out of letters and 
    digits; the keyword </font><font face="Arial"><strong>label</strong></font><font
     face="Arial"> is required and the label itself should be unique within 
    your program. Note that yabasic allows for </font><a href="#linenumber"><font
     face="Arial">line numbers</font></a><font face="Arial"> too.</font> 
    <dt><a name="Jumping around in your program"><font face="Arial"><strong>Jumping 
    around in your program</strong></font></a><a name="Jumping around in your program"> 
    </a>
    <dd><font face="Arial">A label by itself causes no special action. Only 
    in conjunction with the </font><font face="Arial"><strong>goto</strong></font><font
     face="Arial">-statement (or </font><font face="Arial"><strong>gosub</strong></font><font
     face="Arial"> or </font><font face="Arial"><strong>restore</strong></font><font
     face="Arial">) does a label have any function. If yabasic encounters a 
    </font><font face="Arial"><strong>goto</strong></font><font face="Arial">-statement 
    (here: </font><font face="Arial"><strong>goto loop</strong></font><font face="Arial">) 
    then it searches for the matching label (here: </font><font face="Arial"><strong>label 
    loop</strong></font><font face="Arial">) and proceeds to execute at the 
    position of the label.<br> Note that you can even leave (and enter !) a 
    for-next loop with goto.<br> <br> Closely related to the </font><font face="Arial"><strong>goto</strong></font><font
     face="Arial">-command is the </font><font face="Arial"><strong>gosub</strong></font><font
     face="Arial">-command; if yabasic encounters a </font><font face="Arial"><strong>gosub</strong></font><font
     face="Arial">-statement then it searches for the matching label (</font><font
     face="Arial"><strong>label thanx</strong></font><font face="Arial"> in 
    the example) and proceeds with execution at the position of the label, until 
    it finds a </font><font face="Arial"><strong>return</strong></font><font
     face="Arial">-statement. </font><font face="Arial"><strong>return</strong></font><font
     face="Arial"> makes yabasic return to the position of the original gosub 
    and proceed from there.<br> <br> Note that both </font><font face="Arial"><strong>goto</strong></font><font
     face="Arial"> and </font><font face="Arial"><strong>gosub</strong></font><font
     face="Arial"> can be used as </font><a href="#on gosub"><font face="Arial"><strong>on 
    goto</strong></font></a><font face="Arial"> and </font><a href="#on gosub"><font
     face="Arial"><strong>on gosub</strong></font></a><font face="Arial">.</font> 
    
    <dt><a name="Finding strings in strings"><font face="Arial"><strong>Finding 
    strings in strings</strong></font></a><a name="Finding strings in strings"> 
    </a>
    <dd><font face="Arial">The example program above checks whether the user 
    input contains the string </font><font face="Arial"><strong>&quot;yabasic&quot;</strong></font><font
     face="Arial">; this is done with the help of the </font><font face="Arial"><strong>instr()</strong></font><font
     face="Arial">-function; </font><font face="Arial"><strong>instr()</strong></font><font
     face="Arial"> gives back the position of its second string-argument within 
    the first or zero, if it can't be found. E.g. </font><font face="Arial"><strong>instr(&quot;Hallo&quot;,&quot;al&quot;)</strong></font><font
     face="Arial"> gives back 2, because </font><font face="Arial"><strong>&quot;al&quot;</strong></font><font
     face="Arial"> appears at position 2 within </font><font face="Arial"><strong>&quot;Hallo&quot;</strong></font><font
     face="Arial">; whereas </font><font face="Arial"><strong>instr(&quot;Hallo&quot;,&quot;Al&quot;)</strong></font><font
     face="Arial"> returns 0, because </font><font face="Arial"><strong>&quot;Al&quot;</strong></font><font
     face="Arial"> is not contained in </font><font face="Arial"><strong>&quot;Hallo&quot;</strong></font><font
     face="Arial"> (the case doesn't match).</font> <br> <font face="Arial">Furthermore: 
    you may supply a third argument to the </font><font face="Arial"><b>instr()</b></font><font
     face="Arial">-Function, which specifies the position from where the substring 
    will be searched: </font><font face="Arial"><b>instr(&quot;aloha&quot;,&quot;a&quot;)</b></font><font
     face="Arial"> returns 1, whereas </font><font face="Arial"><b>instr(&quot;aloha&quot;,&quot;a&quot;,2)</b></font><font
     face="Arial"> returns 5, because searching the first </font><font face="Arial"><b>&quot;a&quot;</b></font><font
     face="Arial"> in </font><font face="Arial"><b>&quot;aloha&quot;</b></font><font
     face="Arial"> after position 2 is at position 5.</font> 
    <dd><font face="Arial">Finally: There is an </font><font face="Arial"><b>rinstr()</b></font><font
     face="Arial">-function which starts to search at the right end of the string 
    and goes to the left. </font><font face="Arial"><b>rinstr()</b></font><font
     face="Arial"> has a three argument form too.</font> 
    <dt><a name="Changing the case of strings"><font face="Arial"><strong>Changing 
    the case of strings</strong></font></a><a name="Changing the case of strings"> 
    </a>
    <dd><font face="Arial">The sample-program contains some further string-functions: 
    </font><font face="Arial"><strong>lower$()</strong></font><font face="Arial"> 
    and its counterpart </font><font face="Arial"><strong>upper$()</strong></font><font
     face="Arial"> convert their string-argument to all lower or all upper case 
    characters respectively, i.e. </font><font face="Arial"><strong>lower$(&quot;aBcD12fG&quot;)</strong></font><font
     face="Arial"> gives back </font><font face="Arial"><strong>&quot;abcd12fg&quot;</strong></font><font
     face="Arial">.</font> 
    <dt><a name="Removing spaces"><font face="Arial"><strong>Removing spaces</strong></font></a><a
     name="Removing spaces"> </a>
    <dd><font face="Arial"><strong>ltrim$()</strong></font><font face="Arial"> 
    and </font><font face="Arial"><strong>rtrim$()</strong></font><font face="Arial"> 
    are two functions to remove leading or trailing spaces from a string, e.g. 
    </font><font face="Arial"><strong>ltrim$(&quot; foo &quot;) </strong></font><font
     face="Arial">gives</font><font face="Arial"><strong> &quot;foo &quot; </strong></font><font
     face="Arial">and</font><font face="Arial"><strong> rtrim$(&quot; foo &quot;) 
    </strong></font><font face="Arial">gives</font><font face="Arial"><strong> 
    &quot; foo&quot;</strong></font><font face="Arial">. Finally</font><font
     face="Arial"><strong>, trim$() </strong></font><font face="Arial">is the 
    same as</font><font face="Arial"><strong> rtrim$(ltrime$())</strong></font><font
     face="Arial">.</font> 
    <dt><a name="Splitting a string into tokens"><font face="Arial"><strong>Splitting 
    a string into tokens</strong></font></a><a name="Splitting a string into tokens"> 
    </a>
    <dd><font face="Arial">There are two handy functions to split a string into 
    tokens; each function expects these parameters: a string which is to be 
    split into tokens and an array which receives the individual tokens. An 
    example would be:</font> 
    <ul>
        <pre>l$=&quot; one two three &quot;
dim words$(1)
num=token(l$,words$())
for a=1 to num:print words$(a):next a</pre>
    </ul>
    <dd><font face="Arial">Running this program gives:</font> 
    <dl>
        <dd><font face="Arial">one</font> <br> <font face="Arial">two<br> three</font> 
        
    </dl>
    <dd><font face="Arial">Note, that </font><font face="Arial"><strong>token()</strong></font><font
     face="Arial"> automatically resizes the array </font><font face="Arial"><b>words$()</b></font><font
     face="Arial"> as needed; the old contents of the array is discarded. Furthermore 
    you must not supply any indices when supplying the array (i.e. </font><font
     face="Arial"><b>a$(2)</b></font><font face="Arial"> is wrong, </font><font
     face="Arial"><b>a$()</b></font><font face="Arial"> is okay). If you supply 
    a third argument (e.g. </font><font face="Arial"><strong>token(a$,words$(),&quot;:;&quot;)</strong></font><font
     face="Arial">), the tokens are split at the characters given in the third 
    string.</font> <br> <font face="Arial"><br> Closely related with</font><font
     face="Arial"><strong> token() </strong></font><font face="Arial">is the</font><font
     face="Arial"><strong> split() </strong></font><font face="Arial">function. 
    The program:</font> 
    <ul>
        <pre>l$=&quot;::one::two:three::four&quot;
dim words$(1)
num=split(l$,words$(),&quot;:&quot;)
for a=1 to num:print &quot;Token: &quot;,words$(a):next a</pre>
    </ul>
    <p><font face="Arial">will produce this output:</font> 
    <dl>
        <dd><font face="Arial">Token:</font> 
        <dd><font face="Arial">Token:</font> 
        <dd><font face="Arial">Token: one</font> 
        <dd><font face="Arial">Token:</font> 
        <dd><font face="Arial">Token: two</font> 
        <dd><font face="Arial">Token: three</font> 
        <dd><font face="Arial">Token:</font> 
        <dd><font face="Arial">Token: four</font> 
    </dl>
    <dd><font face="Arial"><strong>split()</strong></font><font face="Arial"> 
    focuses on the separator (&quot;:&quot; in the example); if there are n 
    separators in your string, </font><font face="Arial"><b>split()</b></font><font
     face="Arial"> will return exactly n+1 tokens (unless the string is empty, 
    in which case you don't get any tokens). </font><font face="Arial"><b>split()</b></font><font
     face="Arial"> returns what is found between two occurrences of the separator, 
    even if the resulting token is empty. </font>
    <dd><font face="Arial"><strong>token()</strong></font><font face="Arial"> 
    on the other hand focuses on the tokens and may skip one or more separators, 
    if there are no other characters in between. </font><font face="Arial"><b>token()</b></font><font
     face="Arial"> does not give back an empty token as long as there are characters 
    left in the string.</font> 
    <dt><a name="Globbing"><font face="Arial"><strong>Globbing</strong></font></a> 
    
    <dd><font face="Arial"><strong>glob()</strong></font><font face="Arial"> 
    checks, if its first argument matches the pattern supplied as the second 
    argument. This second argument may contain the special characters </font><font
     face="Arial"><strong>?</strong></font><font face="Arial"> and </font><font
     face="Arial"><strong>*</strong></font><font face="Arial">, whereas </font><font
     face="Arial"><strong>?</strong></font><font face="Arial"> matches any single 
    character and </font><font face="Arial"><strong>*</strong></font><font face="Arial"> 
    matches zero or more arbitrary characters. Glob can only be used within 
    conditions (e.g. after </font><font face="Arial"><strong>if</strong></font><font
     face="Arial">, </font><font face="Arial"><strong>while</strong></font><font
     face="Arial"> or </font><font face="Arial"><strong>until</strong></font><font
     face="Arial">) as in </font><font face="Arial"><strong>if (glob(&quot;Hallo&quot;,&quot;H*o&quot;)) 
    print &quot;Matches !&quot;</strong></font><font face="Arial">. Some examples:<br> 
    </font>
    <table border cellpadding="2">
            <tr>
                <th align="center"><p>glob-condition</th>
            <th align="left"><p>True/False ?</th>
        </tr>
        <tr>
            <td><p>glob(&quot;abcd&quot;,&quot;abc?&quot;)</td>
            <td align="center"><p>true</td>
        </tr>
        <tr>
            <td><p>glob(&quot;abab&quot;,&quot;*&quot;)</td>
            <td align="center"><p>true</td>
        </tr>
        <tr>
            <td><p>glob(&quot;abc&quot;,&quot;ab??&quot;)</td>
            <td align="center"><p>false</td>
        </tr>
        <tr>
            <td><p>glob(&quot;abcdabab&quot;,&quot;ab*ab&quot;)</td>
            <td align="center"><p>true</td>
        </tr>
        <tr>
            <td><p>glob(&quot;abcd&quot;,&quot;*a&quot;)</td>
            <td align="center"><p>false</td>
        </tr>
    </table>
    <dt>&nbsp; 
</dl>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="70%"> </p>
<h2><a name="User defined functions"><font face="Arial">User defined </font></a><font
 face="Arial">subroutines</font></h2>
<p><font face="Arial">One day you won't be satisfied with yabasic's builtin 
functions and commands; this will be the time to define and use your first subroutine:</font></p>
<blockquote><p><font face="Arial" size="2">print multiply$(&quot;Hello&quot;,3)<br> 
    <br> sub multiply$(a$,a)<br> local b$,b<br> for b=1 to a:b$=b$+a$:next b<br> 
    return b$<br> end sub</font></p></blockquote>
<p><font face="Arial">This program simply prints the string </font><font face="Arial"><strong>HelloHelloHello</strong></font><font
 face="Arial"> which is (sort of) </font><font face="Arial"><strong>Hello</strong></font><font
 face="Arial"> multiplied with three. As there is no function in yabasic to 
&quot;multiply&quot; strings, the program defines it's own function </font><font
 face="Arial"><strong>multiply$() </strong></font><font face="Arial">(starting 
with </font><font face="Arial"><strong>sub multiply$(a$,a)</strong></font><font
 face="Arial">). </font><font face="Arial"><strong>multiply$()</strong></font><font
 face="Arial"> is a user defined string-function; you can tell from the </font><font
 face="Arial"><strong>$</strong></font><font face="Arial">-sign in </font><font
 face="Arial"><strong>multiply$()</strong></font><font face="Arial">, that it 
returns a string. </font><font face="Arial"><strong>multiply$()</strong></font><font
 face="Arial"> takes two arguments, a string and a number, which are passed 
to the function through the variables </font><font face="Arial"><strong>a$</strong></font><font
 face="Arial"> and </font><font face="Arial"><strong>a</strong></font><font face="Arial">. 
These variables, as well as </font><font face="Arial"><strong>b$</strong></font><font
 face="Arial"> and </font><font face="Arial"><strong>b</strong></font><font face="Arial"> 
(defined in </font><font face="Arial"><strong>local b$,b</strong></font><font
 face="Arial">), are local to the function: They are initialized as the subroutine 
is entered and keep their value just as long as the subroutine is executed. 
The computation within the subroutine is straightforward and the result is returned 
with the statement </font><font face="Arial"><strong>return b$</strong></font><font
 face="Arial">. </font></p>
<p><font face="Arial">Instead of </font><font face="Arial"><strong>return b$</strong></font><font
 face="Arial"> you might just write </font><font face="Arial"><strong>return</strong></font><font
 face="Arial"> or omit the return-statement altogether; in this case an empty 
string (or 0.0 for numerical functions) would be returned; of course, this wouldn't 
be very useful for this subroutine.</font></p>
<p><font face="Arial">Here are some examples showing, that yabasic is quite 
tolerant with user defined subroutines:</font></p>
<blockquote><p><font face="Arial" size="2">print sum(1,4),sum(2),sum()<br> sum(2,3)<br> 
    <br> sub sum(a,b)<br> if (numparams&lt;2) b=1<br> return a+b<br> end sub</font></p></blockquote>
<p><font face="Arial"><strong>sub()</strong></font><font face="Arial"> is a 
numerical subroutine (because </font><font face="Arial"><strong>sub()</strong></font><font
 face="Arial"> doesn't contain a </font><font face="Arial"><strong>$</strong></font><font
 face="Arial">-sign) and returns just the sum of its two numerical arguments. 
Running this program prints the line &quot;</font><font face="Arial"><strong>5 
3 1</strong></font><font face="Arial">&quot; which are the three values returned 
by the three calls to </font><font face="Arial"><strong>sum()</strong></font><font
 face="Arial">. </font></p>
<p><font face="Arial">As you see the function </font><font face="Arial"><strong>sum()</strong></font><font
 face="Arial"> can be called with less than two arguments; in this case </font><font
 face="Arial"><strong>0.0</strong></font><font face="Arial"> is inserted for 
a missing numerical argument and the empty string </font><font face="Arial"><strong>&quot;&quot;</strong></font><font
 face="Arial"> for a missing string argument. However you may query local variable 
</font><a name="numparams"><font face="Arial"><strong>numparams</strong></font></a><font
 face="Arial">, which is automatically created by yabasic, to get the nuber 
of parameters actially supplied during the subroutine call. If you omit an array 
argument, yabasic will supply a local dummy array instead; however, as soon 
as you try to access this array argument you will receive an error. Therefore 
it is good practice to check numparams before accessing array parameters.</font></p>
<p><font face="Arial">Furthermore you may call a subroutine (in the example: 
</font><font face="Arial"><strong>sub(2,3)</strong></font><font face="Arial">) 
without caring for the value returned (techincally spoken there is no distinction 
between functions and procedures in yabasic).</font></p>
<p><font face="Arial">Local variables are invisible outside your subroutine, 
but they are newly created each time you call your subroutine; but sometimes 
you may want to keep the values of variables within your routines. In this case 
you may use </font><font face="Arial"><strong>static</strong></font><font face="Arial"> 
variables like this:</font></p>
<blockquote><pre><font face="Arial">for a=1 to 4:stars():next a</font>
&nbsp;
<font face="Arial">sub stars()</font>
<font face="Arial">  static a$</font>
<font face="Arial">  local b$</font>
<font face="Arial">  a$=a$+&quot;*&quot;</font>
<font face="Arial">  b$=b$+&quot;*&quot;</font>
<font face="Arial">  print a$,&quot; &quot;,b$</font>
<font face="Arial">end sub</font></pre></blockquote>
<p><font face="Arial">Running this program produces the following pattern:</font></p>
<blockquote><pre>* *
** *
*** *
**** *</pre></blockquote>
<p><font face="Arial">As you see the static variable </font><font face="Arial"><strong>a$</strong></font><font
 face="Arial"> keeps its value over calls to </font><font face="Arial"><strong>stars()</strong></font><font
 face="Arial">, while </font><font face="Arial"><strong>b$</strong></font><font
 face="Arial"> is initialized every time.</font></p>
<p><font face="Arial">Finally note, that subroutines may easily use arrays in 
subroutines as parameters, local or static variables; look </font><a href="#More on Arrays"><font
 face="Arial">here</font></a><font face="Arial"> for an example.</font></p>
<p><a href="yabasic.htm#Description of yabasic"><font face="Arial">Back to table 
of contents ...</font></a></p>
<p><hr width="70%"> </p>
<h2><a name="Defining subroutines at runtime"><font face="Arial">Defining subroutines 
at runtime</font></a></h2>
<p><font face="Arial">Sometimes a program might want to create a subroutine&nbsp;during 
its execution: Let's say a user wants to enter an arbitrary function, which 
the program should then plot on the screen:</font></p>
<ul>
    <pre class="much_code"><font face="Arial">input &quot;Please enter an arithmetic expression: f(x) = &quot; f$</font></pre>
    <pre><font face="Arial">compile &quot;sub f(x):return &quot;+f$+&quot;:end sub&quot;</font>
<font face="Arial">for x=1 to 10:for i=1 to f(x):print &quot;*&quot;;:next i:print:next x</font></pre>
</ul>
<p class="much_code"><font face="Arial">This program reads an arithmetic expression 
into the variable f$; possible values would be &quot;sin(x)&quot; or &quot;x*x&quot;. 
With this arithmetic expression a simple function definition is created and 
handed over to the </font><font face="Arial"><b>compile</b></font><font face="Arial">-command, 
which turns its string argument into valid yabasic-code. After this you can 
simply use the newly defined function f(x), as in the third line, which does 
a simple plot of the function.</font></p>
<p class="much_code"><font face="Arial">A different feature (but still related 
with subroutines) is the ability to </font><font face="Arial"><b>execute</b></font><font
 face="Arial"> a function by specifying its name and arguments: </font><font
 face="Arial"><b>execute(&quot;f&quot;,x)</b></font><font face="Arial"> is exactly 
the same as </font><font face="Arial"><b>f(x)</b></font><font face="Arial">; 
of course execute(&quot;f&quot;,x) is ugly, but it might be used to plot a function 
which is specified by its name only:</font></p>
<ul>
    <pre class="much_code"><font face="Arial">sub plot(f$)</font></pre>
    <ul>
        <pre class="much_code"><font face="Arial">local x,y,a</font></pre>
        <pre><font face="Arial">for x=1 to 10</font></pre>
        <ul>
            <pre class="much_code"><font face="Arial">y=execute(f$,x)</font></pre>
            <pre><font face="Arial">for i=1 to y:print &quot;*&quot;;:next i</font>
<font face="Arial">print</font></pre>
        </ul>
        <pre class="much_code"><font face="Arial">next x</font></pre>
    </ul>
    <pre class="much_code"><font face="Arial">end sub</font></pre>
</ul>
<p class="much_code"><font face="Arial">With this handy plot function you may 
just say </font><font face="Arial"><b>plot(&quot;f&quot;)</b></font><font face="Arial"> 
to get a plot of function f. However, note that plot(&quot;x*x&quot;) would 
give you an error, because it would try to execute a function named &quot;x*x&quot; 
which does not exist.</font></p>
<p class="much_code"><font face="Arial">Whether you want to save the value returned 
by </font><font face="Arial"><b>execute </b></font><font face="Arial">(or whether 
the executed function returns one), you may use execute within an assignment 
or standalone: </font><font face="Arial"><b>execute(&quot;f&quot;,x)</b></font><font
 face="Arial"> and </font><font face="Arial"><b>y=execute(&quot;f&quot;,x)</b></font><font
 face="Arial"> are both valid.</font></p>
<p class="much_code"><font face="Arial">Finally, you may use </font><font face="Arial"><b>execute$</b></font><font
 face="Arial"> for functions returning a string.</font></p>
<p><a href="yabasic.htm#Description of yabasic"><font face="Arial">Back to table 
of contents ...</font></a></p>
<p><hr width="70%"> </p>
<h2><a name="Libraries"><font face="Arial">Libraries</font></a></h2>
<p><font face="Arial">A library is a separate file which contains &quot;readymade&quot; 
subroutines. Libraries are useful, if you have written a set of subroutines, 
which you want to use in more than one yabasic program. Better even, if someone 
else has written a library, which you could use without efford.</font></p>
<p><font face="Arial">Let's go ahead and try an example (as libraries contain 
mostly </font><a href="#User defined functions"><font face="Arial">subroutines</font></a><font
 face="Arial">, you may branch off and read about them first). This simply uses 
a library:</font></p>
<blockquote><pre><font face="Arial">import ufirst</font>
&nbsp;
<font face="Arial">print uf$(&quot;foO&quot;)</font></pre></blockquote>
<p dir="ltr"><font face="Arial">If you run this program, it prints &quot;</font><font
 face="Arial"><strong>Foo</strong></font><font face="Arial">&quot; which is 
&quot;</font><font face="Arial"><strong>foO</strong></font><font face="Arial">&quot; 
with the first character (&quot;</font><font face="Arial"><strong>f</strong></font><font
 face="Arial">&quot;) capitalized and the rest (&quot;</font><font face="Arial"><strong>oO</strong></font><font
 face="Arial">&quot;) changed to lowercase. The name of this subroutine (&quot;</font><font
 face="Arial"><strong>uf</strong></font><font face="Arial">&quot;) is just an 
abbreviation of &quot;upper-first&quot;.</font></p>
<p dir="ltr"><font face="Arial">The Subroutine </font><font face="Arial"><strong>uf$()</strong></font><font
 face="Arial"> is defined in the library </font><font face="Arial"><strong>ufirst</strong></font><font
 face="Arial"> which is made available with the statement </font><font face="Arial"><strong>import 
ufirst</strong></font><font face="Arial">. The library </font><font face="Arial"><strong>ucfirst</strong></font><font
 face="Arial"> is quite simple:</font></p>
<blockquote><pre><font face="Arial">rem Here comes the embedded documentation:</font>
<font face="Arial">docu </font>
<font face="Arial">docu   This library ufirst provides just a single function: uf$(),</font>
<font face="Arial">doc   which returns its string argument all lower case except for</font>
<font face="Arial">doc   the first letter, which is capitalized.</font>
<font face="Arial">doc </font>
<font face="Arial">docu   e.g. uf$(&quot;foo&quot;) returns &quot;Foo&quot; and uf$(&quot;bAr&quot;) returns &quot;Bar&quot;</font>
<font face="Arial">docu </font>
&nbsp;
<font face="Arial">a=2: rem  This statement has no use !</font>
&nbsp;
<font face="Arial">export sub uf$(a$) : rem export uf$()</font>
<font face="Arial">return upper$(left$(a$,1))+lower$(butfirst$(a$))</font>
<font face="Arial">end sub</font>
&nbsp;
<font face="Arial">sub butfirst$(a$) : rem butfirst$() is only visible locally</font>
<font face="Arial">return right$(a$,len(a$)-1)</font>
<font face="Arial">end sub</font></pre></blockquote>
<p dir="ltr"><font face="Arial" size="3">If you import this library (with </font><font
 face="Arial" size="3"><strong>import ufirst</strong></font><font face="Arial"
 size="3">) into your yabasic program, yabasic reads in the library and inserts 
it into your program: Any statements in the library (e.g. </font><font face="Arial"
 size="3"><strong>a=2</strong></font><font face="Arial" size="3"> in the example) 
is executed and any subroutine (</font><font face="Arial" size="3"><strong>uf$()</strong></font><font
 face="Arial" size="3"> and </font><font face="Arial" size="3"><strong>butfirst$()</strong></font><font
 face="Arial" size="3">) is defined. After</font><font face="Arial" size="3"><strong> 
import</strong></font><font face="Arial" size="3"> the variable </font><font
 face="Arial" size="3"><strong>a</strong></font><font face="Arial" size="3"> 
and the functions </font><font face="Arial" size="3"><strong>uf$()</strong></font><font
 face="Arial" size="3"> and </font><font face="Arial" size="3"><strong>butfirst$()</strong></font><font
 face="Arial" size="3"> are defined within your program. To avoid conflicts 
between the variables and subroutines defined in you program and those defined 
in the library, all variables and subroutines are prefixed with the name of 
the library. I.e. </font><font face="Arial" size="3"><strong>a</strong></font><font
 face="Arial" size="3"> is imported as </font><font face="Arial" size="3"><strong>ufirst.a</strong></font><font
 face="Arial" size="3">, </font><font face="Arial" size="3"><strong>uf$()</strong></font><font
 face="Arial" size="3"> , is imported as </font><font face="Arial" size="3"><strong>ufirst.uf$()</strong></font><font
 face="Arial" size="3"> and </font><font face="Arial" size="3"><strong>butfirst$()</strong></font><font
 face="Arial" size="3"> is imported as </font><font face="Arial" size="3"><strong>ufirst.butfirst$()</strong></font><font
 face="Arial" size="3">. You may check, that </font><font face="Arial" size="3"><strong>a</strong></font><font
 face="Arial" size="3"> from the library </font><font face="Arial" size="3"><strong>ufirst</strong></font><font
 face="Arial" size="3"> does not conflict with any </font><font face="Arial"
 size="3"><strong>a</strong></font><font face="Arial" size="3"> in your program 
with this simple program:</font></p>
<blockquote><pre><font face="Arial">import ufirst</font>
&nbsp;
<font face="Arial">a=1</font>
<font face="Arial">print a,ufirst.a</font></pre></blockquote>
<p dir="ltr"><font face="Arial" size="3">This simply prints &quot;</font><font
 face="Arial" size="3"><strong>1 2</strong></font><font face="Arial" size="3">&quot;, 
prooving that &quot;</font><font face="Arial" size="3"><strong>a</strong></font><font
 face="Arial" size="3">&quot; in your program and &quot;</font><font face="Arial"
 size="3"><strong>a</strong></font><font face="Arial" size="3">&quot; in the 
library </font><font face="Arial" size="3"><strong>ufirst</strong></font><font
 face="Arial" size="3"> don't collide.</font></p>
<p dir="ltr"><font face="Arial" size="3">On the other hand you may want to use 
some selected subroutines from the library without prefixing them with the library 
name. This can be achieved by adding the keyword </font><font face="Arial" size="3"><strong>export</strong></font><font
 face="Arial" size="3"> to the definition of the routine (in the example: </font><font
 face="Arial"><strong>export sub uf$(a$)</strong></font><font face="Arial">). 
Such an exported subroutine can be used without prefixing it with the library 
name (as in </font><font face="Arial"><strong>print uf$(&quot;foO&quot;)</strong></font><font
 face="Arial">).</font></p>
<p dir="ltr"><font face="Arial" size="3">The library starts with a bunch of 
</font><font face="Arial" size="3"><strong>docu</strong></font><font face="Arial"
 size="3"> (or </font><font face="Arial" size="3"><strong>doc</strong></font><font
 face="Arial" size="3">) statements, which contain the </font><font face="Arial"
 size="3"><em>embedded documentation </em></font><font face="Arial" size="3">of 
the library. This embedded documentation can be viewed by calling yabasic with 
the &quot;</font><font face="Arial" size="3"><strong>-lib</strong></font><font
 face="Arial" size="3">&quot; option; you would use </font><font face="Arial"
 size="3"><strong>yabasic -lib ufirst</strong></font><font face="Arial"> to 
view the text from the </font><font face="Arial"><strong>docu</strong></font><font
 face="Arial"> statements. Therefore it is always a </font><font face="Arial"><strong><em><u>brilliant</u></em></strong></font><font
 face="Arial"> idea to add some documentation to your library, telling what 
subroutines the library provides. Furthermore you might put a small, embedded 
sample program into your library, demonstrating its usage. If you enclose this 
sample program with </font><font face="Arial"><strong>if (peek$(&quot;library&quot;=&quot;main&quot;)) 
then ... endif </strong></font>, <font face="Arial">your embedded sample program 
is only executed, if the library is run as a program and not, if other programs 
</font><font face="Arial"><strong>import</strong></font><font face="Arial"> 
your library.</font><br>
<font face="Arial">Once you have written some embedded documentation, you may 
access it also from within your program. Just query the array </font><font face="Arial"><strong>docu$()</strong></font><font
 face="Arial">, which automatically contains the text of all </font><font face="Arial"><strong>docu</strong></font><font
 face="Arial">-statements. </font></p>
<p dir="ltr"><font face="Arial">Once you have written or received a library, 
you should install it. This is simple: The file containing the library should 
end on &quot;</font><font face="Arial"><strong>.yab</strong></font><font face="Arial">&quot; 
(e.g. </font><font face="Arial"><strong>ucfirst.yab</strong></font><font face="Arial">); 
this file should than be moved to a special directory. This special directory 
(e.g. </font><font face="Arial"><strong>c:\yabasic\lib</strong></font><font face="Arial"> 
under Windows or </font><font face="Arial"><strong>\usr\lib\yabasic</strong></font><font
 face="Arial"> under Unix) appears (along with the explanation of the </font><font
 face="Arial"><strong>-lib</strong></font><font face="Arial"> option) if you 
call yabasic with the option </font><font face="Arial"><strong>-help</strong></font><font
 face="Arial"> (i.e. </font><font face="Arial"><strong>yabasic -help</strong></font><font
 face="Arial">). Once you have moved the file to the right directory, you're 
done ! From now on you can use the library in your yabasic programs, e.g. by 
writing </font><font face="Arial"><strong>import ucfirst</strong></font><font
 face="Arial">. Furthermore, yabasic finds a library even if it resides in the 
current directory, i.e. the directory where the yabasic program (with the import-statement) 
lives; this is quite handy for developing and testing a library. </font></p>
<p dir="ltr"><font face="Arial">You may notice, that the name of the file and 
the name of the library (which appears in the </font><font face="Arial"><strong>import</strong></font><font
 face="Arial">-statement) are always (and by construction) the same.</font></p>
<p dir="ltr"><font face="Arial">Having read all this stuff about libraries, 
you may wonder where to get libraries. One solution would be to write your own; 
but it would be much more preferable (because it is less work) to get and use 
libraries other people have written. Libraries are a new feature in yabasic, 
so there is no set of standard libraries yet, but I hope that users will develop 
and contribute useful libraries ! Go ahead !!</font></p>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="70%"> </p>
<h2><a name="Graphics and printing"><font face="Arial">Graphics and printing</font></a></h2>
<p><font face="Arial">Yabasic provides some simple, general purpose graphic-commands:</font> 

<dl>
    <dd><font face="Arial">open window 400,400</font> 
    <pre><font face="Arial">line 0,0 to 400,400 </font>
<font face="Arial">circle 200,200,150</font>
<font face="Arial">clear fill circle 200,200,130</font>
<font face="Arial">clear line 0,400 to 400,0</font>
<font face="Arial">dot 200,200</font>
<font face="Arial">a$=inkey$ </font>
<font face="Arial">clear window</font>
<font face="Arial">text 100,200,&quot;Hello !&quot; </font>
<font face="Arial">print &quot;Press any key to close the window&quot; </font>
<font face="Arial">inkey$ </font>
<font face="Arial">close window</font></pre>
    <dt><font face="Arial"><strong>Drawing</strong></font> 
    <dd><font face="Arial">If you run this program, you will see a window with 
    size of 400 pixels in x- and y-direction (the window size is given along 
    with the </font><font face="Arial"><strong>open window</strong></font><font
     face="Arial">-statement). To specify a certain font for the text within 
    this window, you may add a third argument, e.g. </font><font face="Arial"><strong>open 
    window 400,400,&quot;swiss&quot;</strong></font><font face="Arial">.</font> 
    
</dl>
<dl>
    <dd><font face="Arial">Not surprising: The </font><font face="Arial"><strong>line</strong></font><font
     face="Arial">-command draws a line, the </font><font face="Arial"><strong>circle</strong></font><font
     face="Arial">-command draws a circle (the arguments determine x- and y-position 
    of the center and the radius of the circle) and the </font><font face="Arial"><strong>dot</strong></font><font
     face="Arial">-command draws a single dot at the specified location.<br> 
    As appropriate you may modify these commands with the keywords </font><font
     face="Arial"><b>clear</b></font><font face="Arial"> and </font><font face="Arial"><b>fill</b></font><font
     face="Arial">: E.g. </font><font face="Arial"><b>clear line</b></font><font
     face="Arial"> simply erases the specified line; </font><font face="Arial"><b>fill 
    circle</b></font><font face="Arial"> draws a black filled circle, whereas 
    </font><font face="Arial"><b>clear fill circle</b></font><font face="Arial"> 
    erases a circle with its interior.<br> <br> After the user has pressed a 
    key (see </font><a href="#Getting a key from the keyboard"><font face="Arial">below</font></a><font
     face="Arial">) the window contents is cleared with the </font><font face="Arial"><strong>clear 
    window</strong></font><font face="Arial">-statement. If you have your printer 
    open (i.e. if you have issued the </font><font face="Arial"><strong>open 
    printer</strong></font><font face="Arial">-command) </font><font face="Arial"><strong>clear 
    window</strong></font><font face="Arial"> finishes the current page, sends 
    it to the printer and starts a new one.<br> <br> The next command in the 
    example is the </font><font face="Arial"><strong>text</strong></font><font
     face="Arial">-statement, which writes its text at the specified position. 
    Aligned with this position is the left lower corner of the text. To change 
    the alignement, you can add as a third argument a two character string; 
    The first one specifies the horizontal alignement and can be </font><font
     face="Arial"><strong>&quot;l&quot;</strong></font><font face="Arial"> (text 
    is left aligned), </font><font face="Arial"><strong>&quot;r&quot; </strong></font><font
     face="Arial">(right aligned) or </font><font face="Arial"><strong>&quot;c&quot;</strong></font><font
     face="Arial"> (centered); the second character specifies the vertical alignement 
    and can be </font><font face="Arial"><strong>&quot;t&quot;</strong></font><font
     face="Arial"> (top of text is aligned), </font><font face="Arial"><strong>&quot;b&quot;</strong></font><font
     face="Arial"> (bottom) or </font><font face="Arial"><strong>&quot;c&quot;</strong></font><font
     face="Arial"> (center). Some valid arguments would be </font><font face="Arial"><strong>&quot;ct&quot;</strong></font><font
     face="Arial">, </font><font face="Arial"><strong>&quot;rb&quot;</strong></font><font
     face="Arial">, </font><font face="Arial"><strong>&quot;lc&quot;</strong></font><font
     face="Arial">, ... By the way: Textalignement can also be changed by </font><a href="#Peek and Poke"><font
     face="Arial"><strong>poking</strong></font></a><font face="Arial"> into 
    </font><font face="Arial"><strong>&quot;textalign&quot;</strong></font><font
     face="Arial">.<br> <br> Finally </font><font face="Arial"><strong>close 
    window</strong></font><font face="Arial"> closes the graphics-window.</font> 
    
    <dt>&nbsp; 
    <dt><a name="Getting a key from the keyboard"><font face="Arial"><strong>Getting 
    a key from the keyboard</strong></font></a><a name="Getting a key from the keyboard"> 
    </a>
    <dd><font face="Arial">But before the window is closed, the </font><font
     face="Arial"><strong>inkey$</strong></font><font face="Arial">-statement 
    waits, until the user presses any key (in the text console or in the grafic 
    window) and returns this key as a string. In this example the key, which 
    is actually pressed is not important, so you may just write </font><font
     face="Arial"><strong>inkey$</strong></font><font face="Arial"> (without 
    assignment). Some important nonprintable keys (e.g. the function or cursor 
    keys) are returned as strings: </font><font face="Arial"><strong>up, down, 
    left, right, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, esc, ins, 
    del, home, end, scrnup, scrndown, enter, tab, backspace. </strong></font><font
     face="Arial">If your keyboard gives other keycodes than mine, or if you 
    press a key, which is unknown to yabasic, you will receive a rather lengthy 
    string (e.g. key1b5b31317e).<br> Normally yabasic's </font><font face="Arial"><strong>inkey$</strong></font><font
     face="Arial"> waits until the user presses a key; but if you want the inkey$-function 
    to return even if no key has been pressed, you may add a timeout (in seconds) 
    argument. E.g. </font><font face="Arial"><strong>inkey$(2)</strong></font><font
     face="Arial"> returns immediately, if the user hits a key and after 2 seconds 
    (returning an empty string) if not; note that a timeout of 0 seconds is 
    possible, which is the normal behaviour of other basics.<br> </font><a name="mouse"><font
     face="Arial">If</font></a><font face="Arial"> you press a mousebutton in 
    the grafic window, you will receive a string like &quot;</font><font face="Arial"><strong>MB1d+1:0100,0200</strong></font><font
     face="Arial">&quot; which stands for &quot;Mouse Button 1 has gone down 
    with the shift key pressed at x=100, y=200&quot;; likewise &quot;</font><font
     face="Arial"><strong>MB2u+0:0300,0400</strong></font><font face="Arial">&quot; 
    stands for &quot;Mouse Button 2 has gone up with no modifier key pressed 
    at x=300, y=400&quot;. The functions </font><font face="Arial"><strong>mousex()</strong></font><font
     face="Arial">, </font><font face="Arial"><strong>mousey(), mousemod() </strong></font><font
     face="Arial">and </font><font face="Arial"><strong>mouseb()</strong></font><font
     face="Arial"> can be used to extract the details from the string returned 
    by inkey$:<br> </font><font face="Arial"><strong>a$=inkey$:if (left$(a$,2)=&quot;MB&quot;) 
    print mousex(a$),mousey(a$),mousemod(a$),mouseb(a$)<br> </strong></font><font
     face="Arial">If you omit the argument (e.g. </font><font face="Arial"><strong>print 
    mousex</strong></font><font face="Arial">) you get the values of the last 
    mouse-event returned by </font><font face="Arial"><strong>inkey$</strong></font><font
     face="Arial">. This means, that you can not use </font><font face="Arial"><strong>mousex</strong></font><font
     face="Arial"> to track the position of the mouse, because it's value is 
    updated only by the </font><font face="Arial"><b>inkey$</b></font><font face="Arial">-function. 
    Finally </font><font face="Arial"><strong>mouseb</strong></font><font face="Arial"> 
    returns a positive value if the button has been pressed and a negative value 
    if the button has been released.<br> </font>
    <dt><a name="printing"><font face="Arial"><strong>Printing</strong></font></a><a
     name="printing"> </a>
    <dd><font face="Arial">Getting a hardcopy of your graphics involves two 
    new commands:</font> 
    <dd><font face="Arial">open window 200,200 </font>
    <pre><font face="Arial">open printer </font>
<font face="Arial">circle 100,100,80 </font>
<font face="Arial">close printer </font>
<font face="Arial">close window</font></pre>
    <dd><font face="Arial">Everything between </font><font face="Arial"><strong>open 
    printer</strong></font><font face="Arial"> and </font><font face="Arial"><strong>close 
    printer</strong></font><font face="Arial"> appears on paper. If you prefer 
    sending your hardcopy to a file, you may add a filename, e.g. </font><font
     face="Arial"><strong>open printer &quot;foo&quot;</strong></font><font face="Arial"> 
    sends the output to the file </font><font face="Arial"><strong>foo</strong></font><font
     face="Arial">. Note that the </font><font face="Arial"><strong>open printer</strong></font><font
     face="Arial"> statement has to appear after the window has been opened. 
    </font><font face="Arial"><strong>close printer</strong></font><font face="Arial"> 
    can be omitted; it is done automatically, if the window is closed.</font> 
    
    <dd>&nbsp; 
    <dd><a name="lineprinting">Besides</a> graphics you may want to print plain 
    text to your printer: 
    <pre><font face="Arial">open #1,printer</font>
<font face="Arial">print #1 &quot;Hello World !&quot;</font>
<font face="Arial">close #1</font></pre>
    <dd>Running this program prints the text &quot;Hello World !&quot; on your 
    line-printer. 
</dl>
<p dir="ltr"><a href="#Description of yabasic"><font face="Arial">Back to table 
of contents ...</font></a></p>
<p><hr width="454"> </p>
<p><a name="Some more graphics"><font face="Arial" size="5"><strong>Some more 
graphics</strong></font></a></p>
<p><font face="Arial">The following program shows some further commands for 
drawing:</font> 
<dl>
    <dd><font face="Arial">open window 600,400</font> 
    <pre><font face="Arial">window origin &quot;lb&quot;</font>
&nbsp;
<font face="Arial">new curve</font>
<font face="Arial">for x=-3 to 3 step 0.1: rem this loop draws a sine()-function</font>
<font face="Arial">  y=sin(x)</font>
<font face="Arial">  line to 300+90*x,200+150*y</font>
<font face="Arial">next x</font>
<font face="Arial">rectangle</font><a href="#rectangle"><font face="Arial"> </font></a><font face="Arial">10,10 to 110,60: rem draw the legend</font>
<font face="Arial">text 55,35,&quot;sine-function&quot;,&quot;cc&quot;</font>
<font face="Arial">inkey$</font>
<font face="Arial">close window</font></pre>
</dl>
<p><font face="Arial">This program just draws a simple sine function.</font> 

<dl>
    <dt><font face="Arial"><strong>window origin &quot;lb&quot;</strong></font> 
    
    <dd><font face="Arial">In normal cases the coordinate origin (i.e. the point 
    0,0) of any window lies in the upper left corner; the command </font><font
     face="Arial"><strong>window origin</strong></font><font face="Arial"> can 
    move this origin to any of the four corners of a window. The string argument 
    (&quot;lb&quot; in the example) consists of two chars; the first one can 
    be &quot;l&quot; (for left) or &quot;r&quot; (for right); the second char 
    can be &quot;t&quot; (for top) or &quot;b&quot; (for bottom). This gives 
    you a total of four variants &quot;lb&quot;, &quot;lt&quot;, &quot;rb&quot; 
    and &quot;rt&quot;, which correspond with the four corners of a window.<br> 
    Once the origin has been moved, it applies to any grafic operation whatsoever.</font> 
    
    <dt><font face="Arial"><strong>rectangle 10,10 to 590,390</strong></font> 
    
    <dd><font face="Arial">This command simply draws a rectangle, defined by 
    any two opposite corners and clears the interior. You may modify the </font><font
     face="Arial"><b>rectangle</b></font><font face="Arial"> (</font><font face="Arial"><b>rect</b></font><font
     face="Arial"> for short) command with </font><font face="Arial"><b>clear</b></font><font
     face="Arial"> and/or </font><font face="Arial"><b>fill</b></font><font face="Arial"> 
    to clear the rectangle or fill it.</font> 
    <dt><font face="Arial"><strong>new curve </strong></font><font face="Arial">and</font><font
     face="Arial"><strong> line to x,y</strong></font> 
    <dd><font face="Arial">These functions help to plot a curve as a sequence 
    of many lines. Each </font><font face="Arial"><strong>line to</strong></font><font
     face="Arial">-command draws a line from the point specified in the previous 
    </font><font face="Arial"><strong>line to</strong></font><font face="Arial">-command 
    to the point specified in the command itself ; to add more line segments, 
    you just have to specify further </font><font face="Arial"><strong>line 
    to</strong></font><font face="Arial">-commands. If you want to start with 
    a new curve (i.e. a new sequence of lines) just issue the </font><font face="Arial"><strong>new 
    curve</strong></font><font face="Arial">-command.</font> 
    <dd>&nbsp; 
</dl>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h2><a name="Bitmaps"><font face="Arial">Bitmaps</font></a></h2>
<p><font face="Arial">Yabasic allows to retrieve and change rectangualr regions 
of the screen with simple commands:</font> 
<dl>
    <dd><font face="Arial">open window 200,200</font> 
    <pre><font face="Arial">for a=0 to 200 step 10</font>
<font face="Arial">  line a,0 to a,200:line 0,a to 200,a: rem draw some pattern on the screen</font>
<font face="Arial">next a</font>
<font face="Arial">rem this is a picture of a star</font>
<font face="Arial">star$=&quot;24,24:00c10000e10000f10000f10008f3&quot;</font>
<font face="Arial">star$=star$+&quot;0008f30008f700fff700ffff30fff&quot;</font>
<font face="Arial">star$=star$+&quot;fffefffffefffff0ffff70eff700e&quot;</font>
<font face="Arial">star$=star$+&quot;ff000cff100eff300fff70cfff70e&quot;</font>
<font face="Arial">star$=star$+&quot;f7ef1ef1cf3e700e3e100c3000000&quot;</font>
<font face="Arial">for a=50 to 150</font>
<font face="Arial">  saved$=getbit$(a,150,a+24,150+24): rem save old content of window</font>
<font face="Arial">  bitblit star$ to a,150,&quot;or&quot;: rem put star at new location</font>
<font face="Arial">  pause 0.1</font>
<font face="Arial">  bitblit saved$ to a,150: rem restore old window content</font>
<font face="Arial">next a</font></pre>
</dl>
<p><font face="Arial">This program moves a tiny star across the window. Yabasic 
stores bitmaps within ordinary strings, e.g. the star-bitmap is contained within 
the variable </font><font face="Arial"><strong>star$</strong></font><font face="Arial">. 
</font><font face="Arial"><strong><br>
</strong></font><font face="Arial">The </font><font face="Arial"><strong>getbit$()</strong></font><font
 face="Arial">-function returns such a bitmap-string, if called with the coordinates 
of a rectangle; in the example the line </font><font face="Arial"><strong>saved$=getbit$(a,150,a+24,150+24)</strong></font><font
 face="Arial"> stores the contents of a 24x24 rectangle with corners (a,150) 
and (a+24,150+24) within the variable </font><font face="Arial"><strong>saved$</strong></font><font
 face="Arial">.<br>
Once you've got a bitmap-string you can put it on the window with the </font><font
 face="Arial"><strong>putbit</strong></font><font face="Arial">-command. E.g. 
</font><font face="Arial"><strong>putbit star$ to a,150,&quot;or&quot;</strong></font><font
 face="Arial"> puts the bitmap contained within star$ onto the screen at position 
(a,150). The fourth, optional argument (&quot;or&quot; in the example) specifies, 
how to combine the pixels from the window with those from the bitmap:</font> 

<table border cellpadding="2">
    <tr>
        <th align="center"><p align="left"><font face="Arial">Mode</font></th>
        <th align="center"><p align="left"><font face="Arial">Action</font></th>
    </tr>
    <tr>
        <td><p><font face="Arial">&quot;and&quot;</font></td>
        <td><p><font face="Arial">The pixel is set, if both window pixel and 
            the bitmap pixel are set.</font></td>
    </tr>
    <tr>
        <td><p><font face="Arial">&quot;or&quot;</font></td>
        <td><p><font face="Arial">The pixel is set, if either the window pixel 
            or the bitmap pixel are set</font></td>
    </tr>
    <tr>
        <td><p><font face="Arial">&quot;replace&quot;</font></td>
        <td><p><font face="Arial">The pixel is set, if the bitmap pixel is set. 
            This is the default</font></td>
    </tr>
    <tr>
        <td><p><font face="Arial">&quot;xor&quot;</font></td>
        <td><p><font face="Arial">The pixel is set, if exactly one of window 
            and pitmap pixel is set</font></td>
    </tr>
    <tr>
        <td><p><font face="Arial">&quot;nand&quot;</font></td>
        <td><p><font face="Arial">The pixel is set, if not both window pixel 
            and bitmap pixel are set</font></td>
    </tr>
    <tr>
        <td><p><font face="Arial">&quot;clear&quot;</font></td>
        <td><p><font face="Arial">If the bitmap pixel is set, the corrosponding 
            window pixel is cleared</font></td>
    </tr>
    <tr>
        <td><p><font face="Arial">&quot;1&quot;</font></td>
        <td><p><font face="Arial">The window pixel is set, without regarding 
            the bitmap</font></td>
    </tr>
    <tr>
        <td><p><font face="Arial">&quot;0&quot;</font></td>
        <td><p><font face="Arial">The window pixel is cleared, without regarding 
            the bitmap</font></td>
    </tr>
</table>
<p><font face="Arial">If you omit the mode argument, the default &quot;replace&quot; 
applies.<br>
<br>
Having said all this, there is a serious drawback: You can put bitmaps on the 
window, but you can't print them ! </font></p>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h2><a name="Data and Arrays"><font face="Arial">Data and Arrays</font></a></h2>
<p><font face="Arial">Now and then the need arises to supply a program with 
initial data. The next sample-program converts numbers to strings:</font> 
<dl>
    <dd><font face="Arial">restore names </font>
    <pre><font face="Arial">read maxnum </font>
<font face="Arial">dim names$(maxnum) </font>
<font face="Arial">for a=1 to maxnum:read names$(a):next a </font>
<font face="Arial">label loop </font>
<font face="Arial">  input &quot;Please enter a number: &quot; number:number=int(number) </font>
<font face="Arial">  if (number&gt;=1 and number&lt;=maxnum) then </font>
<font face="Arial">    print number,&quot;=&quot;,names$(number) </font>
<font face="Arial">    goto loop </font>
<font face="Arial">  endif </font>
<font face="Arial">print &quot;Sorry, can't convert &quot;,number </font>
<font face="Arial">label names </font>
<font face="Arial">data 9,&quot;one&quot;,&quot;two&quot;,&quot;three&quot;,&quot;four&quot;,&quot;five&quot;,&quot;six&quot;</font>
<font face="Arial">data &quot;seven&quot;,&quot;eight&quot;,&quot;nine&quot;</font></pre>
</dl>
<p><font face="Arial">If you run this program, it goes like this: </font>
<dl>
    <dd><font face="Arial">Please enter a number: </font><font face="Arial"><u>2</u></font> 
    
    <pre><font face="Arial">2=two </font>
<font face="Arial">Please enter a number: </font><font face="Arial"><u>3</u></font>
<font face="Arial">3=three </font>
<font face="Arial">Please enter a number: </font><font face="Arial"><u>8</u></font>
<font face="Arial">8=eight </font>
<font face="Arial">Please enter a number: </font><font face="Arial"><u>12</u></font>
<font face="Arial">Sorry, can't convert 12</font></pre>
    <dt><a name="Reading Data"><font face="Arial"><strong>Reading Data</strong></font></a><a
     name="Reading Data"> </a>
    <dd><font face="Arial">As you see this program just converts numbers to 
    their textual representation; for this purpose, it needs to know the numbers 
    from 1 to 9 as text. This information is stored in the </font><font face="Arial"><strong>data</strong></font><font
     face="Arial">-lines at the bottom of the program: With the </font><font
     face="Arial"><strong>read</strong></font><font face="Arial">-command the 
    program gets one piece of data after the other.<br> If you want to deviate 
    from the linear ordering while reading the </font><font face="Arial"><strong>data</strong></font><font
     face="Arial">-statements, you may use the </font><font face="Arial"><strong>restore</strong></font><font
     face="Arial">-statement: In the example above </font><font face="Arial"><strong>restore 
    names</strong></font><font face="Arial"> makes sure, that the next </font><font
     face="Arial"><strong>read</strong></font><font face="Arial">-statement 
    reads its data after the label </font><font face="Arial"><strong>names</strong></font><font
     face="Arial">.</font> 
    <dt><a name="Arrays"><font face="Arial"><strong>Arrays</strong></font></a><a
     name="Arrays"> </a>
    <dd><font face="Arial">In the example above the words &quot;one&quot; ... 
    &quot;nine&quot; are stored within a string-array </font><font face="Arial"><strong>names$()</strong></font><font
     face="Arial">. You may use arrays to process large quantities of data. 
    There are numerical arrays as well as a string-arrays, but both sorts of 
    arrays need to be declared prior to their first use; this is necessary, 
    because yabasic needs to know, how much memory has to be reserved for the 
    array. The example uses </font><font face="Arial"><strong>dim names$(maxnum)</strong></font><font
     face="Arial"> to declare a string array, another example would be </font><font
     face="Arial"><strong>dim numbers(200)</strong></font><font face="Arial"> 
    to create a numerical array with 200 elements.<br> More complex tasks may 
    even require multidimensional arrays with more than one index: </font><font
     face="Arial"><strong>dim matrix(10,10)</strong></font><font face="Arial"> 
    defines a two dimensional array. Array-dimension can be up to ten, if needed.<br> 
    <br> Arrays offer more functionality than demonstrated in this simple example, 
    you can learn about this in the section on </font><a href="#More on Arrays"><font
     face="Arial">advanced usage of arrays</font></a><font face="Arial">.</font> 
    
</dl>
<p><font face="Arial">It should be mentioned, that the functionality of the 
above sample-program can be achieved by using totally different language-constructs:</font> 

<dl>
    <dd><font face="Arial">label loop </font>
    <pre><font face="Arial">  input &quot;Please enter a number: &quot; </font>
<font face="Arial">  number:number=int(number) </font>
<font face="Arial">  on number+1 gosub sorry,one,two,three,four,five,sorry </font>
<font face="Arial">goto loop </font>
<font face="Arial">label sorry:print &quot;Sorry, can't convert &quot;,number:end</font>
<font face="Arial">label one:print &quot;1=one&quot;:return </font>
<font face="Arial">label two:print &quot;2=two&quot;:return </font>
<font face="Arial">label three:print &quot;3=three&quot;:return </font>
<font face="Arial">label four:print &quot;4=four&quot;:return </font>
<font face="Arial">label five:print &quot;5=five&quot;:return</font></pre>
</dl>
<p><font face="Arial">This program produces the same output as the example above.</font> 

<dl>
    <dt><a name="on gosub"><font face="Arial"><strong>on gosub, on goto</strong></font></a><a
     name="on gosub"> </a>
    <dd><font face="Arial">The heart of this sample is the </font><font face="Arial"><strong>on 
    gosub</strong></font><font face="Arial">-statement, which is followed by 
    a list of labels (</font><font face="Arial"><strong>sorry,one,two,...</strong></font><font
     face="Arial">). Depending on the value of the expression (</font><font face="Arial"><strong>number+1</strong></font><font
     face="Arial">) the corresponding label in the list is chosen: E.g. if </font><font
     face="Arial"><strong>number+1</strong></font><font face="Arial"> gives 
    3, the third label (</font><font face="Arial"><strong>three</strong></font><font
     face="Arial">) is selected and a </font><font face="Arial"><strong>gosub</strong></font><font
     face="Arial"> to this label is performed.</font> 
    <dd><font face="Arial">A </font><font face="Arial"><strong>gosub</strong></font><font
     face="Arial"> is always performed, regardless of the value of the expression. 
    More specifically, if </font><font face="Arial"><strong>number+1</strong></font><font
     face="Arial"> gives anything less or equal to 1, then the first label (</font><font
     face="Arial"><strong>sorry</strong></font><font face="Arial">) is chosen; 
    if </font><font face="Arial"><strong>number+1</strong></font><font face="Arial"> 
    gives anything greater or equal to the number of elements in the list (which 
    is 7 in the example), then the last label (</font><font face="Arial"><strong>sorry</strong></font><font
     face="Arial">) is chosen. Therefore the label </font><font face="Arial"><strong>sorry</strong></font><font
     face="Arial"> is chosen whenever the program can't convert the given number.<br> 
    <br> Finally, note that the </font><font face="Arial"><strong>on</strong></font><font
     face="Arial">-construct can be used as</font><font face="Arial"><strong> 
    on goto </strong></font><font face="Arial">too.</font> 
    <dt><a name="End of your program"><font face="Arial"><strong>End of your 
    program</strong></font></a><a name="End of your program"> </a>
    <dd><font face="Arial">Another new appearance in the above sample is the 
    </font><font face="Arial"><strong>end</strong></font><font face="Arial">-statement, 
    which ends your program immediately. The </font><font face="Arial"><strong>exit</strong></font><font
     face="Arial"> statements is quite similar in ending your program, but you 
    may add an argument (e.g. </font><font face="Arial"><strong>exit(2)</strong></font><font
     face="Arial">) which will be returned to the underlying operating system. 
    Furthermore </font><font face="Arial"><strong>exit</strong></font><font face="Arial"> 
    terminates you program immediately, even if a grafic window is open. The 
    third way to end a program is the error-statement, which takes a single 
    string argument. E.g. writing </font><font face="Arial"><strong>error &quot;no 
    good&quot;</strong></font><font face="Arial"> terminates the yabasic program 
    and prints &quot;</font><font face="Arial"><strong>no good</strong></font><font
     face="Arial">&quot; in the style of yabasic-errors.</font> 
</dl>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h2><a name="More on Arrays"><font face="Arial">More on Arrays</font></a></h2>
<p><font face="Arial">Have a look at this program</font></p>
<blockquote><pre><font face="Arial">dim a$(3,4)</font>
<font face="Arial">for a=1 to 3:for b=1 to 4</font>
<font face="Arial">a$(a,b)=str$(a)+&quot;,&quot;+str$(b)</font>
<font face="Arial">next b:next a</font>
&nbsp;
<font face="Arial">print_array(a$())</font>
<font face="Arial">dim a$(5,6)</font>
<font face="Arial">print_array(a$())</font>
&nbsp;
<font face="Arial">sub print_array(b$())</font>
<font face="Arial">  local x,y,a,b</font>
<font face="Arial">  x=arraysize(b$(),1)</font>
<font face="Arial">  y=arraysize(b$(),2)</font>
<font face="Arial">  for a=1 to x</font>
<font face="Arial">    for b=1 to y</font>
<font face="Arial">      b$(a,b)=&quot;(&quot;+b$(a,b)+&quot;)&quot;</font>
<font face="Arial">      print left$(b$(a,b)+&quot;           &quot;,10);</font>
<font face="Arial">    next b</font>
<font face="Arial">    print</font>
<font face="Arial">  next a</font>
<font face="Arial">  print</font>
<font face="Arial">end sub</font></pre></blockquote>
<pre><font face="Arial" size="4">If you run this program you will see something like this:</font></pre>
<blockquote><pre><font size="3">(1,1)     (1,2)     (1,3)     (1,4)</font>
<font size="3">(2,1)     (2,2)     (2,3)     (2,4)</font>
<font size="3">(3,1)     (3,2)     (3,3)     (3,4)</font>
&nbsp;
<font size="3">((1,1))   ((1,2))   ((1,3))   ((1,4))   ()        ()</font>
<font size="3">((2,1))   ((2,2))   ((2,3))   ((2,4))   ()        ()</font>
<font size="3">((3,1))   ((3,2))   ((3,3))   ((3,4))   ()        ()</font>
<font size="3">()        ()        ()        ()        ()        ()</font>
<font size="3">()        ()        ()        ()        ()        ()</font></pre></blockquote>
<p><font face="Arial" size="3">First this program creates the string array a$(4,3) 
and assigns to each element a string, which consists of the indices of the individual 
elements. Then the program calls the subroutine </font><font face="Arial" size="3"><strong>print_array()</strong></font><font
 face="Arial" size="3"> which just prints the array.</font></p>
<p><font face="Arial" size="3"><strong>print_array()</strong></font><font face="Arial"
 size="3"> accepts an array as a parameter; when the sub is called (e.g. </font><font
 face="Arial" size="3"><strong>print_array(a$())</strong></font><font face="Arial"
 size="3"> ), the array is passed without any indices (i.e. just </font><font
 face="Arial" size="3"><strong>a$()</strong></font><font face="Arial" size="3"> 
).</font></p>
<p><font face="Arial" size="3">First thing the subroutine does, is to get the 
size of the passed array: </font><font face="Arial" size="3"><strong>arraysize(b$(),1)</strong></font><font
 face="Arial" size="3"> returns the size of the first dimension of the array 
b$(). Likewise arraydim(b$()) returns the dimension of the supplied array (e.g. 
2 in the example).</font></p>
<p><font face="Arial" size="3">The routine print_array() not just prints the 
array, but also modifies it: the statement </font><font face="Arial"><strong>b$(a,b)=&quot;(&quot;+b$(a,b)+&quot;)&quot; 
</strong></font><font face="Arial" size="3">puts braces around each element. 
As the </font><font face="Arial" size="3"><strong>print_array()</strong></font><font
 face="Arial" size="3"> is called twice, array elements are modified twice, 
i.e. they get enclosed in double braces. This shows that the array </font><font
 face="Arial" size="3"><strong>a$() </strong></font><font face="Arial" size="3">which 
is passed to the subroutine is modified directly. Although the subroutine uses 
a different name ( b$() ) for the array, it has no local copy of the array but 
rather works with the array from the main program ( a$() ). This behaviour is 
known as &quot;</font><font face="Arial" size="3"><strong>call by reference</strong></font><font
 face="Arial" size="3">&quot; unlike the treatment of non array parameters (simple 
strings and numbers) which are &quot;called by value&quot;.</font></p>
<p><font face="Arial">After calling the routine </font><font face="Arial"><strong>print_array()</strong></font><font
 face="Arial"> for the first time, the sample program does another </font><font
 face="Arial"><strong>dim</strong></font><font face="Arial"> for the array a$(), 
which simply changes the arrays size. This re-dimensioning (you could just as 
well write </font><font face="Arial"><strong>redim</strong></font><font face="Arial">) 
keeps all the old contents and initializes any new elements with the empty string 
(or with 0.0 for numerical arrays). If you try to reduce the size of an array 
(e.g. do a </font><font face="Arial"><strong>dim a(10)</strong></font><font face="Arial"> 
first and then </font><font face="Arial"><strong>dim a(5)</strong></font><font
 face="Arial"> ), the statement is ignored.</font></p>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h2><a name="Files and more on input"><font face="Arial">Files and more on input</font></a></h2>
<p><font face="Arial">To understand the examples in this section, let us assume 
that a file named </font><font face="Arial"><strong>test.dat</strong></font><font
 face="Arial"> exists in the current directory and that it contains the following 
three lines:</font> </p>
<ul>
    <pre><font face="Arial">one two three </font>
<font face="Arial">four five </font>
<font face="Arial">six seven eight nine</font></pre>
</ul>
<p><font face="Arial">The next example opens that file and prints out its content:</font> 
</p>
<ul>
    <pre><font face="Arial">open 1,&quot;test.dat&quot;,&quot;r&quot; </font>
<font face="Arial">while(!eof(1))</font>
<font face="Arial">  input #1 a$ </font>
<font face="Arial">  line input b$ </font>
<font face="Arial">  print &quot;a$=\&quot;&quot;,a$,&quot;\&quot;, b$=\&quot;&quot;,b$,&quot;\&quot;&quot; </font>
<font face="Arial">wend</font></pre>
</ul>
<dl>
    <dt><a name="Opening a file"><font face="Arial"><strong>Opening a file</strong></font></a><a
     name="Opening a file"> </a>
    <dd><font face="Arial">The first thing to do if you want to use a file is 
    to open it: </font><font face="Arial"><strong>open 1,&quot;test.dat&quot;,&quot;r&quot;</strong></font><font
     face="Arial"> opens the file </font><font face="Arial"><strong>test.dat</strong></font><font
     face="Arial"> and gives it the file number </font><font face="Arial"><strong>1</strong></font><font
     face="Arial">. This file number is used to refer to the file later on (e.g. 
    </font><font face="Arial"><strong>input #1</strong></font><font face="Arial">). 
    File numbers can range from </font><font face="Arial"><strong>#1</strong></font><font
     face="Arial"> to some maximum value (usually more than 50), which depends 
    on your system; the hash is traditionally required. The optional third argument 
    (</font><font face="Arial"><strong>&quot;r&quot;</strong></font><font face="Arial">) 
    of the open-statement gives the filemode; depending on whether you want 
    to open a file for reading or writing you should choose a different mode. 
    Filemodes are borrowed from the C-language; here are the possible choices:</font> 
    
    <dt>&nbsp; 
    <dd><table border cellpadding="2">
            <tr>
                <td><p align="center"><font face="Arial"><strong>Filemode</strong></font></td>
            <td><p align="center"><font face="Arial"><strong>Result</strong></font></td>
        </tr>
        <tr>
            <td><p align="center"><font face="Arial"><strong>&quot;r&quot;</strong></font></td>
            <td><p><font face="Arial">Open file for reading, start reading at 
                the beginning of the file. This is the default</font></td>
        </tr>
        <tr>
            <td><p align="center"><font face="Arial"><strong>&quot;w&quot;</strong></font></td>
            <td><p><font face="Arial">Open file for writing, overwrite old contents</font></td>
        </tr>
        <tr>
            <td><p align="center"><font face="Arial"><strong>&quot;a&quot;</strong></font></td>
            <td><p><font face="Arial">Append to an existing file for writing 
                or open a new one if no file with the specified name exists</font></td>
        </tr>
    </table>
    <dd>&nbsp; 
    <dd><font face="Arial">You may also try &quot;</font><font face="Arial"><strong>rb</strong></font><font
     face="Arial">&quot;, &quot;</font><font face="Arial"><strong>wb</strong></font><font
     face="Arial">&quot;, &quot;</font><font face="Arial"><strong>ab</strong></font><font
     face="Arial">&quot;; the character &quot;</font><font face="Arial"><strong>b</strong></font><font
     face="Arial">&quot; stands for </font><a href="#binary"><font face="Arial">binary</font></a><font
     face="Arial"> mode, which allows to open and read files with non-text contents;</font> 
    
    <dd><font face="Arial"><br> If you are done with a file, you should </font><font
     face="Arial"><strong>close</strong></font><font face="Arial"> it, making 
    the file number available for another open-statement.</font> <br> <br> <font
     face="Arial">There is a special variant of the open-statement, which allows 
    to check, if the statement has been successful:</font> 
    <dl>
        <dd><font face="Arial">if (not open(#1,&quot;test.dat&quot;,&quot;r&quot;)) 
        print &quot;Can't open the file !&quot;</font> 
    </dl>
    <dd>&nbsp; 
    <dd><font face="Arial">Finally: Note that the file number (the &quot;1&quot; 
    in &quot;#1&quot; from the above example) can be a variable. I.e. you may 
    use this to open and read a line from a file &quot;foo&quot;:</font> 
    <ul>
        <pre><font face="Arial">a=open(&quot;foo&quot;)</font>
<font face="Arial">input #a a$</font></pre>
    </ul>
    <dt><a name="Specifying Window-pathnames"><font face="Arial"><strong>Specifying 
    Window-pathnames</strong></font></a><a name="Specifying Window-pathnames"> 
    </a>
    <dd><font face="Arial">Be careful, when specifying an absolute pathname: 
    </font><font face="Arial"><strong>&quot;C:\yabasic\test.dat&quot;</strong></font><font
     face="Arial"> is not a valid pathname, because the sequence</font><font
     face="Arial"><strong> &quot;\t&quot; </strong></font><font face="Arial">within 
    this string is interpreted as an </font><a href="#Escape-sequences"><font
     face="Arial">escape sequence</font></a><font face="Arial">, and will be 
    translated into the </font><font face="Arial"><strong>Tab</strong></font><font
     face="Arial">-character. To avoid problems like these, you should always 
    double your backslashes like</font><font face="Arial"><strong> &quot;C:\\yabasic\\test.dat&quot;</strong></font><font
     face="Arial">, because</font><font face="Arial"><strong> &quot;\\&quot; 
    </strong></font><font face="Arial">is an escape sequence and translated 
    into</font><font face="Arial"><strong> &quot;\&quot;</strong></font><font
     face="Arial">.</font> 
    <dt><a name="Reading and Writing"><font face="Arial"><strong>Reading and 
    Writings</strong></font></a><a name="Reading and Writing"> </a>
    <dd><font face="Arial">You can write to file just the same way as you would 
    write to your screen; the only difference is the file number, that comes 
    with the print-statement: </font><font face="Arial"><strong>print #1 &quot;Hello&quot;</strong></font><font
     face="Arial"> writes the string </font><font face="Arial"><strong>&quot;Hello&quot;</strong></font><font
     face="Arial"> to the file with file number </font><font face="Arial"><strong>#1</strong></font><font
     face="Arial">; note that there is no comma between the file number (</font><font
     face="Arial"><strong>#1</strong></font><font face="Arial">) and the text 
    to be written (</font><font face="Arial"><strong>&quot;Hello&quot;</strong></font><font
     face="Arial">). Reading works the same way: </font><font face="Arial"><strong>input 
    #1 a$</strong></font><font face="Arial">, reads the variable </font><font
     face="Arial"><strong>a$</strong></font><font face="Arial"> from the file 
    with file number </font><font face="Arial"><strong>#1</strong></font><font
     face="Arial">.</font> 
</dl>
<p><font face="Arial">Back to our sample program. If your run it, you will get 
the following output:</font> 
<blockquote><dl>
        <dd><font face="Arial">a$=&quot;one&quot;,b$=&quot;two three&quot; </font>
        <pre><font face="Arial">a$=&quot;four&quot;, b$=&quot;five&quot; </font>
<font face="Arial">a$=&quot;six&quot;, b$=&quot;seven eight nine&quot;</font></pre></blockquote>
    <dt><a name="End of File"><font face="Arial"><strong>End of File</strong></font></a><a
     name="End of File"> </a>
    <dd><font face="Arial">As you can see, the program loops until the file 
    has been fully read; this is achieved by means of the end-of-file-function 
    </font><font face="Arial"><strong>eof(1)</strong></font><font face="Arial">, 
    which returns </font><font face="Arial"><strong>false</strong></font><font
     face="Arial">, if there are more characters in the file, whose file number 
    is given as an argument, and returns </font><font face="Arial"><strong>true</strong></font><font
     face="Arial"> if the end of the file has been reached. As a special case 
    you may use</font><font face="Arial"><strong> eof(0) </strong></font><font
     face="Arial">to test if there are characters waiting on standard input; 
    this probably makes sense only if yabasic runs as a script.</font> 
    <dt><a name="More on input"><font face="Arial"><strong>More on input</strong></font></a><a
     name="More on input"> </a>
    <dd><font face="Arial">You may already have been wondering about how the 
    three lines of </font><font face="Arial"><strong>test.dat </strong></font><font
     face="Arial">are distributed among the variables of the input-statement; 
    this depends on the type of input-statement actually used:<br> </font>
    <ul type="disc">
        <li><font face="Arial"><strong>input</strong></font><font face="Arial"> 
        reads input until it encounters a space; leading and trailing spaces 
        are skipped.</font> 
        <li><font face="Arial"><strong>line input</strong></font><font face="Arial"> 
        reads input until it encounters the end of a line.</font> 
    </ul>
</dl>
<dl>
    <dd><font face="Arial">This applies regardless of whether you read from 
    a file (e.g. </font><font face="Arial"><strong>input a$</strong></font><font
     face="Arial">) or from the terminal (e.g. </font><font face="Arial"><strong>input 
    #1 a$</strong></font><font face="Arial">)</font> 
    <dt><a name="Binary files"><font face="Arial"><strong>Binary files</strong></font></a><a
     name="Binary files"> </a>
    <dd><font face="Arial">If you need to process binary files you have to resort 
    to </font><a href="#binary"><font face="Arial"><strong>peek</strong></font></a><a href="#binary"><font
     face="Arial"> and </font></a><a href="#binary"><font face="Arial"><strong>poke</strong></font></a><font
     face="Arial">.</font> 
    <dt><a name="Random access to files"><font face="Arial"><b>Random access 
    to files</b></font></a> 
    <dd>Normally yabasic reads one byte after the other from your file; however 
    you may use the functions <b>seek()</b> and <b>tell()</b> to navigate within 
    an open file: 
    <ul>
        <pre><font face="Arial">open #1,&quot;test.dat&quot;,&quot;w&quot;:print #1 &quot;abcdefghijkl&quot;;:close #1</font>
<font face="Arial">open #1,&quot;test.dat&quot;,&quot;r&quot;</font>
<font face="Arial">print chr$(peek(#1)),&quot; &quot;;</font>
<font face="Arial">seek #1,2:print chr$(peek(#1)),&quot; &quot;;</font>
<font face="Arial">seek #1,3,&quot;here&quot;:print chr$(peek(#1)),&quot; &quot;;</font>
<font face="Arial">seek #1,-2,&quot;end&quot;:print chr$(peek(#1)),&quot; &quot;;</font>
<font face="Arial">print tell(#1)</font>
<font face="Arial">close #1</font></pre>
    </ul>
    <dd>The Program first creates a file <b>test.dat , </b>which contains the 
    text &quot;<b>abcdefghijkl</b>&quot;. Afterwards single characters are read 
    from this file with <b>peek()</b>; between peeks, the current position within 
    the file is changed through <b>seek</b>; finally <b>tell()</b> gives back 
    the position within the file. Running this program gives you one line of 
    output: &quot;<b>a c g k 11</b>&quot;. 
    <dd>seek takes two or three arguments: The file number, the new offset within 
    the file and (optionally) the position from where the offset is counted. 
    This position can be one of &quot;begin&quot; (the offset counts from the 
    beginning of the file; this is the default), &quot;here&quot; (the offset 
    counts from the current position within the file) and &quot;end&quot; (the 
    offset counts from the end of the file). <br> Similar to the open command 
    you may use seek within conditions (e.g. <b>if (seek(...)</b>) which allows 
    you to check the success of this statement. 
    <dt><b>Printing plain text</b> 
    <dd>You may specify the unquoted keyword <b>printer</b> instead of a filename 
    to print to your line printer; see <a href="#lineprinting">here</a> for 
    an example. 
    <dt>&nbsp; 
    <dt><font face="Arial"><strong>The other way around ...</strong></font> 
    
    <dd><font face="Arial">Now that you understand the sample program, you may 
    look at it rewritten:</font> 
</dl>
<blockquote><blockquote><pre><font face="Arial">a=open(&quot;test.dat&quot;,&quot;r&quot;) </font>
<font face="Arial">while(!eof(a))</font>
<font face="Arial">  input #(a) a$ </font>
<font face="Arial">  print a$</font>
<font face="Arial">wend</font></pre></blockquote>
    <dl>
        <dd><font face="Arial"><strong>open()</strong></font><font face="Arial"> 
        is used as a function, which returns the first available file number 
        (probably 1). With the print statement you may use this file number; 
        note however, that yabasic demands braces after the hash (as in </font><font
         face="Arial"><strong>input #(a) a$</strong></font><font face="Arial"> 
        ).</font> 
    </dl></blockquote>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h2><a name="Calling the Operating System"><font face="Arial">Interaction with 
the Operating System</font></a></h2>
<h3><a name="The system()-function"><font face="Arial">The </font></a><a name="The system()-function"><font
 face="Arial"><strong>system()</strong></font></a><a name="The system()-function"><font
 face="Arial">-function</font></a></h3>
<p><font face="Arial">Although </font><font face="Arial"><strong>yabasic</strong></font><font
 face="Arial"> is by no means designed as a scripting-language, it can interact 
with the Operating System in a limited way:</font> 
<dl>
    <dd><font face="Arial">if (peek$(&quot;os&quot;)=&quot;unix&quot;) then 
    </font>
    <pre><font face="Arial">  command$=&quot;ls&quot; </font>
<font face="Arial">else </font>
<font face="Arial">  command$=&quot;dir /w&quot;</font>
<font face="Arial">endif </font>
<font face="Arial">cont$=system$(command$) </font>
<font face="Arial">print &quot;This is the contents of the current directory:&quot; </font>
<font face="Arial">print cont$ </font>
<font face="Arial">print len(cont$),&quot; characters have been printed.&quot;</font></pre>
</dl>
<p><font face="Arial">The </font><font face="Arial"><strong>system$()</strong></font><font
 face="Arial">-function is the heart of this program: It hands its argument 
over for execution to the shell of the underlying operating system; under Unix 
it is the bourne-shell </font><font face="Arial"><strong>sh</strong></font><font
 face="Arial"> and under Windows it is </font><font face="Arial"><strong>command.com</strong></font><font
 face="Arial">, which will execute the argument of the </font><font face="Arial"><strong>system()</strong></font><font
 face="Arial">-function.</font></p>
<p><font face="Arial">If I run this program under Windows95, I receive the following 
output:</font> 
<dl>
    <dd><font face="Arial">This is the contents of the current directory: </font>
    <pre><font face="Arial">Datentraeger in Laufwerk C: heisst WIN95</font>
<font face="Arial">Seriennummer des Datentr&auml;gers: 0B1D-10F8 </font>
<font face="Arial">Verzeichnis von C:\WINDOWS\Desktop </font>
FLOPPY.LNK    EMACS.LNK   DRUCKER.LNK
T.YAB         TELNET.LNK  TEST.YAB     MICROS~1.LNK  CD.LNK  PLATTE.LNK
WATCOM~1.LNK  [YABDOK~1]  TEST.DAT     WINDOW~1.LNK  [KINO] 
<font face="Arial">12 Datei(en) 2.693 Bytes 4 Verzeichnis(se) </font>
<font face="Arial">199.753.728 Bytes frei </font>
<font face="Arial">456 characters have been printed.</font></pre>
</dl>
<p><font face="Arial">Of course, you may get something different on your system 
(especially if you don't have a german windows installation).</font></p>
<p><font face="Arial">As this yabasic-program runs under Unix, as well as under 
Windows, the argument of the </font><font face="Arial"><strong>system$()</strong></font><font
 face="Arial">-function (</font><font face="Arial"><strong>command$</strong></font><font
 face="Arial">) has to be chosen according to the operating system. To find 
type of operating system (&quot;unix&quot; or &quot;windows&quot;), the program 
employs the command </font><a href="#Peek and Poke"><font face="Arial"><strong>peek$(&quot;os&quot;)</strong></font></a><font
 face="Arial">.</font></p>
<p><font face="Arial">Finally, there is a very similar command named </font><font
 face="Arial"><strong>system()</strong></font><font face="Arial"> (without a 
trailing </font><font face="Arial"><strong>$</strong></font><font face="Arial">), 
which doesn't catch the output of the executed command, which instead goes directly 
to your terminal. </font><font face="Arial"><strong>system()</strong></font><font
 face="Arial"> returns a numerical value, which is generated by the executed 
command. If you don't care about this value, you can safely ignore it; e.g. 
</font><font face="Arial"><strong>system(&quot;dir&quot;)</strong></font><font
 face="Arial"> (without assignment) is just as valid as </font><font face="Arial"><strong>a=system(&quot;dir&quot;)</strong></font><font
 face="Arial">.</font></p>
<h3><a name="date$ and time$"><font face="Arial"><strong>date$</strong></font></a><a
 name="date$ and time$"><font face="Arial"> and </font></a><a name="date$ and time$"><font
 face="Arial"><strong>time$</strong></font></a></h3>
<p><font face="Arial">To print the current date and time you may write:</font> 

<dl>
    <dd><font face="Arial">print date$,&quot; &quot;,time$</font> 
</dl>
<p><font face="Arial">This gave me the following output (your output will be 
different of course, because the times they </font><font face="Arial"><strong>are</strong></font><font
 face="Arial"> changing):</font> 
<dl>
    <dd><font face="Arial">5-08-28-1998-Fri-Aug 13-51-53-0</font> 
</dl>
<p><font face="Arial">The </font><font face="Arial"><strong>date$</strong></font><font
 face="Arial">-string has six fields: </font><font face="Arial"><strong>5</strong></font><font
 face="Arial"> is the day of the week (0-6, 0 is sunday, 6 saturday), </font><font
 face="Arial"><strong>08</strong></font><font face="Arial"> is the month (01-12), 
</font><font face="Arial"><strong>28</strong></font><font face="Arial"> is the 
day of the month (01-31), </font><font face="Arial"><strong>1998</strong></font><font
 face="Arial"> is the year, </font><font face="Arial"><strong>Fri</strong></font><font
 face="Arial"> is the name of the day and </font><font face="Arial"><strong>Aug</strong></font><font
 face="Arial"> is the name of the month.</font></p>
<p><font face="Arial">The </font><font face="Arial"><strong>time$</strong></font><font
 face="Arial">-string has four fields: </font><font face="Arial"><strong>13</strong></font><font
 face="Arial"> is the hour (00-23), </font><font face="Arial"><strong>51</strong></font><font
 face="Arial"> is the minute (00-59), </font><font face="Arial"><strong>53</strong></font><font
 face="Arial"> is the second (00-59) and </font><font face="Arial"><strong>0</strong></font><font
 face="Arial"> is the time, that has elapsed since the program started.</font></p>
<p><font face="Arial">As most fields of </font><font face="Arial"><strong>date$</strong></font><font
 face="Arial"> and </font><font face="Arial"><strong>time$</strong></font><font
 face="Arial"> (except the last field within </font><font face="Arial"><strong>time$</strong></font><font
 face="Arial">) are fixed length, it is easy to extract fields with the </font><a href="#Getting pieces out of a string:"><font
 face="Arial"><strong>mid$</strong></font></a><font face="Arial">-function.</font></p>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h2><a name="Peek and Poke"><font face="Arial">Peek and Poke</font></a></h2>
<p><font face="Arial"><strong>peek</strong></font><font face="Arial"> and </font><font
 face="Arial"><strong>poke</strong></font><font face="Arial"> are an interface 
to some of yabasics internals and allow to query and change yabasics states 
and behaviour. Unlike early homecomputers, you can't peek and poke around anywhere 
in memory; just a few predefined variants are allowed. An example would be:</font> 

<dl>
    <dd><font face="Arial">print peek$(&quot;infolevel&quot;)</font> 
    <pre><font face="Arial">poke &quot;infolevel&quot;,&quot;debug&quot;</font></pre>
</dl>
<p><font face="Arial">Which would print the current </font><a href="#infolevel"><font
 face="Arial">infolevel</font></a><font face="Arial"> and change it to &quot;debug&quot;.</font></p>
<p><font face="Arial">From this example you see: </font><font face="Arial"><strong>peek</strong></font><font
 face="Arial"> and </font><font face="Arial"><strong>poke</strong></font><font
 face="Arial"> accept string arguments (some </font><font face="Arial"><strong>poke</strong></font><font
 face="Arial">-commands except an integer argument too) and </font><font face="Arial"><strong>peek</strong></font><font
 face="Arial"> may return a string (in this case it appears as </font><font face="Arial"><strong>peek$</strong></font><font
 face="Arial">).</font></p>
<p><font face="Arial">Anyway there are few peek's and poke's right now, so they 
may be fully enumerated:</font> 
<dl>
    <dt><font face="Arial"><strong>peek$(&quot;infolevel&quot;)</strong></font> 
    
    <dd><font face="Arial">Gives back the current </font><a href="#infolevel"><font
     face="Arial">infolevel</font></a><font face="Arial">.</font> 
    <dt><font face="Arial"><strong>poke &quot;infolevel&quot;, &quot;error&quot;</strong></font> 
    
    <dd><font face="Arial">Sets the </font><a href="#infolevel"><font face="Arial">infolevel</font></a><font
     face="Arial"> to any of &quot;debug&quot;, &quot;note&quot;, &quot;warning&quot;, 
    &quot;error&quot; or &quot;fatal&quot;.</font> 
    <dt><font face="Arial"><b>poke &quot;dump&quot;,&quot;symbols&quot;</b></font> 
    
    <dd><font face="Arial">Dumps a list of all known variables (including those 
    within subroutines).</font> 
    <dt><font face="Arial"><b>poke &quot;dump&quot;,&quot;subroutines&quot;</b></font> 
    
    <dd><font face="Arial">Dumps the call stack, i.e. lists from which sub the 
    current sub was called, from which sub the calling sub was called and so 
    on.</font> 
    <dt><font face="Arial"><strong>peek(&quot;fontheight&quot;)</strong></font> 
    
    <dd><font face="Arial">Gives back the height in pixels of the font used 
    for graphic-text.</font> 
    <dt><font face="Arial"><strong>peek$(&quot;os&quot;)</strong></font> 
    <dd><font face="Arial">Gives back the </font><font face="Arial"><strong>o</strong></font><font
     face="Arial">perating </font><font face="Arial"><strong>s</strong></font><font
     face="Arial">ystem (either &quot;windows&quot; or &quot;unix&quot;)</font> 
    
    <dt><font face="Arial"><strong>poke &quot;textalign&quot;,&quot;cc&quot;</strong></font> 
    
    <dd><font face="Arial">This changes the way text is aligned with respect 
    to the point given within the </font><a href="#Graphics and printing"><font
     face="Arial"><strong>text</strong></font></a><font face="Arial">-command 
    (see there, for further explanation).</font> 
    <dt><font face="Arial"><strong>peek$(&quot;textalign&quot;)</strong></font> 
    
    <dd><font face="Arial">Gives back a string specifying the current mode of 
    text alignement; among possible return values are</font><font face="Arial"><strong> 
    &quot;cb&quot;</strong></font><font face="Arial">, </font><font face="Arial"><strong>&quot;rc&quot;</strong></font><font
     face="Arial">, </font><font face="Arial"><strong>&quot;cc&quot;</strong></font><font
     face="Arial">, ...</font> 
    <dt><font face="Arial"><strong>peek(&quot;version&quot;)</strong></font> 
    
    <dd><font face="Arial">This returns the version of yabasic (e.g. 2.47).</font> 
    
    <dt><font face="Arial"><strong>peek$(&quot;library&quot;)</strong></font> 
    
    <dd><font face="Arial">This returns the </font><a href="#Libraries"><font
     face="Arial">library</font></a><font face="Arial"> which contains the </font><font
     face="Arial"><strong>peek</strong></font><font face="Arial">. If called 
    from the yabasic program itself, it will return &quot;main&quot;.</font> 
    
    <dt><a name="Command line arguments"><font face="Arial"><strong>peek(&quot;argument&quot;)</strong></font></a><a
     name="Command line arguments"> </a>
    <dd><font face="Arial">Returns the number of arguments given to your yabasic-program. 
    This might be useful, if you call yabasic from the command-line only; let's 
    say you type</font><font face="Arial"><strong> yabasic test.yab 1 2 3</strong></font><font
     face="Arial">. This would start yabasic to execute the program test.yab; 
    within test.yab you could then query</font><font face="Arial"><strong> peek(&quot;argument&quot;) 
    </strong></font><font face="Arial">to get the number of arguments given 
    on the command line. In the example</font><font face="Arial"><strong> peek(&quot;argument&quot;) 
    </strong></font><font face="Arial">would return 3, because there are three 
    different arguments (&quot;1&quot;, &quot;2&quot; and &quot;3&quot;) on 
    the command line (the name of the program &quot;test.yab&quot; doesn't count 
    as an argument).<br> To retrieve the arguments, use</font><font face="Arial"><strong> 
    peek$(&quot;argument&quot;)</strong></font><font face="Arial">; every call 
    to</font><font face="Arial"><strong> peek$(&quot;argument&quot;) </strong></font><font
     face="Arial">reduces the value returned by</font><font face="Arial"><strong> 
    peek(&quot;argument&quot;) </strong></font><font face="Arial">by one.</font> 
    
    <dt><font face="Arial"><strong>peek$(&quot;argument&quot;)</strong></font> 
    
    <dd><font face="Arial">Every call to</font><font face="Arial"><strong> peek$(&quot;argument&quot;) 
    </strong></font><font face="Arial">returns one of the command-line arguments 
    handed to your yabasic program. E.g.: if you call</font><font face="Arial"><strong> 
    yabasic test.yab 1 2 3</strong></font><font face="Arial">, then the first 
    call to</font><font face="Arial"><strong> peek$(&quot;argument&quot;) </strong></font><font
     face="Arial">would return &quot;1&quot;, the second call would return &quot;2&quot;, 
    the third &quot;3&quot; and any further call would return an empty string 
    (&quot;&quot;).</font> 
    <dt><font face="Arial"><b>peek(&quot;read_controls&quot;)</b></font><font
     face="Arial"> </font>
    <dd>Returns 1 if an <b>input</b> statement will return nonprintable characters 
    (e.g. ctrl-a, ctrl-v, escape); returns 0 if nonprintable characters are 
    ignored. The initial value is 0 (i.e. nonprintable characters will be ignored). 
    
    <dt><font face="Arial"><b>poke &quot;read_controls&quot;,x</b></font><font
     face="Arial"> </font>
    <dd>Depending on the value of x (0 or 1) nonprintable characters will be 
    ignored (x=0) or returned (x=1) by any subsequent input statement. 
</dl>
<p><a name="binary"><font face="Arial">Yabasic offers limited support for processing 
binary files:</font></a> 
<ul>
    <dl>
        <dt><font face="Arial"><strong>peek(#1)</strong></font> 
        <dd><font face="Arial">This returns the next byte from the file #1 (#2 
        ... #9 are possible too of course).</font> Note that there are no quotes 
        around <b>#1</b>. 
        <dt><font face="Arial"><strong>poke #1,byte</strong></font> 
        <dd><font face="Arial">Writes the specified byte to file #1. </font><font
         face="Arial"><strong>byte</strong></font><font face="Arial"> can be 
        any number within the range 0...255</font> 
        <dt><font face="Arial"><strong>poke #1,string</strong></font> 
        <dd><font face="Arial">Writes the content of string$ to file #1.</font> 
        
    </dl>
</ul>
<blockquote><p><font face="Arial">These peek's and poke's for binary files should 
    not be mixed with normal file I/O through print and input (you might get 
    trouble with yabasic's internal buffering).<br> Additionally it is wise 
    to open such files with a </font><a href="#Opening a file"><font face="Arial">filemode</font></a><font
     face="Arial"> containing</font><font face="Arial"><strong> &quot;b&quot;</strong></font></p></blockquote>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h2><a name="More on print"><font face="Arial">Advanced printing: print at(),</font></a><a
 name="More on print"><font face="Arial"><strong> print colour and print using</strong></font></a></h2>
<p><font face="Arial">For interactive programs you might want to print output 
at specific locations. Try the next example:</font> 
<dl>
    <dd><font face="Arial">clear screen </font>
    <pre><font face="Arial">print at(10,5) &quot;1 -- Setup&quot; </font>
<font face="Arial">print at(10,7) &quot;2 -- Save&quot;</font>
<font face="Arial">print reverse at(10,9) &quot;3 -- Quit&quot; </font>
<font face="Arial">input at(5,12) &quot;Your choice: &quot; a$</font></pre>
</dl>
<p><font face="Arial">If you run this program, you will get a screen resembling 
the following layout (note that the third line will be displayed in reverse 
video):</font> 
<dl>
    <dd><font face="Arial">1 -- Setup </font>
    <pre><font face="Arial">2 -- Save </font>
<font face="Arial">3 -- Quit         </font><font face="Arial" size="3"><em>This line is displayed in reverse !</em></font>
<font face="Arial">Your choice:</font></pre>
</dl>
<p><font face="Arial">Note, that you should call </font><font face="Arial"><strong>clear 
screen</strong></font><font face="Arial"> before doing reverse printing. Afterwards, 
you may also use the </font><font face="Arial"><strong>at()</strong></font><font
 face="Arial">-clause in print or input-statements to move to any location (specified 
by the two arguments of the </font><font face="Arial"><strong>at()</strong></font><font
 face="Arial">-clause) on your screen. Note that </font><font face="Arial"><strong>at()</strong></font><font
 face="Arial"> can be written as </font><font face="Arial"><strong>@()</strong></font><font
 face="Arial"> too.</font></p>
<p><a name="colour"><font face="Arial">If you want colour you may try this program</font></a><font
 face="Arial">:</font></p>
<blockquote><pre><font face="Arial">rem Prepare everything</font>
<font face="Arial">clear screen</font>
<font face="Arial">dim c$(8)</font>
<font face="Arial">for a=1 to 8:read c$(a):next a </font>
&nbsp;
<font face="Arial">rem Print in various colors</font>
<font face="Arial">for a=1 to 8:for b=1 to 8</font>
<font face="Arial">print colour(c$(a),c$(b)) &quot; -- Hello -- &quot;;</font>
<font face="Arial">next b:next a</font>
&nbsp;
<font face="Arial">rem Move a rectangle over the screen</font>
<font face="Arial">a$=getscreen$(1,1,10,10)</font>
<font face="Arial">for a=1 to 100:putscreen a$ to a,a:next a</font>
&nbsp;
<font face="Arial">rem Available colors</font>
<font face="Arial">data &quot;black&quot;,&quot;white&quot;,&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;,&quot;yellow&quot;,&quot;magenta&quot;,&quot;cyan&quot;</font></pre></blockquote>
<p><font face="Arial">This program prints &quot;-- Hello --&quot; with the eight 
colours known to yabasic: black, white, red, blue, green, yellow, magenta and 
cyan. With the statement </font><font face="Arial"><strong>colour(f$,b$)</strong></font><font
 face="Arial"> (or </font><font face="Arial"><strong>color(f$,b$)</strong></font><font
 face="Arial">) you can choose the fore- and background colors for the following 
print-statement.</font></p>
<p><font face="Arial">The second part of the sample program moves a 10x10 rectangle 
of characters over the screen: The </font><font face="Arial"><strong>getscreen$(xfrom,yfrom,xto,yto)</strong></font><font
 face="Arial"> function, converts the contents of the specified screen rectangle 
to a string, which can be stored away in a string variable (</font><font face="Arial"><strong>a$ 
</strong></font><font face="Arial">in the example). Once you have retrieved 
such a screen rectangle, you may put it back to the screen at any location with 
the </font><font face="Arial"><strong>putscreen</strong></font><font face="Arial"> 
command.</font></p>
<p><font face="Arial">Since not all terminals have the same size (of course 
80x25 is the most common size), you might want to know what are the actual dimensions 
of your screen; There are two predefined variables for this purpose: The width 
of your screen can be retrieved though special </font><a href="#Peek and Poke"><font
 face="Arial">peek's</font></a><font face="Arial">: </font><font face="Arial"><strong>peek(&quot;screenwidth&quot;)</strong></font><font
 face="Arial"> returns the width of the screen (in characters), whereas </font><font
 face="Arial"><strong>peek(&quot;screenheight&quot;)</strong></font><font face="Arial"> 
returns the height. Both peeks have meaningful values only after the first call 
to </font><font face="Arial"><strong>clear screen</strong></font><font face="Arial">.</font></p>
<h3><a name="print using"><font face="Arial"><strong>print using</strong></font></a></h3>
<p><font face="Arial">To control the way numbers are printed, use the</font><font
 face="Arial"><strong> print using </strong></font><font face="Arial">statement: 
</font><font face="Arial"><strong>print 12.34 using &quot;###.####&quot;</strong></font><font
 face="Arial"> produces </font><font face="Arial"><strong>12.3400</strong></font><font
 face="Arial">. The format string (</font><font face="Arial"><strong>&quot;###.####&quot;</strong></font><font
 face="Arial">) consists of hashes (#) with one optional dot and it pictures 
the appearance of the number to print. Some examples:</font> 
<table border cellpadding="2" cellspacing="3">
    <tr>
        <th align="center"><p><font face="Arial">Command</font></th>
        <th align="center"><p><font face="Arial">Output</font></th>
        <th align="center"><p><font face="Arial">Remarks</font></th>
    </tr>
    <tr>
        <td><p><font face="Arial"><strong>print &quot;=&quot;,12.34 using &quot;###.####&quot;,&quot;=&quot;</strong></font></td>
        <td><p><font face="Arial"><strong>= 12.3400=</strong></font></td>
        <td><p><font face="Arial">The output is filled up with spaces (from 
            the left) and zeros (from the right) as the format requires.</font></td>
    </tr>
    <tr>
        <td><p><font face="Arial"><strong>print &quot;=&quot;,12.36 using ##.#,&quot;=&quot;</strong></font></td>
        <td><p><font face="Arial"><strong>=12.4=</strong></font></td>
        <td><p><font face="Arial">Last digit of output is rounded.</font></td>
    </tr>
    <tr>
        <td><p><font face="Arial"><strong>print &quot;=&quot;,12.34 using #.#,&quot;=&quot;</strong></font></td>
        <td><p><font face="Arial"><strong>=***=</strong></font></td>
        <td><p><font face="Arial">The number can not be formatted as required.</font></td>
    </tr>
</table>
<p><font face="Arial">This way of formatting is straightforward and simple, 
but not very flexible; e.g. it is not possible to print numbers left-aligned 
or with leading zeroes. To get such effects, the </font><font face="Arial"><strong>print 
using</strong></font><font face="Arial"> statement allows for format strings 
as used by the </font><font face="Arial"><strong>printf()</strong></font><font
 face="Arial">-function of the C-language. Some examples:</font> 
<table border cellpadding="2">
    <tr>
        <th align="center" valign="top"><p><font face="Arial">Print-statement</font></th>
        <th align="center"><p><font face="Arial">Output produced</font></th>
    </tr>
    <tr>
        <td><p><font face="Arial"><strong>print &quot;==&quot;,str$(12.123455,&quot;%08.3f&quot;),&quot;==&quot;</strong></font></td>
        <td><p><font face="Arial"><strong>==0012.123==</strong></font></td>
    </tr>
    <tr>
        <td><p><font face="Arial"><strong>print &quot;==&quot;,str$(12.123455,&quot;%8.2f&quot;),&quot;==&quot;</strong></font></td>
        <td><p><font face="Arial"><strong>== 12.12==</strong></font></td>
    </tr>
    <tr>
        <td><p><font face="Arial"><strong>print &quot;==&quot;,str$(12.123455,&quot;%-6.2f&quot;),&quot;==&quot;</strong></font></td>
        <td><p><font face="Arial"><strong>==12.12 ==</strong></font></td>
    </tr>
</table>
<p><font face="Arial">More about these formats can be found in any book on the 
C-language.</font></p>
<p><font face="Arial">All these formats can be used for the </font><a href="#strings to numbers (and reverse):"><font
 face="Arial"><strong>str$()</strong></font></a><a href="#strings to numbers (and reverse):"><font
 face="Arial">-function</font></a><font face="Arial"> too.</font></p>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h2><a name="Loose Ends"><font face="Arial">Loose Ends</font></a></h2>
<p><font face="Arial">Some properties of yabasic are still left to explain; 
here is a sample program, that employs them:</font> 
<dl>
    <dd><font face="Arial">10 beep </font>
    <pre><font face="Arial">pause 1 </font>
<font face="Arial">goto 10</font></pre>
</dl>
<p><font face="Arial">This program beeps once every second:</font> 
<ul type="disc">
    <li><font face="Arial"><strong>beep</strong></font><font face="Arial"> does 
    the beeping (can be written as </font><font face="Arial"><strong>bell</strong></font><font
     face="Arial"> too) and</font> 
    <li><font face="Arial"><strong>pause</strong></font><font face="Arial"> 
    does the waiting (can be written as </font><font face="Arial"><strong>wait</strong></font><font
     face="Arial"> too), its argument is the delay in seconds</font> 
</ul>
<p><a name="linenumber"><font face="Arial">Finally, the program employs a line 
number (</font></a><a name="linenumber"><font face="Arial"><strong>10</strong></font></a><a
 name="linenumber"><font face="Arial">) to mark a specific line; this feature 
makes yabasic more compatible with traditional basics. Line numbers are just 
special types of labels; they have the following properties:</font></a> 
<ul type="disc">
    <li><font face="Arial">Line numbers can appear only at the beginning of 
    a line.</font> 
    <li><font face="Arial">Not every line needs a number and line numbers need 
    not be consecutive.</font> 
    <li><font face="Arial">Line numbers can be used with the </font><font face="Arial"><strong>restore</strong></font><font
     face="Arial">-statement too.</font> 
</ul>
<h3><a name="Keyboard interrupts"><font face="Arial">Keyboard interrupts</font></a></h3>
<p><font face="Arial">A feature you might need is the ability to suppress keyboard-interrupts 
(i.e. pressing of </font><font face="Arial"><strong>Ctrl-C</strong></font><font
 face="Arial">); normally yabasic terminates immediately, if the user presses 
</font><font face="Arial"><strong>Ctrl-C</strong></font><font face="Arial">. 
This can be suppressed like this:</font> 
<dl>
    <dd><font face="Arial">on interrupt continue</font> 
</dl>
<p><font face="Arial">After processing of this statement keyboard interrupts 
are completely ignored. The default behaviour is restored with the command</font><font
 face="Arial"><strong> on interrupt break</strong></font><font face="Arial">.</font></p>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h1><a name="Index"><font face="Arial">Index</font></a></h1>
<h2><a name="Index of keywords"><font face="Arial">Index of keywords</font></a></h2>
<blockquote><p><a href="#Operators"><font face="Arial"><strong>+ - * / ^</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#print"><font face="Arial"><strong>?</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Printing at a Random Position"><font
     face="Arial"><strong>@</strong></font></a><font face="Arial"><strong> </strong></font><a href="#Multiple commands on one line"><font
     face="Arial"><strong>:</strong></font></a><font face="Arial"><strong> </strong></font><a href="#Reading and Writing"><font
     face="Arial"><strong>#</strong></font></a><font face="Arial"><strong> </strong></font><a href="#print"><font
     face="Arial"><strong>,</strong></font></a><font face="Arial"><strong> </strong></font><a href="#print"><font
     face="Arial"><strong>;</strong></font></a><font face="Arial"><strong><br> 
    <br> </strong></font><font face="Arial" size="4"><strong>A:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#Absolut values and signum"><font
     face="Arial"><strong>abs()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Trigonometric functions:"><font face="Arial"><strong>acos()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Making decisions"><font
     face="Arial"><strong>and</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Bitmanipulation:"><font face="Arial"><strong>and()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#More on Arrays"><font face="Arial"><strong>arraydim()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#More on Arrays"><font face="Arial"><strong>arraysize()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#The Ascii-Charset:"><font
     face="Arial"><strong>asc()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Trigonometric functions:"><font face="Arial"><strong>asin()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Printing at a Random Position"><font
     face="Arial"><strong>at()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Trigonometric functions:"><font face="Arial"><strong>atan()</strong></font></a><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>B:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#Loose Ends"><font face="Arial"><strong>beep</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Loose Ends"><font face="Arial"><strong>bell</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#hex"><font face="Arial"><strong>bin$()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Keyboard interrupts"><font
     face="Arial"><strong>break</strong></font></a><a href="#Keyboard interrupts"><font
     face="Arial"><strong><i> [keyboard interrupts]</i></strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#break and continue"><font
     face="Arial"><strong>break </strong></font></a><a href="#break and continue"><font
     face="Arial"><strong><i>[loop control]</i></strong></font></a><font face="Arial"><strong><br> 
    </strong></font><font face="Arial" size="4"><strong>C:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#switch"><font face="Arial"><strong>case</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#The Ascii-Charset:"><font
     face="Arial"><strong>chr$()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Graphics and printing"><font face="Arial"><strong>circle</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Graphics and printing"><font
     face="Arial"><strong>clear circle</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Some more graphics"><font face="Arial"><strong>clear 
    rect</strong></font></a><font face="Arial"><strong> </strong></font><a href="#Printing at a Random Position"><font
     face="Arial"><strong>clear screen</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Graphics and printing"><font face="Arial"><strong>clear 
    window</strong></font></a><font face="Arial"><strong> </strong></font><a href="#Opening a file"><font
     face="Arial"><strong>close</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#printing"><font face="Arial"><strong>close printer</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Graphics and printing"><font
     face="Arial"><strong>close window</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#colour"><font face="Arial"><strong>colour</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#colour"><font face="Arial"><strong>color</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Defining subroutines at runtime"><font
     face="Arial"><strong>compile</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Keyboard interrupts"><font face="Arial"><strong>continue</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Trigonometric functions:"><font
     face="Arial"><strong>cos()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#new line"><font face="Arial"><strong>curve</strong></font></a><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>D:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#date$ and time$"><font face="Arial"><strong>date$</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Reading Data"><font face="Arial"><strong>data</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#hex"><font face="Arial"><strong>dec()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Arrays"><font face="Arial"><strong>dim</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#repeat-while"><font face="Arial"><strong>do</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Libraries"><font face="Arial"><strong>doc</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Libraries"><font face="Arial"><strong>docu</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Libraries"><font face="Arial"><strong>docu$()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Graphics and printing"><font
     face="Arial"><strong>dot</strong></font></a><font face="Arial"><strong><br> 
    </strong></font><font face="Arial" size="4"><strong>E:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#Making decisions"><font
     face="Arial"><strong>else</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Making decisions"><font face="Arial"><strong>elsif</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#End of your program"><font
     face="Arial"><strong>end</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Making decisions"><font face="Arial"><strong>endif</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#User defined functions"><font
     face="Arial"><strong>end sub</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#End of File"><font face="Arial"><strong>eof()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Bitmanipulation:"><font
     face="Arial"><strong>eor()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#End of your program"><font face="Arial"><strong>error</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Exponentiation:"><font face="Arial"><strong>euler</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Defining subroutines at runtime"><font
     face="Arial"><strong>execute()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Defining subroutines at runtime"><font face="Arial"><strong>execute$()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#End of your program"><font
     face="Arial"><strong>exit</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Exponentiation:"><font face="Arial"><strong>exp()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Libraries"><font face="Arial"><strong>export</strong></font></a><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>F: 
    </strong></font><a href="#true and false"><font face="Arial"><strong>false</strong></font></a><font
     face="Arial" size="4"><strong> </strong></font><a href="#Note that endif"><font
     face="Arial"><strong>fi</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Graphics and printing"><font face="Arial"><strong>fill</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#for-next-loop"><font face="Arial"><strong>for</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Integer and fractional parts:"><font
     face="Arial"><strong>frac()</strong></font></a><font face="Arial"><strong><br> 
    </strong></font><font face="Arial" size="4"><strong>G:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#Bitmaps"><font face="Arial"><strong>getbit$()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#colour"><font face="Arial"><strong>getscreen$()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Globbing"><font face="Arial"><strong>glob()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Jumping around in your program"><font
     face="Arial"><strong>gosub</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Jumping around in your program"><font face="Arial"><strong>goto</strong></font></a><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>H:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#hex"><font face="Arial"><strong>hex$()</strong></font></a><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>I:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#Making decisions"><font
     face="Arial"><strong>if</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Libraries"><font face="Arial"><strong>import</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Getting a key from the keyboard"><font
     face="Arial"><strong>inkey$</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#input"><font face="Arial"><strong>input</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Printing at a Random Position"><font
     face="Arial"><strong>input at</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Reading and Writing"><font face="Arial"><strong>input 
    #</strong></font></a><font face="Arial"><strong> </strong></font><a href="#Finding strings in strings"><font
     face="Arial"><strong>instr()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Integer and fractional parts:"><font face="Arial"><strong>int()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Keyboard interrupts"><font
     face="Arial"><strong>interrupt</strong></font></a><font face="Arial"><strong><br> 
    </strong></font><font face="Arial" size="4"><strong>J:</strong></font><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>K:</strong></font><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>L:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#Marking locations in a program"><font
     face="Arial"><strong>label</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Getting pieces out of a string:"><font face="Arial"><strong>left$()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#for-next-loop"><font face="Arial"><strong>len()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Graphics and printing"><font
     face="Arial"><strong>line</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#More on input"><font face="Arial"><strong>line 
    input</strong></font></a><font face="Arial"><strong> </strong></font><a href="#new line"><font
     face="Arial"><strong>line to</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#User defined functions"><font face="Arial"><strong>local</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Exponentiation:"><font face="Arial"><strong>log()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#repeat-while"><font face="Arial"><strong>loop</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Changing the case of strings"><font
     face="Arial"><strong>lower$()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Removing spaces"><font face="Arial"><strong>ltrim$()</strong></font></a><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>M:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#map"><font face="Arial"><strong>map()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#map"><font face="Arial"><strong>mapx()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#map"><font face="Arial"><strong>mapy()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Minimum and Maximum:"><font
     face="Arial"><strong>max()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Getting pieces out of a string:"><font face="Arial"><strong>mid$()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Minimum and Maximum:"><font
     face="Arial"><strong>min()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Remainder"><font face="Arial"><strong>mod()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#mouse"><font face="Arial"><strong>mouseb</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#mouse"><font face="Arial"><strong>mousemod</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#mouse"><font face="Arial"><strong>mousex</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#mouse"><font face="Arial"><strong>mousey</strong></font></a><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>N:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#Some more graphics"><font
     face="Arial"><strong>new curve</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#for-next-loop"><font face="Arial"><strong>next</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Making decisions"><font
     face="Arial"><strong>not</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#numparams"><font face="Arial"><strong>numparams</strong></font></a><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>O:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#on gosub"><font face="Arial"><strong>on 
    gosub</strong></font></a><font face="Arial"><strong> </strong></font><a href="#on gosub"><font
     face="Arial"><strong>on goto</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Opening a file"><font face="Arial"><strong>open</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#printing"><font face="Arial"><strong>open 
    printer</strong></font></a><font face="Arial"><strong> </strong></font><a href="#Graphics and printing"><font
     face="Arial"><strong>open window</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Making decisions"><font face="Arial"><strong>or</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Bitmanipulation:"><font
     face="Arial"><strong>or()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#window origin"><font face="Arial"><strong>origin</strong></font></a><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>P:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#Loose Ends"><font face="Arial"><strong>pause</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Peek and Poke"><font face="Arial"><strong>peek</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Peek and Poke"><font face="Arial"><strong>peek$</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Trigonometric functions:"><font
     face="Arial"><strong>pi</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Peek and Poke"><font face="Arial"><strong>poke</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#print"><font face="Arial"><strong>print</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Printing at a Random Position"><font
     face="Arial"><strong>print at</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#print using"><font face="Arial"><strong>print 
    using</strong></font></a><font face="Arial"><strong> </strong></font><a href="#Reading and Writing"><font
     face="Arial"><strong>print #</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Graphics and printing"><font face="Arial"><strong>printer</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Bitmaps"><font face="Arial"><strong>putbit</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#colour"><font face="Arial"><strong>putscreen</strong></font></a><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>Q:</strong></font><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>R:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#Random numbers"><font face="Arial"><strong>ran()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Some more graphics"><font
     face="Arial"><strong>rectangle</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Reading Data"><font face="Arial"><strong>read</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#REM"><font face="Arial"><strong>rem</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#More on Arrays"><font face="Arial"><strong>redim</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#repeat-while"><font face="Arial"><strong>repeat</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Reading Data"><font face="Arial"><strong>restore</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Jumping around in your program"><font
     face="Arial"><strong>return</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Fancy Printing"><font face="Arial"><strong>reverse</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Getting pieces out of a string:"><font
     face="Arial"><strong>right$()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Finding strings in strings"><font face="Arial"><strong>rinstr()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Removing spaces"><font face="Arial"><strong>rtrim$()</strong></font></a><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>S: 
    </strong></font><a href="#Random access to files"><font face="Arial"><strong>seek()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Absolut values and signum"><font
     face="Arial"><strong>sig()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Trigonometric functions:"><font face="Arial"><strong>sin()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#User defined functions"><font
     face="Arial"><strong>static</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#for-next-loop"><font face="Arial"><strong>step</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Splitting a string into tokens"><font
     face="Arial"><strong>split()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#The square root"><font face="Arial"><strong>sqr()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#The square root"><font face="Arial"><strong>sqrt()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#strings to numbers (and reverse):"><font
     face="Arial"><strong>str$()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#User defined functions"><font face="Arial"><strong>sub</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#switch"><font face="Arial"><strong>switch</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#The system()-function"><font
     face="Arial"><strong>system()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#The system()-function"><font face="Arial"><strong>system$()</strong></font></a><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>T:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#Trigonometric functions:"><font
     face="Arial"><strong>tan()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Random access to files"><font face="Arial"><strong>tell</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Graphics and printing"><font
     face="Arial"><strong>text</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Making decisions"><font face="Arial"><strong>then</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#date$ and time$"><font face="Arial"><strong>time$</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#for-next-loop"><font face="Arial"><strong>to</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Splitting a string into tokens"><font
     face="Arial"><strong>token()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Removing spaces"><font face="Arial"><strong>trim$()</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#true and false"><font face="Arial"><strong>true</strong></font></a><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>U:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#repeat-while"><font face="Arial"><strong>until</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Changing the case of strings"><font
     face="Arial"><strong>upper$()</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#print using"><font face="Arial"><strong>using</strong></font></a><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>V:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#Getting pieces out of a string:"><font
     face="Arial"><strong>val()</strong></font></a><font face="Arial"><strong><br> 
    </strong></font><font face="Arial" size="4"><strong>W:</strong></font><font
     face="Arial"><strong> </strong></font><a href="#Loose Ends"><font face="Arial"><strong>wait</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#repeat-while"><font face="Arial"><strong>wend</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#repeat-while"><font face="Arial"><strong>while</strong></font></a><font
     face="Arial"><strong> </strong></font><a href="#Graphics and printing"><font
     face="Arial"><strong>window</strong></font></a><font face="Arial"><strong> 
    </strong></font><a href="#Some more graphics"><font face="Arial"><strong>window 
    origin</strong></font></a><font face="Arial"><strong><br> </strong></font><font
     face="Arial" size="4"><strong>X:</strong></font><font face="Arial"><strong> 
    </strong></font><a href="#Bitmanipulation:"><font face="Arial"><strong>xor()</strong></font></a><font
     face="Arial"><strong><br> </strong></font><font face="Arial" size="4"><strong>Y:</strong></font><font
     face="Arial"><strong> <br> </strong></font><font face="Arial" size="4"><strong>Z:</strong></font></p></blockquote>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h2><a name="Index of concepts"><font face="Arial">Index of concepts</font></a></h2>
<blockquote><p><a href="#Arrays"><font face="Arial">Arrays</font></a><font face="Arial"><br> 
    </font><a href="#binary"><font face="Arial">Binary files</font></a><font
     face="Arial"><br> </font><a href="#Bitmanipulation:"><font face="Arial">Bitmanipulation</font></a><font
     face="Arial"><br> </font><a href="#Case"><font face="Arial">Case of Keywords 
    and Variables</font></a><font face="Arial"><br> </font><a href="#Command line arguments"><font
     face="Arial">Command line arguments</font></a><font face="Arial"><br> </font><a href="#Conditions"><font
     face="Arial">Conditions in the </font></a><a href="#Conditions"><font face="Arial"><strong>if</strong></font></a><a href="#Conditions"><font
     face="Arial">-statement</font></a><font face="Arial"><br> </font><a href="#Escape-sequences"><font
     face="Arial">Escape Sequences within strings</font></a><font face="Arial"><br> 
    </font><a href="#print using"><font face="Arial">Formatting numbers</font></a><font
     face="Arial"><br> </font><a href="#inkey$-statement"><font face="Arial">Getting 
    mouse input</font></a><font face="Arial"><br> </font><a href="#Globbing"><font
     face="Arial">Globbing</font></a><font face="Arial"><br> </font><a href="#More on input"><font
     face="Arial">How the </font></a><a href="#More on input"><font face="Arial"><strong>input</strong></font></a><a href="#More on input"><font
     face="Arial">-statement chops a line into pieces</font></a><font face="Arial"><br> 
    </font><a href="#Keyboard interrupts"><font face="Arial">Keyboard interrupts</font></a><font
     face="Arial"><br> </font><a href="#linenumber"><font face="Arial">Line 
    numbers</font></a><font face="Arial"><br> </font><a href="#Multiple commands on one line"><font
     face="Arial">Multiple commands in one line</font></a><font face="Arial"><br> 
    </font><a href="#lineprinting"><font face="Arial">Printing Text</font></a><font
     face="Arial"><br> </font><a href="#Random access to files"><font face="Arial">Random 
    access to files</font></a><font face="Arial"><br> </font><a href="#Specifying Window-pathnames"><font
     face="Arial">Specifying Windows-pathnames</font></a><font face="Arial"><br> 
    </font><a href="#Variables"><font face="Arial">Variables</font></a></p></blockquote>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<h1><a name="internals"><font face="Arial">Internals </font></a></h1>
<h2><font face="Arial">History</font></h2>
<p><font face="Arial">Yabasic started sometime around eastern 1995; a first 
version was completed about one month later, still missing many features. After 
this quick start a long period of adding features and squashing bugs followed, 
which has more or less persisted until today. </font></p>
<p><font face="Arial">The only interruption during those peaceful days came 
in the summer of 1996, when I got my Windows95-machine: Porting yabasic took 
two weeks and writing an installation program took me a month.</font></p>
<h2><font face="Arial">Flex and Bison</font></h2>
<p><font face="Arial">You may have noticed from the previous section, that yabasic 
made quite a rapid start; this is mainly due to </font><font face="Arial"><strong>flex 
</strong></font><font face="Arial">and </font><font face="Arial"><strong>bison</strong></font><font
 face="Arial">, the prime tools, used to implement yabasic.</font></p>
<p><font face="Arial">Bison and flex take the grammar and produce a C-program, 
which implements this grammar. The only thing left to the programmer is to put 
flesh on this skeleton.</font></p>
<p><font face="Arial">This process is remarkably efficient: 17 KBytes of flex 
and bison instructions generate 129 KBytes of C-code, which has to be compared 
with the 108 KBytes of C-code which I wrote. Together these implement the functionality 
of yabasic. So actually most of the code has been generated by flex and bison 
!</font></p>
<h2><font face="Arial">Execution of a program</font></h2>
<p><font face="Arial">Although yabasic behaves mostly like an interpreter, in 
fact it is not. Rather it's a compiler: If you give it any basic-code for execution, 
the code is compiled, yielding instructions for a simple stack-machine; these 
instructions are then interpreted immediately, so that you will never get in 
touch with the stack-machine. You can find out the time needed for this process 
if you invoke yabasic with infolevel set to </font><font face="Arial"><strong>note</strong></font><font
 face="Arial">.</font></p>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
<p><hr width="454"> </p>
<p>&nbsp;</p>
<h1><a name="copy"><font face="Arial">Copyright </font></a></h1>
<p><font face="Arial">Yabasic may be copied only under the terms of either the 
</font><a href="http://www.yabasic.de/artistic.htm"><font face="Arial">Artistic 
License</font></a><font face="Arial"> or the </font><a href="http://www.yabasic.de/gpl.htm"><font
 face="Arial">GNU General Public License</font></a><font face="Arial"> (GPL).</font></p>
<p><font face="Arial">Earlier versions of yabasic have been subject to the GPL 
alone and it is kept for backward compatibility. Since version 2.60 you have 
the </font><font face="Arial"><strong>choice</strong></font><font face="Arial"> 
to use yabasic under the terms of the Artistic License, which gives you the 
right to </font><font face="Arial"><strong>use and distribute yabasic in a more-or-less 
customary fashion</strong></font><font face="Arial">, plus the right to make 
reasonable modifications, while giving the original author some semblance of 
</font><font face="Arial"><strong>artistic control</strong></font><font face="Arial"> 
over the development of yabasic.</font></p>
<p><font face="Arial">Regardless which license you choose (GPL or Artistic) 
for yabasic, it does not apply to your own </font><font face="Arial"><strong>yabasic-programs</strong></font><font
 face="Arial">. The programs you write are </font><font face="Arial"><strong>your 
own work</strong></font><font face="Arial"> and you may use </font><font face="Arial"><strong>any 
license</strong></font><font face="Arial"> you like.</font></p>
<p><font face="Arial">Finally some examples of what is possible under the terms 
of the Artistic License:</font> 
<ul type="disc">
    <li><font face="Arial">Put yabasic on your own </font><font face="Arial"><strong>webpage</strong></font><font
     face="Arial">, </font><font face="Arial"><strong>CD</strong></font><font
     face="Arial"> or other medium, </font><font face="Arial"><strong>charge</strong></font><font
     face="Arial"> for the service of distibuting yabasic.</font> 
    <li><font face="Arial">Write your own </font><font face="Arial"><strong>yabasic-programs</strong></font><font
     face="Arial">, put yabasic itself into the package and </font><font face="Arial"><strong>sell</strong></font><font
     face="Arial"> the whole thing. &quot;</font><font face="Arial"><strong>Sell</strong></font><font
     face="Arial">&quot; is more than charging for distribution costs and time: 
    You may </font><font face="Arial"><strong>make real profit</strong></font><font
     face="Arial"> with your own programs.</font> 
    <li><font face="Arial"><strong>Modify yabasic</strong></font><font face="Arial">, 
    add or remove features and capabilities, </font><font face="Arial"><strong>sell</strong></font><font
     face="Arial"> the modified version.</font> 
</ul>
<p><font face="Arial">If you are still in doubt, please check out the licenses 
above.</font></p>
<p><a href="#Description of yabasic"><font face="Arial">Back to table of contents 
...</font></a></p>
</body>

</html>