Mercurial > hg > Members > kono > nitros9-code
comparison docs/basic09/basic09.docbook @ 649:28d9e5a4ef52 Revision_F
XMLified
author | roug |
---|---|
date | Wed, 11 Dec 2002 20:41:50 +0000 |
parents | 30480200b0f1 |
children | 07a25643d033 |
comparison
equal
deleted
inserted
replaced
648:f9c66ad345d1 | 649:28d9e5a4ef52 |
---|---|
1 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [ | 1 <?xml version="1.0" ?> |
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" | |
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [ | |
2 <!ENTITY b09 "BASIC09"> | 4 <!ENTITY b09 "BASIC09"> |
3 <!ENTITY minus "-"> | 5 <!ENTITY mdash "—"> |
4 ]> | 6 ]> |
5 <book id="basic09" lang="en"> | 7 <book id="basic09" lang="en"> |
6 <bookinfo> | 8 <bookinfo> |
7 <title>&b09;</title> | 9 <title>&b09;</title> |
8 <subtitle>Programming Language Reference Manual</subtitle> | 10 <subtitle>Programming Language Reference Manual</subtitle> |
845 current working name if a name is omitted. These commands change | 847 current working name if a name is omitted. These commands change |
846 the mode of &b09; by exiting the command mode and entering another mode. | 848 the mode of &b09; by exiting the command mode and entering another mode. |
847 These commands are: | 849 These commands are: |
848 <informaltable frame="none"> | 850 <informaltable frame="none"> |
849 <tgroup cols="2"> | 851 <tgroup cols="2"> |
850 <colspec colwidth="1in"> | 852 <colspec colwidth="1in"/> |
851 <tbody> | 853 <tbody> |
852 <row> | 854 <row> |
853 <entry>RUN</entry> | 855 <entry>RUN</entry> |
854 <entry>which enters Execution Mode to run a procedure</entry> | 856 <entry>which enters Execution Mode to run a procedure</entry> |
855 </row> | 857 </row> |
870 order to precisely describe their formats, the syntax notation shown below | 872 order to precisely describe their formats, the syntax notation shown below |
871 is used. | 873 is used. |
872 | 874 |
873 <informaltable frame="none"> | 875 <informaltable frame="none"> |
874 <tgroup cols="2"> | 876 <tgroup cols="2"> |
875 <colspec colwidth="1.3in"> | 877 <colspec colwidth="1.3in"/> |
876 <tbody> | 878 <tbody> |
877 <row> | 879 <row> |
878 <entry>[ ]</entry> | 880 <entry>[ ]</entry> |
879 <entry>things in brackets are optional.</entry> | 881 <entry>things in brackets are optional.</entry> |
880 </row> | 882 </row> |
982 They have completely different functions. | 984 They have completely different functions. |
983 </para> | 985 </para> |
984 | 986 |
985 <cmdsynopsis> | 987 <cmdsynopsis> |
986 <command>EDIT [<procname>]</command> | 988 <command>EDIT [<procname>]</command> |
987 <sbr> | 989 <sbr/> |
988 <command>E [<procname>]</command> | 990 <command>E [<procname>]</command> |
989 </cmdsynopsis> | 991 </cmdsynopsis> |
990 <para> | 992 <para> |
991 | 993 |
992 Exits command mode and enters the text editor/compiler mode. If the specified | 994 Exits command mode and enters the text editor/compiler mode. If the specified |
1003 </informalexample> | 1005 </informalexample> |
1004 | 1006 |
1005 </para> | 1007 </para> |
1006 <cmdsynopsis> | 1008 <cmdsynopsis> |
1007 <command>KILL [<procname> {,<procname>}]</command> | 1009 <command>KILL [<procname> {,<procname>}]</command> |
1008 <sbr> | 1010 <sbr/> |
1009 <command>KILL*</command> | 1011 <command>KILL*</command> |
1010 </cmdsynopsis> | 1012 </cmdsynopsis> |
1011 <para> | 1013 <para> |
1012 Erases the procedure(s) specified. KILL* clears the | 1014 Erases the procedure(s) specified. KILL* clears the |
1013 entire workspace. The process may take some time if there are many | 1015 entire workspace. The process may take some time if there are many |
1024 </informalexample> | 1026 </informalexample> |
1025 </para> | 1027 </para> |
1026 | 1028 |
1027 <cmdsynopsis> | 1029 <cmdsynopsis> |
1028 <command>LIST [<procname> {,<procname>}] [> <pathlist>]</command> | 1030 <command>LIST [<procname> {,<procname>}] [> <pathlist>]</command> |
1029 <sbr> | 1031 <sbr/> |
1030 <command>LIST* [<pathlist>]</command> | 1032 <command>LIST* [<pathlist>]</command> |
1031 </cmdsynopsis> | 1033 </cmdsynopsis> |
1032 <para> | 1034 <para> |
1033 Prints a formatted "pretty printed" listing of one or more procedures. | 1035 Prints a formatted "pretty printed" listing of one or more procedures. |
1034 The listing includes | 1036 The listing includes |
1091 </informalexample> | 1093 </informalexample> |
1092 | 1094 |
1093 </para> | 1095 </para> |
1094 <cmdsynopsis> | 1096 <cmdsynopsis> |
1095 <command>MEM</command> | 1097 <command>MEM</command> |
1096 <sbr> | 1098 <sbr/> |
1097 <command>MEM [<number>]</command> | 1099 <command>MEM [<number>]</command> |
1098 </cmdsynopsis> | 1100 </cmdsynopsis> |
1099 <para> | 1101 <para> |
1100 MEM used without a number displays the present total workspace size in | 1102 MEM used without a number displays the present total workspace size in |
1101 (decimal) bytes. If a number is given, &b09; asks OS-9 to expand or | 1103 (decimal) bytes. If a number is given, &b09; asks OS-9 to expand or |
1115 </informalexample> | 1117 </informalexample> |
1116 | 1118 |
1117 </para> | 1119 </para> |
1118 <cmdsynopsis> | 1120 <cmdsynopsis> |
1119 <command>PACK [<procname> {,<procname>}] [> <pathlist>]</command> | 1121 <command>PACK [<procname> {,<procname>}] [> <pathlist>]</command> |
1120 <sbr> | 1122 <sbr/> |
1121 <command>PACK* [<pathlist>]</command> | 1123 <command>PACK* [<pathlist>]</command> |
1122 </cmdsynopsis> | 1124 </cmdsynopsis> |
1123 <para> | 1125 <para> |
1124 This command | 1126 This command |
1125 causes an extra compiler pass on the procedure(s) specified, which | 1127 causes an extra compiler pass on the procedure(s) specified, which |
1139 to run it later. Here is an example sequence that demonstrates packing a | 1141 to run it later. Here is an example sequence that demonstrates packing a |
1140 procedure: | 1142 procedure: |
1141 | 1143 |
1142 <informaltable frame="none"> | 1144 <informaltable frame="none"> |
1143 <tgroup cols="2"> | 1145 <tgroup cols="2"> |
1144 <colspec colwidth="2in"> | 1146 <colspec colwidth="2in"/> |
1145 <tbody> | 1147 <tbody> |
1146 <row> | 1148 <row> |
1147 <entry>pack sort</entry> | 1149 <entry>pack sort</entry> |
1148 <entry>packs procedure sort and creates a file</entry> | 1150 <entry>packs procedure sort and creates a file</entry> |
1149 </row> | 1151 </row> |
1234 </informalexample> | 1236 </informalexample> |
1235 </para> | 1237 </para> |
1236 | 1238 |
1237 <cmdsynopsis> | 1239 <cmdsynopsis> |
1238 <command>SAVE [<procname> { <procname>} [> <pathlist>]]</command> | 1240 <command>SAVE [<procname> { <procname>} [> <pathlist>]]</command> |
1239 <sbr> | 1241 <sbr/> |
1240 <command>SAVE* [<pathlist>]</command> | 1242 <command>SAVE* [<pathlist>]</command> |
1241 </cmdsynopsis> | 1243 </cmdsynopsis> |
1242 <para> | 1244 <para> |
1243 Writes the procedure(s) (or all procedures) to an output | 1245 Writes the procedure(s) (or all procedures) to an output |
1244 file or device in source format. SAVE is similar to the LIST command | 1246 file or device in source format. SAVE is similar to the LIST command |
1305 in detail later in this chapter. | 1307 in detail later in this chapter. |
1306 | 1308 |
1307 <table frame="none"> | 1309 <table frame="none"> |
1308 <title>Edit Mode Commands</title> | 1310 <title>Edit Mode Commands</title> |
1309 <tgroup cols="2"> | 1311 <tgroup cols="2"> |
1310 <colspec colwidth="2in"> | 1312 <colspec colwidth="2in"/> |
1311 <tbody> | 1313 <tbody> |
1312 <row> | 1314 <row> |
1313 <entry><cr></entry> | 1315 <entry><cr></entry> |
1314 <entry>move edit pointer forward</entry> | 1316 <entry>move edit pointer forward</entry> |
1315 </row> | 1317 </row> |
1320 <row> | 1322 <row> |
1321 <entry>+*</entry> | 1323 <entry>+*</entry> |
1322 <entry>move edit pointer to end of text</entry> | 1324 <entry>move edit pointer to end of text</entry> |
1323 </row> | 1325 </row> |
1324 <row> | 1326 <row> |
1325 <entry>−</entry> | 1327 <entry>-</entry> |
1326 <entry>move edit pointer backward</entry> | 1328 <entry>move edit pointer backward</entry> |
1327 </row> | 1329 </row> |
1328 <row> | 1330 <row> |
1329 <entry>−*</entry> | 1331 <entry>-*</entry> |
1330 <entry>move edit pointer to beginning of text</entry> | 1332 <entry>move edit pointer to beginning of text</entry> |
1331 </row> | 1333 </row> |
1332 <row> | 1334 <row> |
1333 <entry><space> <text></entry> | 1335 <entry><space> <text></entry> |
1334 <entry>insert unnumbered line</entry> | 1336 <entry>insert unnumbered line</entry> |
1465 <para> | 1467 <para> |
1466 The line-number oriented commands are: | 1468 The line-number oriented commands are: |
1467 | 1469 |
1468 <informaltable frame="none"> | 1470 <informaltable frame="none"> |
1469 <tgroup cols="2"> | 1471 <tgroup cols="2"> |
1470 <colspec colwidth="2in"> | 1472 <colspec colwidth="2in"/> |
1471 <tbody> | 1473 <tbody> |
1472 <row> | 1474 <row> |
1473 <entry><line#> <text></entry> | 1475 <entry><line#> <text></entry> |
1474 <entry>insert or replace numbered line</entry> | 1476 <entry>insert or replace numbered line</entry> |
1475 </row> | 1477 </row> |
1540 "*" at the left side of the program line where the edit pointer is | 1542 "*" at the left side of the program line where the edit pointer is |
1541 presently located. | 1543 presently located. |
1542 </para> | 1544 </para> |
1543 <sect2><title>Moving the Edit Pointer</title> | 1545 <sect2><title>Moving the Edit Pointer</title> |
1544 <para> | 1546 <para> |
1545 The "+" and "−" are used to reposition the edit pointer: | 1547 The "+" and "-" are used to reposition the edit pointer: |
1546 | 1548 |
1547 <informaltable frame="none"> | 1549 <informaltable frame="none"> |
1548 <tgroup cols="2"> | 1550 <tgroup cols="2"> |
1549 <colspec colwidth="2in"> | 1551 <colspec colwidth="2in"/> |
1550 <tbody> | 1552 <tbody> |
1551 <row> | 1553 <row> |
1552 <entry>−</entry> | 1554 <entry>-</entry> |
1553 <entry>moves backward one line</entry> | 1555 <entry>moves backward one line</entry> |
1554 </row> | 1556 </row> |
1555 <row> | 1557 <row> |
1556 <entry>− <number></entry> | 1558 <entry>- <number></entry> |
1557 <entry>moves backward n lines</entry> | 1559 <entry>moves backward n lines</entry> |
1558 </row> | 1560 </row> |
1559 <row> | 1561 <row> |
1560 <entry>−*</entry> | 1562 <entry>-*</entry> |
1561 <entry>moves to the beginning of the procedure</entry> | 1563 <entry>moves to the beginning of the procedure</entry> |
1562 </row> | 1564 </row> |
1563 <row> | 1565 <row> |
1564 <entry>+</entry> | 1566 <entry>+</entry> |
1565 <entry>moves forward one line</entry> | 1567 <entry>moves forward one line</entry> |
1610 | 1612 |
1611 The first form deletes the <number> of lines starting at the current edit | 1613 The first form deletes the <number> of lines starting at the current edit |
1612 pointer location. | 1614 pointer location. |
1613 The second form deletes ALL lines in the procedure (caution!). | 1615 The second form deletes ALL lines in the procedure (caution!). |
1614 The editor accepts | 1616 The editor accepts |
1615 "+*" and "−*" to mean to the end, or to the beginning of the procedure | 1617 "+*" and "-*" to mean to the end, or to the beginning of the procedure |
1616 respectively. If the number is negative, that many lines BEFORE the | 1618 respectively. If the number is negative, that many lines BEFORE the |
1617 current line is deleted. | 1619 current line is deleted. |
1618 If a line number is omitted, only the current line is deleted. | 1620 If a line number is omitted, only the current line is deleted. |
1619 </para></sect2> | 1621 </para></sect2> |
1620 <sect2><title>Listing Lines</title> | 1622 <sect2><title>Listing Lines</title> |
1813 passed following the pathname specified. For | 1815 passed following the pathname specified. For |
1814 example, the following OS-9 command lines use this feature: | 1816 example, the following OS-9 command lines use this feature: |
1815 | 1817 |
1816 <programlisting> | 1818 <programlisting> |
1817 OS9: &b09; printreport("Past Due Accounts") | 1819 OS9: &b09; printreport("Past Due Accounts") |
1818 OS9: &b09; evaluate(COS(7.8814)/12.075,−22.5,129.055) | 1820 OS9: &b09; evaluate(COS(7.8814)/12.075,-22.5,129.055) |
1819 </programlisting> | 1821 </programlisting> |
1820 | 1822 |
1821 </para> | 1823 </para> |
1822 </sect1> | 1824 </sect1> |
1823 </chapter> | 1825 </chapter> |
1936 programs suspended by Control-C, PAUSE statements, BREAK command | 1938 programs suspended by Control-C, PAUSE statements, BREAK command |
1937 breakpoints, or after non-fatal run-time errors. | 1939 breakpoints, or after non-fatal run-time errors. |
1938 | 1940 |
1939 <cmdsynopsis> | 1941 <cmdsynopsis> |
1940 <command>DEG</command> | 1942 <command>DEG</command> |
1941 <sbr> | 1943 <sbr/> |
1942 <command>RAD</command> | 1944 <command>RAD</command> |
1943 </cmdsynopsis> | 1945 </cmdsynopsis> |
1944 These commands select either degrees or radians as the angle unit | 1946 These commands select either degrees or radians as the angle unit |
1945 measure used by trigonometric functions. These commands only affect | 1947 measure used by trigonometric functions. These commands only affect |
1946 the procedure currently being debugged or run. | 1948 the procedure currently being debugged or run. |
2028 once, so the statement that appears to be the top of the loop is actually | 2030 once, so the statement that appears to be the top of the loop is actually |
2029 the one following the "FOR" statement. | 2031 the one following the "FOR" statement. |
2030 | 2032 |
2031 <cmdsynopsis> | 2033 <cmdsynopsis> |
2032 <command>TRON</command> | 2034 <command>TRON</command> |
2033 <sbr> | 2035 <sbr/> |
2034 <command>TROFF</command> | 2036 <command>TROFF</command> |
2035 </cmdsynopsis> | 2037 </cmdsynopsis> |
2036 These commands turn the suspended procedure's trace mode on and off. In | 2038 These commands turn the suspended procedure's trace mode on and off. In |
2037 trace mode, the compiled code of each equivalent statement line is | 2039 trace mode, the compiled code of each equivalent statement line is |
2038 reconstructed to source statements and displayed before the statement | 2040 reconstructed to source statements and displayed before the statement |
2210 overview of the characteristics of each type: | 2212 overview of the characteristics of each type: |
2211 | 2213 |
2212 <table frame="none"> | 2214 <table frame="none"> |
2213 <title>&b09; Atomic Data Type Summary</title> | 2215 <title>&b09; Atomic Data Type Summary</title> |
2214 <tgroup cols="3"> | 2216 <tgroup cols="3"> |
2215 <colspec colwidth="1.2in"> | 2217 <colspec colwidth="1.2in"/> |
2216 <colspec colwidth="2.1in"> | 2218 <colspec colwidth="2.1in"/> |
2217 <thead> | 2219 <thead> |
2218 <row> | 2220 <row> |
2219 <entry>Type:</entry> | 2221 <entry>Type:</entry> |
2220 <entry>Allowable values:</entry> | 2222 <entry>Allowable values:</entry> |
2221 <entry>Memory requirement:</entry> | 2223 <entry>Memory requirement:</entry> |
2227 <entry>Whole Numbers 0 to 255</entry> | 2229 <entry>Whole Numbers 0 to 255</entry> |
2228 <entry>One byte</entry> | 2230 <entry>One byte</entry> |
2229 </row> | 2231 </row> |
2230 <row> | 2232 <row> |
2231 <entry>INTEGER</entry> | 2233 <entry>INTEGER</entry> |
2232 <entry>Whole Numbers 32768 to 32767</entry> | 2234 <entry>Whole Numbers -32768 to 32767</entry> |
2233 <entry>Two bytes</entry> | 2235 <entry>Two bytes</entry> |
2234 </row> | 2236 </row> |
2235 <row> | 2237 <row> |
2236 <entry>REAL</entry> | 2238 <entry>REAL</entry> |
2237 <entry>Floating Point +/ 1*10^38</entry> | 2239 <entry>Floating Point +/- 1*10^38</entry> |
2238 <entry>Five bytes</entry> | 2240 <entry>Five bytes</entry> |
2239 </row> | 2241 </row> |
2240 <row> | 2242 <row> |
2241 <entry>STRING</entry> | 2243 <entry>STRING</entry> |
2242 <entry>Letters, digits, punctuation</entry> | 2244 <entry>Letters, digits, punctuation</entry> |
2276 | 2278 |
2277 </para></sect2> | 2279 </para></sect2> |
2278 <sect2><title>Type INTEGER</title> | 2280 <sect2><title>Type INTEGER</title> |
2279 <para> | 2281 <para> |
2280 INTEGER variables consist of two bytes of storage, and hold a | 2282 INTEGER variables consist of two bytes of storage, and hold a |
2281 numeric value in the range 32768 through 32767 as | 2283 numeric value in the range -32768 through 32767 as |
2282 signed 16-bit data. Decimal points are not allowed. INTEGER constants | 2284 signed 16-bit data. Decimal points are not allowed. INTEGER constants |
2283 may also be represented as hexadecimal values in the range $0000 | 2285 may also be represented as hexadecimal values in the range $0000 |
2284 through $FFFF to facilitate address calculations. INTEGER values | 2286 through $FFFF to facilitate address calculations. INTEGER values |
2285 are printed without a decimal point. INTEGER arithmetic is faster and | 2287 are printed without a decimal point. INTEGER arithmetic is faster and |
2286 requires less storage than REAL values. | 2288 requires less storage than REAL values. |
2287 </para> | 2289 </para> |
2288 <para> | 2290 <para> |
2289 Arithmetic which results in values outside the INTEGER range does not | 2291 Arithmetic which results in values outside the INTEGER range does not |
2290 cause run-time errors but instead "wraps around" modulo 65536; i.e., | 2292 cause run-time errors but instead "wraps around" modulo 65536; i.e., |
2291 32767 + 1 yields −32768. Division of an integer by another integer | 2293 32767 + 1 yields -32768. Division of an integer by another integer |
2292 yields an integer result, and any remainder is discarded. The programmer | 2294 yields an integer result, and any remainder is discarded. The programmer |
2293 should be aware that numeric comparisons made on values in the range | 2295 should be aware that numeric comparisons made on values in the range |
2294 32767 through 65535 will actually be dealing with negative numbers, | 2296 32767 through 65535 will actually be dealing with negative numbers, |
2295 so it may be desirable to limit such comparisons to tests for equality | 2297 so it may be desirable to limit such comparisons to tests for equality |
2296 or non-equality. Additionally, certain functions (LAND, LNOT, LOR, LXOR) | 2298 or non-equality. Additionally, certain functions (LAND, LNOT, LOR, LXOR) |
2322 </literallayout> | 2324 </literallayout> |
2323 </figure> | 2325 </figure> |
2324 | 2326 |
2325 </para> | 2327 </para> |
2326 <para> | 2328 <para> |
2327 The exponent covers the range 2.938735877 * 10^−39 (2^−128) | 2329 The exponent covers the range 2.938735877 * 10^-39 (2^-128) |
2328 through 1.701411835 * 10^38 (2^127) as powers of 2. Operations which | 2330 through 1.701411835 * 10^38 (2^127) as powers of 2. Operations which |
2329 result in values out of the representation range cause overflow or | 2331 result in values out of the representation range cause overflow or |
2330 underflow errors (which may be handled automatically by the ON ERROR | 2332 underflow errors (which may be handled automatically by the ON ERROR |
2331 command). The mantissa covers the range from 0.5 through .9999999995 | 2333 command). The mantissa covers the range from 0.5 through .9999999995 |
2332 in steps of 2^-31. This means that REAL numbers can represent values | 2334 in steps of 2^-31. This means that REAL numbers can represent values |
2453 <row> | 2455 <row> |
2454 <entry>1.0</entry> | 2456 <entry>1.0</entry> |
2455 <entry>9.8433218</entry> | 2457 <entry>9.8433218</entry> |
2456 </row> | 2458 </row> |
2457 <row> | 2459 <row> |
2458 <entry>−.01</entry> | 2460 <entry>-.01</entry> |
2459 <entry>−999.000099</entry> | 2461 <entry>-999.000099</entry> |
2460 </row> | 2462 </row> |
2461 <row> | 2463 <row> |
2462 <entry>100000000</entry> | 2464 <entry>100000000</entry> |
2463 <entry>5655.34532</entry> | 2465 <entry>5655.34532</entry> |
2464 </row> | 2466 </row> |
2465 <row> | 2467 <row> |
2466 <entry>1.95E+12</entry> | 2468 <entry>1.95E+12</entry> |
2467 <entry>−99999.9E-33</entry> | 2469 <entry>-99999.9E-33</entry> |
2468 </row> | 2470 </row> |
2469 </tbody> | 2471 </tbody> |
2470 </tgroup> | 2472 </tgroup> |
2471 </informaltable> | 2473 </informaltable> |
2472 | 2474 |
2473 | 2475 |
2474 </para> | 2476 </para> |
2475 <para> | 2477 <para> |
2476 | 2478 |
2477 Numbers that do not have a decimal point and are in the range of | 2479 Numbers that do not have a decimal point and are in the range of |
2478 32768 to +32767 are treated as INTEGER numbers. | 2480 -32768 to +32767 are treated as INTEGER numbers. |
2479 &b09; will also accept integer constants in hexadecimal in the range 0 to | 2481 &b09; will also accept integer constants in hexadecimal in the range 0 to |
2480 $FFFF. Hex numbers must have a leading dollar sign. Here are some | 2482 $FFFF. Hex numbers must have a leading dollar sign. Here are some |
2481 examples of INTEGER constants: | 2483 examples of INTEGER constants: |
2482 | 2484 |
2483 <informaltable frame="none"> | 2485 <informaltable frame="none"> |
2484 <tgroup cols="3"> | 2486 <tgroup cols="3"> |
2485 <tbody> | 2487 <tbody> |
2486 <row> | 2488 <row> |
2487 <entry>12</entry> | 2489 <entry>12</entry> |
2488 <entry>−3000</entry> | 2490 <entry>-3000</entry> |
2489 <entry>64000</entry> | 2491 <entry>64000</entry> |
2490 </row> | 2492 </row> |
2491 <row> | 2493 <row> |
2492 <entry>$20</entry> | 2494 <entry>$20</entry> |
2493 <entry>$FFFE</entry> | 2495 <entry>$FFFE</entry> |
2494 <entry>$0</entry> | 2496 <entry>$0</entry> |
2495 </row> | 2497 </row> |
2496 <row> | 2498 <row> |
2497 <entry>0</entry> | 2499 <entry>0</entry> |
2498 <entry>−12</entry> | 2500 <entry>-12</entry> |
2499 <entry>−32768</entry> | 2501 <entry>-32768</entry> |
2500 </row> | 2502 </row> |
2501 </tbody> | 2503 </tbody> |
2502 </tgroup> | 2504 </tgroup> |
2503 </informaltable> | 2505 </informaltable> |
2504 | 2506 |
2742 available and the types they accept and produce. | 2744 available and the types they accept and produce. |
2743 "NUMERIC" refers to either BYTE, INTEGER, or REAL types. | 2745 "NUMERIC" refers to either BYTE, INTEGER, or REAL types. |
2744 <table frame="none"> | 2746 <table frame="none"> |
2745 <title>&b09; Expression Operators</title> | 2747 <title>&b09; Expression Operators</title> |
2746 <tgroup cols="4"> | 2748 <tgroup cols="4"> |
2747 <colspec colwidth="0.8in"> | 2749 <colspec colwidth="0.8in"/> |
2748 <thead> | 2750 <thead> |
2749 <row rowsep="1"> | 2751 <row rowsep="1"> |
2750 <entry>Operator</entry> | 2752 <entry>Operator</entry> |
2751 <entry>Function</entry> | 2753 <entry>Function</entry> |
2752 <entry>Operand type</entry> | 2754 <entry>Operand type</entry> |
2753 <entry>Result type</entry> | 2755 <entry>Result type</entry> |
2754 </row> | 2756 </row> |
2755 </thead> | 2757 </thead> |
2756 <tbody> | 2758 <tbody> |
2757 <row> | 2759 <row> |
2758 <entry>−</entry> | 2760 <entry>-</entry> |
2759 <entry>Negation</entry> | 2761 <entry>Negation</entry> |
2760 <entry>NUMERIC</entry> | 2762 <entry>NUMERIC</entry> |
2761 <entry>NUMERIC</entry> | 2763 <entry>NUMERIC</entry> |
2762 </row> | 2764 </row> |
2763 <row> | 2765 <row> |
2783 <entry>Addition</entry> | 2785 <entry>Addition</entry> |
2784 <entry>NUMERIC</entry> | 2786 <entry>NUMERIC</entry> |
2785 <entry>NUMERIC</entry> | 2787 <entry>NUMERIC</entry> |
2786 </row> | 2788 </row> |
2787 <row> | 2789 <row> |
2788 <entry></entry> | 2790 <entry>-</entry> |
2789 <entry>Subtraction</entry> | 2791 <entry>Subtraction</entry> |
2790 <entry>NUMERIC</entry> | 2792 <entry>NUMERIC</entry> |
2791 <entry>NUMERIC</entry> | 2793 <entry>NUMERIC</entry> |
2792 </row> | 2794 </row> |
2793 <row> | 2795 <row> |
2872 may be removed by the compiler. The legal operators are listed below, | 2874 may be removed by the compiler. The legal operators are listed below, |
2873 in precedence order from highest to lowest. | 2875 in precedence order from highest to lowest. |
2874 | 2876 |
2875 <informaltable frame="none"> | 2877 <informaltable frame="none"> |
2876 <tgroup cols="7"> | 2878 <tgroup cols="7"> |
2877 <colspec colname="c1"> | 2879 <colspec colname="c1"/> |
2878 <colspec colname="c2"> | 2880 <colspec colname="c2"/> |
2879 <colspec colname="c3"> | 2881 <colspec colname="c3"/> |
2880 <colspec colnum="7" colname="c7"> | 2882 <colspec colnum="7" colname="c7"/> |
2881 <spanspec spanname="firstop" namest="c2" nameend="c2"> | 2883 <spanspec spanname="firstop" namest="c2" nameend="c2"/> |
2882 <spanspec spanname="secondop" namest="c3" nameend="c7"> | 2884 <spanspec spanname="secondop" namest="c3" nameend="c7"/> |
2883 <spanspec spanname="onlyop" namest="c2" nameend="c7"> | 2885 <spanspec spanname="onlyop" namest="c2" nameend="c7"/> |
2884 <spanspec spanname="all" namest="c1" nameend="c7"> | 2886 <spanspec spanname="all" namest="c1" nameend="c7"/> |
2885 <tbody> | 2887 <tbody> |
2886 <row> | 2888 <row> |
2887 <entry spanname="all">Highest Precedence</entry> | 2889 <entry spanname="all">Highest Precedence</entry> |
2888 </row> | 2890 </row> |
2889 <row> | 2891 <row> |
2890 <entry spanname="firstop">NOT</entry> | 2892 <entry spanname="firstop">NOT</entry> |
2891 <entry spanname="secondop">(negate)</entry> | 2893 <entry spanname="secondop">-(negate)</entry> |
2892 </row> | 2894 </row> |
2893 <row> | 2895 <row> |
2894 <entry spanname="firstop">^</entry> | 2896 <entry spanname="firstop">^</entry> |
2895 <entry spanname="secondop">**</entry> | 2897 <entry spanname="secondop">**</entry> |
2896 </row> | 2898 </row> |
2898 <entry spanname="firstop">*</entry> | 2900 <entry spanname="firstop">*</entry> |
2899 <entry spanname="secondop">/</entry> | 2901 <entry spanname="secondop">/</entry> |
2900 </row> | 2902 </row> |
2901 <row> | 2903 <row> |
2902 <entry spanname="firstop">+</entry> | 2904 <entry spanname="firstop">+</entry> |
2903 <entry spanname="secondop"></entry> | 2905 <entry spanname="secondop">-</entry> |
2904 </row> | 2906 </row> |
2905 <row> | 2907 <row> |
2906 <entry spanname="firstop">></entry> | 2908 <entry spanname="firstop">></entry> |
2907 <entry><</entry> | 2909 <entry><</entry> |
2908 <entry><></entry> | 2910 <entry><></entry> |
2956 <row> | 2958 <row> |
2957 <entry>a:= b**c**d/e</entry> | 2959 <entry>a:= b**c**d/e</entry> |
2958 <entry>a:= (b**(c**d))/e</entry> | 2960 <entry>a:= (b**(c**d))/e</entry> |
2959 </row> | 2961 </row> |
2960 <row> | 2962 <row> |
2961 <entry>a:= (b)**2</entry> | 2963 <entry>a:= -(b)**2</entry> |
2962 <entry>a:= (b)**2</entry> | 2964 <entry>a:= (-b)**2</entry> |
2963 </row> | 2965 </row> |
2964 <row> | 2966 <row> |
2965 <entry>a:=b=c</entry> | 2967 <entry>a:=b=c</entry> |
2966 <entry>a:= (b=c) (returns BOOLEAN value)</entry> | 2968 <entry>a:= (b=c) (returns BOOLEAN value)</entry> |
2967 </row> | 2969 </row> |
3007 functions is 8+ decimal digits. Angles can be either degrees or radians (see | 3009 functions is 8+ decimal digits. Angles can be either degrees or radians (see |
3008 DEG/RAD statement descriptions). | 3010 DEG/RAD statement descriptions). |
3009 | 3011 |
3010 <informaltable frame="none"> | 3012 <informaltable frame="none"> |
3011 <tgroup cols="2"> | 3013 <tgroup cols="2"> |
3012 <colspec colwidth="1.5in"> | 3014 <colspec colwidth="1.5in"/> |
3013 <tbody> | 3015 <tbody> |
3014 <row> | 3016 <row> |
3015 <entry>SIN(<num>)</entry> | 3017 <entry>SIN(<num>)</entry> |
3016 <entry>trigonometric sine of <num></entry> | 3018 <entry>trigonometric sine of <num></entry> |
3017 </row> | 3019 </row> |
3086 The following functions can return any numeric type, depending on the | 3088 The following functions can return any numeric type, depending on the |
3087 type of the input parameter(s). | 3089 type of the input parameter(s). |
3088 | 3090 |
3089 <informaltable frame="none"> | 3091 <informaltable frame="none"> |
3090 <tgroup cols="2"> | 3092 <tgroup cols="2"> |
3091 <colspec colwidth="1.5in"> | 3093 <colspec colwidth="1.5in"/> |
3092 <tbody> | 3094 <tbody> |
3093 <row> | 3095 <row> |
3094 <entry>ABS(<num>)</entry> | 3096 <entry>ABS(<num>)</entry> |
3095 <entry>absolute value of <num></entry> | 3097 <entry>absolute value of <num></entry> |
3096 </row> | 3098 </row> |
3097 <row> | 3099 <row> |
3098 <entry>SGN(<num>)</entry> | 3100 <entry>SGN(<num>)</entry> |
3099 <entry>signum of <num>: 1 if <num> < 0; 0 if <num> = 0; or 1 if <num> > 0</entry> | 3101 <entry>signum of <num>: -1 if <num> < 0; 0 if <num> = 0; or 1 if <num> > 0</entry> |
3100 </row> | 3102 </row> |
3101 <row> | 3103 <row> |
3102 <entry>SQ(<num>)</entry> | 3104 <entry>SQ(<num>)</entry> |
3103 <entry><num> squared</entry> | 3105 <entry><num> squared</entry> |
3104 </row> | 3106 </row> |
3113 | 3115 |
3114 The following functions can return results of type INTEGER or BYTE: | 3116 The following functions can return results of type INTEGER or BYTE: |
3115 | 3117 |
3116 <informaltable frame="none"> | 3118 <informaltable frame="none"> |
3117 <tgroup cols="2"> | 3119 <tgroup cols="2"> |
3118 <colspec colwidth="1.5in"> | 3120 <colspec colwidth="1.5in"/> |
3119 <tbody> | 3121 <tbody> |
3120 <row> | 3122 <row> |
3121 <entry>FIX(<num>)</entry> | 3123 <entry>FIX(<num>)</entry> |
3122 <entry>round REAL <num> and convert to type INTEGER.</entry> | 3124 <entry>round REAL <num> and convert to type INTEGER.</entry> |
3123 </row> | 3125 </row> |
3166 or byte data types and return integer results. They should NOT be confused | 3168 or byte data types and return integer results. They should NOT be confused |
3167 with the BOOLEAN-type operators. | 3169 with the BOOLEAN-type operators. |
3168 | 3170 |
3169 <informaltable frame="none"> | 3171 <informaltable frame="none"> |
3170 <tgroup cols="2"> | 3172 <tgroup cols="2"> |
3171 <colspec colwidth="1.5in"> | 3173 <colspec colwidth="1.5in"/> |
3172 <tbody> | 3174 <tbody> |
3173 <row> | 3175 <row> |
3174 <entry>LAND(<num>,<num>)</entry> | 3176 <entry>LAND(<num>,<num>)</entry> |
3175 <entry>Logical AND</entry> | 3177 <entry>Logical AND</entry> |
3176 </row> | 3178 </row> |
3192 | 3194 |
3193 These functions return a result of type STRING: | 3195 These functions return a result of type STRING: |
3194 | 3196 |
3195 <informaltable frame="none"> | 3197 <informaltable frame="none"> |
3196 <tgroup cols="2"> | 3198 <tgroup cols="2"> |
3197 <colspec colwidth="1.7in"> | 3199 <colspec colwidth="1.7in"/> |
3198 <tbody> | 3200 <tbody> |
3199 <row> | 3201 <row> |
3200 <entry>CHR$(<int>)</entry> | 3202 <entry>CHR$(<int>)</entry> |
3201 <entry>ASCII char. equivalent of <int></entry> | 3203 <entry>ASCII char. equivalent of <int></entry> |
3202 </row> | 3204 </row> |
3233 The following functions return BOOLEAN values: | 3235 The following functions return BOOLEAN values: |
3234 | 3236 |
3235 | 3237 |
3236 <informaltable frame="none"> | 3238 <informaltable frame="none"> |
3237 <tgroup cols="2"> | 3239 <tgroup cols="2"> |
3238 <colspec colwidth="1.5in"> | 3240 <colspec colwidth="1.5in"/> |
3239 <tbody> | 3241 <tbody> |
3240 <row> | 3242 <row> |
3241 <entry>TRUE</entry> | 3243 <entry>TRUE</entry> |
3242 <entry>always returns TRUE.</entry> | 3244 <entry>always returns TRUE.</entry> |
3243 </row> | 3245 </row> |
3317 <sect2><title>LET Statement</title> | 3319 <sect2><title>LET Statement</title> |
3318 <para> | 3320 <para> |
3319 Syntax: | 3321 Syntax: |
3320 <cmdsynopsis> | 3322 <cmdsynopsis> |
3321 <command>[LET] <var> := <expr></command> | 3323 <command>[LET] <var> := <expr></command> |
3322 <sbr> | 3324 <sbr/> |
3323 <command>[LET] <var> = <expr></command> | 3325 <command>[LET] <var> = <expr></command> |
3324 <sbr> | 3326 <sbr/> |
3325 <command>[LET] <struct> := <struct></command> | 3327 <command>[LET] <struct> := <struct></command> |
3326 <sbr> | 3328 <sbr/> |
3327 <command>[LET] <struct> = <struct></command> | 3329 <command>[LET] <struct> = <struct></command> |
3328 </cmdsynopsis> | 3330 </cmdsynopsis> |
3329 | 3331 |
3330 </para> | 3332 </para> |
3331 <para> | 3333 <para> |
3434 <sect2><title>IF Statement: Type 2</title> | 3436 <sect2><title>IF Statement: Type 2</title> |
3435 <para> | 3437 <para> |
3436 Syntax: | 3438 Syntax: |
3437 <cmdsynopsis> | 3439 <cmdsynopsis> |
3438 <command>IF <bool expr> THEN <statements></command> | 3440 <command>IF <bool expr> THEN <statements></command> |
3439 <sbr> | 3441 <sbr/> |
3440 <command>[ ELSE <statements> ]</command> | 3442 <command>[ ELSE <statements> ]</command> |
3441 <sbr> | 3443 <sbr/> |
3442 <command>ENDIF</command> | 3444 <command>ENDIF</command> |
3443 </cmdsynopsis> | 3445 </cmdsynopsis> |
3444 This kind of IF structure evaluates the expression to a BOOLEAN | 3446 This kind of IF structure evaluates the expression to a BOOLEAN |
3445 value. If the result is TRUE the statement(s) immediately following | 3447 value. If the result is TRUE the statement(s) immediately following |
3446 the THEN are executed. If an ELSE clause exists, statements between | 3448 the THEN are executed. If an ELSE clause exists, statements between |
3474 <sect2><title>FOR/NEXT Statement</title> | 3476 <sect2><title>FOR/NEXT Statement</title> |
3475 <para> | 3477 <para> |
3476 Syntax: | 3478 Syntax: |
3477 <cmdsynopsis> | 3479 <cmdsynopsis> |
3478 <command>FOR <var> = <expr> TO <expr> [ STEP <expr> ]</command> | 3480 <command>FOR <var> = <expr> TO <expr> [ STEP <expr> ]</command> |
3479 <sbr> | 3481 <sbr/> |
3480 <command>NEXT <var></command> | 3482 <command>NEXT <var></command> |
3481 </cmdsynopsis> | 3483 </cmdsynopsis> |
3482 Creates a loop that usually executes a specified number of times | 3484 Creates a loop that usually executes a specified number of times |
3483 while automatically increasing or decreasing a specified counter variable. | 3485 while automatically increasing or decreasing a specified counter variable. |
3484 The first expression is evaluated and the result is stored in <var> which | 3486 The first expression is evaluated and the result is stored in <var> which |
3504 FOR counter = 1 to 100 step .5 | 3506 FOR counter = 1 to 100 step .5 |
3505 PRINT counter | 3507 PRINT counter |
3506 NEXT counter | 3508 NEXT counter |
3507 | 3509 |
3508 | 3510 |
3509 FOR var = min1 TO min+max STEP increment-adjustment | 3511 FOR var = min-1 TO min+max STEP increment-adjustment |
3510 PRINT var | 3512 PRINT var |
3511 NEXT var | 3513 NEXT var |
3512 | 3514 |
3513 | 3515 |
3514 FOR x = 1000 TO 1 STEP 1 | 3516 FOR x = 1000 TO 1 STEP -1 |
3515 PRINT x | 3517 PRINT x |
3516 NEXT x | 3518 NEXT x |
3517 </programlisting> | 3519 </programlisting> |
3518 </informalexample> | 3520 </informalexample> |
3519 </para></sect2> | 3521 </para></sect2> |
3520 <sect2><title>WHILE..DO Statement</title> | 3522 <sect2><title>WHILE..DO Statement</title> |
3521 <para> | 3523 <para> |
3522 Syntax: | 3524 Syntax: |
3523 <cmdsynopsis> | 3525 <cmdsynopsis> |
3524 <command>WHILE <bool expr> DO</command> | 3526 <command>WHILE <bool expr> DO</command> |
3525 <sbr> | 3527 <sbr/> |
3526 <command>ENDWHILE</command> | 3528 <command>ENDWHILE</command> |
3527 </cmdsynopsis> | 3529 </cmdsynopsis> |
3528 This is a loop construct with the test at the "top" of the | 3530 This is a loop construct with the test at the "top" of the |
3529 loop. Statements within the loop are executed as long as <bool | 3531 loop. Statements within the loop are executed as long as <bool |
3530 expr> is TRUE. The body of the loop will not be executed if the | 3532 expr> is TRUE. The body of the loop will not be executed if the |
3551 REM reverse the letters in word$ | 3553 REM reverse the letters in word$ |
3552 backward$ := "" | 3554 backward$ := "" |
3553 INPUT word$ | 3555 INPUT word$ |
3554 WHILE LEN(word$) > 0 DO | 3556 WHILE LEN(word$) > 0 DO |
3555 backward$ := backward$ + RIGHT$(word$,1) | 3557 backward$ := backward$ + RIGHT$(word$,1) |
3556 word$ := LEFT$(word$,LEN(word$)1) | 3558 word$ := LEFT$(word$,LEN(word$)-1) |
3557 ENDWHILE | 3559 ENDWHILE |
3558 word$ := backward$ | 3560 word$ := backward$ |
3559 PRINT word$ | 3561 PRINT word$ |
3560 </programlisting> | 3562 </programlisting> |
3561 </informalexample> | 3563 </informalexample> |
3564 <sect2><title>REPEAT..UNTIL Statement</title> | 3566 <sect2><title>REPEAT..UNTIL Statement</title> |
3565 <para> | 3567 <para> |
3566 Syntax: | 3568 Syntax: |
3567 <cmdsynopsis> | 3569 <cmdsynopsis> |
3568 <command>REPEAT</command> | 3570 <command>REPEAT</command> |
3569 <sbr> | 3571 <sbr/> |
3570 <command>UNTIL <bool expr></command> | 3572 <command>UNTIL <bool expr></command> |
3571 </cmdsynopsis> | 3573 </cmdsynopsis> |
3572 This is a loop that has its test at the bottom of the loop. The | 3574 This is a loop that has its test at the bottom of the loop. The |
3573 statement(s) within the loop are executed until the result of <bool expr> is | 3575 statement(s) within the loop are executed until the result of <bool expr> is |
3574 TRUE. The body of the loop is always executed at least one time. | 3576 TRUE. The body of the loop is always executed at least one time. |
3586 (* compute factorial: n! *) | 3588 (* compute factorial: n! *) |
3587 temp := 1. | 3589 temp := 1. |
3588 INPUT "Factorial of what number? ",n | 3590 INPUT "Factorial of what number? ",n |
3589 REPEAT | 3591 REPEAT |
3590 temp := temp * n | 3592 temp := temp * n |
3591 n := n1 | 3593 n := n-1 |
3592 UNTIL n <= 1.0 | 3594 UNTIL n <= 1.0 |
3593 PRINT "The factorial is "; temp | 3595 PRINT "The factorial is "; temp |
3594 </programlisting> | 3596 </programlisting> |
3595 </informalexample> | 3597 </informalexample> |
3596 </para></sect2> | 3598 </para></sect2> |
3597 <sect2><title>LOOP and ENDLOOP/EXITIF and ENDEXIT Statements</title> | 3599 <sect2><title>LOOP and ENDLOOP/EXITIF and ENDEXIT Statements</title> |
3598 <para> | 3600 <para> |
3599 Syntax: | 3601 Syntax: |
3600 <cmdsynopsis> | 3602 <cmdsynopsis> |
3601 <command>LOOP</command> | 3603 <command>LOOP</command> |
3602 <sbr> | 3604 <sbr/> |
3603 <command>ENDLOOP</command> | 3605 <command>ENDLOOP</command> |
3604 </cmdsynopsis> | 3606 </cmdsynopsis> |
3605 | 3607 |
3606 <cmdsynopsis> | 3608 <cmdsynopsis> |
3607 <command>EXITIF <bool expr> THEN <statements></command> | 3609 <command>EXITIF <bool expr> THEN <statements></command> |
3608 <sbr> | 3610 <sbr/> |
3609 <command>ENDEXIT</command> | 3611 <command>ENDEXIT</command> |
3610 </cmdsynopsis> | 3612 </cmdsynopsis> |
3611 These related types of statements can be used to construct | 3613 These related types of statements can be used to construct |
3612 loops with test(s) located anywhere in the body of the loop. | 3614 loops with test(s) located anywhere in the body of the loop. |
3613 The LOOP and ENDLOOP statements define the body of the loop. | 3615 The LOOP and ENDLOOP statements define the body of the loop. |
3645 LOOP | 3647 LOOP |
3646 PRINT | 3648 PRINT |
3647 EXITIF x < 0 THEN | 3649 EXITIF x < 0 THEN |
3648 PRINT "x became zero first" | 3650 PRINT "x became zero first" |
3649 ENDEXIT | 3651 ENDEXIT |
3650 x := x1 | 3652 x := x-1 |
3651 EXITIF y < 0 THEN PRINT "y became zero first" | 3653 EXITIF y < 0 THEN PRINT "y became zero first" |
3652 ENDEXIT | 3654 ENDEXIT |
3653 y := y1 | 3655 y := y-1 |
3654 ENDLOOP | 3656 ENDLOOP |
3655 </programlisting> | 3657 </programlisting> |
3656 </informalexample> | 3658 </informalexample> |
3657 | 3659 |
3658 </para></sect2> | 3660 </para></sect2> |
3678 <sect2><title>GOSUB/RETURN Statements</title> | 3680 <sect2><title>GOSUB/RETURN Statements</title> |
3679 <para> | 3681 <para> |
3680 Syntax: | 3682 Syntax: |
3681 <cmdsynopsis> | 3683 <cmdsynopsis> |
3682 <command>GOSUB <line #></command> | 3684 <command>GOSUB <line #></command> |
3683 <sbr> | 3685 <sbr/> |
3684 <command>RETURN</command> | 3686 <command>RETURN</command> |
3685 </cmdsynopsis> | 3687 </cmdsynopsis> |
3686 The GOSUB statement | 3688 The GOSUB statement |
3687 transfers program execution to a subroutine starting at the specified | 3689 transfers program execution to a subroutine starting at the specified |
3688 line number. The subroutine is executed until a RETURN statement is | 3690 line number. The subroutine is executed until a RETURN statement is |
3712 <sect2><title>ON GOTO/GOSUB Statement</title> | 3714 <sect2><title>ON GOTO/GOSUB Statement</title> |
3713 <para> | 3715 <para> |
3714 Syntax: | 3716 Syntax: |
3715 <cmdsynopsis> | 3717 <cmdsynopsis> |
3716 <command>ON <int expr> GOTO <line #> {,<line #>}</command> | 3718 <command>ON <int expr> GOTO <line #> {,<line #>}</command> |
3717 <sbr> | 3719 <sbr/> |
3718 <command>ON <int expr> GOSUB <line #> {,<line #>}</command> | 3720 <command>ON <int expr> GOSUB <line #> {,<line #>}</command> |
3719 </cmdsynopsis> | 3721 </cmdsynopsis> |
3720 These statements evaluate an integer expression and use the result to select | 3722 These statements evaluate an integer expression and use the result to select |
3721 a corresponding line number from an ordered list. Control is then | 3723 a corresponding line number from an ordered list. Control is then |
3722 transferred to that line number unconditionally in ON GOTO statements or | 3724 transferred to that line number unconditionally in ON GOTO statements or |
3821 <sect2><title>Run Statement</title> | 3823 <sect2><title>Run Statement</title> |
3822 <para> | 3824 <para> |
3823 Syntax: | 3825 Syntax: |
3824 <cmdsynopsis> | 3826 <cmdsynopsis> |
3825 <command>RUN <proc name> [ ( <param> {,<param>} ) ]</command> | 3827 <command>RUN <proc name> [ ( <param> {,<param>} ) ]</command> |
3826 <sbr> | 3828 <sbr/> |
3827 <command>RUN <string var> [ ( <param> {,<param>} ) ]</command> | 3829 <command>RUN <string var> [ ( <param> {,<param>} ) ]</command> |
3828 </cmdsynopsis> | 3830 </cmdsynopsis> |
3829 This statement | 3831 This statement |
3830 calls a procedure by name; when that procedure ends, control will pass | 3832 calls a procedure by name; when that procedure ends, control will pass |
3831 to the next statement after the RUN. It is most often used to call a | 3833 to the next statement after the RUN. It is most often used to call a |
4166 <sect2><title>CHD and CHX Statements</title> | 4168 <sect2><title>CHD and CHX Statements</title> |
4167 <para> | 4169 <para> |
4168 Syntax: | 4170 Syntax: |
4169 <cmdsynopsis> | 4171 <cmdsynopsis> |
4170 <command>CHD <str expr></command> | 4172 <command>CHD <str expr></command> |
4171 <sbr> | 4173 <sbr/> |
4172 <command>CHX <str expr></command> | 4174 <command>CHX <str expr></command> |
4173 </cmdsynopsis> | 4175 </cmdsynopsis> |
4174 These statements | 4176 These statements |
4175 change the current default Data or Execution directory, | 4177 change the current default Data or Execution directory, |
4176 respectively. The string must specify the pathlist of a file | 4178 respectively. The string must specify the pathlist of a file |
4181 <sect2><title>DEG and RAD Statements</title> | 4183 <sect2><title>DEG and RAD Statements</title> |
4182 <para> | 4184 <para> |
4183 Syntax: | 4185 Syntax: |
4184 <cmdsynopsis> | 4186 <cmdsynopsis> |
4185 <command>DEG</command> | 4187 <command>DEG</command> |
4186 <sbr> | 4188 <sbr/> |
4187 <command>RAD</command> | 4189 <command>RAD</command> |
4188 </cmdsynopsis> | 4190 </cmdsynopsis> |
4189 These statements | 4191 These statements |
4190 set the procedure's state flag to assume angles stated in | 4192 set the procedure's state flag to assume angles stated in |
4191 degrees or radians in SIN, COS, TAN, ACS, ASN, and ATN functions. | 4193 degrees or radians in SIN, COS, TAN, ACS, ASN, and ATN functions. |
4195 <sect2><title>BASE 0 and BASE 1 Statements</title> | 4197 <sect2><title>BASE 0 and BASE 1 Statements</title> |
4196 <para> | 4198 <para> |
4197 Syntax: | 4199 Syntax: |
4198 <cmdsynopsis> | 4200 <cmdsynopsis> |
4199 <command>BASE 0</command> | 4201 <command>BASE 0</command> |
4200 <sbr> | 4202 <sbr/> |
4201 <command>BASE 1</command> | 4203 <command>BASE 1</command> |
4202 </cmdsynopsis> | 4204 </cmdsynopsis> |
4203 | 4205 |
4204 These statements indicate whether a particular procedure's lowest array | 4206 These statements indicate whether a particular procedure's lowest array |
4205 or data structure index (subscript) is zero or one. The | 4207 or data structure index (subscript) is zero or one. The |
4210 <sect2><title>TRON and TROFF Statements</title> | 4212 <sect2><title>TRON and TROFF Statements</title> |
4211 <para> | 4213 <para> |
4212 Syntax: | 4214 Syntax: |
4213 <cmdsynopsis> | 4215 <cmdsynopsis> |
4214 <command>TRON</command> | 4216 <command>TRON</command> |
4215 <sbr> | 4217 <sbr/> |
4216 <command>TROFF</command> | 4218 <command>TROFF</command> |
4217 </cmdsynopsis> | 4219 </cmdsynopsis> |
4218 These statements turn the trace mode on or off, and are useful for debugging. | 4220 These statements turn the trace mode on or off, and are useful for debugging. |
4219 When trace mode is turned on, each statement is decompiled and printed | 4221 When trace mode is turned on, each statement is decompiled and printed |
4220 before execution. Also, the result of each expression evaluation is printed as | 4222 before execution. Also, the result of each expression evaluation is printed as |
4223 <sect2><title>Comment Statements</title> | 4225 <sect2><title>Comment Statements</title> |
4224 <para> | 4226 <para> |
4225 Syntax: | 4227 Syntax: |
4226 <cmdsynopsis> | 4228 <cmdsynopsis> |
4227 <command>REM <chars></command> | 4229 <command>REM <chars></command> |
4228 <sbr> | 4230 <sbr/> |
4229 <command>(* <chars> [ *) ]</command> | 4231 <command>(* <chars> [ *) ]</command> |
4230 </cmdsynopsis> | 4232 </cmdsynopsis> |
4231 These statements are used to put comments in programs. The second form | 4233 These statements are used to put comments in programs. The second form |
4232 of the statement is for compatibility with PASCAL programs. Comments | 4234 of the statement is for compatibility with PASCAL programs. Comments |
4233 are retained in the I-code but are removed by the PACK compile command. | 4235 are retained in the I-code but are removed by the PACK compile command. |
4291 <sect2><title>DIM Statement</title> | 4293 <sect2><title>DIM Statement</title> |
4292 <para> | 4294 <para> |
4293 Syntax: | 4295 Syntax: |
4294 <cmdsynopsis> | 4296 <cmdsynopsis> |
4295 <command>DIM <decl seq> {; <decl seq>}</command> | 4297 <command>DIM <decl seq> {; <decl seq>}</command> |
4296 <sbr> | 4298 <sbr/> |
4297 <command><decl seq> := <decl> {, <decl>} : <type>}</command> | 4299 <command><decl seq> := <decl> {, <decl>} : <type>}</command> |
4298 <sbr> | 4300 <sbr/> |
4299 <command><decl> := <name> [, <subscript> ]</command> | 4301 <command><decl> := <name> [, <subscript> ]</command> |
4300 <sbr> | 4302 <sbr/> |
4301 <command><subscr> := ( <const> [,<const> [,<const>]] )</command> | 4303 <command><subscr> := ( <const> [,<const> [,<const>]] )</command> |
4302 <sbr> | 4304 <sbr/> |
4303 <command><type> := BYTE | INTEGER | REAL | BOOLEAN | | 4305 <command><type> := BYTE | INTEGER | REAL | BOOLEAN | |
4304 STRING | STRING <max len> | <user defined type></command> | 4306 STRING | STRING <max len> | <user defined type></command> |
4305 <sbr> | 4307 <sbr/> |
4306 <command><user def> := user defined by TYPE statement</command> | 4308 <command><user def> := user defined by TYPE statement</command> |
4307 </cmdsynopsis> | 4309 </cmdsynopsis> |
4308 The DIM statement is used to declare simple variables, | 4310 The DIM statement is used to declare simple variables, |
4309 arrays, or complex data structures of the five | 4311 arrays, or complex data structures of the five |
4310 atomic types or any user-defined type. During compilation, &b09; assigns | 4312 atomic types or any user-defined type. During compilation, &b09; assigns |
4393 (* make a circular list *) | 4395 (* make a circular list *) |
4394 BASE0 | 4396 BASE0 |
4395 FOR index := 0 TO 99 | 4397 FOR index := 0 TO 99 |
4396 list(index).data := "secret message " + STR$(index) | 4398 list(index).data := "secret message " + STR$(index) |
4397 list(index).ptr.fwd := index+1 | 4399 list(index).ptr.fwd := index+1 |
4398 list(index).ptr.back := index1 | 4400 list(index).ptr.back := index-1 |
4399 NEXT index | 4401 NEXT index |
4400 (* fix the ends *) | 4402 (* fix the ends *) |
4401 list(0).ptr.back := 99 | 4403 list(0).ptr.back := 99 |
4402 list(99).ptr.fwd := 0 | 4404 list(99).ptr.fwd := 0 |
4403 | 4405 |
4446 <para> | 4448 <para> |
4447 Syntax: | 4449 Syntax: |
4448 | 4450 |
4449 <cmdsynopsis> | 4451 <cmdsynopsis> |
4450 <command>TYPE <type decl> {; <type decl>}</command> | 4452 <command>TYPE <type decl> {; <type decl>}</command> |
4451 <sbr> | 4453 <sbr/> |
4452 <command><type decl> := <field name> . <decl> : <type>}</command> | 4454 <command><type decl> := <field name> . <decl> : <type>}</command> |
4453 <sbr> | 4455 <sbr/> |
4454 <command><decl> := <name> [, <subscript> ]</command> | 4456 <command><decl> := <name> [, <subscript> ]</command> |
4455 <sbr> | 4457 <sbr/> |
4456 <command><subscript> := ( <const> [,<const> [,<const>]] )</command> | 4458 <command><subscript> := ( <const> [,<const> [,<const>]] )</command> |
4457 <sbr> | 4459 <sbr/> |
4458 <command><type> := BYTE | INTEGER | REAL | BOOLEAN | | 4460 <command><type> := BYTE | INTEGER | REAL | BOOLEAN | |
4459 STRING | STRING [<max len>] | <user defined></command> | 4461 STRING | STRING [<max len>] | <user defined></command> |
4460 <sbr> | 4462 <sbr/> |
4461 <command><user defined> := user defined by TYPE statement</command> | 4463 <command><user defined> := user defined by TYPE statement</command> |
4462 </cmdsynopsis> | 4464 </cmdsynopsis> |
4463 | 4465 |
4464 This statement is used to define new data types. New data types are | 4466 This statement is used to define new data types. New data types are |
4465 defined as a "vector" (a one-dimensional array) of previously | 4467 defined as a "vector" (a one-dimensional array) of previously |
4586 I/O paths" representing &b09;'s interactive input/output (your terminal). | 4588 I/O paths" representing &b09;'s interactive input/output (your terminal). |
4587 These are automatically "opened" for you and should not be closed except | 4589 These are automatically "opened" for you and should not be closed except |
4588 in very special circumstances. The standard I/O path numbers are: | 4590 in very special circumstances. The standard I/O path numbers are: |
4589 <informaltable frame="none"> | 4591 <informaltable frame="none"> |
4590 <tgroup cols="2"> | 4592 <tgroup cols="2"> |
4591 <colspec colwidth="0.3in"> | 4593 <colspec colwidth="0.3in"/> |
4592 <tbody> | 4594 <tbody> |
4593 <row> | 4595 <row> |
4594 <entry>0</entry> | 4596 <entry>0</entry> |
4595 <entry>Standard Input (Keyboard)</entry> | 4597 <entry>Standard Input (Keyboard)</entry> |
4596 </row> | 4598 </row> |
4611 general usage. This reflects typical usage; most statements can be used | 4613 general usage. This reflects typical usage; most statements can be used |
4612 with any I/O device or file. Sometimes certain statements are used in | 4614 with any I/O device or file. Sometimes certain statements are used in |
4613 unusual ways by advanced programmers to achieve certain special effects. | 4615 unusual ways by advanced programmers to achieve certain special effects. |
4614 <informaltable frame="none"> | 4616 <informaltable frame="none"> |
4615 <tgroup cols="3"> | 4617 <tgroup cols="3"> |
4616 <colspec colwidth="0.8in"> | 4618 <colspec colwidth="0.8in"/> |
4617 <thead> | 4619 <thead> |
4618 <row> | 4620 <row> |
4619 <entry>Statement</entry> | 4621 <entry>Statement</entry> |
4620 <entry>Generally Used With</entry> | 4622 <entry>Generally Used With</entry> |
4621 <entry>Data Format (File Type)</entry> | 4623 <entry>Data Format (File Type)</entry> |
4710 </para> | 4712 </para> |
4711 <para> | 4713 <para> |
4712 If any error occurs (type mismatch, insufficient amount of data, etc.), | 4714 If any error occurs (type mismatch, insufficient amount of data, etc.), |
4713 the message: | 4715 the message: |
4714 <screen> | 4716 <screen> |
4715 **INPUT ERROR RETYPE** | 4717 **INPUT ERROR - RETYPE** |
4716 </screen> | 4718 </screen> |
4717 is displayed, followed by a new prompt. The entire input line must | 4719 is displayed, followed by a new prompt. The entire input line must |
4718 then be reentered. | 4720 then be reentered. |
4719 </para> | 4721 </para> |
4720 <para> | 4722 <para> |
4750 <sect2><title>PRINT Statement</title> | 4752 <sect2><title>PRINT Statement</title> |
4751 <para> | 4753 <para> |
4752 Syntax: | 4754 Syntax: |
4753 <cmdsynopsis> | 4755 <cmdsynopsis> |
4754 <command>PRINT <output list></command> | 4756 <command>PRINT <output list></command> |
4755 <sbr> | 4757 <sbr/> |
4756 <command>PRINT #<int expr>, <output list></command> | 4758 <command>PRINT #<int expr>, <output list></command> |
4757 <sbr> | 4759 <sbr/> |
4758 <command>PRINT USING <str expr>, <output list></command> | 4760 <command>PRINT USING <str expr>, <output list></command> |
4759 <sbr> | 4761 <sbr/> |
4760 <command>PRINT #<int expr>, USING <str expr>, <output list></command> | 4762 <command>PRINT #<int expr>, USING <str expr>, <output list></command> |
4761 </cmdsynopsis> | 4763 </cmdsynopsis> |
4762 This statement outputs the values of the items given in the output list | 4764 This statement outputs the values of the items given in the output list |
4763 to the standard output device (path #1, the terminal) unless another | 4765 to the standard output device (path #1, the terminal) unless another |
4764 path number is specified. | 4766 path number is specified. |
4805 | 4807 |
4806 PRINT USING "R10.2,X2,R5.3",x,y | 4808 PRINT USING "R10.2,X2,R5.3",x,y |
4807 | 4809 |
4808 PRINT #outpath USING fmt$,count,value | 4810 PRINT #outpath USING fmt$,count,value |
4809 | 4811 |
4810 (* print an 80character line of all dashes *) | 4812 (* print an 80-character line of all dashes *) |
4811 REPEAT | 4813 REPEAT |
4812 PRINT ""; | 4814 PRINT "-"; |
4813 UNTIL POS >= 80 | 4815 UNTIL POS >= 80 |
4814 PRINT | 4816 PRINT |
4815 </programlisting> | 4817 </programlisting> |
4816 </informalexample> | 4818 </informalexample> |
4817 | 4819 |
4819 <sect2><title>OPEN Statement</title> | 4821 <sect2><title>OPEN Statement</title> |
4820 <para> | 4822 <para> |
4821 Syntax: | 4823 Syntax: |
4822 <cmdsynopsis> | 4824 <cmdsynopsis> |
4823 <command>OPEN #<int var>,"<str expr>" [ : <access mode> ]</command> | 4825 <command>OPEN #<int var>,"<str expr>" [ : <access mode> ]</command> |
4824 <sbr> | 4826 <sbr/> |
4825 <command><access mode> := <mode> ! <mode> + <access mode></command> | 4827 <command><access mode> := <mode> ! <mode> + <access mode></command> |
4826 <sbr> | 4828 <sbr/> |
4827 <command><mode> := READ ! WRITE ! UPDATE ! EXEC ! DIR</command> | 4829 <command><mode> := READ ! WRITE ! UPDATE ! EXEC ! DIR</command> |
4828 </cmdsynopsis> | 4830 </cmdsynopsis> |
4829 This statement issues a request to OS-9 to open an I/O path to an existing | 4831 This statement issues a request to OS-9 to open an I/O path to an existing |
4830 file or device. The STRING expression is evaluated and passed to OS-9 as | 4832 file or device. The STRING expression is evaluated and passed to OS-9 as |
4831 the descriptive pathlist.The variable name specified must be DIMensioned | 4833 the descriptive pathlist.The variable name specified must be DIMensioned |
4869 <sect2><title>CREATE Statement</title> | 4871 <sect2><title>CREATE Statement</title> |
4870 <para> | 4872 <para> |
4871 Syntax: | 4873 Syntax: |
4872 <cmdsynopsis> | 4874 <cmdsynopsis> |
4873 <command>CREATE #<int var>,"<str expr>" [ : <access mode> ]</command> | 4875 <command>CREATE #<int var>,"<str expr>" [ : <access mode> ]</command> |
4874 <sbr> | 4876 <sbr/> |
4875 <command><access mode> := <mode> ! <mode> + <access mode></command> | 4877 <command><access mode> := <mode> ! <mode> + <access mode></command> |
4876 <sbr> | 4878 <sbr/> |
4877 <command><mode> := WRITE ! UPDATE ! EXEC</command> | 4879 <command><mode> := WRITE ! UPDATE ! EXEC</command> |
4878 </cmdsynopsis> | 4880 </cmdsynopsis> |
4879 The CREATE statement is used to create a new file on a multifile mass storage | 4881 The CREATE statement is used to create a new file on a multifile mass storage |
4880 device such as disk or tape. If the device is not of multifile type, | 4882 device such as disk or tape. If the device is not of multifile type, |
4881 this statement works like an "OPEN" statement. | 4883 this statement works like an "OPEN" statement. |
5010 <programlisting> | 5012 <programlisting> |
5011 SEEK #fileone,filptr*2 | 5013 SEEK #fileone,filptr*2 |
5012 | 5014 |
5013 SEEK #outfile,208894 | 5015 SEEK #outfile,208894 |
5014 | 5016 |
5015 SEEK #inventory,(part_num 1) * SIZE(inv_rcd) | 5017 SEEK #inventory,(part_num - 1) * SIZE(inv_rcd) |
5016 </programlisting> | 5018 </programlisting> |
5017 </informalexample> | 5019 </informalexample> |
5018 | 5020 |
5019 </para></sect2> | 5021 </para></sect2> |
5020 <sect2><title>WRITE Statement</title> | 5022 <sect2><title>WRITE Statement</title> |
5099 <sect2><title>GET/PUT Statement</title> | 5101 <sect2><title>GET/PUT Statement</title> |
5100 <para> | 5102 <para> |
5101 Syntax: | 5103 Syntax: |
5102 <cmdsynopsis> | 5104 <cmdsynopsis> |
5103 <command>GET #<expr>,<struct name></command> | 5105 <command>GET #<expr>,<struct name></command> |
5104 <sbr> | 5106 <sbr/> |
5105 <command>PUT #<expr>,<struct name></command> | 5107 <command>PUT #<expr>,<struct name></command> |
5106 </cmdsynopsis> | 5108 </cmdsynopsis> |
5107 The GET and PUT statements read and write fixed-size binary data records | 5109 The GET and PUT statements read and write fixed-size binary data records |
5108 to files or devices. These are the primary I/O statements | 5110 to files or devices. These are the primary I/O statements |
5109 used for random access input and output. | 5111 used for random access input and output. |
5206 INPUT "Record number ?",recnum | 5208 INPUT "Record number ?",recnum |
5207 INPUT "Item name? ",work_rec.name | 5209 INPUT "Item name? ",work_rec.name |
5208 INPUT "List price? ",work_rec.list | 5210 INPUT "List price? ",work_rec.list |
5209 INPUT "Cost price? ",work_rec.cost | 5211 INPUT "Cost price? ",work_rec.cost |
5210 INPUT "Quantity? ",work_rec.qty | 5212 INPUT "Quantity? ",work_rec.qty |
5211 SEEK #path, (recnum 1) * SIZE(work_rec) | 5213 SEEK #path, (recnum - 1) * SIZE(work_rec) |
5212 PUT #path,work_rec | 5214 PUT #path,work_rec |
5213 </programlisting> | 5215 </programlisting> |
5214 This routine below uses a loop to read the entire file into the array | 5216 This routine below uses a loop to read the entire file into the array |
5215 "inv_array": | 5217 "inv_array": |
5216 | 5218 |
5270 <sect2><title>DATA/READ/RESTORE Statements</title> | 5272 <sect2><title>DATA/READ/RESTORE Statements</title> |
5271 <para> | 5273 <para> |
5272 Syntax: | 5274 Syntax: |
5273 <cmdsynopsis> | 5275 <cmdsynopsis> |
5274 <command>READ <input list></command> | 5276 <command>READ <input list></command> |
5275 <sbr> | 5277 <sbr/> |
5276 <command>DATA <expr> , { <expr> }</command> | 5278 <command>DATA <expr> , { <expr> }</command> |
5277 <sbr> | 5279 <sbr/> |
5278 <command>RESTORE [ <line number> ]</command> | 5280 <command>RESTORE [ <line number> ]</command> |
5279 </cmdsynopsis> | 5281 </cmdsynopsis> |
5280 These statements provide an efficient way to build constant tables | 5282 These statements provide an efficient way to build constant tables |
5281 within a program. DATA statements provide values, the READ statement | 5283 within a program. DATA statements provide values, the READ statement |
5282 assign the values to variables, and RESTORE statements can be used to | 5284 assign the values to variables, and RESTORE statements can be used to |
5356 six basic output editing directives. Each has a corresponding one-letter | 5358 six basic output editing directives. Each has a corresponding one-letter |
5357 identifier: | 5359 identifier: |
5358 | 5360 |
5359 <informaltable frame="none"> | 5361 <informaltable frame="none"> |
5360 <tgroup cols="2"> | 5362 <tgroup cols="2"> |
5361 <colspec colwidth="0.6in"> | 5363 <colspec colwidth="0.6in"/> |
5362 <tbody> | 5364 <tbody> |
5363 <row> | 5365 <row> |
5364 <entry>R</entry> | 5366 <entry>R</entry> |
5365 <entry>real format</entry> | 5367 <entry>real format</entry> |
5366 </row> | 5368 </row> |
5401 <para> | 5403 <para> |
5402 The abbreviations and symbols used in the syntax specifications are: | 5404 The abbreviations and symbols used in the syntax specifications are: |
5403 | 5405 |
5404 <informaltable frame="none"> | 5406 <informaltable frame="none"> |
5405 <tgroup cols="3"> | 5407 <tgroup cols="3"> |
5406 <colspec colwidth="0.4in"> | 5408 <colspec colwidth="0.4in"/> |
5407 <tbody> | 5409 <tbody> |
5408 <row> | 5410 <row> |
5409 <entry>w</entry> | 5411 <entry>w</entry> |
5410 <entry>Total field width</entry> | 5412 <entry>Total field width</entry> |
5411 <entry>1 <= w <= 255</entry> | 5413 <entry>1 <= w <= 255</entry> |
5445 | 5447 |
5446 The justification modes are: | 5448 The justification modes are: |
5447 | 5449 |
5448 <informaltable frame="none"> | 5450 <informaltable frame="none"> |
5449 <tgroup cols="2"> | 5451 <tgroup cols="2"> |
5450 <colspec colwidth="0.3in"> | 5452 <colspec colwidth="0.3in"/> |
5451 <tbody> | 5453 <tbody> |
5452 <row> | 5454 <row> |
5453 <entry><</entry> | 5455 <entry><</entry> |
5454 <entry>Left justify with leading sign and trailing spaces. (default if | 5456 <entry>Left justify with leading sign and trailing spaces. (default if |
5455 justification mode omitted)</entry> | 5457 justification mode omitted)</entry> |
5472 | 5474 |
5473 <informalexample> | 5475 <informalexample> |
5474 <programlisting> | 5476 <programlisting> |
5475 PRINT USING "R8.2<",5678.123 5678.12 | 5477 PRINT USING "R8.2<",5678.123 5678.12 |
5476 PRINT USING "R8.2>",12.3 12.30 | 5478 PRINT USING "R8.2>",12.3 12.30 |
5477 PRINT USING "R8.2<",555.9 555.90 | 5479 PRINT USING "R8.2<",-555.9 -555.90 |
5478 PRINT USING "10.2^",6722.4599 6722.46 | 5480 PRINT USING "10.2^",-6722.4599 6722.46- |
5479 PRINT USING "R5.1","9999999" ***** | 5481 PRINT USING "R5.1","9999999" ***** |
5480 </programlisting> | 5482 </programlisting> |
5481 </informalexample> | 5483 </informalexample> |
5482 </para></sect2> | 5484 </para></sect2> |
5483 <sect2><title>Exponential Format</title> | 5485 <sect2><title>Exponential Format</title> |
5498 | 5500 |
5499 <informalexample> | 5501 <informalexample> |
5500 <programlisting> | 5502 <programlisting> |
5501 PRINT USING "E12.3",1234.567 1.235E+03 | 5503 PRINT USING "E12.3",1234.567 1.235E+03 |
5502 | 5504 |
5503 PRINT USING "E12.6>",0.001234 1.234000E-3 | 5505 PRINT USING "E12.6>",-0.001234 -1.234000E-3 |
5504 </programlisting> | 5506 </programlisting> |
5505 </informalexample> | 5507 </informalexample> |
5506 | 5508 |
5507 </para></sect2> | 5509 </para></sect2> |
5508 <sect2><title>Integer Format</title> | 5510 <sect2><title>Integer Format</title> |
5516 The "w" field width must allow for one position overhead for the sign. | 5518 The "w" field width must allow for one position overhead for the sign. |
5517 The justification modes are: | 5519 The justification modes are: |
5518 | 5520 |
5519 <informaltable frame="none"> | 5521 <informaltable frame="none"> |
5520 <tgroup cols="2"> | 5522 <tgroup cols="2"> |
5521 <colspec colwidth="0.3in"> | 5523 <colspec colwidth="0.3in"/> |
5522 <tbody> | 5524 <tbody> |
5523 <row> | 5525 <row> |
5524 <entry><</entry> | 5526 <entry><</entry> |
5525 <entry>left justify with leading sign and trailing spaces (default)</entry> | 5527 <entry>left justify with leading sign and trailing spaces (default)</entry> |
5526 </row> | 5528 </row> |
5559 specification determines the number of hexadecimal characters to | 5561 specification determines the number of hexadecimal characters to |
5560 output. Justification modes are: | 5562 output. Justification modes are: |
5561 | 5563 |
5562 <informaltable frame="none"> | 5564 <informaltable frame="none"> |
5563 <tgroup cols="2"> | 5565 <tgroup cols="2"> |
5564 <colspec colwidth="0.3in"> | 5566 <colspec colwidth="0.3in"/> |
5565 <tbody> | 5567 <tbody> |
5566 <row> | 5568 <row> |
5567 <entry><</entry> | 5569 <entry><</entry> |
5568 <entry>left justify with trailing spaces</entry> | 5570 <entry>left justify with trailing spaces</entry> |
5569 </row> | 5571 </row> |
5583 according to type, the following specification make the most sense for | 5585 according to type, the following specification make the most sense for |
5584 each data type: | 5586 each data type: |
5585 | 5587 |
5586 <informaltable frame="none"> | 5588 <informaltable frame="none"> |
5587 <tgroup cols="2"> | 5589 <tgroup cols="2"> |
5588 <colspec colwidth="0.5in"> | 5590 <colspec colwidth="0.5in"/> |
5589 <tbody> | 5591 <tbody> |
5590 <row> | 5592 <row> |
5591 <entry>H2</entry> | 5593 <entry>H2</entry> |
5592 <entry>boolean, byte (one byte)</entry> | 5594 <entry>boolean, byte (one byte)</entry> |
5593 </row> | 5595 </row> |
5634 justification mode. If it is too long, it will be truncated on the right side. | 5636 justification mode. If it is too long, it will be truncated on the right side. |
5635 The format specifications are: | 5637 The format specifications are: |
5636 | 5638 |
5637 <informaltable frame="none"> | 5639 <informaltable frame="none"> |
5638 <tgroup cols="2"> | 5640 <tgroup cols="2"> |
5639 <colspec colwidth="0.3in"> | 5641 <colspec colwidth="0.3in"/> |
5640 <tbody> | 5642 <tbody> |
5641 <row> | 5643 <row> |
5642 <entry><</entry> | 5644 <entry><</entry> |
5643 <entry>Left justify (default if mode omitted)</entry> | 5645 <entry>Left justify (default if mode omitted)</entry> |
5644 </row> | 5646 </row> |
5684 line. They are not matched with items in the output list and can be used | 5686 line. They are not matched with items in the output list and can be used |
5685 freely. The control formats are | 5687 freely. The control formats are |
5686 | 5688 |
5687 <informaltable frame="none"> | 5689 <informaltable frame="none"> |
5688 <tgroup cols="2"> | 5690 <tgroup cols="2"> |
5689 <colspec colwidth="0.5in"> | 5691 <colspec colwidth="0.5in"/> |
5690 <tbody> | 5692 <tbody> |
5691 <row> | 5693 <row> |
5692 <entry>Tn</entry> | 5694 <entry>Tn</entry> |
5693 <entry>Tab to column n</entry> | 5695 <entry>Tab to column n</entry> |
5694 </row> | 5696 </row> |
5780 <para> | 5782 <para> |
5781 Because &b09; includes several different numeric representations | 5783 Because &b09; includes several different numeric representations |
5782 (i.e., REAL, INTEGER, and BYTE) and does "automatic type conversions" | 5784 (i.e., REAL, INTEGER, and BYTE) and does "automatic type conversions" |
5783 between them, it is easy to write expressions or loops that take at | 5785 between them, it is easy to write expressions or loops that take at |
5784 least ten times longer to execute than is necessary. Some particular | 5786 least ten times longer to execute than is necessary. Some particular |
5785 &b09; numeric operators (+, , *, /) and control structures (FOR..NEXT) | 5787 &b09; numeric operators (+, -, *, /) and control structures (FOR..NEXT) |
5786 include versions for both REAL and INTEGER values. The INTEGER versions, | 5788 include versions for both REAL and INTEGER values. The INTEGER versions, |
5787 off course, are much faster and may have slightly different properties | 5789 off course, are much faster and may have slightly different properties |
5788 (e.g., INTEGER divides discard any remainder). Type conversions takes | 5790 (e.g., INTEGER divides discard any remainder). Type conversions takes |
5789 time so expressions whose operands and operators are of the same type | 5791 time so expressions whose operands and operators are of the same type |
5790 are more efficient. | 5792 are more efficient. |
5819 it is to be assigned to a variable of that type. Thus a single decimal | 5821 it is to be assigned to a variable of that type. Thus a single decimal |
5820 point will slow this particular operation down by about ten times! | 5822 point will slow this particular operation down by about ten times! |
5821 <table frame="none"> | 5823 <table frame="none"> |
5822 <title>Arithmetic Functions Ranked by Speed</title> | 5824 <title>Arithmetic Functions Ranked by Speed</title> |
5823 <tgroup cols="2"> | 5825 <tgroup cols="2"> |
5824 <colspec colwidth="3in"> | 5826 <colspec colwidth="3in"/> |
5825 <colspec colwidth="2in"> | 5827 <colspec colwidth="2in"/> |
5826 <thead> | 5828 <thead> |
5827 <row> | 5829 <row> |
5828 <entry>Operation</entry> | 5830 <entry>Operation</entry> |
5829 <entry>Typical Speed (MPU Cycles)</entry> | 5831 <entry>Typical Speed (MPU Cycles)</entry> |
5830 </row> | 5832 </row> |
6002 </programlisting> | 6004 </programlisting> |
6003 | 6005 |
6004 <programlisting> | 6006 <programlisting> |
6005 PROCEDURE fractions | 6007 PROCEDURE fractions |
6006 REM by T.F. Ritter | 6008 REM by T.F. Ritter |
6007 REM finds increasinglyclose rational approximations | 6009 REM finds increasingly-close rational approximations |
6008 REM to the desired real value | 6010 REM to the desired real value |
6009 DIM m:INTEGER | 6011 DIM m:INTEGER |
6010 | 6012 |
6011 desired:=PI | 6013 desired:=PI |
6012 last:=0 | 6014 last:=0 |
6013 | 6015 |
6014 FOR m=1 TO 30000 | 6016 FOR m=1 TO 30000 |
6015 n:=INT(.5+m*desired) | 6017 n:=INT(.5+m*desired) |
6016 trial:=n/m | 6018 trial:=n/m |
6017 IF ABS(trialdesired)<ABS(lastdesired) THEN | 6019 IF ABS(trial-desired)<ABS(last-desired) THEN |
6018 PRINT n; "/"; m; " = "; trial, | 6020 PRINT n; "/"; m; " = "; trial, |
6019 PRINT "difference = "; trialdesired; | 6021 PRINT "difference = "; trial-desired; |
6020 PRINT | 6022 PRINT |
6021 last:=trial | 6023 last:=trial |
6022 ENDIF | 6024 ENDIF |
6023 NEXT m | 6025 NEXT m |
6024 </programlisting> | 6026 </programlisting> |
6028 REM by T.F. Ritter | 6030 REM by T.F. Ritter |
6029 REM prints the integer parameter value in binary | 6031 REM prints the integer parameter value in binary |
6030 PARAM n:INTEGER | 6032 PARAM n:INTEGER |
6031 DIM i:INTEGER | 6033 DIM i:INTEGER |
6032 | 6034 |
6033 FOR i=15 TO 0 STEP 1 | 6035 FOR i=15 TO 0 STEP -1 |
6034 IF n<0 THEN | 6036 IF n<0 THEN |
6035 PRINT "1"; | 6037 PRINT "1"; |
6036 ELSE PRINT "0"; | 6038 ELSE PRINT "0"; |
6037 ENDIF | 6039 ENDIF |
6038 n:=n+n | 6040 n:=n+n |
6051 PARAM n:INTEGER; from,to_,other:STRING[8] | 6053 PARAM n:INTEGER; from,to_,other:STRING[8] |
6052 | 6054 |
6053 IF n=1 THEN | 6055 IF n=1 THEN |
6054 PRINT "move #"; n; " from "; from; " to "; to_ | 6056 PRINT "move #"; n; " from "; from; " to "; to_ |
6055 ELSE | 6057 ELSE |
6056 RUN hanoi(n1,from,other,to_) | 6058 RUN hanoi(n-1,from,other,to_) |
6057 PRINT "move #"; n; " from "; from; " to "; to_ | 6059 PRINT "move #"; n; " from "; from; " to "; to_ |
6058 RUN hanoi(n1,other,to_,from) | 6060 RUN hanoi(n-1,other,to_,from) |
6059 ENDIF | 6061 ENDIF |
6060 | 6062 |
6061 END | 6063 END |
6062 </programlisting> | 6064 </programlisting> |
6063 | 6065 |
6076 READ value | 6078 READ value |
6077 READ svalu | 6079 READ svalu |
6078 | 6080 |
6079 WHILE x>=value DO | 6081 WHILE x>=value DO |
6080 PRINT MID$(char,i,1); | 6082 PRINT MID$(char,i,1); |
6081 x:=xvalue | 6083 x:=x-value |
6082 ENDWHILE | 6084 ENDWHILE |
6083 | 6085 |
6084 IF x>=valuesvalu THEN | 6086 IF x>=value-svalu THEN |
6085 PRINT MID$(subs,i,1); MID$(char,i,1); | 6087 PRINT MID$(subs,i,1); MID$(char,i,1); |
6086 x:=xvalue+svalu | 6088 x:=x-value+svalu |
6087 ENDIF | 6089 ENDIF |
6088 | 6090 |
6089 NEXT i | 6091 NEXT i |
6090 END | 6092 END |
6091 </programlisting> | 6093 </programlisting> |
6092 | 6094 |
6093 <programlisting> | 6095 <programlisting> |
6094 PROCEDURE eightqueens | 6096 PROCEDURE eightqueens |
6095 REM originally by N. Wirth; here recoded from Pascal | 6097 REM originally by N. Wirth; here re-coded from Pascal |
6096 REM finds the arrangements by which eight queens | 6098 REM finds the arrangements by which eight queens |
6097 REM can be placed on a chess board without conflict | 6099 REM can be placed on a chess board without conflict |
6098 DIM n,k,x(8):INTEGER | 6100 DIM n,k,x(8):INTEGER |
6099 DIM col(8),up(15),down(15):BOOLEAN | 6101 DIM col(8),up(15),down(15):BOOLEAN |
6100 BASE 0 | 6102 BASE 0 |
6111 PARAM col(8),up(15),down(15):BOOLEAN | 6113 PARAM col(8),up(15),down(15):BOOLEAN |
6112 DIM h,k:INTEGER \h:=0 | 6114 DIM h,k:INTEGER \h:=0 |
6113 BASE 0 | 6115 BASE 0 |
6114 | 6116 |
6115 REPEAT | 6117 REPEAT |
6116 IF col(h) AND up(nh+7) AND down(n+h) THEN | 6118 IF col(h) AND up(n-h+7) AND down(n+h) THEN |
6117 (* set queen on square [n,h] *) | 6119 (* set queen on square [n,h] *) |
6118 x(n):=h | 6120 x(n):=h |
6119 col(h):=FALSE \up(nh+7):=FALSE \down(n+h) := FALSE | 6121 col(h):=FALSE \up(n-h+7):=FALSE \down(n+h) := FALSE |
6120 n:=n+1 | 6122 n:=n+1 |
6121 IF n=8 THEN | 6123 IF n=8 THEN |
6122 (* board full; print configuration *) | 6124 (* board full; print configuration *) |
6123 FOR k=0 TO 7 | 6125 FOR k=0 TO 7 |
6124 PRINT x(k); " "; | 6126 PRINT x(k); " "; |
6126 PRINT | 6128 PRINT |
6127 ELSE RUN generate(n,x,col,up,down) | 6129 ELSE RUN generate(n,x,col,up,down) |
6128 ENDIF | 6130 ENDIF |
6129 | 6131 |
6130 (* remove queen from square [n,h] *) | 6132 (* remove queen from square [n,h] *) |
6131 n:=n1 | 6133 n:=n-1 |
6132 col(h):=TRUE \up(nh+7):=TRUE \down(n+h):=TRUE | 6134 col(h):=TRUE \up(n-h+7):=TRUE \down(n+h):=TRUE |
6133 ENDIF | 6135 ENDIF |
6134 h:=h+1 | 6136 h:=h+1 |
6135 UNTIL h=8 | 6137 UNTIL h=8 |
6136 END | 6138 END |
6137 </programlisting> | 6139 </programlisting> |
6138 | 6140 |
6139 <programlisting> | 6141 <programlisting> |
6140 PROCEDURE electric | 6142 PROCEDURE electric |
6141 REM reprogrammed from "ELECTRIC" | 6143 REM re-programmed from "ELECTRIC" |
6142 REM by Dwyer and Critchfield | 6144 REM by Dwyer and Critchfield |
6143 REM Basic and the Personal Computer (AddisonWesley, 1978) | 6145 REM Basic and the Personal Computer (Addison-Wesley, 1978) |
6144 REM provides a pictorial representation of the | 6146 REM provides a pictorial representation of the |
6145 REM resultant electrical field around charged points | 6147 REM resultant electrical field around charged points |
6146 DIM a(10),b(10),c(10) | 6148 DIM a(10),b(10),c(10) |
6147 DIM x,y,i,j:INTEGER | 6149 DIM x,y,i,j:INTEGER |
6148 xscale:=50./78. | 6150 xscale:=50./78. |
6149 yscale:=50./32. | 6151 yscale:=50./32. |
6150 | 6152 |
6151 INPUT "How many charges do you have? ",n | 6153 INPUT "How many charges do you have? ",n |
6152 PRINT "The field of view is 050,050 (x,y)" | 6154 PRINT "The field of view is 0-50,0-50 (x,y)" |
6153 FOR i=1 TO n | 6155 FOR i=1 TO n |
6154 PRINT "type in the x and y positions of charge "; | 6156 PRINT "type in the x and y positions of charge "; |
6155 PRINT i; | 6157 PRINT i; |
6156 INPUT a(i),b(i) | 6158 INPUT a(i),b(i) |
6157 NEXT i | 6159 NEXT i |
6160 PRINT "charge "; i; | 6162 PRINT "charge "; i; |
6161 INPUT c(i) | 6163 INPUT c(i) |
6162 NEXT i | 6164 NEXT i |
6163 | 6165 |
6164 REM visit each screen position | 6166 REM visit each screen position |
6165 FOR y=32 TO 0 STEP 1 | 6167 FOR y=32 TO 0 STEP -1 |
6166 FOR x=0 TO 78 | 6168 FOR x=0 TO 78 |
6167 REM compute field strength into v | 6169 REM compute field strength into v |
6168 GOSUB 10 | 6170 GOSUB 10 |
6169 z:=v*50. | 6171 z:=v*50. |
6170 REM map z to valid ASCII in b$ | 6172 REM map z to valid ASCII in b$ |
6176 NEXT y | 6178 NEXT y |
6177 END | 6179 END |
6178 | 6180 |
6179 10 v=1. | 6181 10 v=1. |
6180 FOR i=1 TO n | 6182 FOR i=1 TO n |
6181 r:=SQRT(SQ(xscale*xa(i))+SQ(yscale*yb(i))) | 6183 r:=SQRT(SQ(xscale*x-a(i))+SQ(yscale*y-b(i))) |
6182 EXITIF r=.0 THEN | 6184 EXITIF r=.0 THEN |
6183 v:=99999. | 6185 v:=99999. |
6184 ENDEXIT | 6186 ENDEXIT |
6185 v:=v+c(i)/r | 6187 v:=v+c(i)/r |
6186 NEXT i | 6188 NEXT i |
6208 | 6210 |
6209 n:=bot | 6211 n:=bot |
6210 m:=top | 6212 m:=top |
6211 | 6213 |
6212 LOOP \REM each element gets the once over | 6214 LOOP \REM each element gets the once over |
6213 REPEAT \REM this is a postinc instruction | 6215 REPEAT \REM this is a post-inc instruction |
6214 btemp:=d(n)<d(top) | 6216 btemp:=d(n)<d(top) |
6215 n:=n+1 | 6217 n:=n+1 |
6216 UNTIL NOT (btemp) | 6218 UNTIL NOT (btemp) |
6217 n:=n1 \REM point at the tested element | 6219 n:=n-1 \REM point at the tested element |
6218 EXITIF n=m THEN | 6220 EXITIF n=m THEN |
6219 ENDEXIT | 6221 ENDEXIT |
6220 | 6222 |
6221 REPEAT \REM this is a postdec instruction | 6223 REPEAT \REM this is a post-dec instruction |
6222 m:=m1 | 6224 m:=m-1 |
6223 UNTIL d(m)<=d(top) OR m=n | 6225 UNTIL d(m)<=d(top) OR m=n |
6224 EXITIF n=m THEN | 6226 EXITIF n=m THEN |
6225 ENDEXIT | 6227 ENDEXIT |
6226 | 6228 |
6227 RUN exchange(d(m),d(n)) | 6229 RUN exchange(d(m),d(n)) |
6228 n:=n+1 \REM prepare for postinc | 6230 n:=n+1 \REM prepare for post-inc |
6229 EXITIF n=m THEN | 6231 EXITIF n=m THEN |
6230 ENDEXIT | 6232 ENDEXIT |
6231 | 6233 |
6232 ENDLOOP | 6234 ENDLOOP |
6233 | 6235 |
6235 IF d(n)<>d(top) THEN | 6237 IF d(n)<>d(top) THEN |
6236 RUN exchange(d(n),d(top)) | 6238 RUN exchange(d(n),d(top)) |
6237 ENDIF | 6239 ENDIF |
6238 ENDIF | 6240 ENDIF |
6239 | 6241 |
6240 IF bot<n1 THEN | 6242 IF bot<n-1 THEN |
6241 RUN qsort1(bot,n1,d) | 6243 RUN qsort1(bot,n-1,d) |
6242 ENDIF | 6244 ENDIF |
6243 IF n+1<top THEN | 6245 IF n+1<top THEN |
6244 RUN qsort1(n+1,top,d) | 6246 RUN qsort1(n+1,top,d) |
6245 ENDIF | 6247 ENDIF |
6246 | 6248 |
6352 REM print a byte as binary | 6354 REM print a byte as binary |
6353 PARAM n: INTEGER | 6355 PARAM n: INTEGER |
6354 DIM i: INTEGER | 6356 DIM i: INTEGER |
6355 | 6357 |
6356 n:= n*256 | 6358 n:= n*256 |
6357 FOR i = 7 TO 0 STEP 1 | 6359 FOR i = 7 TO 0 STEP -1 |
6358 IF n < 0 THEN PRINT "1"; | 6360 IF n < 0 THEN PRINT "1"; |
6359 ELSE PRINT "0"; | 6361 ELSE PRINT "0"; |
6360 ENDIF | 6362 ENDIF |
6361 n:= n + 1 | 6363 n:= n + 1 |
6362 NEXT i | 6364 NEXT i |
6379 REM a+b=>c:five_integer_number (T.F. Ritter) | 6381 REM a+b=>c:five_integer_number (T.F. Ritter) |
6380 PARAM a(5),b(5),c(5):INTEGER | 6382 PARAM a(5),b(5),c(5):INTEGER |
6381 DIM i,carry:INTEGER | 6383 DIM i,carry:INTEGER |
6382 | 6384 |
6383 carry:=0 | 6385 carry:=0 |
6384 FOR i=5 TO 1 STEP 1 | 6386 FOR i=5 TO 1 STEP -1 |
6385 c(i):=a(i)+b(i)+carry | 6387 c(i):=a(i)+b(i)+carry |
6386 IF c(i)>=10000 THEN | 6388 IF c(i)>=10000 THEN |
6387 c(i):=c(i)10000 | 6389 c(i):=c(i)-10000 |
6388 carry:=1 | 6390 carry:=1 |
6389 ELSE carry:=0 | 6391 ELSE carry:=0 |
6390 ENDIF | 6392 ENDIF |
6391 NEXT i | 6393 NEXT i |
6392 </programlisting> | 6394 </programlisting> |
6396 PROCEDURE mpsub | 6398 PROCEDURE mpsub |
6397 PARAM a(5),b(5),c(5):INTEGER | 6399 PARAM a(5),b(5),c(5):INTEGER |
6398 DIM i,borrow:INTEGER | 6400 DIM i,borrow:INTEGER |
6399 | 6401 |
6400 borrow:=0 | 6402 borrow:=0 |
6401 FOR i=5 TO 1 STEP 1 | 6403 FOR i=5 TO 1 STEP -1 |
6402 c(i):=a(i)b(i)borrow | 6404 c(i):=a(i)-b(i)-borrow |
6403 IF c(i)<0 THEN | 6405 IF c(i)<0 THEN |
6404 c(i):=c(i)+10000 | 6406 c(i):=c(i)+10000 |
6405 borrow:=1 | 6407 borrow:=1 |
6406 ELSE borrow:=0 | 6408 ELSE borrow:=0 |
6407 ENDIF | 6409 ENDIF |
6425 <programlisting> | 6427 <programlisting> |
6426 PROCEDURE mpinput | 6428 PROCEDURE mpinput |
6427 PARAM a(5):INTEGER | 6429 PARAM a(5):INTEGER |
6428 DIM n,i:INTEGER | 6430 DIM n,i:INTEGER |
6429 | 6431 |
6430 INPUT "input ultraprecision number: ",b$ | 6432 INPUT "input ultra-precision number: ",b$ |
6431 n:=SUBSTR(".",b$) | 6433 n:=SUBSTR(".",b$) |
6432 | 6434 |
6433 IF n<>0 THEN | 6435 IF n<>0 THEN |
6434 a(5):=VAL(MID$(b$+"0000",n+1,4)) | 6436 a(5):=VAL(MID$(b$+"0000",n+1,4)) |
6435 b$:=LEFT$(b$,n1) | 6437 b$:=LEFT$(b$,n-1) |
6436 ELSE a(5):=0 | 6438 ELSE a(5):=0 |
6437 ENDIF | 6439 ENDIF |
6438 | 6440 |
6439 b$:="00000000000000000000"+b$ | 6441 b$:="00000000000000000000"+b$ |
6440 n:=1+LEN(b$) | 6442 n:=1+LEN(b$) |
6441 FOR i=4 TO 1 STEP 1 | 6443 FOR i=4 TO 1 STEP -1 |
6442 n:=n4 | 6444 n:=n-4 |
6443 a(i):=VAL(MID$(b$,n,4)) | 6445 a(i):=VAL(MID$(b$,n,4)) |
6444 NEXT i | 6446 NEXT i |
6445 </programlisting> | 6447 </programlisting> |
6446 | 6448 |
6447 <programlisting> | 6449 <programlisting> |
6481 ENDEXIT | 6483 ENDEXIT |
6482 EXITIF rewrite="S" OR rewrite="s" THEN ENDEXIT | 6484 EXITIF rewrite="S" OR rewrite="s" THEN ENDEXIT |
6483 offset=VAL(rewrite)+1 | 6485 offset=VAL(rewrite)+1 |
6484 LOOP | 6486 LOOP |
6485 EXITIF offset>256 THEN ENDEXIT | 6487 EXITIF offset>256 THEN ENDEXIT |
6486 modloc=loc+offset1 | 6488 modloc=loc+offset-1 |
6487 PRINT USING "h4,' ',h2",modloc,buffer(offset); | 6489 PRINT USING "h4,' - ',h2",modloc,buffer(offset); |
6488 INPUT ":",rewrite | 6490 INPUT ":",rewrite |
6489 EXITIF rewrite="" THEN ENDEXIT | 6491 EXITIF rewrite="" THEN ENDEXIT |
6490 IF rewrite<>" " THEN | 6492 IF rewrite<>" " THEN |
6491 buffer(offset)=VAL(rewrite) | 6493 buffer(offset)=VAL(rewrite) |
6492 ENDIF | 6494 ENDIF |
6506 (* Called by PATCH *) | 6508 (* Called by PATCH *) |
6507 TYPE buffer=char(8):INTEGER | 6509 TYPE buffer=char(8):INTEGER |
6508 PARAM loc:REAL; line(16):buffer | 6510 PARAM loc:REAL; line(16):buffer |
6509 DIM i,j:INTEGER | 6511 DIM i,j:INTEGER |
6510 WHILE loc>65535. DO | 6512 WHILE loc>65535. DO |
6511 loc=loc65536. | 6513 loc=loc-65536. |
6512 ENDWHILE | 6514 ENDWHILE |
6513 FOR j=1 TO 16 | 6515 FOR j=1 TO 16 |
6514 PRINT USING "h4",FIX(INT(loc))+(j1)*16; | 6516 PRINT USING "h4",FIX(INT(loc))+(j-1)*16; |
6515 PRINT ":"; | 6517 PRINT ":"; |
6516 FOR i=1 TO 8 | 6518 FOR i=1 TO 8 |
6517 PRINT USING "X1,H4",line(j).char(i); | 6519 PRINT USING "X1,H4",line(j).char(i); |
6518 NEXT i | 6520 NEXT i |
6519 RUN printascii(line(j)) | 6521 RUN printascii(line(j)) |
6526 DIM ascii:STRING; nextchar:BYTE; i:INTEGER | 6528 DIM ascii:STRING; nextchar:BYTE; i:INTEGER |
6527 ascii="" | 6529 ascii="" |
6528 FOR i=1 TO 16 | 6530 FOR i=1 TO 16 |
6529 nextchar=line.char(i) | 6531 nextchar=line.char(i) |
6530 IF nextchar>127 THEN | 6532 IF nextchar>127 THEN |
6531 nextchar=nextchar128 | 6533 nextchar=nextchar-128 |
6532 ENDIF | 6534 ENDIF |
6533 IF nextchar<32 OR nextchar>125 THEN | 6535 IF nextchar<32 OR nextchar>125 THEN |
6534 ascii=ascii+" " | 6536 ascii=ascii+" " |
6535 ELSE | 6537 ELSE |
6536 ascii=ascii+CHR$(nextchar) | 6538 ascii=ascii+CHR$(nextchar) |
6539 PRINT " "; ascii; | 6541 PRINT " "; ascii; |
6540 </programlisting> | 6542 </programlisting> |
6541 | 6543 |
6542 <programlisting> | 6544 <programlisting> |
6543 PROCEDURE MakeProc | 6545 PROCEDURE MakeProc |
6544 (* Generates an OS9 command file to apply a command *) | 6546 (* Generates an OS-9 command file to apply a command *) |
6545 (* Such as copy, del, etc., to all files in a directory *) | 6547 (* Such as copy, del, etc., to all files in a directory *) |
6546 (* or directory system. Author: L. Crane *) | 6548 (* or directory system. Author: L. Crane *) |
6547 | 6549 |
6548 DIM DirPath,ProcPath,i,j,k:INTEGER | 6550 DIM DirPath,ProcPath,i,j,k:INTEGER |
6549 DIM CopyAll,CopyFile:BOOLEAN | 6551 DIM CopyAll,CopyFile:BOOLEAN |
6592 Options=TRIM$(response) | 6594 Options=TRIM$(response) |
6593 ENDIF | 6595 ENDIF |
6594 INPUT "Destination Directory? ",DestDir | 6596 INPUT "Destination Directory? ",DestDir |
6595 DestDir=TRIM$(DestDir) | 6597 DestDir=TRIM$(DestDir) |
6596 WRITE #ProcPath,"t" | 6598 WRITE #ProcPath,"t" |
6597 WRITE #ProcPath,"TMode .1 pause" | 6599 WRITE #ProcPath,"TMode .1 -pause" |
6598 READ #DirPath,DirLine | 6600 READ #DirPath,DirLine |
6599 INPUT "Use all files? ",response | 6601 INPUT "Use all files? ",response |
6600 CopyAll=response="y" OR response="Y" | 6602 CopyAll=response="y" OR response="Y" |
6601 WHILE NOT(EOF(#DirPath)) DO | 6603 WHILE NOT(EOF(#DirPath)) DO |
6602 READ #DirPath,DirLine | 6604 READ #DirPath,DirLine |
6606 REPEAT | 6608 REPEAT |
6607 k=j | 6609 k=j |
6608 WHILE j<=i AND MID$(DirLine,j,1)<>" " DO | 6610 WHILE j<=i AND MID$(DirLine,j,1)<>" " DO |
6609 j=j+1 | 6611 j=j+1 |
6610 ENDWHILE | 6612 ENDWHILE |
6611 FileName=MID$(DirLine,k,jk) | 6613 FileName=MID$(DirLine,k,j-k) |
6612 IF NOT(CopyAll) THEN | 6614 IF NOT(CopyAll) THEN |
6613 PRINT "Use "; FileName; | 6615 PRINT "Use "; FileName; |
6614 INPUT response | 6616 INPUT response |
6615 CopyFile=response="y" OR response="Y" | 6617 CopyFile=response="y" OR response="Y" |
6616 ENDIF | 6618 ENDIF |
7178 </table> | 7180 </table> |
7179 | 7181 |
7180 <table frame="none"> | 7182 <table frame="none"> |
7181 <title>Operator Precedence</title> | 7183 <title>Operator Precedence</title> |
7182 <tgroup cols="7"> | 7184 <tgroup cols="7"> |
7183 <colspec colname="c1"> | 7185 <colspec colname="c1"/> |
7184 <colspec colname="c2"> | 7186 <colspec colname="c2"/> |
7185 <colspec colname="c3"> | 7187 <colspec colname="c3"/> |
7186 <colspec colnum="7" colname="c7"> | 7188 <colspec colnum="7" colname="c7"/> |
7187 <spanspec spanname="firstop" namest="c2" nameend="c2"> | 7189 <spanspec spanname="firstop" namest="c2" nameend="c2"/> |
7188 <spanspec spanname="secondop" namest="c3" nameend="c7"> | 7190 <spanspec spanname="secondop" namest="c3" nameend="c7"/> |
7189 <spanspec spanname="onlyop" namest="c2" nameend="c7"> | 7191 <spanspec spanname="onlyop" namest="c2" nameend="c7"/> |
7190 <spanspec spanname="all" namest="c1" nameend="c7"> | 7192 <spanspec spanname="all" namest="c1" nameend="c7"/> |
7191 <tbody> | 7193 <tbody> |
7192 <row> | 7194 <row> |
7193 <entry>highest -></entry> | 7195 <entry>highest -></entry> |
7194 <entry spanname="firstop">NOT</entry> | 7196 <entry spanname="firstop">NOT</entry> |
7195 <entry spanname="secondop">(negate)</entry> | 7197 <entry spanname="secondop">-(negate)</entry> |
7196 </row> | 7198 </row> |
7197 <row> | 7199 <row> |
7198 <entry spanname="firstop">^</entry> | 7200 <entry spanname="firstop">^</entry> |
7199 <entry spanname="secondop">**</entry> | 7201 <entry spanname="secondop">**</entry> |
7200 </row> | 7202 </row> |
7202 <entry spanname="firstop">*</entry> | 7204 <entry spanname="firstop">*</entry> |
7203 <entry spanname="secondop">/</entry> | 7205 <entry spanname="secondop">/</entry> |
7204 </row> | 7206 </row> |
7205 <row> | 7207 <row> |
7206 <entry spanname="firstop">+</entry> | 7208 <entry spanname="firstop">+</entry> |
7207 <entry spanname="secondop"></entry> | 7209 <entry spanname="secondop">-</entry> |
7208 </row> | 7210 </row> |
7209 <row> | 7211 <row> |
7210 <entry spanname="firstop">></entry> | 7212 <entry spanname="firstop">></entry> |
7211 <entry><</entry> | 7213 <entry><</entry> |
7212 <entry><></entry> | 7214 <entry><></entry> |
7231 </appendix> | 7233 </appendix> |
7232 <appendix> | 7234 <appendix> |
7233 <title>&b09; Error Codes</title> | 7235 <title>&b09; Error Codes</title> |
7234 <para> | 7236 <para> |
7235 <literallayout> | 7237 <literallayout> |
7236 10 Unrecognized Symbol | 7238 10 - Unrecognized Symbol |
7237 11 Excessive Verbage (too many keywords or symbols) | 7239 11 - Excessive Verbage (too many keywords or symbols) |
7238 12 Illegal Statement Construction | 7240 12 - Illegal Statement Construction |
7239 13 I-code Overflow (need more workspace memory) | 7241 13 - I-code Overflow (need more workspace memory) |
7240 14 Illegal Channel Reference (bad path number given) | 7242 14 - Illegal Channel Reference (bad path number given) |
7241 15 Illegal Mode (Read/Write/Update/Dir only) | 7243 15 - Illegal Mode (Read/Write/Update/Dir only) |
7242 16 Illegal Number | 7244 16 - Illegal Number |
7243 17 Illegal Prefix | 7245 17 - Illegal Prefix |
7244 18 Illegal Operand | 7246 18 - Illegal Operand |
7245 19 Illegal Operator | 7247 19 - Illegal Operator |
7246 | 7248 |
7247 20 Illegal Record Field Name | 7249 20 - Illegal Record Field Name |
7248 21 Illegal Dimension | 7250 21 - Illegal Dimension |
7249 22 Illegal Literal | 7251 22 - Illegal Literal |
7250 23 Illegal Relational | 7252 23 - Illegal Relational |
7251 24 Illegal Type Suffix | 7253 24 - Illegal Type Suffix |
7252 25 Too-Large Dimension | 7254 25 - Too-Large Dimension |
7253 26 Too-Large Line Number | 7255 26 - Too-Large Line Number |
7254 27 Missing Assignment Statement | 7256 27 - Missing Assignment Statement |
7255 28 Missing Path Number | 7257 28 - Missing Path Number |
7256 29 Missing Comma | 7258 29 - Missing Comma |
7257 | 7259 |
7258 30 Missing Dimension | 7260 30 - Missing Dimension |
7259 31 Missing DO Statement | 7261 31 - Missing DO Statement |
7260 32 Memory Full (need more workspace memory) | 7262 32 - Memory Full (need more workspace memory) |
7261 33 Missing GOTO | 7263 33 - Missing GOTO |
7262 34 Missing Left Parenthesis | 7264 34 - Missing Left Parenthesis |
7263 35 Missing Line Reference | 7265 35 - Missing Line Reference |
7264 36 Missing Operand | 7266 36 - Missing Operand |
7265 37 Missing Right Parenthesis | 7267 37 - Missing Right Parenthesis |
7266 38 Missing THEN statement | 7268 38 - Missing THEN statement |
7267 39 Missing TO | 7269 39 - Missing TO |
7268 | 7270 |
7269 40 Missing Variable Reference | 7271 40 - Missing Variable Reference |
7270 41 No Ending Quote | 7272 41 - No Ending Quote |
7271 42 Too Many Subscripts | 7273 42 - Too Many Subscripts |
7272 43 Unknown Procedure | 7274 43 - Unknown Procedure |
7273 44 Multiply-Defined Procedure | 7275 44 - Multiply-Defined Procedure |
7274 45 Divide by Zero | 7276 45 - Divide by Zero |
7275 46 Operand Type Mismatch | 7277 46 - Operand Type Mismatch |
7276 47 String Stack Overflow | 7278 47 - String Stack Overflow |
7277 48 Unimplemented Routine | 7279 48 - Unimplemented Routine |
7278 49 Undefined Variable | 7280 49 - Undefined Variable |
7279 | 7281 |
7280 50 Floating Overflow | 7282 50 - Floating Overflow |
7281 51 Line with Compiler Error | 7283 51 - Line with Compiler Error |
7282 52 Value out of Range for Destination | 7284 52 - Value out of Range for Destination |
7283 53 Subroutine Stack Overflow | 7285 53 - Subroutine Stack Overflow |
7284 54 Subroutine Stack Underflow | 7286 54 - Subroutine Stack Underflow |
7285 55 Subscript out of Range | 7287 55 - Subscript out of Range |
7286 56 Parameter Error | 7288 56 - Parameter Error |
7287 57 System Stack Overflow | 7289 57 - System Stack Overflow |
7288 58 I/O Type Mismatch | 7290 58 - I/O Type Mismatch |
7289 59 I/O Numeric Input Format Bad | 7291 59 - I/O Numeric Input Format Bad |
7290 | 7292 |
7291 60 I/O Conversion: Number out of Range | 7293 60 - I/O Conversion: Number out of Range |
7292 61 Illegal Input Format | 7294 61 - Illegal Input Format |
7293 62 I/O Format Repeat Error | 7295 62 - I/O Format Repeat Error |
7294 63 I/O Format Syntax Error | 7296 63 - I/O Format Syntax Error |
7295 64 Illegal Path Number | 7297 64 - Illegal Path Number |
7296 65 Wrong Number of Subscripts | 7298 65 - Wrong Number of Subscripts |
7297 66 Non-Record-Type Operand | 7299 66 - Non-Record-Type Operand |
7298 67 Illegal Argument | 7300 67 - Illegal Argument |
7299 68 Illegal Control Structure | 7301 68 - Illegal Control Structure |
7300 69 Unmatched Control Structure | 7302 69 - Unmatched Control Structure |
7301 | 7303 |
7302 70 Illegal FOR Variable | 7304 70 - Illegal FOR Variable |
7303 71 Illegal Expression Type | 7305 71 - Illegal Expression Type |
7304 72 Illegal Declarative Statement | 7306 72 - Illegal Declarative Statement |
7305 73 Array Size Overflow | 7307 73 - Array Size Overflow |
7306 74 Undefined Line Number | 7308 74 - Undefined Line Number |
7307 75 Multiply-Defined Line Number | 7309 75 - Multiply-Defined Line Number |
7308 76 Multiply-Defined Variable | 7310 76 - Multiply-Defined Variable |
7309 77 Illegal Input Variable | 7311 77 - Illegal Input Variable |
7310 78 Seek Out of Range | 7312 78 - Seek Out of Range |
7311 79 Missing Data Statement | 7313 79 - Missing Data Statement |
7312 80 Print Buffer Overflow | 7314 80 - Print Buffer Overflow |
7313 </literallayout> | 7315 </literallayout> |
7314 | 7316 |
7315 Error codes above 80 are those used by OS-9 or other external programs. | 7317 Error codes above 80 are those used by OS-9 or other external programs. |
7316 Consult the "OS-9 User's Guide" for a list of error codes and explanations. | 7318 Consult the "OS-9 User's Guide" for a list of error codes and explanations. |
7317 </para> | 7319 </para> |
7346 191 will be replaced by 191. Some of the graphics functions require | 7348 191 will be replaced by 191. Some of the graphics functions require |
7347 or optionally accept a colour mode which controls the foreground | 7349 or optionally accept a colour mode which controls the foreground |
7348 colour and colour set. The mode and colour codes are given in the | 7350 colour and colour set. The mode and colour codes are given in the |
7349 table on the next page. | 7351 table on the next page. |
7350 </para> | 7352 </para> |
7351 <beginpage> | 7353 <beginpage/> |
7352 <table frame="none"> | 7354 <table frame="none"> |
7353 <title>Colour Graphics Modes and Colour Codes</title> | 7355 <title>Colour Graphics Modes and Colour Codes</title> |
7354 <tgroup cols="6"> | 7356 <tgroup cols="6"> |
7355 <colspec colname="c1" colwidth="0.6in"> | 7357 <colspec colname="c1" colwidth="0.6in"/> |
7356 <colspec colname="c2" colwidth="0.4in"> | 7358 <colspec colname="c2" colwidth="0.4in"/> |
7357 <colspec colname="c3" colwidth="1in"> | 7359 <colspec colname="c3" colwidth="1in"/> |
7358 <colspec colname="c4" colwidth="1in"> | 7360 <colspec colname="c4" colwidth="1in"/> |
7359 <colspec colname="c5" colwidth="1in"> | 7361 <colspec colname="c5" colwidth="1in"/> |
7360 <colspec colname="c6" colwidth="1in"> | 7362 <colspec colname="c6" colwidth="1in"/> |
7361 <thead> | 7363 <thead> |
7362 <row> | 7364 <row> |
7363 <entry morerows="1" namest="c2">Colour Code</entry> | 7365 <entry morerows="1" namest="c2">Colour Code</entry> |
7364 <entry align="center" namest="c3" nameend="c4">Two Colour Format</entry> | 7366 <entry align="center" namest="c3" nameend="c4">Two Colour Format</entry> |
7365 <entry align="center" namest="c5" nameend="c6">Four Colour Format</entry> | 7367 <entry align="center" namest="c5" nameend="c6">Four Colour Format</entry> |
7528 changes the foreground colour to green in four-colour format (or | 7530 changes the foreground colour to green in four-colour format (or |
7529 black in two-colour format). | 7531 black in two-colour format). |
7530 </para> | 7532 </para> |
7531 <bridgehead renderas="sect2">POINT</bridgehead> | 7533 <bridgehead renderas="sect2">POINT</bridgehead> |
7532 <cmdsynopsis> | 7534 <cmdsynopsis> |
7533 <command>Calling Syntax: RUN GFX("Point",X,Y) or</command><sbr> | 7535 <command>Calling Syntax: RUN GFX("Point",X,Y) or</command><sbr/> |
7534 <command>RUN GFX("Point",X,Y,Colour)</command> | 7536 <command>RUN GFX("Point",X,Y,Colour)</command> |
7535 </cmdsynopsis> | 7537 </cmdsynopsis> |
7536 <para> | 7538 <para> |
7537 POINT moves the graphics cursor to the specified X.Y coordinate and | 7539 POINT moves the graphics cursor to the specified X.Y coordinate and |
7538 sets the pixel at that coordinate to the current foreground colour. | 7540 sets the pixel at that coordinate to the current foreground colour. |
7545 the foreground colour to green in two-colour format, or it changes | 7547 the foreground colour to green in two-colour format, or it changes |
7546 the colour to yellow in the four-colour format. | 7548 the colour to yellow in the four-colour format. |
7547 </para> | 7549 </para> |
7548 <bridgehead renderas="sect2">CLEAR</bridgehead> | 7550 <bridgehead renderas="sect2">CLEAR</bridgehead> |
7549 <cmdsynopsis> | 7551 <cmdsynopsis> |
7550 <command>Calling Syntax: RUN GFX("Clear") or</command><sbr> | 7552 <command>Calling Syntax: RUN GFX("Clear") or</command><sbr/> |
7551 <command>RUN GFX("Clear",Colour)</command> | 7553 <command>RUN GFX("Clear",Colour)</command> |
7552 </cmdsynopsis> | 7554 </cmdsynopsis> |
7553 <para> | 7555 <para> |
7554 CLEAR resets all points on the screen to the background colour, or | 7556 CLEAR resets all points on the screen to the background colour, or |
7555 if the optional colour is given presets the screen to that colour. | 7557 if the optional colour is given presets the screen to that colour. |
7556 The current graphics cursor is reset to (0,0). | 7558 The current graphics cursor is reset to (0,0). |
7557 </para> | 7559 </para> |
7558 <bridgehead renderas="sect2">LINE</bridgehead> | 7560 <bridgehead renderas="sect2">LINE</bridgehead> |
7559 <cmdsynopsis> | 7561 <cmdsynopsis> |
7560 <command>Calling Syntax: RUN GFX("Line",x2,y2)</command><sbr> | 7562 <command>Calling Syntax: RUN GFX("Line",x2,y2)</command><sbr/> |
7561 <command>RUN GFX("Line",x2,y2,Colour)</command><sbr> | 7563 <command>RUN GFX("Line",x2,y2,Colour)</command><sbr/> |
7562 <command>RUN GFX("Line",x1,y1,x2,y2)</command><sbr> | 7564 <command>RUN GFX("Line",x1,y1,x2,y2)</command><sbr/> |
7563 <command>RUN GFX("Line",x1,y1,x2,y2,Colour)</command> | 7565 <command>RUN GFX("Line",x1,y1,x2,y2,Colour)</command> |
7564 </cmdsynopsis> | 7566 </cmdsynopsis> |
7565 <para> | 7567 <para> |
7566 LINE draw lines in various ways. If one coordinate is given, the | 7568 LINE draw lines in various ways. If one coordinate is given, the |
7567 line will be drawn from the current graphics cursor position to the | 7569 line will be drawn from the current graphics cursor position to the |
7579 </programlisting> | 7581 </programlisting> |
7580 draws a blue line (4-colour mode) to point 24,65. | 7582 draws a blue line (4-colour mode) to point 24,65. |
7581 </para> | 7583 </para> |
7582 <bridgehead renderas="sect2">CIRCLE</bridgehead> | 7584 <bridgehead renderas="sect2">CIRCLE</bridgehead> |
7583 <cmdsynopsis> | 7585 <cmdsynopsis> |
7584 <command>Calling Syntax: RUN GFX("Circle",Radius)</command><sbr> | 7586 <command>Calling Syntax: RUN GFX("Circle",Radius)</command><sbr/> |
7585 <command>RUN GFX("Circle",Radius,Colour)</command><sbr> | 7587 <command>RUN GFX("Circle",Radius,Colour)</command><sbr/> |
7586 <command>RUN GFX("Circle",X,Y,Radius)</command><sbr> | 7588 <command>RUN GFX("Circle",X,Y,Radius)</command><sbr/> |
7587 <command>RUN GFX("Circle",X,Y,Radius,Colour)</command> | 7589 <command>RUN GFX("Circle",X,Y,Radius,Colour)</command> |
7588 </cmdsynopsis> | 7590 </cmdsynopsis> |
7589 <para> | 7591 <para> |
7590 CIRCLE draws a circle of the given radius. The current graphics | 7592 CIRCLE draws a circle of the given radius. The current graphics |
7591 cursor position is assumed if no X,Y value is given. The current | 7593 cursor position is assumed if no X,Y value is given. The current |
7620 to create special functions that are not available in the Graphics | 7622 to create special functions that are not available in the Graphics |
7621 Module. | 7623 Module. |
7622 </para> | 7624 </para> |
7623 <bridgehead renderas="sect2">GCOLR</bridgehead> | 7625 <bridgehead renderas="sect2">GCOLR</bridgehead> |
7624 <cmdsynopsis> | 7626 <cmdsynopsis> |
7625 <command>Calling Syntax: RUN GFX("Gcolr",Colour)</command><sbr> | 7627 <command>Calling Syntax: RUN GFX("Gcolr",Colour)</command><sbr/> |
7626 <command>RUN GFX("Gcolr",X,Y,Colour)</command> | 7628 <command>RUN GFX("Gcolr",X,Y,Colour)</command> |
7627 </cmdsynopsis> | 7629 </cmdsynopsis> |
7628 <para> | 7630 <para> |
7629 GCOLR is used to read the colour of the pixel at the current | 7631 GCOLR is used to read the colour of the pixel at the current |
7630 graphics cursor position, or from the coordinates X,Y. The | 7632 graphics cursor position, or from the coordinates X,Y. The |