annotate docs/basic09/basic09.docbook @ 1504:d3a421a9f13f

added shell+ features
author boisy
date Tue, 13 Jan 2004 21:56:38 +0000 (2004-01-13)
parents 958740284209
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1 <?xml version="1.0" ?>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
1015
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
4 <!ENTITY b09 "BASIC09">
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
5 <!ENTITY CPU "6809">
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
6 <!ENTITY os9level "OS-9 Level One">
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
7 <!ENTITY os9version "Version 02.01.01 BETA1">
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
8 <!ENTITY vendor "The CoCo Community">
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
9 <!ENTITY make "TRS-80/Tandy Color Computer">
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
10 <!ENTITY mdash "&#8212;">
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
11 <!ENTITY gfxapp SYSTEM "gfx.appendix">
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
12 <!ENTITY gfx2app SYSTEM "gfx2.appendix">
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
13 ]>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
14 <book id="basic09" lang="en">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
15 <bookinfo>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
16 <title>&b09;</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
17 <subtitle>Programming Language Reference Manual</subtitle>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
18 <titleabbrev>&b09; Reference Manual</titleabbrev>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
19
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
20 <copyright>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
21 <year>1983</year>
1015
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
22 <holder>Microware Systems Corporation.
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
23 All Rights Reserved.
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
24 Basic09 is a trademark of Microware Systems Corporation and Motorola Inc.
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
25 </holder>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
26
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
27 </copyright>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
28 <revhistory>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
29 <revision>
1015
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
30 <revnumber>A</revnumber>
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
31 <date>March 2003</date>
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
32 <revremark>Updated for OS-9 Level One Version 02.01.01</revremark>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
33 </revision>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
34 </revhistory>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
35 </bookinfo>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
36
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
37
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
38
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
39 <chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
40 <title>Introduction</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
41 <subtitle>Introduction to &b09; Programming</subtitle>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
42 <sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
43 <title>Comments on &b09;</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
44 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
45 &b09; is an enhanced structured Basic language programming
1015
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
46 system specially created for the &CPU; Advanced Microprocessor
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
47 used by the &make;.
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
48 In addition to the standard BASIC language statements and functions,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
49 &b09; includes many of the useful elements of the PASCAL
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
50 programming language so that programs can be modular,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
51 well-structured, and use sophisticated data structures.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
52 It also permits full access
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
53 to almost all of the OS-9 Operating System commands and functions so it
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
54 can be used as a systems programming language.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
55 These features make &b09; an ideal language for many applications:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
56 scientific, business, industrial control, education and more.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
57 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
58 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
59 &b09; is unusual in that it is an <emphasis>Interactive Compiler</emphasis> that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
60 has the best of both kinds of language system: it gives
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
61 the fast execution speed typical of compiler languages plus the ease of use
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
62 and memory space efficiency typical of interpreter languages.
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
63 &b09; is a complete <emphasis>programming system</emphasis> that
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
64 includes a powerful text editor, multi-pass compiler,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
65 run-time interpreter, high-level interactive debugger, and a system
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
66 executive. Each of these components was carefully integrated
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
67 to give the user a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
68 friendly, highly interactive programming resource. that provides all the tools
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
69 and helpful "extra" facilities needed for fast, accurate creation and testing of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
70 structured programs.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
71 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
72
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
73 <highlights>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
74 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
75 &b09; Features
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
76
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
77 <itemizedlist mark="bullet">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
78
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
79 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
80 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
81 Structured, recursive BASIC with Pascal-type enhancements:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
82 <itemizedlist mark="dash">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
83 <listitem><para>allows multiple, independent, named procedures</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
84 <listitem><para>procedures called by name with parameters</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
85 <listitem><para>multi-character, upper or lower case identifiers</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
86 <listitem><para>variables and line numbers local to procedures</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
87 <listitem><para>line numbers optional</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
88 <listitem><para>automatic linkage to ROM or RAM "library" procedures</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
89 <listitem><para>PACK command compacts program and provides security</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
90 <listitem><para>PRINT USING with FORTRAN-like format specifications</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
91 </itemizedlist>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
92 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
93 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
94
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
95
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
96 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
97 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
98 Extended data structures:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
99 <itemizedlist mark="dash">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
100 <listitem><para>Five Basic data types: BYTE, INTEGER, REAL, BOOLEAN, and STRING</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
101 <listitem><para>One, two, or three dimensional arrays</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
102 <listitem><para>User-defined complex structures and data types</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
103 </itemizedlist>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
104 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
105 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
106
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
107
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
108 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
109 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
110 Extended Control Structures (with Unique Closure Elements):
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
111 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
112 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
113
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
114
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
115 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
116 <para>
1015
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
117 Graphics Interface Module for Access to &make; Color
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
118 Graphics Functions
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
119 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
120 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
121
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
122
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
123 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
124 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
125 Powerful interactive debugging and editing features:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
126 <itemizedlist mark="dash">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
127 <listitem><para>Integral, full-featured text editor</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
128 <listitem><para>Syntax error check upon line entry and procedure compile</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
129 <listitem><para>Trace mode reproduces original source statements</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
130 <listitem><para>Renumber command for line numbered procedures</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
131 </itemizedlist>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
132 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
133 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
134
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
135
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
136 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
137 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
138 High-speed, high-accuracy math:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
139 <itemizedlist mark="dash">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
140 <listitem><para>9 decimal-digit 40 bit binary floating point</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
141 <listitem><para>Full set of transcendentals (SIN, ASN, ACS, LOG, etc.)</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
142 </itemizedlist>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
143 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
144 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
145 </itemizedlist>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
146
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
147 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
148 </highlights>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
149 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
150 <sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
151 <title>The History of &b09;</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
152 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
153 &b09; was conceived in 1978 as a high-performance
1015
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
154 programming language to demonstrate the capabilities of the &CPU;
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
155 microprocessor to efficiently run high-level languages. &b09;
1015
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
156 was developed at the same time as the &CPU; under the auspices of the
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
157 architects of the &CPU;. The project covered
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
158 almost two years, and incorporated the results of research in such areas as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
159 interactive compilation, fast floating point arithmetic algorithms, storage
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
160 management, high-level symbolic debugging, and structured language
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
161 design. These innovations give &b09; its speed, power, and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
162 unique flavor.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
163 </para><para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
164 &b09; was commissioned by Motorola, Inc., Austin, Texas,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
165 and developed by Microware Systems Corporation, Des Moines, Iowa.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
166 Principal designers of &b09; were Larry Crane, Robert
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
167 Doggett, Ken Kaplan, and Terry Ritter. The first release was in February,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
168 1980.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
169 </para><para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
170 Excellent feedback, thoughtful suggestions, and carefully documented bug
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
171 reports from &b09; users all over the world have been
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
172 invaluable to the designers in their efforts to achieve the degree of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
173 sophistication and reliability &b09; has today.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
174 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
175 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
176 </chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
177
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
178
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
179
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
180 <chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
181 <title>Introduction to &b09; Programming</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
182 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
183
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
184 This section is intended for persons who have not previously
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
185 written computer programs. If you are familiar with programming in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
186 general or BASIC programming specifically, this section can give you
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
187 a "feel" for the &b09; interactive environment.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
188
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
189 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
190 <sect1><title>What is a Program?</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
191 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
192 A computer works something like a pocket calulator. With a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
193 calculator you push a button, some calculation occurs, and the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
194 result is displayed. On some calculators you can write a program
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
195 which is just a list of the buttons you want pushed, in the order
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
196 you want them pushed. This is very similar to a computer program,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
197 but most computer languages use command names instead of buttons.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
198 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
199
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
200 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
201 To get results from a computer, you must first put into the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
202 computer the list of commands you want executed in the order you
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
203 want them executed. Each command will mean "do this thing" or "do
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
204 that thing", but the computer only has certain commands which it
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
205 will understand. A computer can do things like "add" or "save the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
206 result into memory". Typing "get me a taco" to a computer won't
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
207 get it; similarly, on a calculator you can't push buttons which
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
208 aren't there. After you have stored a list of commands into the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
209 computer, you can tell it to perform those operations. This is like
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
210 actually pushing the buttons on a hand calculator. Then, if you
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
211 remembered to have the compuer display your results, you get to see
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
212 them. Generaly, a computer does not automatically display results
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
213 like a hand calculator. More calculations occur in a computer then
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
214 in a calculator, and displaying all these results would simply be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
215 overwhelming.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
216 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
217
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
218 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
219 You enter a program into a computer by using the computer
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
220 itself as a "text editor", to store the commands you type in. Some
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
221 editors allow you to enter any text you want. Other editors will
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
222 only store valid computer commands. Even if the computer does store
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
223 all the text you type in, it can only execute those commands it
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
224 knows. If during program execution, &b09; finds a word which does
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
225 not correspond to a command it will probably stop and print out an
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
226 "error message". Other editors check each command as you enter it
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
227 (usually after the carriage-return ending each line) and print error
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
228 messages immediately for invalid commands. After typing in your
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
229 list of commands, there are ways to display that list, to modify the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
230 commands you have typed in, and to insert others. But simpy
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
231 entering a computer program does not get results any more than
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
232 thinking which buttons to push will get results on a calculator.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
233 You store your program by typing it into a computer, but no results
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
234 are available until after you start the program running.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
235 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
236 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
237 Even though programming is conceptually simple, it is easy to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
238 misspell commands which &b09; will not interpret correctly.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
239 Unlike humans, &b09; does not infer anything: Every command must
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
240 be perfectly spelled and punctuated or it is wrong. Even after
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
241 spelling errors are eliminated, it is likely that the sequence of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
242 commands you have entered will not do the job you wanted it to do.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
243 The meaning of the program to &b09; is often quite different than
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
244 was intended by the programmer, biut good intentions just don't push
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
245 the right buttons. After you get the program to run without obvious
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
246 error, you must test the program with sample input and see that it
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
247 produces results which are known correct. If the results are incorrect,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
248 the program must be modified and tested until it does
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
249 produce correct results. This is known as testing and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
250 debugging. Computer malfunctions are rare, and if the computer
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
251 works to store the program, it is probably working perfectly. If the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
252 program does not work, you need to puzzle out how the computer is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
253 doing something hich you didn't realize that you told it to do.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
254 Programming can be frustrating, but if you enter the right commands,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
255 the computer will do the right things for you.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
256 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
257 <sect1><title>A Simple &b09; Program</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
258 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
259 Probably the easiest way to explain programming is by example.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
260 This simple program sometimes keeps kids happy for hours. First,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
261 the program asks the user for his name. Then the computer types out
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
262 "Hi", then the name, then "see you later". This may not seem like
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
263 much, but it is great fun to type in things which are not your name,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
264 and see if they will be printed out. They will, of course.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
265 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
266 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
267 When you turn on the &b09; computer it will print some heading
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
268 information. If the prompt is "OS9: ", enter the "basic09" (and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
269 a carriage-return) to get to the prompt "B:". When you have the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
270 prompt "B:", it means that the system is in the &b09; "command
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
271 mode". While in the command mode, you can do several things, like:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
272 list, kill, or create programs (called "procedures" in &b09;).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
273 &b09; lets you keep several different programs in memory at the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
274 same time. Each procedure is identified by a name you give it when
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
275 you create the procedure.</para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
276 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
277 To create a new procedure you command the system to enter the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
278 "edit mode" by typing a simpl "e" (in upper or lower case) and a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
279 carriage-return (the ENTER or RETURN key). The Editor lets you
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
280 enter or change programs and actually checks for many common errors
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
281 as you type in your program. This automatic checking feature is one
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
282 of the nicest things about &b09;. Because it's always "looking
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
283 over your shoulder" to catch mistakes, it saves a lot of debugging
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
284 time! If you're not 100% sure about how something works - you can
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
285 go ahead and try it instead of digging through this manual. If you
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
286 guess wrong &b09; will usually show you where and why.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
287 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
288 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
289 Because you did not specify a particular procedure name,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
290 &b09; will automatically select the name "PROGRAM" for you, and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
291 will respond by printing out "PROCEDURE PROGRAM"; this means that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
292 you will be editing a procedure which is named PROGRAM. Later you
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
293 will see that you can enter many different procedures and give them
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
294 different names (just type the name you want to use for the program
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
295 after the "e").
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
296 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
297 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
298 The computer output so far is a follows:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
299 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
300 B:e
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
301 PROCEDURE PROGRAM
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
302 *
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
303 E:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
304 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
305 The asterisk (*) indicates the "current edit line" in the procedure
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
306 being edited. In this case the current line is empty since you have
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
307 not yet entered anything. The asterisk is handy, since you will be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
308 moving back and forth between different lines to edit them. Later
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
309 you will be "opening" existing procedures for modification, and the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
310 first line will be displayed automatically, helping identify that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
311 you are editing the correct program.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
312 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
313 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
314 When &b09; responds with the edit prompt "E:", it is in the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
315 edit mode. Now you can enter "edit commands" which help us enter
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
316 the computer program. While in edit mode, <emphasis>&b09; always takes the
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
317 first character of every line as an edit command.</emphasis>
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
318 Some of the basic edit commands are:
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
319 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
320 &lt;space> &lt;program statement> &lt;cr> insert line
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
321 ? &lt;cr> go to next line down (just &lt;cr> also does the same)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
322 - &lt;cr> move back to previous line
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
323 L &lt;cr> list current line
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
324 d &lt;cr> delete current line
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
325 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
326 The most-important edit command is the (invisible) space character;
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
327 this means "save the following line of text", The "space" command
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
328 is the way most text is entered into the system. you must type an
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
329 edit command at the start of each line. If a line is to be entered,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
330 you must type a space before the rest of the line. If you forget to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
331 type an edit command, &b09; will respond with "WHAT?". Another
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
332 useful edit command is "L*" (or "l*", since the editor accepts
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
333 either upper or lower case) which will display the whole procedure.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
334 This allows you to watch the procedure develop as lines are entered.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
335 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
336 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
337 You use the "space" command to enter the following line:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
338 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
339 E: print "type your name"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
340 *
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
341 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
342 When &b09; executes procedure PROGRAM, this line will tell it to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
343 print on the screen all of the characters between the quotes.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
344 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
345 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
346 As mentioned before, &b09; checks for errors at the end of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
347 each line and again when the edit is finished. These errors are, in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
348 general, anything &b09; cannot identify or things that don't
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
349 conform to the rules of the language. An error could be a bad
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
350 character, mismatched parenthesis, or one of many other things.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
351 &b09; will print out an "error code" to identify the error and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
352 print an up arrow character under the place in the line where it
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
353 detected the error. The error codes are listed at the end of this
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
354 manual. If the error was detected at the end of the edit session,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
355 the I-code location of the error will also be printed. This cryptic
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
356 information is all &b09; knows about the problem, hopefully, it
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
357 will help you to find and fix the error.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
358 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
359 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
360 In the same way that you entered the first line, enter the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
361 following lines. Remember that the first character entered must be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
362 a space to get &b09; to save the rest of the line. Example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
363 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
364 E: input name$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
365 *
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
366 E: print "Hi ";name$;", see you later."
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
367 *
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
368 E: end
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
369 *
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
370 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
371 The second line ("input name$"), when executed, commands &b09; to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
372 wait for a line of text to come in from the keyboard (this will
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
373 happen after the user reads the message printed out in the first
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
374 line). &b09; will accumulate text from the keyboard character-by-character
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
375 until a carriage-return ends the line. This text is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
376 placed in memory corresponding to the variable "name$". The dollar-sign
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
377 ($) on the end of the variable tells &b09; that you want to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
378 store a sequence of characters as opposed to a number.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
379 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
380 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
381 The third line of procedure PROGRAM (print "Hi ";name$;", see
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
382 you later."), starts out like the first line. The command "print"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
383 causes &b09; to print out the various values which come after it.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
384 When this line is executed, the characters H, i, and "space" are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
385 printed out since the are enclosed in double-quotes. Next, without
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
386 additional spaces, &b09; prints out the line which was typed in by
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
387 the user and saved in the memory corresponding to "name$" and prints
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
388 out " see you later". When a PRINT statement contains multiple values,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
389 it will print them out one after the other. If the separator
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
390 is a comma, &b09; will move to the next 16-column "tab stop"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
391 before printing the next value. However, if the separator between
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
392 print values is a semicolon, absolutely no space will separate the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
393 values. The last line of the procedure ("END") tells &b09; to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
394 stop executing the program and return to the command mode (B:).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
395 You have not yet EXECUTED the procedure, you are just EDITING. If
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
396 you type in l* the whole program will be listed, as follows:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
397 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
398 E:l*
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
399 PROCEDURE PROGRAM
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
400 0000 PRINT "type your name"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
401 0012 INPUT name$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
402 0017 PRINT "Hi ";name$;", see you later."
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
403 0035 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
404 *
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
405 E:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
406 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
407 Notice that the editor has added some information which you did not
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
408 type in. You can use this listing to show exactly what to type in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
409 to run this program, but the editor only wants the relevant
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
410 information.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
411 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
412 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
413 The numbers to the left are "I-code addresses". These are the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
414 actual memory locations relative to the start of the procedure where
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
415 each line begins. These numbers may look strange because they are in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
416 hexadecimal (base 16). These values are important, since the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
417 compiler may find errors at some I-code location and will try to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
418 convey that information it has to the programmer. I-code addresses
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
419 are supplied automatically by &b09;.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
420 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
421 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
422 The space between the "I-code addresses" and the beginning of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
423 the program line is reserved for "line numbers". Line numbers are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
424 required in many versions of BASIC (although not in &b09;).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
425 Notice that although the program was typed in lower case some words
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
426 are printed in upper case. &b09; identifies valid command
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
427 "keywords" and converts them to upper case automatically.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
428 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
429 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
430 Now let's run it. First type "q" to quit the editor. We are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
431 nowback in "command mode" ( B:). Now type "run". &b09;
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
432 remembers the procedure edited (PROGRAM) and starts to execute
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
433 it.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
434 <screen>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
435 E:q
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
436 READY
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
437 B:run
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
438 type your name
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
439 ? tex
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
440 Hi tex, see you later.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
441 READY
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
442 B:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
443 </screen>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
444 The question mark (?) is the normal input prompt to tell the user
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
445 that the program is waiting for input.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
446 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
447 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
448 This program is extremely simple, but younger kids can get
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
449 grat fun from it. Its action is especially amusing to young people
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
450 who are learning a computer language for the first time because a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
451 machine is "responding" to them, and because the machine is too
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
452 easily "fooled" if you do not type in a real name.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
453 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
454 <sect1><title>Basic Programming Techniques: Loops and Arithmetic</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
455 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
456 Another simple program that most of us can identify with is a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
457 program to print out multiplication tables.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
458 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
459 PROCEDURE multable
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
460 FOR i=1 TO 9
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
461 FOR j=1 TO 9
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
462 PRINT i*j; TAB(5*j);
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
463 NEXT j
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
464 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
465 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
466 First, open the editor by typing "e multable", as follows:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
467 <screen>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
468 B: e multable
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
469 PROCEDURE multable
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
470 *
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
471 E:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
472 </screen>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
473 Next, type in the program line-by-line staring with "FOR i=1 TO 9"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
474 (lower-case is perfectly fine). If you loose your way, type "L*" to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
475 see where you are. This will display the entire procedure and put
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
476 an asterisk at the left of the current line. If you make a mistake,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
477 use "+" or "-" to mode to that line, use "d" to delete the line, and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
478 use the space command to enter the line over. Make sure that there
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
479 are no errors and then type "q". When you have the program running,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
480 try adding a statement before "FOR i=1 TO 9" as follows: "DIM
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
481 i,j:INTEGER".
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
482 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
483 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
484 The FOR i=1 TO 9 and NEXT i constitute the start and end of a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
485 control structure or "loop". A control structure is used to cause
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
486 repeated or conditional execution of the statement(s) it surrounds.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
487 A control structure usually has one entry at the top and one exit at
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
488 the bottom. In this way, the entire structure take on the properties
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
489 of a single statement. The beginning statement of the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
490 FOR...NEXT structure (FOR...) provides a "loop initialization", places
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
491 the value 1 in the storage called "i", and sets up the operation of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
492 the following NEXT (every FOR must have a NEXT). When "NEXT i" is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
493 executed, the value in "i" is increased by 1 (which is the default
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
494 STEP size) and compared to the value 9 (which is the ending value
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
495 for this loop). If the resulting "i" is less than or equal to 9,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
496 the statement(s) following that FOR... is (are) executed.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
497 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
498 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
499 Loops can be "nested" to execute the enclosed statements even
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
500 more times. For example, the PRINT statement in "multable" is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
501 executed 81 times; once for each of 9 values of "j" and this number
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
502 (9 times) for each of 9 values of "i". The ability to tremendously
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
503 increase the number of times some code is executed is at the heart
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
504 of both computer programming and computer errors. It means that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
505 a vary small portion of a program can often be made to do the vast
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
506 majority of the work. But a few remaining special cases may require
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
507 individual handling and may consume more programming and code than
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
508 that which "usually" works. Unfortunately, "usually" is not
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
509 sufficient. A special case which occurs once in a thousand times
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
510 may occur once a second, and if the error stops the program, further
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
511 processing of normal values also stops. Experience has indicated
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
512 that the programmer should know what is happening in the first and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
513 second pass, and the next-to-the-last and last pass through each
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
514 loop in the program.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
515 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
516 <sect1><title>Listing Procedure Names</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
517 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
518 The "DIR" command causes &b09; to display the names and sizes
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
519 of all procedures in memory. This command is used so frequently
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
520 that there is a quick shorthand for DIR: a simple &lt;cr> when in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
521 command mode does the same thing. You will see
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
522 a table of all procedure names and two numbers next to each
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
523 name. The first column, "proc size", is the size of the corresponding
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
524 procedure. The "data size" column shows the amount of memory that the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
525 procedure requires for its variables.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
526 On the last line this command shows the amount of free bytes of workspace memory
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
527 remaining. You can use this information to estimate how much memory
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
528 your program needs to run. You must have at least as much free memory as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
529 the <emphasis>data size</emphasis> of the procedure(s) to be run. If a data size number is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
530 followed by a question mark, you need more memory.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
531 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
532 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
533 <sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
534 <title>Requesting More Memory</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
535 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
536 &b09; automatically get 4K of workspace memory from
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
537 OS-9 when it starts up. There is almost always more than this
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
538 available, but &b09; does not grab it all so other tasks running
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
539 on your computer can have memory too. If you are not multitasking
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
540 and need more memory, the MEM command can get it if available.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
541 Just type MEM and the amount of memory you want. Depending on your
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
542 computer and how it is configured, you can usually get at least 24K
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
543 in OS-9 Level One Systems or 40K in OS-9 Level Two systems. For
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
544 example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
545 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
546 MEM 20000
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
547 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
548
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
549 requests 20.000 (20K) bytes of memory. &b09; will always round the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
550 amount you request up to the next highest multiple of 256 bytes. If MEM
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
551 responds with "WHAT?", this means that much memory is not
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
552 available. There is another convenient way to do the same thing
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
553 when you first call up &b09; from OS-9. OS-9 has a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
554 "#" <emphasis>memory size option</emphasis> on command lines
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
555 that let you specify how much memory to give the program.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
556 To call &b09; with 16K of memory to start with, you can type:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
557 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
558 OS9: basic #16k
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
559 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
560 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
561 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
562 <sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
563 <title>Storing and Recalling Programs</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
564 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
565 Nobody wants to retype a whole program every time it is to be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
566 run. Two commands, SAVE and LOAD, are used to store programs and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
567 recall previously "SAVEd" programs to or from OS-9 disk files. The
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
568 simples way to use SAVE is by itself. It will store the procedure
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
569 last edited or run on a disk file having the same name. For
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
570 example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
571 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
572 B: save
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
573 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
574 If our procedure name was the default name "PROGRAM", &b09; will
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
575 create a file called "PROGRAM" to hold it. OS-9 won't let you have
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
576 two files of the same name because unique names are necesary to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
577 identify the specific file you want. Therefore if a file called
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
578 "PROGRAM" already exists, &b09; will ask you:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
579 <screen>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
580 Overwrite?
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
581 </screen>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
582 If you respond "Y" for YES, it will replace the file previously
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
583 stored on that file with the program to be saved. This is OK if
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
584 what you want to save is a never version of the same program. But if
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
585 not you will permanently erase another program you may have wanted
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
586 to keep. If this is the case answer "N" for NO. Fortunately, there
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
587 is a simple way to store the procedure on a file using a different
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
588 name: just type SAVE, a ">", and a different file name of your
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
589 choice. The file can consist of any combination of up to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
590 thirty-one letters, numbers, periods, or underscores ("_"). The only
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
591 restriction is that the name must start with a letter A-Z or a-z.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
592 For example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
593 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
594 save >newprogram5
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
595 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
596 will save the program on a file called "newprogram5". There are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
597 several useful variations of the SAVE command that let you save
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
598 various combinations of programs on the same file. See the SAVE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
599 command description for more information. You should also read
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
600 Chapter 2 of the "OS-9 Users Manual" to learn about the OS-9
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
601 commands that deal with disk files.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
602 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
603 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
604 If you exit from &b09;, it will not automatically save your
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
605 programs. You must make sure to save them before you quit, or they
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
606 will be lost unless the were saved at some time before!
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
607 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
608 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
609 The LOAD command, as it's name implies, reads in a previously
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
610 save program from a file. You must give the name of the file with
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
611 the command. For example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
612 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
613 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
614 load program
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
615 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
616 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
617 If you just started &b09; and have not created any procedures,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
618 the command is very straightforward. As the procedure(s) stored in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
619 the file are loaded, &b09; displays their name(s) as they are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
620 brought in. Once the program is loaded, you can edit and/or run
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
621 it. But if you have a procedure in &b09; that has the same name
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
622 as a procedure stored in the file, &b09; will replace it with the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
623 new version loaded from the file. If this kind of conflict exists
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
624 you could loose your old program, so be sure to save or RENAME it
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
625 before loading a new one (remember that &b09; can keep several
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
626 procedures in memory at the same time as long as they have different
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
627 names). If you want to permanently erase all other procedures
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
628 before loading new ones, you can type:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
629 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
630 B: kill*
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
631 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
632 This tells &b09; to "kill" all procedures in memory and has the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
633 same effect as completely resetting &b09;.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
634 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
635 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
636 <sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
637 <title>How to Print Program Listings</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
638 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
639 If your computer is equipped with a printer, you will want to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
640 make hard-copy listings of your programs. This is easy to do - just
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
641 type:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
642 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
643 B: LIST* /p
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
644 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
645 This tells &b09; to LIST all procedures in memory to the output
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
646 device "/p" which is the printer device name in most OS-9 systems.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
647 Like the SAVE command, LIST has several useful variations. If you
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
648 want to list just one procedure (if there are more than on in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
649 memory) you can type:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
650 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
651 B: LIST procedurename >/P
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
652 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
653 If you want, you can put two or more procedure names (seperated by
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
654 spaces) before the semicolon and those specific procedures will be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
655 listed.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
656 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
657 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
658 Notice that if you omit the "/p" or ">/p" from the commands above,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
659 the programs will be listed on your display instead of the printer.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
660 This is the same as the "L*" command in Edit Mode. You will also
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
661 notice that the listing will be automatically "pretty-printed",
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
662 e.g. program levels within loops are indented for easy reading.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
663 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
664 <sect1><title>&b09;'s Four Modes:</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
665 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
666 At any given time, &b09; is in one of four modes:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
667
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
668 <literallayout>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
669 SYSTEM MODE: Used for executing system commands.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
670 EDIT MODE: Used for creating/editing procedures.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
671 EXECUTION MODE: Used for running procedures.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
672 DEBUG MODE: Used for testing procedures for errors.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
673 </literallayout>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
674 So far, you have been exposed to System Mode (SAVE, LOAD, etc.),
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
675 Edit Mode (the editor), and Execution Mode (RUN). A section of this
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
676 manual is devoted to each mode. The chart below shows how various
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
677 commands in each mode causes changes to other modes.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
678
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
679 <figure>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
680 <title>&b09; Mode Change Possibilities</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
681 <screen>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
682 OS-9 SYSTEM MODE EDIT MODE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
683 ---------- ------------ ------------
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
684 | | | | | + |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
685 | | | $ | | - |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
686 | | &lt;-----+--&lt;eof> | | &lt;cr> |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
687 | | &lt;-----+--BYE | | &lt;line#> |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
688 | | | CHD | | &lt;space> |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
689 | | | CHX | | c |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
690 | | | DIR | | d |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
691 | | | EDIT----+-------> | l |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
692 | | | KILL | &lt;-------+-q |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
693 | | | LIST | | r | ------------
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
694 |BASIC09-+-----> | LOAD | | s | | TRON |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
695 | | | MEM | ------------ | TROFF |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
696 | | | PACK | &lt;--------------------------+ END or Q |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
697 | | | RENAME | | DEG/RAD |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
698 | | | RUN-----+-------> ------------ | STATE |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
699 | | | SAVE | &lt;-------+-END | | $ |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
700 | | | | &lt;-------+-&lt;CTRL Q> | | BREAK |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
701 | | ------------ &lt;-------+-STOP | &lt;-----+-CONT |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
702 |BASIC09 | | PAUSE----+-----> | DIR |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
703 |AUTORUN-+--------------------------> | ERROR----+-----> | LET |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
704 | | | &lt;CTRL C>-+-----> | LIST |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
705 | | &lt;--------------------------+-BYE | | PRINT |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
706 | | | PROGRAM | &lt;-----+-STEP |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
707 ---------- ------------ ------------
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
708 EXECUTION MODE DEBUG MODE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
709 </screen>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
710 </figure>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
711 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
712 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
713 <sect1><title>More about the Workspace...</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
714 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
715 The workspace concept is important because &b09; and OS-9 are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
716 both highly modular systems, and the workspace is a way to logically
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
717 group a set of procedures (i.e. modules) which are applicable to a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
718 particular line of study or development. Modular software
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
719 development lets the programmer divide a large and complex project
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
720 into smaller, more manageable, and individually testable sections.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
721 Modularity also lets programmers accumulate and use libraries of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
722 commonly used routines.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
723 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
724 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
725 As the software is written and debugged, &b09; makes it easy
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
726 to deal with the procedures that comprise an overall project, either
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
727 individually or as a group. For example, you can save all procedures
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
728 on the wrkspace to a single mass stoarage file or load a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
729 file containing multiple procedures. Usually all procedures
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
730 associated witha project exists inside the workspace. However, you
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
731 can also call library procedures which are "outside" the workspace
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
732 in OS-9 memory module format. The library procedures can be written
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
733 in &b09; or machine language, can be in RAM or ROM memory, and can
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
734 even be shared by several users.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
735 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
736 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
737 &b09; always reserves approximately 1.2K bytes of the workspace
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
738 for internal use. All remaining space is used for storage of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
739 procedures and for procedure variable storage during execution.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
740 &b09; will not run a procedure if there is not enough space for
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
741 variables. If you run out of workspace area, you can use the MEM
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
742 command to enlarge the workspace or you can kill procedures in the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
743 workspace that are not needed. The "MEM" command can be used at any
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
744 time to change the size of the workspace. The size of the workspace
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
745 can be increased (subject to availability of free memory) or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
746 decreased (but not below the minimal amount needed to store the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
747 present workspace).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
748 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
749 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
750 <sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
751 <title>Where to go From Here?</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
752 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
753 A good way to learn &b09; is to use it! Try typing in and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
754 running some of the example programs in the back of the book. Look
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
755 at and study the function of each program statement. Read the chapters
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
756 on the EDIT and DEBUG modes and experiment with more advanced
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
757 commands. Also, &b09; and the OS-9 Operating System are so intimately
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
758 connected, a basic understanding of OS-9 is important. See
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
759 Chapter 2 of the "OS-9 User's Manual".
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
760 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
761 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
762 </chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
763 <chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
764 <title>System Mode</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
765 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
766 System mode includes commands to save, load, examine procedures;
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
767 commands to interact with OS-9; and other commands to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
768 control the workspace environment. A complete list of system commands
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
769 is given below.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
770 <table frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
771 <title>System Mode Commands</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
772 <tgroup cols="5">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
773 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
774 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
775 <entry>$</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
776 <entry>CHX</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
777 <entry>EDIT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
778 <entry>LOAD</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
779 <entry>RENAME</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
780 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
781 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
782 <entry>BYE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
783 <entry>DIR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
784 <entry>KILL</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
785 <entry>MEM</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
786 <entry>RUN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
787 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
788 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
789 <entry>CHD</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
790 <entry>E</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
791 <entry>LIST</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
792 <entry>PACK</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
793 <entry>SAVE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
794 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
795 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
796 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
797 </table>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
798 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
799 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
800 The system commands are processed by the &b09; "command interpreter"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
801 which always identifies itself with the "B:" prompt. It is entered
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
802 automatically when &b09; is started up and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
803 whenever you exit any other mode. Commands can be entered in either upper or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
804 lower-case letters.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
805 Commands such as DIR, MEM, "$", and BYE don't operate on specific
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
806 procedures, but may have optional or required parameters. Other commands
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
807 (such as SAVE, LOAD, PACK, KILL, and LIST) can operate on a specific
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
808 procedure or on ALL procedures within the workspace.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
809 If the command is used with a specific procedure name, the command is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
810 applied to only that procedure. For example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
811 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
812 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
813 list pete
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
814 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
815 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
816 will display the procedure named "pete".
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
817 The asterisk is a special name that means "all procedures in the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
818 workspace". Therefore, if the command is given follwed by an asterisk it
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
819 is applied to all procedures. For example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
820 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
821 list*
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
822 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
823 will display all of the procedures in the workspace.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
824 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
825 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
826 If the command is given without any name at all, the "current" working
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
827 procedure is used. This means the name of the procedure
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
828 last given in another command. The DIR command prints an asterisk
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
829 before its name so it can be found at any time.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
830 If you have not yet given a name in any command,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
831 the name "PROGRAM" is automatically used. Some commands that require a file
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
832 name as well as (one or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
833 more) procedure names require that a ">"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
834 precede the file name so it is not mistaken for a procedure name. If
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
835 you omit the file name, the name of the (first) procedure is used instead.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
836 In this manual, the phrase file name means an OS-9 "pathlist"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
837 which can describe either a file or device.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
838 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
839 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
840 Here are some examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
841 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
842 SAVE tom bill >myfile
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
843 SAVE* big_file
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
844 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
845 or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
846 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
847 SAVE tic tac toe
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
848 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
849 which is exactly equivalent to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
850 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
851 SAVE tic,tac,toe >tic
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
852 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
853
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
854 Another class of commands use only one procedure name, or the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
855 current working name if a name is omitted. These commands change
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
856 the mode of &b09; by exiting the command mode and entering another mode.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
857 These commands are:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
858 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
859 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
860 <colspec colwidth="1in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
861 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
862 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
863 <entry>RUN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
864 <entry>which enters Execution Mode to run a procedure</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
865 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
866 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
867 <entry>EDIT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
868 <entry>which enters Edit Mode to create or change a procedure</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
869 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
870 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
871 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
872 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
873 The one other mode, Debug Mode, cannot be entered directly from the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
874 system mode &mdash; more on this later.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
875 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
876 <bridgehead renderas="sect2">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
877 Syntax Notation Used in System Command Descriptions</bridgehead>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
878 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
879 Individual descriptions of the available commands in each mode follow. In
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
880 order to precisely describe their formats, the syntax notation shown below
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
881 is used.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
882
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
883 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
884 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
885 <colspec colwidth="1.3in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
886 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
887 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
888 <entry>[ ]</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
889 <entry>things in brackets are optional.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
890 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
891 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
892 <entry>{ }</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
893 <entry>things in braces can be optionally repeated.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
894 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
895 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
896 <entry>&lt;procname></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
897 <entry>means a procedure name</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
898 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
899 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
900 <entry>&lt;pathlist></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
901 <entry>An OS-9 file name</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
902 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
903 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
904 <entry>&lt;number></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
905 <entry>A decimal or hex number</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
906 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
907 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
908 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
909 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
910 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
911 <sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
912 <title>System Mode Commands</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
913 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
914 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
915 <command>$ [&lt;text>] ("Shell" Command)</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
916 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
917 This command calls the OS-9 Shell command interpreter to process an OS-9
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
918 command or to run another program. Running the OS-9 command does not
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
919 cause &b09; or its workspace to be disturbed.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
920 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
921 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
922 If the "$" is followed by text, the Shell is called to process the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
923 text as a single OS-9 command line. After the command is executed,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
924 &b09; is immediately re-entered.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
925 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
926 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
927 If no text is specified, &b09; is suspended, and the OS-9 Shell is called to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
928 process multiple command lines individually entered from the keyboard.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
929 Control is returned to &b09; when an end-of-file character (usually ESCAPE) is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
930 entered. The contents of the &b09; workspace is not affected. This is a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
931 convenient way to temporarily leave &b09; to manipulate files or perform
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
932 other housekeeping tasks.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
933 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
934 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
935 This command is the "gateway" to OS-9 from inside &b09;. It allows access to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
936 any OS-9 command or to other programs. It also permits creation of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
937 concurrent processes and other real-time functions.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
938 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
939 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
940 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
941 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
942 <literallayout>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
943 B: $copy file1 file2 Calls the OS-9 copy command
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
944 B: $asm sourcefile&amp; Calls the assembler as a <emphasis>background</emphasis> task
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
945 B: $basic09 fourier(20)&amp; Starts <emphasis>another</emphasis> concurrent &b09; program
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
946 </literallayout>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
947 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
948 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
949 <cmdsynopsis><command>BYE (or ESCAPE character)</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
950 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
951 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
952 Exits &b09; and returns to OS-9 or the program that called &b09;.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
953 Any procedures in the workspace are lost if not previously saved. The
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
954 escape key (technically speaking, an end-of-file character condition on
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
955 &b09;'s standard input path) does the same thing.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
956 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
957 <cmdsynopsis><command>CHD &lt;pathlist> or CHX &lt;pathlist></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
958 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
959 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
960
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
961 Changes the current OS-9 user Data
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
962 or Execution Directory to the specified pathlist
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
963 which must be a directory file. &b09; uses the Data Directory to LOAD or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
964 SAVE procedures. The Execution Directory is used to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
965 PACK or auto-load packed modules.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
966 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
967 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
968 Example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
969 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
970 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
971 CHD /d1/joe/games
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
972 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
973 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
974
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
975
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
976 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
977 <cmdsynopsis><command>DIR [&lt;pathlist>]</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
978 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
979 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
980 Displays the name, size, and variable storage requirement of each
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
981 procedure presently in the workspace. The current working procedure has
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
982 an asterisk before its name. All packed procedures have a dash before their
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
983 name (see PACK). The available free memory within the workspace is also
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
984 given. If a pathlist is specified, output is directed to that file or device.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
985 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
986 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
987 A question mark next to a data storage size means the workspace does not
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
988 have enough free memory to run that procedure.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
989 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
990 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
991 Note: This command should not be confused with the OS-9 "DIR" command.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
992 They have completely different functions.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
993 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
994
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
995 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
996 <command>EDIT [&lt;procname>]</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
997 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
998 <command>E [&lt;procname>]</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
999 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1000 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1001 Exits command mode and enters the text editor/compiler mode. If the specified
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1002 procedure does not exist, a new one is created. See the Chapter 4 for a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1003 complete description of how edit mode works.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1004 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1005 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1006 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1007 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1008 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1009 E newprog
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1010 EDIT printreport
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1011 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1012 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1013
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1014 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1015 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1016 <command>KILL [&lt;procname> {,&lt;procname>}]</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1017 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1018 <command>KILL*</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1019 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1020 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1021 Erases the procedure(s) specified. KILL* clears the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1022 entire workspace. The process may take some time if there are many
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1023 procedures in the workspace.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1024 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1025 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1026 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1027
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1028 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1029 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1030 kill formulas
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1031 kill prog1, prog2, prog7
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1032 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1033 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1034 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1035
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1036 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1037 <command>LIST [&lt;procname> {,&lt;procname>}] [> &lt;pathlist>]</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1038 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1039 <command>LIST* [&lt;pathlist>]</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1040 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1041 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1042 Prints a formatted "pretty printed" listing of one or more procedures.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1043 The listing includes
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1044 the relative I-code storage addresses in hexadecimal format in the first
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1045 column. The second column is reserved for program line numbers (if line
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1046 numbers are used).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1047 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1048 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1049 If a pathlist is given, the listing is output to that file or device. This option
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1050 is commonly used to print hard-copy listings of programs.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1051
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1052 The LIST, SAVE and PACK commands all have identical syntax, except
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1053 that LIST prints on the OS-9 standard error path (#2) if no pathlist is given.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1054 The files produced are formatted differently, but the function is similar.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1055
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1056 <important>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1057 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1058 If an "*" is used with LIST, SAVE or PACK, the file name
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1059 immediately follows WITHOUT a greater-than sign ">" before it!
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1060 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1061 </important>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1062
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1063 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1064
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1065 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1066 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1067 list* /p
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1068 list prog2,prog3 >/p
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1069 list prog5 >temp
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1070 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1071 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1072
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1073 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1074
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1075 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1076 <command>LOAD &lt;pathlist></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1077 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1078 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1079 Loads all procedures from the specified file into the workspace. As
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1080 procedures are loaded, their names are displayed. If any of the procedures
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1081 being loaded have the same name as a procedure already in the workspace,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1082 the existing procedures are erased and replaced with the procedure
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1083 being loaded.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1084 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1085 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1086 If the workspace fills up before the last procedure in the file is loaded, an
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1087 error (#32) is given. In this case, not all procedures may have been loaded,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1088 and the one being loaded when the workspace became full may not be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1089 completely loaded. You should KILL the last procedure, use the MEM
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1090 command to get more memory or KILL unnecessary procedure(s) to free
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1091 up space, and then LOAD the file again.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1092 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1093 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1094 Example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1095
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1096 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1097 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1098 load quadratics
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1099 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1100 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1101
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1102 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1103 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1104 <command>MEM</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1105 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1106 <command>MEM [&lt;number>]</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1107 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1108 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1109 MEM used without a number displays the present total workspace size in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1110 (decimal) bytes. If a number is given, &b09; asks OS-9 to expand or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1111 contract the workspace to that size. A hex value can be used if preceded by
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1112 a dollar sign. If MEM responds with What?, you either asked for more
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1113 memory than is available, tried to give back too much memory (there has
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1114 to be enough to store all procedures in the workspace), or gave an
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1115 invalid number.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1116 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1117 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1118 Example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1119
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1120 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1121 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1122 MEM 18000
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1123 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1124 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1125
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1126 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1127 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1128 <command>PACK [&lt;procname> {,&lt;procname>}] [> &lt;pathlist>]</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1129 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1130 <command>PACK* [&lt;pathlist>]</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1131 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1132 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1133 This command
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
1134 causes an extra compiler pass on the procedure(s) specified, which
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1135 removes names, line numbers, non-executable statements, etc. The result is
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
1136 a smaller, faster procedure(s) that <emphasis>cannot</emphasis> be edited or debugged but can be
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1137 executed by &b09; or by the &b09; run-time-only program called "RunB".
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1138 If a pathlist is not given, the name of the first procedure in the list will be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1139 used as a default pathname.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1140 The procedure is written to the file/device specified in OS-9 memory
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1141 module format suitable for loading in ROM or RAM outside the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1142 workspace.
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
1143 <emphasis>The resulting file cannot be loaded into the workspace later on,</emphasis>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1144 so you should always perform a regular SAVE before PACKing a procedure!
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1145 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1146 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1147 &b09; will automatically load the packed procedure when you try
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1148 to run it later. Here is an example sequence that demonstrates packing a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1149 procedure:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1150
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1151 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1152 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1153 <colspec colwidth="2in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1154 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1155 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1156 <entry>pack sort</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1157 <entry>packs procedure sort and creates a file</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1158 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1159 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1160 <entry>kill sort</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1161 <entry>kills procedure inside the workspace</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1162 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1163 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1164 <entry>run sort</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1165 <entry>run (sort is loaded outside of the workspace)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1166 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1167 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1168 <entry>kill sort</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1169 <entry>done; delete "sort" from outside memory</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1170 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1171 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1172 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1173 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1174
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1175 The last step (kill) does not have to be done immediately if you will use the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1176 procedure again later, but you should kill it when you are done so its
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1177 memory can be used for other purposes.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1178 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1179 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1180 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1181
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1182 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1183 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1184 pack proc1,proc2 >packed.programs
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1185
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1186 pack* packedfile
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1187 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1188 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1189 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1190
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1191 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1192 <command>RENAME &lt;procname>,&lt;new procname></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1193 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1194 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1195
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1196 Changes the name of a procedure. Can be used to allow two
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1197 copies of the same procedure in the workspace under different names.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1198 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1199 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1200 Example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1201
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1202 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1203 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1204 rename thisproc thatproc
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1205 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1206 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1207 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1208
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1209 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1210 <command>RUN [&lt;procname> [ ( &lt;expr> , {&lt;expr>} ) ]]</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1211 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1212 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1213 Runs the procedure specified. Technically speaking, &b09; then
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1214 leaves Command mode and enters Execution mode.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1215 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1216 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1217 A parameter list can be used to pass expected parameters to the procedure
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1218 in the same way a RUN statement inside a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1219 procedure calls another procedure except for the restriction that all
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1220 parameters must be constants or expressions without variables. See the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1221 PARAM statement description.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1222 Assembly language procedures cannot be run from command mode.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1223 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1224 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1225 The procedure called can be normal or "packed". If the procedure is not
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1226 found inside &b09;'s workspace, &b09; will call OS-9 to attempt to LINK
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1227 to an external (outside the workspace) module. If this fails, &b09;
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1228 attempts to LOAD the procedure from a file of the same name.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1229 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1230 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1231 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1232
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1233 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1234 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1235 run getdata
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1236
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1237 run invert("the string to be inverted")
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1238
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1239 run power(12,354.06)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1240
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1241 run power($32, sin(pi/2))
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1242 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1243 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1244 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1245
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1246 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1247 <command>SAVE [&lt;procname> { &lt;procname>} [> &lt;pathlist>]]</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1248 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1249 <command>SAVE* [&lt;pathlist>]</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1250 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1251 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1252 Writes the procedure(s) (or all procedures) to an output
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1253 file or device in source format. SAVE is similar to the LIST command
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1254 except the output is not formatted and I-code addresses are not included. If
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1255 a pathlist is not specified, it defaults to the name of the first
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1256 procedure listed.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1257 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1258 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1259 If a file of the same name already exists, SAVE will prompt with:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1260 <screen>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1261 rewrite?
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1262 </screen>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1263 You may answer "Y" for yes which causes the existing file to be rewritten
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1264 with the new procedure(s); or "N" to cancel the SAVE command.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1265 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1266 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1267 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1268
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1269 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1270 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1271 save proc2 proc3 proc4 >monday.work
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1272
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1273 save* newprogram
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1274
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1275 save
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1276
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1277 save >testprogram
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1278 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1279 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1280 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1281 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1282 </chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1283 <chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1284 <title>Edit Mode</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1285 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1286 Edit Mode (also called "The Editor") is used to enter or modify
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1287 &b09; procedures. It is entered from Command Mode by the EDIT (or E) command.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1288 As soon as Edit Mode is entered, prompts change from "B:" to "E:"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1289 If you have used a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1290 text editor before, you will find the &b09; editor similar to many others
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1291 except for these two differences:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1292
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1293 <orderedlist numeration="arabic">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1294 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1295 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1296 The editor is both "string" and "line number" oriented. The use of line numbers
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1297 is optional and text can be corrected without re-typing the entire line.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1298 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1299 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1300
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1301 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1302 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1303 The editor is interfaced to the &b09; compiler and "decompiler". This
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1304 lets &b09; do continuous syntax error checking and permits
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1305 programs to be stored in memory in a more compact, compiled form.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1306 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1307 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1308 </orderedlist>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1309
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1310 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1311 <sect1><title>Overview of Edit Commands</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1312 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1313 The Editor includes the following commands. Each command is described
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1314 in detail later in this chapter.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1315
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1316 <table frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1317 <title>Edit Mode Commands</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1318 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1319 <colspec colwidth="2in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1320 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1321 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1322 <entry>&lt;cr></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1323 <entry>move edit pointer forward</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1324 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1325 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1326 <entry>+</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1327 <entry>move edit pointer forward</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1328 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1329 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1330 <entry>+*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1331 <entry>move edit pointer to end of text</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1332 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1333 <row>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1334 <entry>-</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1335 <entry>move edit pointer backward</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1336 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1337 <row>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1338 <entry>-*</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1339 <entry>move edit pointer to beginning of text</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1340 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1341 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1342 <entry>&lt;space> &lt;text></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1343 <entry>insert unnumbered line</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1344 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1345 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1346 <entry>&lt;line#> &lt;text></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1347 <entry>insert or replace numbered line</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1348 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1349 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1350 <entry>&lt;line#> &lt;cr></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1351 <entry>find numbered line</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1352 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1353 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1354 <entry>c</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1355 <entry>change string</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1356 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1357 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1358 <entry>c*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1359 <entry>change all occurence of string</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1360 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1361 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1362 <entry>d</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1363 <entry>delete line</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1364 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1365 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1366 <entry>d*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1367 <entry>delete all lines</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1368 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1369 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1370 <entry>l</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1371 <entry>list line(s)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1372 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1373 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1374 <entry>l*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1375 <entry>list all lines</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1376 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1377 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1378 <entry>q</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1379 <entry>quit editing</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1380 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1381 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1382 <entry>r</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1383 <entry>renumber line</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1384 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1385 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1386 <entry>r*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1387 <entry>renumber all lines</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1388 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1389 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1390 <entry>s</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1391 <entry>search for string</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1392 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1393 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1394 <entry>s*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1395 <entry>search for all occurence of string</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1396 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1397 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1398 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1399 </table>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1400
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1401 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1402 <sect1><title>How the Editor Works</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1403 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1404 In order to understand how the editor works it is helpful to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1405 have a general idea of what goes on inside &b09; while you are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1406 editing procedures. &b09; programs are always stored in memory
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1407 in a compiled form called
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1408 "I-code" (short for "Intermediate Code"). I-code is a complex binary coding
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1409 system for programs that lies between your original "source" program and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1410 the computer's native "machine language". I-code is relatively compact, can
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1411 be executed rapidly, and most importantly, can be reconstructed almost exactly
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1412 back to the original source program. The Editor is closely connected to the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1413 "compiler" and "decompiler" systems within &b09; that translate source code
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1414 to I-Code and vice-versa.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1415 It is this innovative system that gives &b09; its most powerful and unusual
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1416 abilities.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1417 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1418 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1419 Whenever you enter (or change) a program line and "return", the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1420 compiler instantly translates this text to the internal I-code form. When
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1421 &b09; needs to display program lines back, it uses the decompiler to translate the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1422 I-code back to the original "source" format. These processes are completely
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1423 automatic and do not require any special action on your part.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1424 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1425 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1426 This technique has several advantages. First,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1427 it allows the text editor to report many (syntax) errors immediately so
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1428 you can correct them instantly. Secondly,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1429 the I-code representation of a program is more compact (by about 30%)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1430 than its original form, so you can have have larger programs in any
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1431 given amount of available memory.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1432 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1433 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1434 When programs are listed by &b09;, it is possible they will have a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1435 slightly different appearance than the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1436 way they were originally typed in, but they will
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1437 <emphasis>always</emphasis> be functionally
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1438 identical to the original form. This can happen if the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1439 original program had extraneous spaces between keywords, unnecessary
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1440 parentheses in expressions, etc. &b09; keywords are always automatically
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1441 capitalized.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1442 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1443 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1444 When you have finished editing the procedure, use the "q" (for "quit")
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1445 command to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1446 exit edit mode and return to the command mode. When you give the "q" command,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1447 the compiler performs another "pass" over the entire procedure again.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1448 At this time syntax
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1449 that extends over multiple lines is checked and errors reported. Examples
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1450 of these errors are: GOTO or GOSUB to a non-existent line,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1451 missing variable or array declarations, improperly constructed loops, etc.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1452 These errors are reported using an error code and the hexadecimal I-code
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1453 address of the error. For example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1454 <screen>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1455 01FC ERR #043
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1456 </screen>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1457 This message means that error number 43 was detected in the line that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1458 included I-code address 01FC (hexadecimal). The LIST command gives
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1459 the I-code addresses so you can locate lines with errors reported during the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1460 compiler's second pass.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1461 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1462 <sect1><title>Line-Number Oriented Editing</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1463 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1464 As mentioned previously, the editor has the capability to work
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1465 on programs with or without line numbers (or both).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1466 Line numbers must be positive whole numbers in the range of 1 to 32767.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1467 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1468 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1469 If you have experience with another version of the BASIC language, this is the kind of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1470 editing you probably used. However, well-structured programs seldom
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1471 really need line numbers. If you don't have to use line numbers, don't.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1472 Your programs will be shorter, faster, and easier to read.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1473 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1474 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1475 The line-number oriented commands are:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1476
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1477 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1478 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1479 <colspec colwidth="2in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1480 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1481 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1482 <entry>&lt;line#> &lt;text></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1483 <entry>insert or replace numbered line</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1484 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1485 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1486 <entry>&lt;line#> &lt;cr></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1487 <entry>find numbered line</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1488 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1489 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1490 <entry>d</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1491 <entry>delete line</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1492 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1493 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1494 <entry>r</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1495 <entry>renumber line</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1496 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1497 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1498 <entry>r*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1499 <entry>renumber all lines</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1500 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1501 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1502 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1503 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1504 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1505 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1506 To enter or replace a numbered line, simply type in the line
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1507 number and statement. Numbered lines can be entered in any order, but will
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1508 be automatically stored in ascending sequence. To move to a numbered
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1509 line, type the line number followed by a carriage return. The editor will move
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1510 to that line (or the line with the next higher number if the specified number
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1511 is not found) and print it. The line may be deleted using the "d" command.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1512 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1513 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1514 The "r" renumber command will uniformly resequence all numbered lines and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1515 lines that refer to numbered lines. Its formats are:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1516 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1517 r [ &lt;beg line #> [,&lt;incr> ] ] &lt;CR>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1518 r*[ &lt;beg line #> [,&lt;incr> ] ] &lt;CR>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1519 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1520
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1521 The first format renumbers the program starting at the current line and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1522 forward. Lines are renumbered using
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1523 &lt;beg line#> as the initial line number. &lt;incr> is added to the previous line
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1524 number for the next line's number. For example,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1525 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1526 r 200,5
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1527 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1528 will give the first line number 200, the second 205, the third 210, etc.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1529 If &lt;beg line#> and/or &lt;incr> are not
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1530 specified, the values 100 and 10, respectively, are assumed.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1531 The second form of the command is identical exect it renumbers all lines in the procedure.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1532
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1533 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1534 <sect1><title>String-Oriented Editing</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1535 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1536 Most editor commands are string-oriented. This means that you can enter or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1537 change whole or partial lines without using line numbers at all. You will
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1538 find that string-oriented editing is generally faster and more convenient.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1539 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1540 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1541 Because line numbers are not used, there has to be another way
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1542 to tell &b09; what place in the program to work on. To do this,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1543 the editor maintains an "edit pointer" that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1544 indicates which line is the present working location within the procedure,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1545 and commands start workin at this point.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1546 The editor shows you the location of the edit pointer by displaying an
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1547 "*" at the left side of the program line where the edit pointer is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1548 presently located.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1549 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1550 <sect2><title>Moving the Edit Pointer</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1551 <para>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1552 The "+" and "-" are used to reposition the edit pointer:
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1553
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1554 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1555 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1556 <colspec colwidth="2in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1557 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1558 <row>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1559 <entry>-</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1560 <entry>moves backward one line</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1561 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1562 <row>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1563 <entry>- &lt;number></entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1564 <entry>moves backward n lines</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1565 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1566 <row>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1567 <entry>-*</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1568 <entry>moves to the beginning of the procedure</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1569 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1570 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1571 <entry>+</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1572 <entry>moves forward one line</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1573 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1574 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1575 <entry>+ &lt;number></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1576 <entry>moves forward N lines</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1577 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1578 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1579 <entry>+*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1580 <entry>moves to the end of procedure</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1581 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1582 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1583 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1584 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1585
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1586 The number indicates how many lines to move. Backward means
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1587 towards the first line of the procedure. If the number is omitted,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1588 a count of one is used (this is true of most edit commands).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1589 A line consisting of a carriage return only also moves the pointer forward one
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1590 line, which makes it easy to step through a program one line at a time.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1591 Therefore, the following commands all do the same thing:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1592
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1593 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1594 &lt;CR>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1595 + &lt;CR>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1596 +1 &lt;CR>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1597 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1598
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1599
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1600 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1601 <sect2><title>Inserting Lines</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1602 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1603 The Insert Line function consists of a "space" followed by a &b09; statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1604 line. The statement is inserted just ahead of the edit pointer position. (the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1605 space itself is not inserted).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1606 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1607 <sect2><title>Deleting Lines</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1608 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1609
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1610
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1611 The "d" command is used to delete one or more lines. Its format is:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1612
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1613 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1614 d [&lt;number>] &lt;CR>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1615 d*
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1616 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1617
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1618 The first form deletes the &lt;number> of lines starting at the current edit
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1619 pointer location.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1620 The second form deletes ALL lines in the procedure (caution!).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1621 The editor accepts
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1622 "+*" and "-*" to mean to the end, or to the beginning of the procedure
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
1623 respectively. If the number is negative, that many lines <emphasis>before</emphasis> the
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1624 current line is deleted.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1625 If a line number is omitted, only the current line is deleted.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1626 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1627 <sect2><title>Listing Lines</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1628 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1629 The "l" command is used to display one or more lines.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1630 It also has the forms:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1631 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1632 l [&lt;number>] &lt;CR>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1633 l*
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1634 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1635 The first form will display the &lt;number> of lines starting at the current
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
1636 edit pointer position. If the number is <emphasis>negative</emphasis>, previous lines
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1637 will be listed.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1638
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1639 The second form displays the entire procedure. Neither change the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1640 edit pointer's position. The line that is the present position of the edit
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1641 pointer is displayed with a leading asterisk.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1642
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1643 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1644 <sect2><title>Search: Finding Strings</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1645 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1646 What's a string? A string is a sequence of one or more characters that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1647 can include letters, numbers, or punctuation in any combination. Strings
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1648 are very usefull because they allow you to change or locate just part
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1649 of a statement without having to type the whole thing.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1650
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1651 In the Editor, strings must be surrounded by two matching punctuation
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1652 characters (called <emphasis>delimiters</emphasis>) so the editor
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1653 knows where the string begins and ends.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1654 The characters used for delimiters are not considered part of the string
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1655 and cannot also appear within the string.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1656 Strings used by the Editor should not be confused with &b09;'s data type
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1657 which is also called STRING &mdash; they are different creatures.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1658 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1659 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1660 The "s" command may be used to locate the next occurrence or all
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1661 occurrences of a string. The format for this command is:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1662
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1663 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1664 s &lt;delim> &lt;match str> [&lt;delim>] &lt;CR>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1665 s*&lt;delim> &lt;match str> [&lt;delim>] &lt;CR>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1666 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1667
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1668 The first format searches for the &lt;match str> starting on the current
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1669 edit pointer line onward. If any line at or following the edit pointer
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1670 includes a sequence of characters that match the search string, the edit
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1671 pointer is moved to that line and the line is displayed. If the string
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1672 cannot be located, the message:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1673
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1674 <screen>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1675 CAN'T FIND: "&lt;match str>"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1676 </screen>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1677 will be displayed and the edit pointer will remain at its original
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1678 position. The "s*" variation searches for all occurrences of the string
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1679 in the procedure starting at the present edit pointer and displays all
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1680 lines it is found in. The edit pointer ends up at the last line the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1681 string occurred in.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1682 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1683 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1684 Here are some examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1685
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1686 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1687 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1688 E:s/counter/ Looks for the string: counter
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1689
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1690 E:s.1/2. Looks for the string: 1/2
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1691
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1692 E:s?three blind mice? Looks for the string: three blind mice
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1693 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1694 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1695 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1696 <sect2><title>Change: String Substitution</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1697 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1698 The "c" change string function is a very handy tool that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1699 can eliminate a tremendous amount of typing.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1700 It allows strings within lines to be located, removed, and replaced by
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1701 another string. This command is very commonly used for things like:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1702 fixing lines with errors
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1703 without having to retype the entire line, changing a variable name
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1704 throughout a program, etc. Its formats are:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1705 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1706 c &lt;delim> &lt;match str> &lt;delim> &lt;repl str> [&lt;delim>] &lt;CR>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1707 c*&lt;delim> &lt;match str> &lt;delim> &lt;repl str> [&lt;delim>] &lt;CR>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1708 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1709 In the first form, the editor looks for the first occurrence of the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1710 match string starting at the present edit pointer position. If found,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1711 the match string is removed from the line and the replacement string is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1712 inserted in its place. The second form works the same way, but changes
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1713 ALL occurrences of the match string in the procedure starting at the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1714 present edit pointer position.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1715 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1716 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1717 The "c*" command will stop anytime it finds or causes a line with an error.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1718 It cannot be used to find or change line numbers.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1719 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1720 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1721 A word of warning:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1722 sometimes you can inadvertently change a line you did't
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1723 intend to change because the match string is imbedded in a longer string.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1724 For example, if you attempt to change "no" to "yes" and the word "normal"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1725 occurs before the "no" you are looking for, "normal" will change to "yesrmal".
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1726 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1727 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1728 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1729
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1730 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1731 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1732 c/xval/yval/
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1733 c*,GOSUB 5300,GOSUB 5500
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1734 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1735 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1736 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1737 </sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1738 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1739 </chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1740
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1741
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1742 <chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1743 <title>Execution Mode</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1744
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1745 <sect1><title>Running Programs</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1746 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1747 To run a &b09; procedure, enter:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1748
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1749 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1750 RUN &lt;procname>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1751 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1752
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1753 If the procedure you want to run was the last procedure edited, listed,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1754 saved, etc., you can type RUN without giving a procedure name (the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1755 "*" shown in the DIR command identifies this procedure).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1756 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1757 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1758 If the procedure expects <emphasis>parameters</emphasis> (see Chapter 7),
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1759 they can be given on the same
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1760 command line, however they must all be constant numbers or strings, as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1761 appropriate, and must be given in the correct order. For example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1762
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1763 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1764 RUN add(4,7)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1765 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1766
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1767 is used to call a program that expects parameter, such as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1768 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1769 PROCEDURE add
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1770 PARAMETER a,b a,b will receive the values 4,7
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1771 PRINT a+b
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1772 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1773 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1774
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1775 The ability to pass parameters to a program allows you to specifically
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1776 initialize program variables. Sometimes certain procedures are parts of a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1777 larger software system and are designed to be called from other
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1778 procedures. You can use this feature to individually test such procedures by
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1779 passing them test values as parameters.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1780 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1781 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1782 The RUN statement causes &b09; to enter <emphasis>Execution Mode</emphasis>,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1783 causing the procedure to run until one of the these things happen:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1784 <orderedlist numeration="arabic">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1785 <listitem><para>an END or STOP statement is executed</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1786 <listitem><para>you type [Ctrl-E]</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1787 <listitem><para>a run-time error occurs</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1788 <listitem><para>you type [Ctrl-C] (keyboard interrupt)</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1789 </orderedlist>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1790 In cases 1 and 2, you will return to system mode. In
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1791 cases 3 and 4, you will enter DEBUG mode.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1792 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1793 <sect1><title>Execution Mode: Technically Speaking</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1794 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1795
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1796
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1797 The RUN statement is simple and normally you do not need to know what
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1798 is happening inside &b09; when you use it. The technical description of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1799 execution mode that follows is given for the benefit of advanced
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1800 &b09; programmers.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1801 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1802 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1803 Execution mode is &b09;'s state when you run any procedure. It involves
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1804 executing the I-code of one or more procedures inside or outside the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1805 workspace. Many procedures can be in use because they can call each
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1806 other (or themselves) and nest exactly like subroutines.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1807
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1808 You can enter execution mode in a number of ways:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1809 <orderedlist numeration="arabic">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1810 <listitem><para>By means of the RUN system command.</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1811 <listitem><para>By &b09;'s auto-run feature.</para></listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1812 </orderedlist>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1813 The Auto-run feature allows &b09; to get the name of a file to load and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1814 run from the same command line used to call &b09;. The file loaded and run
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1815 can be either a SAVED file (in the data directory), or a PACKED file (in the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1816 execution directory). The file may contain several procedures; the one
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1817 executed is the one with the same name as the file. Parameters may be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1818 passed following the pathname specified. For
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1819 example, the following OS-9 command lines use this feature:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1820
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1821 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1822 OS9: &b09; printreport("Past Due Accounts")
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1823 OS9: &b09; evaluate(COS(7.8814)/12.075,-22.5,129.055)
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1824 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1825
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1826 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1827 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1828 </chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1829
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1830
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1831 <chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1832 <title>Debug Mode</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1833 <sect1><title>Overview of Debug Mode</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1834 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1835 One of &b09;'s outstanding features is its set of powerful <emphasis>symbolic
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1836 debugging</emphasis> commands. What is Symbolic Debugging? Simply
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1837 stated, it is testing and manipulation of programs using the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1838 actual names and program statements used in the program.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1839 In this chapter you will learn how Debug Mode can let you watch your
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1840 program run in slow motion you can observe each statement as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1841 it is executed. As a bonus, you will also learn how to use the Debug Mode as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1842 a calculator.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1843 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1844 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1845 Debug mode is entered from execution mode in one of three ways:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1846 <orderedlist numeration="arabic">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1847 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1848 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1849 When an error occurs during execution of a procedure (that is not
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1850 intercepted by an ON ERROR GOTO statement within the program).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1851 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1852 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1853 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1854 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1855 When a procedure executes a PAUSE statement.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1856 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1857 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1858 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1859 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1860 When a keyboard interrupt (control-C) occurs.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1861 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1862 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1863 </orderedlist>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1864 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1865 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1866 When any of the above happen, Debug Mode announces itself by
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1867 displaying the suspended procedure name like this:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1868 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1869 BREAK: PROCEDURE test5
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1870 D:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1871 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1872 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1873 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1874 Notice that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1875 Debug Mode displays a "D:" prompt when it is awaiting a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1876 command. Any debug mode commands can the be used to examine or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1877 change variables, turn trace mode on/off, etc. Depending on which
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1878 commands are used, execution of the program can be terminated, resumed,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1879 or executed one source line at a time.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1880 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1881 <sect1><title>Debug Mode Commands</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1882 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1883 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1884 <command>$ &lt;text></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1885 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1886 Calls OS-9's Shell command interpreter to run a program or OS-9
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1887 command. Exactly the same as the System Mode "$" command.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1888
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1889 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1890 <command>BREAK &lt;proc name></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1891 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1892 Sets up a "breakpoint" at the procedure named. This command is used
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1893 when procedures call each other, and provides a way to re-enter Debug
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1894 Mode when returning to a specific procedure.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1895 To illustrate how BREAK works, suppose there are three procedures in the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1896 workspace: PROC1, PROC2, and PROC3. Assume that PROC1 calls PROC2, which in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1897 turn calls PROC3. While PROC3 is executing, you type Control-C to enter
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1898 debug mode. You can now enter:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1899 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1900 D: BREAK proc1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1901 ok
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1902 D:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1903 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1904 Notice that BREAK responds with "ok" if the procedure was found on the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1905 current RUN stack. If you wish you can use the STATE command to verify that the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1906 three procedures are "nested" as expected.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1907 Now, you can resume execution of PROC3 by typing CONT. After PROC3 terminates,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1908 control passes back to PROC2, which eventually returns to PROC1. As soon as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1909 this happens, the breakpoint you set is encountered, PROC1 is suspended,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1910 and Debug Mode is reentered.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1911 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1912 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1913 There are three characteristics of BREAK you should note:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1914 <orderedlist numeration="arabic">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1915 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1916 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1917 The breakpoint is removed as soon as it occurs.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1918 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1919 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1920
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1921 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1922 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1923 You can use one breakpoint for each active procedure.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1924 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1925 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1926
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1927 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1928 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1929 You can't put a breakpoint on a procedure unless it has been called but
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1930 not yet returned to. Hence, BREAK cannot be used on procedures
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1931 that have not yet been run.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1932 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1933 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1934 </orderedlist>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1935
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1936 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1937 <command>CONT</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1938 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1939 The command causes program execution to continue at the next
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1940 statement. It may resume
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1941 programs suspended by Control-C, PAUSE statements, BREAK command
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1942 breakpoints, or after non-fatal run-time errors.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1943
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1944 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1945 <command>DEG</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
1946 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1947 <command>RAD</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1948 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1949 These commands select either degrees or radians as the angle unit
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1950 measure used by trigonometric functions. These commands only affect
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1951 the procedure currently being debugged or run.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1952
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1953 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1954 <command>DIR [&lt;path>]</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1955 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1956 Displays the workspace procedure directory in exactly the same way as the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1957 System Mode DIR command.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1958
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1959 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1960 <command>END or Q</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1961 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1962 Termintes execution of all procedures and exits Debug Mode by
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1963 returning to System Mode. Any open paths are closed at this point.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1964
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1965
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1966 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1967 <command>LET &lt;var> := &lt;expr></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1968 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1969 This command is essentially the same as the &b09; LET program statement,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1970 which allows the value of a procedure variable to be set to a new value
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1971 using the result of the evaluated expression. The variable names used
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1972 in this command must be the same as in the original "source" program;
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1973 otherwise, an error is generated. LET does not work on user-defined
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1974 data structures.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1975
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1976
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1977 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1978 <command>LIST</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1979 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1980 Displays a formatted source listing of the suspended procedure with I-code
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1981 addresses. An asterisk is printed to the left of the statement where
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1982 the procedure is suspended. Only list the current procedure may be listed.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1983
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1984
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1985 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1986 <command>PRINT [#&lt;expr>,] [USING &lt;expr>,] &lt;expr list></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1987 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1988 This is exactly the same as the &b09; PRINT statement and can be used
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1989 to examine the present value of variables in the suspended program. All
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1990 variable names must be the same as in the original program, and no
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1991 new variable names can be used. User-defined data structures cannot
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1992 be printed.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1993
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1994
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1995 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1996 <command>STATE</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1997 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1998
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
1999
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2000
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2001 This command
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2002 lists the calling ("nesting") order of all active procedures. The
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2003 highest-level procedure is always shown at the bottom of the calling list,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2004 and the lowest-level procedure will always be the suspended procedure.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2005 An example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2006 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2007 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2008 D:state
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2009 PROCEDURE DELTA
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2010 CALLED BY BETA
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2011 CALLED BY ALPHA
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2012 CALLED BY PROGRAM
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2013 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2014 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2015
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2016
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2017 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2018 <command>STEP [&lt;number>] or &lt;CR></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2019 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2020 This command allows the suspended procedure to be executed one or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2021 more source statements at a time.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2022 For example, "STEP 5" would execute the equivalent of the next 5 source
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2023 statements. A debug command line which is just a carriage return is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2024 considered the same as "STEP 1". The STEP command is most commonly
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2025 used with the trace
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2026 mode on, so the original source lines can be seen as they
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2027 are executed.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2028 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2029 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2030 Note: because compiled I-code contains actual statement memory addresses,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2031 the "top" or "bottom" statements of loop structures are usually executed
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2032 just once. For example, in FOR...NEXT loops the FOR statement is executed
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2033 once, so the statement that appears to be the top of the loop is actually
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2034 the one following the "FOR" statement.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2035
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2036 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2037 <command>TRON</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2038 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2039 <command>TROFF</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2040 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2041 These commands turn the suspended procedure's trace mode on and off. In
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2042 trace mode, the compiled code of each equivalent statement line is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2043 reconstructed to source statements and displayed before the statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2044 is executed. If the statement causes the evaluation of one or more
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2045 expressions, an equal sign and the expression result(s) are displayed
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2046 on the following line(s).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2047 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2048 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2049 Trace mode is local to a procedure. If the suspended procedure calls
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2050 another, no tracing occurs until control returns back
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2051 (unless of course, other called procedure(s) have trace mode on).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2052 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2053 <sect1><title>Debugging Techniques</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2054 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2055
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2056 If your program does not do what you expect it to, it is bound to show
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2057 one of two symptoms: incorrect results, or premature termination due to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2058 an error. The second case will automatically send you into Debug Mode.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2059 In the first case, you have to force the program into Debug Mode either
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2060 by hitting Control-C
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2061 (assuming you have time to do so), or by using Edit Mode to put
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2062 one or more PAUSE statements in the program. Once you're in Debug Mode,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2063 you can bring its powerful commands to bear on the problem.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2064 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2065 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2066 Usually the first step after an error stops the program is to place
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2067 a PAUSE statement at the beginning of the suspected procedure or at a place
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2068 within it where you think things begin to go amiss, and the you
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2069 rerun the program. When the program hits the PAUSE statement, and enters
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2070 DEBUG mode, it is time to turn the trace mode on and actually
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2071 watch your program run. To do so, just type:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2072 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2073 D: TRON
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2074 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2075
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2076 After you have done this, you hit the carriage return key once for every
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2077 statement. You will see the original source statement, and if expressions
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2078 are evaluated by the statement, Debug Mode will print an equal sign and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2079 the result of the expression. Notice that some statements such as FOR
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2080 and PRINT may cause more than one expression to be evaluated. Using this
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2081 technique, you can watch your program run one step at a time until you see
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2082 where it goes wrong. But what if in the process of tracing, you encounter
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2083 a loop that works OK, but executes 200 statements repetitively? That's
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2084 a lot of carriage returns. In this case, turn the trace off (if you
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2085 want) and use the STEP command to quickly run through the loop. Then,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2086 turn trace mode back on, and resume single-step debugging. The command
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2087 sequence for this example is:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2088
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2089 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2090 D: TROFF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2091 D: STEP 200
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2092 D: TRON
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2093 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2094 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2095 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2096 Don't forget that trace mode is "local" to one procedure only. If the procedure
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2097 under test returns to another procedure you need to use the BREAK
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2098 command or put a PAUSE statement in the procedure to enter Debug Mode.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2099 If you call another procedure from the procedure being debugged, tracing will
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2100 stop when it is called until it returns. If you also want to trace the called
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2101 procedure, it will need its own PAUSE statement.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2102
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2103 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2104 <sect1><title>Debug Mode as a Desk Calculator</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2105 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2106 The simple program listed below turns Debug Mode into a powerful desk
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2107 calculator. It's function is simple: it declares 26 working variables,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2108 then goes into Debug Mode so you can use interactive PRINT and LET statements.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2109
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2110 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2111 PROCEDURE Calculator
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2112 DIM a,b,c,d,e,f,g,h,i,j,k,l,m
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2113 DIM n,o,p,q,r,s,t,u,v,w,x,y,z
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2114 PAUSE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2115 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2116 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2117
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2118 Recall that while in debug mode, you cannot create new variables,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2119 hence the DIM statements that pre-define 26 working variables for you.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2120 If you wish yu can add more or fewer variables.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2121 The PAUSE statement causes Debug Mode to be entered. Here's a sample session:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2122 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2123 B: run calculator
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2124 BREAK: PROCEDURE Calculator
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2125 D:let x:=12.5
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2126 D:print sin(pi/2)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2127 .7071606781
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2128 D:let y:=exp(4+0.5)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2129 D:print x,y
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2130 12.5 90.0171313
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2131 D:Q
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2132 B:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2133 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2134 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2135 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2136 Don't forget that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2137 the Debug Mode PRINT command can use PRINT USING to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2138 produce formatted output (including hexadecimal).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2139 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2140 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2141 By adding less than a dozen statements to the program, you can
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2142 make it store its variables on a disk file so they're remembered
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2143 from session to session. There are also many other enhancement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2144 possibilities
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2145 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2146 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2147 </chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2148
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2149
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2150
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2151 <chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2152 <title>Data Types, Variables and Data Structures</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2153
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2154 <sect1><title>Why are there different data types?</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2155 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2156 A computer program's primary function is to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2157 process data. The performance of the computer, and even
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2158 sometimes whether or not a computer can handle a particular problem,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2159 depends on how the software stores data in memory and operates on it.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2160 &b09; offers many possibilities for organizing and manipulating data.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2161 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2162 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2163 Complicating matters somewhat is the fact that there are many kinds
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2164 of data. Some data are numbers used for counting or measuring. Another
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2165 example is textual data composed of letters, punctuation, etc., such
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2166 as your name. Seldom can they be mixed (for example multiplication is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2167 meaningless to anything but numbers), and they have different storage
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2168 size requirements. Even within the same general kind of data, it is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2169 frequently advantageous to have different ways to represent data. For
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2170 example, &b09; lets you chose from three different ways to represent
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2171 numbers - each having its own advantages and disadvantages. The decision
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2172 to use one depends entirely on the specific program you are writing. In
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2173 order for you to select the most appropiate way to store data variables,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2174 &b09; provides five different basic data types. &b09; also lets you create
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2175 new customized data types based on combinations of the five basic types.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2176 A good analogy is to consider the five basic types to be atoms, and the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2177 new types you create as molecules. This is why the five basic types are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2178 called <emphasis>atomic data types</emphasis>.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2179 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2180 <sect1><title>Data Structures</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2181 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2182 A <emphasis>data structure</emphasis> refers to storage for
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2183 more than one data item under a single name. Data
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2184 structures are often the most practical and convenient way to organize large
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2185 amounts of similar data.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2186 The simplest kind of data structure is the <emphasis>array</emphasis>,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2187 which is a table of values.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2188 The table has a single name, and the storage space for each individual
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2189 value is numbered. Arrays are created by DIM statements.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2190 For example, to create an array having five storage spaces called "AGES",
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2191 we can use the statement:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2192
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2193 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2194 DIM AGES(5):INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2195 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2196 "(5)" tells &b09; how many spaces to reserve. The ":INTEGER" part
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2197 indicates the array's data type. To assign a value of 22 to the third
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2198 storage space in the array we can use the statement:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2199
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2200 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2201 LET AGES(3):=22
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2202 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2203
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2204 As you shall see, &b09; lets you create complex arrays and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2205 even arrays that have different data types combined.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2206 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2207 <sect2><title>Atomic Data Types</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2208 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2209 &b09; includes five atomic data types: BYTE, INTEGER, REAL,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2210 STRING and BOOLEAN. The first three types are used to represent
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2211 numbers, The STRING type is used to represent character data, and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2212 the BOOLEAN type is used to represent the logical values of either
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2213 TRUE or FALSE. Arrays of any of these data types can be created
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2214 using one, two, or three dimensions. The table below gives an
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2215 overview of the characteristics of each type:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2216
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2217 <table frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2218 <title>&b09; Atomic Data Type Summary</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2219 <tgroup cols="3">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2220 <colspec colwidth="1.2in"/>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2221 <colspec colwidth="2.1in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2222 <thead>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2223 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2224 <entry>Type:</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2225 <entry>Allowable values:</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2226 <entry>Memory requirement:</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2227 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2228 </thead>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2229 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2230 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2231 <entry>BYTE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2232 <entry>Whole Numbers 0 to 255</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2233 <entry>One byte</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2234 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2235 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2236 <entry>INTEGER</entry>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2237 <entry>Whole Numbers -32768 to 32767</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2238 <entry>Two bytes</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2239 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2240 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2241 <entry>REAL</entry>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2242 <entry>Floating Point +/- 1*10^38</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2243 <entry>Five bytes</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2244 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2245 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2246 <entry>STRING</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2247 <entry>Letters, digits, punctuation</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2248 <entry>One byte/character</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2249 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2250 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2251 <entry>BOOLEAN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2252 <entry>True or False</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2253 <entry>One byte</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2254 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2255 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2256 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2257 </table>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2258 Why are there three different ways to represent numbers? Although REAL
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2259 numbers appear to be the most versatile because they have the greatest
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2260 range and are floating-point, arithmetic operations involving them are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2261 relatively slower (by a factor of about four) compared to the INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2262 or BYTE types. Thus using INTEGER values for loop counters, indexing
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2263 arrays, etc. can significantly speed up your programs. The BYTE type
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2264 is not appreciably faster than INTEGER, it conserves memory space in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2265 some cases and serves as a building block for complex data types in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2266 other cases. If you neglect to specify the type of a variable, &b09;
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2267 will automatically use the REAL data type.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2268 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2269 <sect2><title>Type BYTE</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2270 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2271 BYTE variables hold integer values in the range 0 through 255
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2272 (unsigned 8-bit data) which are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2273 stored as a single byte. BYTE values are always converted to another type
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2274 (16-bit integer
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2275 values and/or real values) for computation, thus they have no speed
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2276 advantage over other numeric types. However, BYTE variables require
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2277 only half of the storage used by integers, and an 1/5 of that used by reals.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2278 Attempting to store an integer value outside the BYTE range to a BYTE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2279 variable results in the storage of the least-significant 8-bits (the value
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2280 modulo 256) without error.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2281
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2282 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2283 <sect2><title>Type INTEGER</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2284 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2285 INTEGER variables consist of two bytes of storage, and hold a
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2286 numeric value in the range -32768 through 32767 as
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2287 signed 16-bit data. Decimal points are not allowed. INTEGER constants
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2288 may also be represented as hexadecimal values in the range $0000
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2289 through $FFFF to facilitate address calculations. INTEGER values
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2290 are printed without a decimal point. INTEGER arithmetic is faster and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2291 requires less storage than REAL values.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2292 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2293 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2294 Arithmetic which results in values outside the INTEGER range does not
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2295 cause run-time errors but instead "wraps around" modulo 65536; i.e.,
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2296 32767 + 1 yields -32768. Division of an integer by another integer
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2297 yields an integer result, and any remainder is discarded. The programmer
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2298 should be aware that numeric comparisons made on values in the range
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2299 32767 through 65535 will actually be dealing with negative numbers,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2300 so it may be desirable to limit such comparisons to tests for equality
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2301 or non-equality. Additionally, certain functions (LAND, LNOT, LOR, LXOR)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2302 use integer values, but produce results on a non-numeric bit-by-bit basis.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2303 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2304 <sect2><title>Type REAL</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2305 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2306 The REAL data type is the default type for undeclared variables. However,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2307 a variable may be explicitly typed REAL (for example, twopi:REAL) to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2308 improve a program's internal documentation. REAL-type values are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2309 always printed with a decimal point, and only those constants which
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2310 include a decimal point are actually stored as REAL values.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2311 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2312 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2313 REAL numbers are stored in 5 consecutive memory bytes. The
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2314 first byte is the (8-bit) exponent in binary two's-complement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2315 representation. The next four bytes are the binary sign-and-magnitude
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2316 representation of the mantissa; the mantissa in the first 31 bits,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2317 and the sign of the mantissa in the last (least significant) bit of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2318 the last byte of the real quantity.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2319 <figure>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2320 <title>Internal Representation of REAL Numbers</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2321
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2322 <literallayout>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2323 +--------+--------+--------+--------+--------+
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2324 |exponent| | | | |S| &lt;- mant. sign
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2325 +--------+--------+--------+--------+--------+
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2326 byte: +0 +1 +2 +3 +4
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2327 </literallayout>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2328 </figure>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2329
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2330 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2331 <para>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2332 The exponent covers the range 2.938735877 * 10^-39 (2^-128)
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2333 through 1.701411835 * 10^38 (2^127) as powers of 2. Operations which
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2334 result in values out of the representation range cause overflow or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2335 underflow errors (which may be handled automatically by the ON ERROR
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2336 command). The mantissa covers the range from 0.5 through .9999999995
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2337 in steps of 2^-31. This means that REAL numbers can represent values
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2338 on the number line about .0000000005 apart. Operations which cause
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2339 results between the representable points are rounded to the nearest
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2340 representable number.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2341 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2342 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2343 Floating point arithmetic is inherently inexact, thus a sequence of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2344 operations can produce a cumulative error. Proper rounding (as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2345 implemented in &b09;) reduces this effect but cannot eliminate it.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2346 Programmers using comparisons on REAL quantities should use caution
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2347 with strict comparisons (i.e., = or &lt;>), since
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2348 the exact desired value may not occur during program execution.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2349
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2350 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2351 <sect2><title>Type STRING</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2352 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2353
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2354
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2355 A STRING is a variable length sequence of characters or nil (an empty
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2356 string). A variable may be defined as a STRING either explicitly (e.g.,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2357 DIM title:STRING) or implicitly by appending a dollar-sign character to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2358 the variable name (title$ := "My First Program."). The default maximum
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2359 length allocated to each string is 32 characters, but each string may
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2360 be dimensioned less (e.g., DIM A:STRING [4]) for memory savings or more
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2361 (e.g., DIM long:STRING [2880]) to allow long strings. Notice that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2362 strings are inherently variable-length entities, and dimensioning the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2363 storage for a string only defines the maximum-length string which can
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2364 be stored there. When a STRING value is assigned to a STRING variable,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2365 the bytes composing the string are copied into the variable storage
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2366 byte-by-byte. The beginning of a string is always character number one,
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
2367 and this is <emphasis>not</emphasis> affected by the BASE0 or BASE1 statements. Operations
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2368 which result in strings too long to fit in the dimensioned storage
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2369 truncate the string on the right and no error is generated.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2370 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2371 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2372 Normally the internal representation of the string is hidden. A string
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2373 is stored in a fixed-size storage area and is represented by a sequence
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2374 of bytes terminated by the value zero or by the maximum length allocated
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2375 to the STRING variable. Any remaining "unused" storage after the zero
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2376 byte allows the stored string to expand and contract during execution.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2377
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2378 The example below shows the internal storage of a variable dimensioned as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2379 STRING[6] and assigned a value of "SAM". Notice the byte at +3 contains
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2380 the zero string terminator, and the two following bytes are not used.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2381 <informalfigure>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2382 <literallayout>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2383 +--------+--------+--------+--------+--------+--------+
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2384 | S | A | M | 00 | | |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2385 +--------+--------+--------+--------+--------+--------+
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2386 byte: +0 +1 +2 +3 +4 +5
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2387 </literallayout>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2388 </informalfigure>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2389 If the value "ROBERT" is assigned to the variable, the zero byte terminator
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2390 is not needed because the STRING fills the storage exactly:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2391 <informalfigure>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2392 <literallayout>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2393 +--------+--------+--------+--------+--------+--------+
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2394 | R | O | B | E | R | T |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2395 +--------+--------+--------+--------+--------+--------+
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2396 byte: +0 +1 +2 +3 +4 +5
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2397 </literallayout>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2398 </informalfigure>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2399 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2400 <sect2><title>Type BOOLEAN</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2401 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2402 A BOOLEAN quantity can have only two values: TRUE or FALSE. A variable
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2403 may be typed BOOLEAN (e.g., DIM done_flag:BOOLEAN ). BOOLEAN quantities
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2404 are stored as single byte values, but they may not be used for numeric
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2405 computation. BOOLEAN values print out as the character strings: "TRUE"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2406 and "FALSE."
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2407
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2408 BOOLEAN values result from comparisons (comparing two compatible types),
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2409 and are appropriate for logical flags and expressions. ( result:=a AND
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2410 b AND c ).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2411
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2412 Do not confuse BOOLEAN operations AND, OR, XOR, and NOT (which operate
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
2413 on the Boolean values TRUE end FALSE) with the logical functions LAND,
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2414 LOR, LXOR, and LNOT (which use integer values to produce results on a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2415 bit-by-bit basis). Attempting to store a non-BOOLEAN value in a BOOLEAN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2416 variable (or the reverse) will cause a run-time error.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2417 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2418 <sect2><title>Automatic Type Conversion</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2419 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2420 Expressions that mix numeric data types (BYTE, INTEGER, or REAL) are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2421 automatically and temporarily converted to the largest type necessary to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2422 retain accuracy. In addition, certain &b09; functions also perform
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2423 automatic type conversions as necessary. Thus, numeric quantities of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2424 mixed types may be used in most cases.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2425 Type-mismatch errors happen when an expression includes types that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2426 cannot legally be mixed. These errors are reported by the second compiler
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2427 pass which automatically occurs when you leave EDIT mode. Type
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2428 conversions can take time. Therefore, you should use expressions
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2429 containing all values of a single type wherever possible.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2430 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2431 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2432 <sect1><title>Constants</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2433 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2434 Constants are frequently used in program statements and in expressions to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2435 assign values to variables. &b09; has rules that allow you to specify
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2436 constants that correspond to the five basic data types.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2437 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2438 <sect2><title>Numeric Constants</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2439 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2440 Numeric constants can be either REAL or INTEGER. If a number constant
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2441 includes a decimal point or uses the "E format" exponential form,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2442 it forces &b09; to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2443 store the number in REAL format even if the value could have been
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2444 stored in INTEGER or BYTE format.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2445 Thus, if you specifically want to specify a REAL constant,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2446 use a decimal point (for example, 12.0).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2447 This is sometimes done if all other values in an expression are of type
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2448 REAL so &b09; does not have to do a time-consuming type conversion
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2449 at run-time.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2450
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2451 Numbers that do not have a decimal point but are too large to be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2452 represented as integers are also stored in REAL format. The following are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2453 examples of REAL values:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2454
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2455 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2456 <tgroup cols="2">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2457 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2458 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2459 <entry>1.0</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2460 <entry>9.8433218</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2461 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2462 <row>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2463 <entry>-.01</entry>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2464 <entry>-999.000099</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2465 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2466 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2467 <entry>100000000</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2468 <entry>5655.34532</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2469 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2470 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2471 <entry>1.95E+12</entry>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2472 <entry>-99999.9E-33</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2473 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2474 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2475 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2476 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2477
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2478
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2479 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2480 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2481
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2482 Numbers that do not have a decimal point and are in the range of
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2483 -32768 to +32767 are treated as INTEGER numbers.
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2484 &b09; will also accept integer constants in hexadecimal in the range 0 to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2485 $FFFF. Hex numbers must have a leading dollar sign. Here are some
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2486 examples of INTEGER constants:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2487
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2488 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2489 <tgroup cols="3">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2490 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2491 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2492 <entry>12</entry>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2493 <entry>-3000</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2494 <entry>64000</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2495 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2496 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2497 <entry>$20</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2498 <entry>$FFFE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2499 <entry>$0</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2500 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2501 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2502 <entry>0</entry>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2503 <entry>-12</entry>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2504 <entry>-32768</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2505 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2506 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2507 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2508 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2509
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2510 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2511 <sect2><title>Boolean Constants</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2512 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2513 The two legal boolean constants are "TRUE" and "FALSE".
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2514 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2515 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2516 Example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2517 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2518 DIM flag, state: BOOLEAN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2519 flag := TRUE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2520 state := FALSE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2521 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2522
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2523 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2524 <sect2><title>String Constants</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2525 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2526 String constants consist of a sequence of any characters enclosed in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2527 double quote characters. The binary value of each character byte can be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2528 1 to 255. Double quote characters to be included in the string use two
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2529 characters in a row to represent one double quote.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2530
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2531 The null string "" is important because it represents a string having no
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2532 characters. It is analogous to the numeric zero. Here are some examples
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2533 of string constants:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2534
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2535 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2536 "&b09; is a new microcomputer language"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2537 "AABBCCDD"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2538 "" (a null string)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2539 "An ""older man"" is wiser"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2540 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2541
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2542 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2543 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2544 <sect1><title>Variables</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2545 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2546 Each &b09; variable is "local" to the procedure where it is defined. This
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2547 means that it is only known to the program statements within that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2548 procedure. You can use the same variable name in several procedures and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2549 the variables will be completely independent. If you want other procedures
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2550 to be able to share a variable, you must use the RUN and PARAM statements
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2551 to pass the variable when a procedure calls another procedure.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2552 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2553 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2554 Storage for variables is allocated from the &b09; workspace when
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2555 the procedure is called. It is not possible to force a variable to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2556 occupy a particular absolute address in memory. When the procedure
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2557 is exited, variable storage is given back and the values stored in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2558 it are lost. Procedures can call themselves (this is referred to as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2559 <emphasis>recursion</emphasis>) which causes another separate
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2560 storage space for variables to be allocated.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2561
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2562
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2563 <warning>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2564 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2565 &b09; does not automatically initialize
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2566 variables. When a procedure is run, all variables, arrays, and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2567 structures will have random values. Your program must assign
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2568 any initial value if needed.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2569 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2570 </warning>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2571
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2572 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2573 <sect1><title>Parameter Variables</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2574 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2575 Procedures may pass variables to other procedures. When this occurs, the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2576 variables passed to the called procedure are called "parameters".
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2577 Parameters may be passed either "by reference",
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2578 allowing values to be returned from the called procedure, or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2579 "by value", which protects the values in the calling procedure such
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2580 that they may not be changed by the procdure which is called.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2581 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2582 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2583 Parameters are usually passed "by reference"; this is done by enclosing
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2584 the names of the variables to be sent to the called procedure in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2585 parentheses as part of the RUN statement. The storage address of each
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2586 parameter variable is evaluated and sent to the called procedure, which
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2587 then associates those addresses with names in a local PARAM statement.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2588 The called procedure uses this storage as if it had been created locally
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2589 (although it may have a new name) and can change the values stored there.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2590 Parameters passed by reference allow called procedures to return values
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2591 to their callers.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2592 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2593 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2594 Parameters may be passed "by value" by writing the value to be passed
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2595 as an expression which is evaluated at the time of the call. Useful
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2596 expression-generators that do not alter values are +0 for numbers or +""
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2597 for strings. For example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2598
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2599 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2600 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2601 RUN inverse(x) passes x by reference.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2602 RUN inverse(x+0) passes x by value.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2603 RUN translate(word$) passes word$ by reference.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2604 RUN translate(word$+"") passes word$ by value.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2605 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2606 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2607 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2608 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2609 When parameters are passed by value, a temporary variable is created
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2610 when the expression is evaluated. The result is placed in this new temporary
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2611 storage. The address of this temporary storage is sent to the called
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2612 procedure. Therefore, the value actually given to the called procedure is a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2613 <emphasis>copy</emphasis> of the result, and the called procedure can't
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2614 accidentially (or otherwise) change the variable(s) in the calling program.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2615 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2616 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2617 Notice that expressions containing numeric constants are either of type
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2618 INTEGER or of type REAL; there is no type BYTE constant. Thus, BYTE-type
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2619 VARIABLES may be sent to a procedure as parameters; but expressions will
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2620 be of types INTEGER or REAL. For example, a RUN statement may evaluate
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2621 an INTEGER as a parameter and send it to the called procedure. If the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2622 called procedure is expecting a BYTE-type variable, it uses only the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2623 high-order byte of the (two-byte) INTEGER (which, if the value was
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2624 intended to be in BYTE-range, will probably be zero!).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2625 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2626 <sect1><title>Arrays</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2627 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2628 The DIM statement can create arrays of from 1 to 3 dimensions
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2629 (a one-dimensional array is often called a "vector", while a 2 or 3
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2630 dimensional array is called a "matrix" ). The sizes of each dimension are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2631 defined when the array is typed (e.g., DIM plot(24,80):BYTE) by including
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2632 the number of elements in each dimension. Thus, a table dimensioned
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2633 (24,80) has 24 rows (1-24) of 80 columns (1 - 80) when accessed in the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2634 default (BASE 1) mode. You may elect to access the elements of an array
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2635 starting at zero (BASE 0), in which case there are still 24 rows (now
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2636 0-23) and 80 columns (now 0-79). Arrays may be composed of atomic data
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2637 types, complex data types, or other arrays.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2638 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2639 <sect1><title>Complex Data Types</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2640 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2641 The TYPE statement can be used to define a new data type as a "vector" (a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2642 one-dimensional array) of any atomic or previously-defined types.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2643 For example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2644
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2645 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2646 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2647 TYPE employee_rec = name:STRING; number(2):INTEGER; malesex:BOOLEAN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2648 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2649 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2650
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2651 This structure differs from an array in that the various elements may be of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2652 mixed types, and the elements are accessed by a <emphasis>field name</emphasis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2653 instead of an array index. For example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2654
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2655 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2656 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2657 DIM employee_file(250): employee_rec
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2658 employee_file(1).name := "Tex"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2659 employee_file(20).number(2) := 115
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2660 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2661 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2662 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2663 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2664 The complex structure gives the programmer the ability to store and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2665 manipulate related values that are of many types, to create "new"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2666 types in addition to the five atomic data types, or to create data
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2667 structures of unusual "shape" or size. Additionally, the position of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2668 the desired element in complex-type storage is known and defined at
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2669 "compile time" and need not be calculated at "run time". Therefore,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2670 complex structure accesses may be slightly faster than array accesses.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2671 The elements of a complex structure may be copied to another similar
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2672 structure using a single assignment operator (:= ). An entire structure
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2673 may be written to or read from mass storage as a single entity (e.g.,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2674 PUT #2, employee_file). Arrays or complex structures may be elements
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2675 of subsequent complex structures or arrays.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2676 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2677 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2678 </chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2679
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2680
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2681 <chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2682 <title>Expressions, Operators, and Functions</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2683
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2684 <sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2685 <title>Evaluation of Expressions</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2686 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2687 Many &b09; statements evaluate <emphasis>expressions</emphasis>. The
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2688 result of an evaluation is just a value of some atomi type (e.g., REAL,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2689 INTEGER, STRING, or BOOLEAN). The expression itself may consist of values
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2690 and operators. For example, the expression "5+5" results in an integer
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2691 with a value of ten.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2692 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2693 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2694 A "value" can be a constant value (e.g, 5.0, 5 , "5" , or TRUE), a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2695 variable name, or a function (e.g, SIN(x) ) which "returns" the result as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2696 a value. An <emphasis>operator</emphasis> combines values (typically,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2697 those adjacent to the operator) and also returns a result.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2698 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2699 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2700 In the course of evaluating an expression, each value is copied to an
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2701 "expression stack" where functions and operators take their input values
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2702 and return results. If (as is often the case) the expression is to be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2703 used in an assignment statement, only when the result of the entire
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2704 expression has been found is the assignment made. This allows
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2705 the variable which is being modified (assigned to) to be one of the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2706 values in the expression. The same principles apply for numeric, string,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2707 and boolean operators. These principles make assignment statements such
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2708 as "X=X+1" legal in all cases, even though it would not make sense in a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2709 mathematical context.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2710 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2711 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2712 Any expression evaluates to one of the five "atomic" data types, i.e.,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2713 real, integer, byte, boolean, or string. This does not mean, however,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2714 that all the operators and operands in expressions have to be of an
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2715 identical type. Often types are mixed in expressions because the RESULT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2716 of some operator or function has a different type than its operands.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2717 An example is the "less than" operator. Here is an example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2718
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2719 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2720 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2721 24 &lt; 100
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2722 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2723 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2724
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2725 The "&lt;" operator compares two numeric operands. The result of the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2726 comparison is of type BOOLEAN; in this case, the value TRUE.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2727 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2728 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2729 &b09; allows intermixing of the three numeric types because it performs
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2730 automatic type conversion of operands. If different types are used in an
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2731 expression, the "result" will be the same type as the operand(s)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2732 having the largest representation. As a rule, any numeric type operand
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2733 may be used in a expression that is expected to produce a result of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2734 type REAL. Expressions that must produce BYTE or INTEGER results must
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2735 evaluate to a value that is small enough to fit the representation. &b09;
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2736 has a complete set of functions that can perform compatible type
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2737 conversion. Type-mismatch errors are reported by the second compiler
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2738 pass when leaving Edit mode.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2739 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2740 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2741 <sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2742 <title>Operators</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2743 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2744 Operators take two operands (except negation) and cause some operation
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2745 to be performed producing a result, which is generally the same type
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2746 as the operands (except comparisons). The table below lists the operators
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2747 available and the types they accept and produce.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2748 "NUMERIC" refers to either BYTE, INTEGER, or REAL types.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2749 <table frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2750 <title>&b09; Expression Operators</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2751 <tgroup cols="4">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2752 <colspec colwidth="0.8in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2753 <thead>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2754 <row rowsep="1">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2755 <entry>Operator</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2756 <entry>Function</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2757 <entry>Operand type</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2758 <entry>Result type</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2759 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2760 </thead>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2761 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2762 <row>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2763 <entry>-</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2764 <entry>Negation</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2765 <entry>NUMERIC</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2766 <entry>NUMERIC</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2767 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2768 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2769 <entry>^ or **</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2770 <entry>Exponentiation</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2771 <entry>NUMERIC (positive)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2772 <entry>NUMERIC</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2773 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2774 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2775 <entry>*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2776 <entry>Multiplication</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2777 <entry>NUMERIC</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2778 <entry>NUMERIC</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2779 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2780 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2781 <entry>/</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2782 <entry>Division</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2783 <entry>NUMERIC</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2784 <entry>NUMERIC</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2785 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2786 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2787 <entry>+</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2788 <entry>Addition</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2789 <entry>NUMERIC</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2790 <entry>NUMERIC</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2791 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2792 <row>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2793 <entry>-</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2794 <entry>Subtraction</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2795 <entry>NUMERIC</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2796 <entry>NUMERIC</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2797 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2798 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2799 <entry>NOT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2800 <entry>Logical Negation</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2801 <entry>BOOLEAN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2802 <entry>BOOLEAN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2803 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2804 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2805 <entry>AND</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2806 <entry>Logical AND</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2807 <entry>BOOLEAN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2808 <entry>BOOLEAN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2809 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2810 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2811 <entry>OR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2812 <entry>Logical OR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2813 <entry>BOOLEAN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2814 <entry>BOOLEAN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2815 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2816 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2817 <entry>XOR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2818 <entry>Logical EXCLUSIVE OR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2819 <entry>BOOLEAN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2820 <entry>BOOLEAN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2821 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2822 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2823 <entry>+</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2824 <entry>Concatenation</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2825 <entry>STRING</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2826 <entry>STRING</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2827 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2828 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2829 <entry>=</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2830 <entry>Equal to</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2831 <entry>ANY</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2832 <entry>BOOLEAN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2833 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2834 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2835 <entry>&lt;> or >&lt;</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2836 <entry>Not equal to</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2837 <entry>ANY</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2838 <entry>BOOLEAN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2839 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2840 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2841 <entry>&lt;</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2842 <entry>Less than</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2843 <entry>NUMERIC, STRING*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2844 <entry>BOOLEAN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2845 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2846 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2847 <entry>&lt;= or =&lt;</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2848 <entry>Less than or Equal</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2849 <entry>NUMERIC, STRING*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2850 <entry>BOOLEAN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2851 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2852 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2853 <entry>></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2854 <entry>Greater than</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2855 <entry>NUMERIC, STRING*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2856 <entry>BOOLEAN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2857 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2858 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2859 <entry>>= or =></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2860 <entry>Greater than or Equal</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2861 <entry>NUMERIC, STRING*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2862 <entry>BOOLEAN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2863 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2864 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2865 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2866 </table>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2867 When comparing strings, the ASCII collating sequence is used, so that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2868 0 &lt; 1 &lt; ... &lt; 9 &lt; A &lt; B&lt; ... &lt; Z &lt; a &lt; b&lt;
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2869 ... &lt; z
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2870 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2871 <sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2872 <title>Operator Precedence</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2873 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2874 Operators have "precedence". This means they are evaluated in a specific
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2875 order. (i.e., multiplications performed before addition). Parentheses can
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2876 be used to override natural precedence, however, extraneous parentheses
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2877 may be removed by the compiler. The legal operators are listed below,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2878 in precedence order from highest to lowest.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2879
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2880 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2881 <tgroup cols="7">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2882 <colspec colname="c1"/>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2883 <colspec colname="c2"/>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2884 <colspec colname="c3"/>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2885 <colspec colnum="7" colname="c7"/>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2886 <spanspec spanname="firstop" namest="c2" nameend="c2"/>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2887 <spanspec spanname="secondop" namest="c3" nameend="c7"/>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2888 <spanspec spanname="onlyop" namest="c2" nameend="c7"/>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2889 <spanspec spanname="all" namest="c1" nameend="c7"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2890 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2891 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2892 <entry spanname="all">Highest Precedence</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2893 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2894 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2895 <entry spanname="firstop">NOT</entry>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2896 <entry spanname="secondop">-(negate)</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2897 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2898 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2899 <entry spanname="firstop">^</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2900 <entry spanname="secondop">**</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2901 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2902 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2903 <entry spanname="firstop">*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2904 <entry spanname="secondop">/</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2905 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2906 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2907 <entry spanname="firstop">+</entry>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2908 <entry spanname="secondop">-</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2909 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2910 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2911 <entry spanname="firstop">></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2912 <entry>&lt;</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2913 <entry>&lt;></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2914 <entry>=</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2915 <entry>>=</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2916 <entry>&lt;=</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2917 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2918 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2919 <entry spanname="onlyop">AND</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2920 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2921 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2922 <entry spanname="firstop">OR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2923 <entry spanname="secondop">XOR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2924 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2925 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2926 <entry spanname="all">Lowest Precedence</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2927 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2928 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2929 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2930 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2931 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2932 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2933 Operators of equal precedence are shown on the same line, and are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2934 evaluated left to right in expressions. The only exception to this rule is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2935 exponentiation, which is evaluated right to left. Raising a negative number
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2936 to a power is not legal in &b09;.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2937 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2938 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2939 In the examples below, &b09; expressions on the left are evaluated as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2940 indicated on the right. Either form may be entered,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2941 but the simpler form on the left will always be generated by the decompiler.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2942 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2943 <tgroup cols="2">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2944 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2945 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2946 <entry>&b09; representation</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2947 <entry>Equivalent form</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2948 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2949 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2950 <entry>a:= b+c**2/d</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2951 <entry>a:= b+((c**2)/d)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2952 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2953 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2954 <entry>a:= b>c AND d>e OR c=e</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2955 <entry>a:= ((b>c) AND (d>e)) OR (c=e)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2956 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2957 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2958 <entry>a:= (b+c+d)/e</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2959 <entry>a:= ((b+c)+d)/e</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2960 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2961 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2962 <entry>a:= b**c**d/e</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2963 <entry>a:= (b**(c**d))/e</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2964 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2965 <row>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2966 <entry>a:= -(b)**2</entry>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
2967 <entry>a:= (-b)**2</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2968 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2969 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2970 <entry>a:=b=c</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2971 <entry>a:= (b=c) (returns BOOLEAN value)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2972 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2973 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2974 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2975 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2976
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2977
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2978 </para></sect2></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2979 <sect1><title>Functions</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2980 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2981 Functions take one or more <emphasis>arguments</emphasis> enclosed in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2982 parentheses, perform some operation, and return a value. They may be used
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2983 as operands in expressions. Functions expect that the arguments passed
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2984 to them be expressions, constants, or variables of a certain type and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2985 return a result of a certain type. Giving a function, an argument of an
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2986 incompatible type will result in an error.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2987 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2988 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2989 In the descriptions of functions that follow, the following notation
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2990 describes the type required for the parameter expressions:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2991
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2992 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2993 <tgroup cols="2">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2994 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2995 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2996 <entry>&lt;num></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2997 <entry>means any numeric-result expression.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2998 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
2999 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3000 <entry>&lt;str></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3001 <entry>means any string-result expression.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3002 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3003 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3004 <entry>&lt;int></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3005 <entry>means any integer-result expression.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3006 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3007 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3008 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3009 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3010
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3011 The functions below return REAL results. Accuracy of transcendental
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3012 functions is 8+ decimal digits. Angles can be either degrees or radians (see
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3013 DEG/RAD statement descriptions).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3014
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3015 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3016 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3017 <colspec colwidth="1.5in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3018 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3019 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3020 <entry>SIN(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3021 <entry>trigonometric sine of &lt;num></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3022 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3023 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3024 <entry>COS(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3025 <entry>trigonometric cosine of &lt;num></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3026 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3027 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3028 <entry>TAN(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3029 <entry>trigonometric tangent of &lt;num></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3030 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3031 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3032 <entry>ASN(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3033 <entry>trigonometric arcsine of &lt;num></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3034 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3035 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3036 <entry>ACS(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3037 <entry>trigonometric arcosine of &lt;num></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3038 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3039 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3040 <entry>ATN(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3041 <entry>trigonometric arctangent of &lt;num></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3042 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3043 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3044 <entry>LOG(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3045 <entry>natural logarithm (base e) of &lt;num></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3046 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3047 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3048 <entry>LOG10(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3049 <entry>logarithm (base 10) of &lt;num></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3050 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3051 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3052 <entry>EXP(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3053 <entry>e (2.71828183) raised to the power &lt;num>, which must be a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3054 positive number</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3055 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3056 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3057 <entry>FLOAT(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3058 <entry>&lt;num> converted to type REAL (from BYTE or INTEGER)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3059 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3060 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3061 <entry>INT(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3062 <entry>truncates all digits to the right of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3063 the decimal point of a REAL &lt;num></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3064 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3065 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3066 <entry>PI</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3067 <entry>the constant 3.14159265.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3068 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3069 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3070 <entry>SQR(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3071 <entry>square root of &lt;num>, which must be positive.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3072 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3073 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3074 <entry>SQRT(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3075 <entry>square root of &lt;num>; same as SQR.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3076 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3077 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3078 <entry morerows="2">RND(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3079 <entry>if &lt;num>=0, returns random x, 0 &lt;= x &lt; 1.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3080 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3081 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3082 <entry>if &lt;num>>0, returns random x, 0 &lt;= x &lt; &lt;num>.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3083 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3084 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3085 <entry>if &lt;num>&lt;0, use ABS(&lt;num>) as new random number seed.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3086 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3087 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3088 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3089 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3090
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3091 The following functions can return any numeric type, depending on the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3092 type of the input parameter(s).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3093
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3094 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3095 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3096 <colspec colwidth="1.5in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3097 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3098 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3099 <entry>ABS(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3100 <entry>absolute value of &lt;num></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3101 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3102 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3103 <entry>SGN(&lt;num>)</entry>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3104 <entry>signum of &lt;num>: -1 if &lt;num> &lt; 0; 0 if &lt;num> = 0; or 1 if &lt;num> > 0</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3105 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3106 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3107 <entry>SQ(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3108 <entry>&lt;num> squared</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3109 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3110 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3111 <entry>VAL(&lt;str>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3112 <entry>convert type string to type numeric</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3113 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3114 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3115 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3116 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3117
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3118
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3119 The following functions can return results of type INTEGER or BYTE:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3120
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3121 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3122 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3123 <colspec colwidth="1.5in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3124 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3125 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3126 <entry>FIX(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3127 <entry>round REAL &lt;num> and convert to type INTEGER.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3128 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3129 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3130 <entry>MOD(&lt;num1>,&lt;num2>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3131 <entry>modulus (remainder) function. &lt;num1> mod &lt;num2>.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3132 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3133 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3134 <entry>ADDR(&lt;name>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3135 <entry>absolute memory address of variable, array, or structure named &lt;name>.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3136 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3137 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3138 <entry>SIZE(&lt;name>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3139 <entry>storage size in bytes of variable, array, or structure named &lt;name>.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3140 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3141 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3142 <entry>ERR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3143 <entry>error code of most recent error, automatically resets to zero when referenced.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3144 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3145 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3146 <entry>PEEK(&lt;int>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3147 <entry>value of byte at memory address &lt;int>.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3148 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3149 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3150 <entry>POS</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3151 <entry>current character position of PRINT buffer.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3152 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3153 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3154 <entry>ASC(&lt;str>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3155 <entry>numeric value of first character of &lt;str>.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3156 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3157 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3158 <entry>LEN(&lt;str>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3159 <entry>length of string &lt;str>.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3160 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3161 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3162 <entry>SUBSTR(&lt;str1>,&lt;str2>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3163 <entry>substring search: returns starting position of first occurrence of &lt;str1> in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3164 &lt;str2>, or 0 if not found.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3165 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3166 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3167 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3168 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3169
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3170 The following functions perform bit-by-bit logical operations on integer
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
3171 or byte data types and return integer results. They should <emphasis>not</emphasis> be confused
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3172 with the BOOLEAN-type operators.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3173
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3174 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3175 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3176 <colspec colwidth="1.5in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3177 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3178 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3179 <entry>LAND(&lt;num>,&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3180 <entry>Logical AND</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3181 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3182 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3183 <entry>LOR(&lt;num>,&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3184 <entry>Logical OR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3185 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3186 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3187 <entry>LXOR(&lt;num>,&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3188 <entry>Logical EXCLUSIVE OR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3189 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3190 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3191 <entry>LNOT(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3192 <entry>Logical NOT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3193 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3194 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3195 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3196 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3197
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3198 These functions return a result of type STRING:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3199
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3200 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3201 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3202 <colspec colwidth="1.7in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3203 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3204 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3205 <entry>CHR$(&lt;int>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3206 <entry>ASCII char. equivalent of &lt;int></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3207 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3208 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3209 <entry>DATE$</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3210 <entry>date and time, format: "yy/mm/dd hh:mm:ss"</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3211 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3212 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3213 <entry>LEFT$(&lt;str>,&lt;int>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3214 <entry>leftmost &lt;int> characters of &lt;str>.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3215 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3216 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3217 <entry>RIGHT$(&lt;str>,&lt;int>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3218 <entry>rightmost &lt;int> characters of &lt;str>.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3219 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3220 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3221 <entry>MID$(&lt;str>,&lt;int1>,&lt;int2>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3222 <entry>middle &lt;int2> characters of &lt;str> starting at
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3223 character position &lt;int1>.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3224 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3225 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3226 <entry>STR$(&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3227 <entry>converts numeric type &lt;num> to displayable characters of type
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3228 STRING representing the number converted.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3229 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3230 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3231 <entry>TRIM$(&lt;str>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3232 <entry>&lt;str> with trailing spaces removed.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3233 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3234 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3235 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3236 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3237
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3238 The following functions return BOOLEAN values:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3239
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3240
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3241 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3242 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3243 <colspec colwidth="1.5in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3244 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3245 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3246 <entry>TRUE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3247 <entry>always returns TRUE.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3248 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3249 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3250 <entry>FALSE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3251 <entry>always returns FALSE.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3252 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3253 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3254 <entry>EOF(#&lt;num>)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3255 <entry>End-of-file test on disk file path &lt;num>, returns TRUE if
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3256 end-of-file condition</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3257 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3258 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3259 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3260 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3261
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3262 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3263 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3264 </chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3265 <chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3266 <title>Program Statements and Structure</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3267 <sect1><title>Program Structure</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3268 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3269 Each &b09; can be a complete program in itself, or several procedures
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3270 that call each other can be used to create an application program. It is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3271 up to the programmer to decide which approach to take. One procedure
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3272 may suffice for small programs but large programs are easier to write
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3273 and test if divided into separate modules (procedures) according to the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3274 program's natural flow. These suggestions reflect sound structured
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3275 programming practice. Nonetheless, you can use a single large procedure
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3276 for your program if you so desire.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3277 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3278 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3279 A procedure consists of any number of program statement lines. Each line
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3280 can have an optional line number, and more than one program statement can be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3281 placed on the same line if separated by "\" characters. For
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3282 example, the following statements are equivalent:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3283
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3284 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3285 <tgroup cols="2">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3286 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3287 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3288 <entry>GOSUB 550 \ PRINT X,Y \ RETURN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3289 <entry><literallayout>GOSUB 550
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3290 PRINT X,Y
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3291 RETURN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3292 </literallayout></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3293 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3294 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3295 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3296 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3297 The maximum input line length is 255 characters. Line feeds can
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3298 be used to make a single long line into shorter lines to fit display
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3299 screens better. This is especially useful when working on hard-copy
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3300 terminals.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3301 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3302 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3303 Program statements can be in any order consistent with program logic
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3304 Progra readability is improved if all variables are declared with
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3305 DIM statements at the beginning of the procedure, but this is not mandatory.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3306 The program can be terminated with END or STOP statements, which are also
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3307 optional.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3308 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3309 <sect1><title>Line Numbers</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3310 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3311 Line numbers are optional. They can be any integer number in the range of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3312 1 to 32767. Only use line numbers where absolutely necessary (such as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3313 with GOSUB). They make programs harder to understand, use additional
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3314 memory space, and increase compile time considerably. Line numbers are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3315 local to procedures. That is, the same line number can be used in different
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3316 procedures without conflict.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3317 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3318 <sect1><title>Assignment Statements</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3319 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3320 Assignment statements are used for computing or initializing of variables.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3321 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3322 <sect2><title>LET Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3323 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3324 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3325 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3326 <command>[LET] &lt;var> := &lt;expr></command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3327 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3328 <command>[LET] &lt;var> = &lt;expr></command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3329 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3330 <command>[LET] &lt;struct> := &lt;struct></command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3331 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3332 <command>[LET] &lt;struct> = &lt;struct></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3333 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3334
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3335 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3336 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3337 This statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3338 evaluates an expression and stores the result in &lt;var> which may be a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3339 simple variable or data structure element. The result of the expression
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3340 must be of the same or compatible type as &lt;var>.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3341 &b09; will accept either "=" or ":=" as an assignment operator, however, the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3342 second form ( := ) is preferred because it distinguishes the assignment
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3343 operation from a comparison (the test for equality). The ":=" operator is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3344 the same as used in PASCAL.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3345 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3346 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3347 Another use of the assignment statement is to copy the entire value
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3348 of an array or complex data structure to another array or complex
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3349 data structure. The data structures do not have to have the same type
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3350 or "shape". The only restriction is that the size of the destination
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3351 structure be the same or larger than the source structure. In fact this
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3352 type of assignment can be used to perform unusual type conversions.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3353 For example, a string variable of 80 characters can be copied to a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3354 one-dimensional array of 80 bytes.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3355 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3356 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3357 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3358
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3359 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3360 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3361 A := 0.1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3362
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3363 value := temp/sin(x)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3364
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3365 DIM array1(100), array2(100)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3366 array1 := array2
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3367
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3368 LET AUTHOR$ := FIRST_NAME$ + LAST_NAME$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3369
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3370 DIM truth,lie:BOOLEAN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3371 lie := 100 &lt; 1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3372 truth := NOT lie
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3373
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3374 count = total-adjustment
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3375 matrix(2).coefficient(n+2) := matrix(1).coefficient(n)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3376 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3377 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3378
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3379 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3380 <sect2><title>POKE Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3381 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3382
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3383 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3384 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3385 <command>POKE &lt;integer expr> , &lt;byte expr></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3386 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3387 This statement allows a program to store data at a specific memory
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3388 address. The first expression is used as the absolute address to store
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3389 the type BYTE result of the second expression. This statement can alter
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3390 any memory address so care must be taken when using it.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3391 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3392 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3393 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3394
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3395 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3396 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3397 POKE ADDR(buffer)+5,ASC("A")
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3398
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3399 POKE 1200,14
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3400
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3401 POKE $1C00,$FF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3402
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3403 POKE pointer,PEEK(pointer+1)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3404
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3405 (* alternative to: alphabet$ := "ABCDEFGHIJKLMNOPQRSTUVWXYZ" *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3406 FOR i=0 to 25
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3407 POKE ADDR(alphabet$)+i,$40+i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3408 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3409 POKE ADDR(alphabet$)+26,$FF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3410 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3411 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3412
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3413 </para></sect2></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3414
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3415 <sect1><title>Control Statements</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3416 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3417 This class of statements affect the (usually) sequential execution of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3418 program statements. They are used to construct loops or make decisions
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
3419 that alter program flow. &b09; provides a selection of looping statements
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3420 that allow you to create any kind of loop using sound structured
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3421 programming style.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3422 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3423 <sect2><title>IF Statement: Type 1</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3424 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3425 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3426
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3427 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3428 <command>IF &lt;bool expr> THEN &lt;line #></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3429 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3430 This form of the if statement causes execution to be transferred
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3431 to the statement having the line number specified if the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3432 result of the expression is TRUE, otherwise the next sequential
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3433 statement is executed. For example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3434 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3435 IF payment &lt; balance then 400
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3436 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3437 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3438 </sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3439 <sect2><title>IF Statement: Type 2</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3440 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3441 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3442 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3443 <command>IF &lt;bool expr> THEN &lt;statements></command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3444 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3445 <command>[ ELSE &lt;statements> ]</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3446 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3447 <command>ENDIF</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3448 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3449 This kind of IF structure evaluates the expression to a BOOLEAN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3450 value. If the result is TRUE the statement(s) immediately following
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3451 the THEN are executed. If an ELSE clause exists, statements between
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3452 the ELSE and ENDIF are skipped. If the expression is evaluated to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3453 FALSE control is transferred to the first statement following the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3454 ELSE, if present, or otherwise to the statement following the ENDIF.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3455 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3456 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3457 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3458
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3459 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3460 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3461 IF a &lt; b THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3462 PRINT "a is less than b"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3463 PRINT "a:";a;" b:";b
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3464 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3465
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3466 IF a &lt; b THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3467 PRINT "a is less than b"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3468 ELSE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3469 IF a=b THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3470 PRINT "a equals b"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3471 ELSE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3472 PRINT "a is greater than b"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3473 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3474 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3475 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3476 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3477
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3478 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3479 <sect2><title>FOR/NEXT Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3480 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3481 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3482 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3483 <command>FOR &lt;var> = &lt;expr> TO &lt;expr> [ STEP &lt;expr> ]</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3484 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3485 <command>NEXT &lt;var></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3486 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3487 Creates a loop that usually executes a specified number of times
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3488 while automatically increasing or decreasing a specified counter variable.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3489 The first expression is evaluated and the result is stored in &lt;var> which
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3490 must be a simple integer or real variable. The second expression is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3491 evaluated and stored in a temporary variable.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3492 If the STEP clause is used, the expression following is evaluated
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3493 and used as the loop increment. If it is negative, the loop will count down.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3494 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3495 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3496 The "body" of the loop (i.e. statements between the "FOR" and "NEXT" are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3497 executed until the counter variable is larger than the terminating
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3498 expression value. For negative STEP values, the loop will execute until the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3499 loop counter is less than the termination value. If the initial value of &lt;var>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3500 is beyond the terminating value the body of the loop is never executed.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3501 It is legal to jump out of FOR/NEXT loops. The is no limit to the nesting
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3502 of FOR/NEXT loops.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3503 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3504 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3505 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3506
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3507 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3508 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3509 FOR counter = 1 to 100 step .5
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3510 PRINT counter
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3511 NEXT counter
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3512
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3513
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3514 FOR var = min-1 TO min+max STEP increment-adjustment
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3515 PRINT var
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3516 NEXT var
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3517
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3518
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3519 FOR x = 1000 TO 1 STEP -1
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3520 PRINT x
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3521 NEXT x
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3522 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3523 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3524 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3525 <sect2><title>WHILE..DO Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3526 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3527 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3528 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3529 <command>WHILE &lt;bool expr> DO</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3530 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3531 <command>ENDWHILE</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3532 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3533 This is a loop construct with the test at the "top" of the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3534 loop. Statements within the loop are executed as long as &lt;bool
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3535 expr> is TRUE. The body of the loop will not be executed if the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3536 boolean expression evaluates to FALSE when first executed.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3537 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3538 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3539 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3540
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3541 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3542 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3543 WHILE a&lt;b DO is equivalent to 100 IF a>=b THEN 500
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3544 PRINT a PRINT a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3545 a := a+1 a := a+1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3546 ENDWHILE GOTO 100
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3547 500 REM
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3548
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3549 DIM yes:BOOLEAN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3550 yes=TRUE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3551 WHILE yes DO
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3552 PRINT "yes! ";
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3553 yes := POS&lt;50
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3554 ENDWHILE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3555
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3556 REM reverse the letters in word$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3557 backward$ := ""
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3558 INPUT word$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3559 WHILE LEN(word$) > 0 DO
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3560 backward$ := backward$ + RIGHT$(word$,1)
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3561 word$ := LEFT$(word$,LEN(word$)-1)
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3562 ENDWHILE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3563 word$ := backward$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3564 PRINT word$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3565 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3566 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3567
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3568 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3569 <sect2><title>REPEAT..UNTIL Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3570 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3571 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3572 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3573 <command>REPEAT</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3574 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3575 <command>UNTIL &lt;bool expr></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3576 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3577 This is a loop that has its test at the bottom of the loop. The
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3578 statement(s) within the loop are executed until the result of &lt;bool expr> is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3579 TRUE. The body of the loop is always executed at least one time.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3580 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3581 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3582 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3583 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3584 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3585 x = 0 is the same as x=0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3586 REPEAT 100 PRINT x
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3587 PRINT x x=x+1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3588 x=x+1 IF X &lt;= 10 THEN 100
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3589 UNTIL x>10
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3590
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3591 (* compute factorial: n! *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3592 temp := 1.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3593 INPUT "Factorial of what number? ",n
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3594 REPEAT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3595 temp := temp * n
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3596 n := n-1
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3597 UNTIL n &lt;= 1.0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3598 PRINT "The factorial is "; temp
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3599 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3600 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3601 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3602 <sect2><title>LOOP and ENDLOOP/EXITIF and ENDEXIT Statements</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3603 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3604 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3605 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3606 <command>LOOP</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3607 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3608 <command>ENDLOOP</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3609 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3610
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3611 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3612 <command>EXITIF &lt;bool expr> THEN &lt;statements></command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3613 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3614 <command>ENDEXIT</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3615 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3616 These related types of statements can be used to construct
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3617 loops with test(s) located anywhere in the body of the loop.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3618 The LOOP and ENDLOOP statements define the body of the loop.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3619 EXITIF clauses can be inserted anywhere inside the loop to leave the loop
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3620 if the result of its test is true.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3621 Note that if there is no EXITIF clause, you will create a loop that never ends.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3622 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3623 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3624 The EXITIF clause evaluates an expression to a boolean result. If the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3625 result is FALSE, the statement following the ENDEXIT is executed next.
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
3626 Otherwise, the statement(s) between the EXITIF and ENDEXIT are
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3627 executed, then control is transferred to the statement following
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3628 the body of the loop. This exit clause
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3629 is often used to perform some specific function upon termination of the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3630 loop which depends on where the loop terminated.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3631 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3632 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3633 EXITIF statements are almost always used when LOOP..ENDLOOP is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3634 used, but they can also be useful in ANY type of &b09; loop
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3635 construct (e.g., FOR/NEXT, REPEAT... UNTIL, etc.). Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3636
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3637 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3638 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3639 LOOP is equivalent to 100 REM top of loop
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3640 count=count+1 count=count+1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3641 EXITIF count >100 THEN IF COUNT &lt;= 100 then 200
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3642 done = TRUE done = TRUE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3643 ENDEXIT GOTO 300
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3644 PRINT count 200 PRINT count
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3645 x = count/2 x = count/2
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3646 ENDLOOP GOTO 100
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3647 300 REM out of loop
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3648
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3649 INPUT x,y
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3650 LOOP
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3651 PRINT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3652 EXITIF x &lt; 0 THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3653 PRINT "x became zero first"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3654 ENDEXIT
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3655 x := x-1
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3656 EXITIF y &lt; 0 THEN PRINT "y became zero first"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3657 ENDEXIT
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3658 y := y-1
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3659 ENDLOOP
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3660 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3661 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3662
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3663 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3664 <sect2><title>GOTO Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3665 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3666 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3667 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3668 <command>GOTO &lt;line #></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3669 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3670 The GOTO unconditionally transfers execution flow to the line having the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3671 specified number. Note that the line number is a constant, not an expression
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3672 or a variable.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3673 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3674 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3675 Example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3676 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3677 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3678 GOTO 1000
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3679 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3680 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3681
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3682 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3683 <sect2><title>GOSUB/RETURN Statements</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3684 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3685 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3686 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3687 <command>GOSUB &lt;line #></command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3688 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3689 <command>RETURN</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3690 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3691 The GOSUB statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3692 transfers program execution to a subroutine starting at the specified
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3693 line number. The subroutine is executed until a RETURN statement is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3694 encountered, which causes execution to resume at the statement following
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3695 the calling GOSUB. Subroutines may be "nested" to any depth.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3696 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3697 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3698 Example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3699 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3700 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3701 FOR n := 1 to 10
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3702 x := SIN(n)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3703 GOSUB 100
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3704 NEXT n
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3705 FOR m := 1 TO 10
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3706 x := COS(m)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3707 GOSUB 100
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3708 NEXT m
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3709 STOP
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3710
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3711 100 x := x/2
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3712 PRINT x
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3713 RETURN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3714 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3715 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3716 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3717 <sect2><title>ON GOTO/GOSUB Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3718 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3719 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3720 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3721 <command>ON &lt;int expr> GOTO &lt;line #> {,&lt;line #>}</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3722 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3723 <command>ON &lt;int expr> GOSUB &lt;line #> {,&lt;line #>}</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3724 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3725 These statements evaluate an integer expression and use the result to select
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3726 a corresponding line number from an ordered list. Control is then
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3727 transferred to that line number unconditionally in ON GOTO statements or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3728 as a subroutine in ON GOSUB statements.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3729 These statements are similar to CASE statements in other languages.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3730 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3731 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3732 The expression must evaluate to a positive INTEGER-type result
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3733 having a value between 1 and n, n being the amount of line numbers in the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3734 list. If the result has any other result, no line number is selected
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3735 and the next sequential statement is executed.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3736 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3737 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3738 Example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3739
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3740 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3741 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3742 (* spell out the digits 0 to 9 *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3743 DIM digit:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3744 A$="one digit only, please"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3745 INPUT "type in a digit"; digit
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3746 ON digit+1 GOSUB 10,11,12,13,14,15,16,17,18,19
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3747 PRINT A$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3748 STOP
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3749
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3750 (* names of digits *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3751 10 A$ := "ZERO"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3752 RETURN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3753 11 A$ := "ONE"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3754 RETURN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3755 12 A$ := "TWO"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3756 RETURN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3757 13 A$ := "THREE"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3758 RETURN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3759 14 A$ := "FOUR"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3760 RETURN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3761 15 A$ := "FIVE"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3762 RETURN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3763 16 A$ := "SIX"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3764 RETURN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3765 17 A$ := "SEVEN"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3766 RETURN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3767 18 A$ := "EIGHT"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3768 RETURN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3769 19 A$ := "NINE"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3770 RETURN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3771 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3772 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3773 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3774 <sect2><title>ON ERROR GOTO Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3775 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3776 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3777 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3778 <command>ON ERROR [ GOTO &lt;line #> ]</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3779 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3780 This statement sets a "trap" that transfers control to the line
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3781 number given when a non-fatal run-time error occurs. If no ON ERROR GOTO has
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3782 been executed in a procedure before an error occurs, the procedure will stop
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3783 and enter DEBUG mode. The error trap can be turned of by executing ON
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3784 ERROR without a GOTO.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3785 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3786 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3787 This statement is often used in conjunction with the ERR function,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3788 which returns the specific error code, and the ERROR statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3789 which artificially generates "errors". Note: the ERR function
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3790 automatically resets to zero any time it is called.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3791 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3792 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3793 Example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3794 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3795 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3796 (* List a file *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3797
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3798 DIM path,errnum: INTEGER, name: STRING[45], line: STRING[80]
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3799 ON ERROR GOTO 10
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3800 INPUT "File name? "; name
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3801 OPEN #path,name:READ
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3802 LOOP
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3803 READ #path, line
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3804 PRINT line
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3805 ENDLOOP
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3806
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3807 10 errnum=ERR
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3808 IF errnum = 211 THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3809 (* end-of-file *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3810 PRINT "Listing complete."
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3811 CLOSE #path
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3812 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3813 ELSE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3814 (* other errors *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3815 PRINT "Error number "; errnum
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3816 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3817 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3818 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3819 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3820 </para></sect2></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3821 <sect1><title>Execution Statements</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3822 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3823 Execution statements run procedures, stop execution of procedures, create
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3824 shells, or affect the current execution of the procedure.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3825 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3826 <sect2><title>Run Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3827 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3828 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3829 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3830 <command>RUN &lt;proc name> [ ( &lt;param> {,&lt;param>} ) ]</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
3831 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3832 <command>RUN &lt;string var> [ ( &lt;param> {,&lt;param>} ) ]</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3833 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3834 This statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3835 calls a procedure by name; when that procedure ends, control will pass
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3836 to the next statement after the RUN. It is most often used to call a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3837 procedure inside the workspace, but it can also be used to call a previously
1015
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
3838 compiled (by the PACK command) procedure or a &CPU; machine language
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3839 procedure outside the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3840 workspace. The name can be optionally taken from a string variable.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3841 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3842 <sect2><title>Parameter Passing</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3843 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3844 The RUN statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3845 can include a list of parameters enclosed in parentheses to be passed to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3846 the called procedure. The called procedure must have PARAM statements
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3847 of the same size and order to match the parameters passed to it by the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3848 calling procedure.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3849 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3850 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3851 The parameters can be variables, constants, or the names of entire arrays or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3852 data structures. They can be of any type, (EXCEPT variable of type BYTE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3853 but BYTE arrays are O.K.).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3854 If a parameter is a constant or expression, it is passed "by value", i.e.,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3855 it is evaluated and placed in a temporary storage
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3856 location, and the address of the temporary storage is passed to the called
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3857 procedure. Parameters passed by value can be changed by the receiving
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3858 procedure, but the changes are not reflected in the calling procedure.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3859 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3860 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3861 If the parameter is the name of a variable, array, or data structure, it is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3862 passed by "reference", i.e., the address of that storage
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3863 is sent to the called procedure and thus the value in that storage may be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3864 changed by the receiving procedure. These changes are reflected in the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3865 calling procedure.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3866 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3867 <sect2><title>Calling External Procedures</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3868 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3869 If the procedure named by RUN can't be found in the workspace, &b09;
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3870 will check to see if it was loaded by OS-9 outside the workspace. If it isn't
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3871 found there, &b09; will try to find a disk file having the same name in the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3872 current execution directory, load it, and run it.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3873 In either case, &b09; checks to see if the called procedure is a &b09;
1015
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
3874 I-code module or a &CPU; machine language module, and executes it
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
3875 accordingly. If it is a &CPU; machine language module, &b09; executes a
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
3876 JSR instruction to its entry point and the module is executed as &CPU;
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3877 native code. The machine language routine can return to the original
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3878 calling procedure by executing an RTS instruction. The diagram on the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3879 next page shows what the stack frame passed to machine-language
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3880 subroutines looks like.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3881 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3882 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3883 After an external procedure has been called but is no longer needed, the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3884 KILL statement should be used to get rid of it so its memory space can be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3885 used for other purposes.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3886 <figure>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3887 <title>Stack Frame Passed to Machine Language Procedures</title>
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
3888 <screen>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3889 +----------------------+ ^
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3890 | | |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3891 higher addresses
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3892
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3893 | more parameters |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3894
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3895 | |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3896 +----------------------+ ---
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3897 | | |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3898 | size of 1st param | |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3899 + - - - - - - - + 4 bytes
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3900 | addr of 1st param | |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3901 | | |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3902 +----------------------+ ---
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3903 | | |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3904 | parameter count | 2 bytes
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3905 | | |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3906 +----------------------+ ---
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3907 | | |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3908 | return address | 2 bytes
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3909 | | |
1015
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
3910 +----------------------+ --- &lt;- &CPU; Stack Pointer
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3911 Register value
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
3912 </screen>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3913 </figure>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3914 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3915 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3916 Machine language modules return error status by setting the "C"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3917 bit of the MPU condition codes register, and by setting the B
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3918 register to the appropiate error code. For an example of a machine
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
3919 language subroutine ("INKEY"), See <xref linkend="sample-programs"/>.
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3920 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3921 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3922 Example of use of the RUN statement:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3923
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3924 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3925 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3926 PROCEDURE trig_table
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3927 num1 := 0 \ num2 := 0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3928 REPEAT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3929 RUN display(num1,SIN(num1))
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3930 RUN display(num2,COS(num2))
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3931 PRINT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3932 UNTIL num1 > 1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3933 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3934
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3935 PROCEDURE display
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3936 PARAM passed,funcval
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3937 PRINT passed;":";funcval,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3938 passed := passed + 0.1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3939 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3940 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3941 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3942
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3943 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3944 <sect2><title>KILL Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3945 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3946 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3947 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3948 <command>KILL &lt;str expr></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3949 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3950
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3951 This statement is used to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3952 "unlink" an external procedure, possibly returning system memory,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3953 and remove it from &b09;'s procedure directory. If the procedure is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3954 inside the workspace, nothing happens and no error is generated. KILL can
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3955 be used with auto-loading PACKed procedures as an alternative to CHAIN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3956 when program overlay is desired.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3957 <warning>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3958 <orderedlist numeration="arabic">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3959 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3960 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3961 It can be fatal to OS-9 to KILL a procedure that is still "active".
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3962 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3963 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3964 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3965 <para>
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
3966 When KILL is used together with a RUN statement, the RUN statement <emphasis>must</emphasis> use the
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3967 same string variable which contains the name of the procedure.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3968 See the first example below:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3969 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3970 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3971 </orderedlist>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3972 </warning>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3973 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3974 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3975 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3976 LET procname$="average"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3977 RUN procname$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3978 KILL procname$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3979
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3980 INPUT "Which test do you want to run? ",test$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3981 RUN test$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3982 KILL test$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3983 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3984 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3985 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3986 <sect2><title>CHAIN Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3987 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3988 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3989 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3990 <command>CHAIN &lt;str expr></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3991 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3992 The CHAIN statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3993 performs an OS-9 "chain" operation on the SHELL, passing the specified
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3994 string as an argument. This causes &b09; to be exited, unlinked,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3995 and its memory returned to OS-9. The string should evaluate to the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3996 name of an executable module (such as &b09;), passing parameters if
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3997 appropriate.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3998 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
3999 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4000 CHAIN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4001 can begin execution of any module, not just &b09;. It executes the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4002 module indirectly through the Shell in order to take advantage of Shell's
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4003 parameter processing. This has the side-effect of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4004 leaving an extra "incarnation" of the Shell active. Programs that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4005 repeatedly chain to each other eventually find all of memory filled with
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4006 waiting shells. This can be prevented by using the "ex" option of the Shell.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4007 Consult the OS-9 User's Guide for more details on the capabilities of the shell.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4008 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4009 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4010 Files that are open when a CHAIN occurs are not closed.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4011 However, the OS-9 Fork call will only pass the standard I/O paths
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4012 (0,1,2) to a child process. Therefore, if it is necesary to pass
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4013 an open path to another program segment, the "ex" option of Shell
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4014 must be used.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4015 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4016 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4017 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4018
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4019 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4020 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4021 CHAIN "ex &b09; menu"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4022
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4023 CHAIN "&b09; #10k sort (""datafile"",""tempfile"")"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4024
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4025 CHAIN "DIR /D0"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4026
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4027 CHAIN "Dir; Echo *** Copying Directory ***; ex basic09 copydir"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4028 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4029 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4030
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4031 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4032 <sect2><title>SHELL Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4033 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4034 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4035 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4036 <command>SHELL &lt;str expr></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4037 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4038 This statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4039 allows &b09; programs to run any OS-9 command or program.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4040 This gives access to virtually any OS-9 function including
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4041 multiprogramming, utility commands, terminal, and I/O control,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4042 and more.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4043 Consult the "OS-9 User's Guide" for a detailed
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4044 discussion of OS-9 standard commands.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4045 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4046 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4047 The SHELL statement requests OS-9 to create a new process, initially
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4048 executing the "shell", which is the OS-9 command interpreter. The
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4049 shell can then call any program in the system (subject to the normal
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4050 security functions). The string expression is evaluated and passed to the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4051 shell to be executed as a command line. (just as if it had
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4052 been typed in). If the string is null, &b09; is temporarily
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4053 suspended and the shell process displays prompts
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4054 and accepts commands in its normal manner. When the shell process
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4055 terminates, &b09; becomes active again and resumes execution at the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4056 statement following the SHELL statement.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4057 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4058 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4059 Here are a few examples of using the shell from &b09;:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4060
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4061 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4062 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4063 SHELL "copy file1 file2" sequential execution
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4064
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4065 SHELL "copy file1 file2&amp;" concurrent execution
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4066
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4067 SHELL "edit document" calling text editor
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4068
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4069 SHELL "asm source o=obj ! spool &amp;" concurrent assembly
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4070
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4071 N:=5
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4072 SHELL "kill "+STR$(N)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4073
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4074 file$ := "/d1/batch_jobs" concurrent execution of a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4075 SHELL file$ + " -p >/p &amp;" batch procedure file
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4076 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4077 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4078 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4079 <sect2><title>END Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4080 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4081 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4082 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4083 <command>END [&lt;output list>]</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4084 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4085 This statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4086 ends execution of the procedure and returns to the calling procedure,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4087 or to &b09; command mode if it was the highest level procedure. If an
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4088 output list is given, it also works the same as the PRINT statement.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4089 END is an executable statement and can be used several times in the same
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4090 procedure. END is optional: it is not required at the "bottom" of a procedure.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4091 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4092 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4093 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4094
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4095 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4096 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4097 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4098
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4099 END "I have finished execution"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4100 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4101 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4102 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4103 <sect2><title>Stop Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4104 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4105 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4106 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4107 <command>STOP [&lt;output list>]</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4108 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4109 This statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4110 immediately terminates execution of all procedures and returns to the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4111 command mode. If an output list is given it also works like a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4112 PRINT statement.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4113 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4114 <sect2><title>BYE Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4115 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4116 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4117 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4118 <command>BYE</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4119 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4120
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4121 This statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4122 ends execution of the procedure and terminates &b09;. Any open files
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4123 are closed, and any unsaved procedures or data in the workspace will be lost.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4124 This command is especially useful for creating PACKed programs and/or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4125 programs to be called from OS-9 procedure files.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4126 <warning>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4127 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4128 This command causes &b09; to abort.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4129 It should only be used if the program has been saved before it is tested!
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4130 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4131 </warning>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4132 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4133 <sect2><title>ERROR Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4134 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4135 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4136 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4137 <command>ERROR(&lt;integer expr>)</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4138 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4139 This statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4140 generates an error having the error code specified by the result of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4141 evaluation of the expression. ERROR is often used for testing error routines.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4142 For details on error handling see the ON ERROR GOTO statement description.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4143 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4144 <sect2><title>PAUSE Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4145 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4146 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4147 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4148 <command>PAUSE [&lt;output list>]</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4149 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4150 PAUSE suspends execution of the procedure and causes &b09; to enter
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4151 Debug Mode. If an output list is given it also works like a PRINT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4152 statement.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4153 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4154 &lt;output> BREAK IN PROCEDURE &lt;procedure name>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4155 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4156 The Debug Mode "CONT" command can be used to resume procedure
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4157 execution at the following statement.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4158 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4159 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4160 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4161
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4162 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4163 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4164 PAUSE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4165
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4166 PAUSE "now outside main loop"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4167 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4168 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4169
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4170 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4171 <sect2><title>CHD and CHX Statements</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4172 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4173 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4174 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4175 <command>CHD &lt;str expr></command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4176 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4177 <command>CHX &lt;str expr></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4178 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4179 These statements
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4180 change the current default Data or Execution directory,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4181 respectively. The string must specify the pathlist of a file
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4182 which has the DIR attribute.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4183 For more information on the OS-9 directory structure, consult
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4184 the OS-9 User's Guide.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4185 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4186 <sect2><title>DEG and RAD Statements</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4187 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4188 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4189 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4190 <command>DEG</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4191 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4192 <command>RAD</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4193 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4194 These statements
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4195 set the procedure's state flag to assume angles stated in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4196 degrees or radians in SIN, COS, TAN, ACS, ASN, and ATN functions.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4197 This flag applies only to the currently active procedure. The default state
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4198 is radians.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4199 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4200 <sect2><title>BASE 0 and BASE 1 Statements</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4201 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4202 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4203 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4204 <command>BASE 0</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4205 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4206 <command>BASE 1</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4207 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4208
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4209 These statements indicate whether a particular procedure's lowest array
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4210 or data structure index (subscript) is zero or one. The
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4211 default is one. These statements do not affect the string operations
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4212 (e.g., MID$, RIGHT$, OR LEFT$) where the beginning character of a string
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4213 is always index one.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4214 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4215 <sect2><title>TRON and TROFF Statements</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4216 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4217 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4218 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4219 <command>TRON</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4220 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4221 <command>TROFF</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4222 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4223 These statements turn the trace mode on or off, and are useful for debugging.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4224 When trace mode is turned on, each statement is decompiled and printed
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4225 before execution. Also, the result of each expression evaluation is printed as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4226 it occurs.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4227 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4228 <sect2><title>Comment Statements</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4229 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4230 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4231 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4232 <command>REM &lt;chars></command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4233 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4234 <command>(* &lt;chars> [ *) ]</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4235 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4236 These statements are used to put comments in programs. The second form
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4237 of the statement is for compatibility with PASCAL programs. Comments
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4238 are retained in the I-code but are removed by the PACK compile command.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4239 The "!" character can be typed in place of the keyword
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4240 REM when editing programs. The compiler trims away extra spaces
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4241 following REM to conserve memory space.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4242 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4243 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4244 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4245 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4246 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4247 REM this is a comment
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4248
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4249 (* This is also a comment *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4250
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4251 (* This is another kind of comment
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4252 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4253 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4254 </para></sect2></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4255 <sect1><title>Declarative Statements</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4256 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4257 The DIM, PARAM, and TYPE statements are called
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4258 <emphasis>declarative statements</emphasis> because
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4259 they are used to define and/or declare variables, arrays, and complex data
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4260 structures. The DIM and PARAM statements
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4261 are almost identical, the difference being that DIM are used to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4262 declare storage used exclusively within the procedure, and the PARAM statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4263 is used to declare variables <emphasis>received</emphasis> from another calling procedure.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4264 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4265 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4266 When do you need to use the DIM statement?
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4267 You don't need to for simple variables of type REAL because
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4268 this is the default format for undeclared variables. You also don't need to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4269 for 32-character STRING type variables (any name ending with a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4270 "$" is automatically assigned this type). Even though you don't have to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4271 declare variables in these two cases, you may want to anyway to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4272 improve your program's internal documentation. Those
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4273 things you <emphasis>must</emphasis> declare are:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4274 <orderedlist numeration="arabic">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4275 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4276 <para>Any simple variables of type BYTE, INTEGER, or BOOLEAN.</para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4277 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4278 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4279 <para>Any simple STRING variables shorter or longer than 32 characters.</para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4280 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4281 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4282 <para>Arrays of any type.</para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4283 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4284 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4285 <para>Complex data structures of any type.</para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4286 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4287 </orderedlist>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4288 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4289 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4290 The TYPE statement does not really create variable storage. Its purpose is to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4291 describe a <emphasis>new</emphasis> data structure type that can be used
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4292 in DIM or PARAM statements in addition to the five atomic data
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4293 types built-in to &b09;.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4294 Therefore, TYPE is only used in programs that use complex data structures.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4295 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4296 <sect2><title>DIM Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4297 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4298 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4299 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4300 <command>DIM &lt;decl seq> {; &lt;decl seq>}</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4301 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4302 <command>&lt;decl seq> := &lt;decl> {, &lt;decl>} : &lt;type>}</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4303 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4304 <command>&lt;decl> := &lt;name> [, &lt;subscript> ]</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4305 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4306 <command>&lt;subscr> := ( &lt;const> [,&lt;const> [,&lt;const>]] )</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4307 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4308 <command>&lt;type> := BYTE | INTEGER | REAL | BOOLEAN |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4309 STRING | STRING &lt;max len> | &lt;user defined type></command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4310 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4311 <command>&lt;user def> := user defined by TYPE statement</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4312 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4313 The DIM statement is used to declare simple variables,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4314 arrays, or complex data structures of the five
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4315 atomic types or any user-defined type. During compilation, &b09; assigns
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4316 storage required for all variables declared in DIM statements.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4317 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4318 <sect3><title>Declaring Simple Variables</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4319 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4320 Simple variables are declared by using the variable name in a DIM
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4321 statement without a subscript. If variables are not explicitly declared, they
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4322 are automatically assumed to be REAL, or tpe STRING[32]
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4323 if the variable name ends with a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4324 "$" character. Therefore all simple variables of other types
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4325 must be explicitly declared. For example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4326
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4327 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4328 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4329 DIM logical:BOOLEAN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4330 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4331 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4332
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4333 Several variables can be declared in sequence with a :&lt;type>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4334 following a group of the same type:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4335 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4336 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4337 DIM a,b,c: STRING
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4338 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4339 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4340 In addition, several different types can be declared in a single DIM
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4341 statement by using a semicolon ";" to separate different types:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4342
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4343 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4344 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4345 DIM a,b,c:INTEGER; n,m:decimal; x,y,z:BOOLEAN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4346 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4347 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4348
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4349 In this example a, b, and c are type INTEGER, n and m are type "decimal" (a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4350 user-defined type), and x, y, and z are type BOOLEAN.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4351 String variables are declared the same way except an optional
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4352 maximum string length can be specified. If a length is not explicitly
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4353 given, 32 characters are assumed:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4354
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4355 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4356 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4357 DIM name:STRING[40]; address,city:STRING; zip:REAL
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4358 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4359 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4360
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4361 In this case, "name" is a string variable of 40 characters maximum, "address"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4362 and "city" are string variables of 32 characters each, and "zip" is a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4363 real variable.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4364 </para></sect3>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4365 <sect3><title>Array Declarations</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4366 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4367 Arrays can have one, two, or three dimensions. The DIM statement format
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4368 (including type grouping)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4369 is the same as for simple variables except each name is followed by
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4370 subscript(s) to indicate its size. The maximum subscript size is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4371 32767. Simple variable and array declarations can be mixed
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4372 in the same DIM statement:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4373
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4374 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4375 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4376 DIM a(10),b(20,30),c:INTEGER; x(5,5,5):STRING[12]
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4377 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4378 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4379
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4380 In the example above, "a" is an array of 10 integers, "b" is a 20 by 30
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4381 matrix of integers, "c" is a simple integer variable, and "x" is a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4382 three-dimensional array of 12-character strings.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4383 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4384 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4385 Arrays can be any atomic or user-defined type. By declaring arrays of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4386 user-defined types, structures of arbitrary complexity and shape can
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4387 be generated.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4388 Here's an example declaration that generates a doubly-linked list
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4389 of character strings. Each element of the array consists of the string
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4390 containing the data and two integer "pointers".
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4391
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4392 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4393 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4394 TYPE link_pointers = fwd,back: INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4395 TYPE element = data: STRING[64]; ptr: link_pointers
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4396 DIM list(100): element
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4397
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4398 (* make a circular list *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4399 BASE0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4400 FOR index := 0 TO 99
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4401 list(index).data := "secret message " + STR$(index)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4402 list(index).ptr.fwd := index+1
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4403 list(index).ptr.back := index-1
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4404 NEXT index
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4405 (* fix the ends *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4406 list(0).ptr.back := 99
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4407 list(99).ptr.fwd := 0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4408
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4409 (* Print the list *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4410 index=0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4411 REPEAT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4412 PRINT list(index).data
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4413 index := list(index).ptr.fwd
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4414 UNTIL index=0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4415 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4416 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4417 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4418 </para></sect3></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4419 <sect2><title>PARAM Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4420 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4421 Syntax: Same as DIM statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4422 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4423 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4424 PARAM is identical to the DIM statement, but it does not create
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4425 variable storage. Instead, it describes what parameters the "called" procedure
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4426 expects to receive from the "calling" procedure.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4427 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4428 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4429 The programmer must insure that the total size of each
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4430 parameter (as evaluated by the RUN statement in the calling procedure)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4431 conforms to the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4432 amount of storage expected for each parameter in the called procedure as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4433 specified by the PARAM statement.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4434 &b09; checks the size of each parameter (to prevent
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4435 accidental access to storage other than the parameter)
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
4436 but <emphasis>does not check type</emphasis>. However, in most cases the programmer
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4437 should ensure that the parameters evaluated in the RUN statement and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4438 sent to the called procedure agree exactly with the PARAM statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4439 specification with respect to: the number of parameters, their order, size,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4440 shape, and type.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4441 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4442 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4443 Because type-checking is not performed, if you really know what you are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4444 doing you can make the parameter passing operation perform useful but
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4445 normally illegal type conversions of identically-sized data structures. For
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4446 example, passing a string of 80 characters to a procedure expecting a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4447 BYTE array having 80 elements assigns the numeric value of each
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4448 character in the string to the corresponding element of the byte array.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4449 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4450 <sect2><title>TYPE Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4451 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4452 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4453
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4454 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4455 <command>TYPE &lt;type decl> {; &lt;type decl>}</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4456 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4457 <command>&lt;type decl> := &lt;field name> . &lt;decl> : &lt;type>}</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4458 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4459 <command>&lt;decl> := &lt;name> [, &lt;subscript> ]</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4460 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4461 <command>&lt;subscript> := ( &lt;const> [,&lt;const> [,&lt;const>]] )</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4462 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4463 <command>&lt;type> := BYTE | INTEGER | REAL | BOOLEAN |
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4464 STRING | STRING [&lt;max len>] | &lt;user defined></command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4465 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4466 <command>&lt;user defined> := user defined by TYPE statement</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4467 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4468
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4469 This statement is used to define new data types. New data types are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4470 defined as a "vector" (a one-dimensional array) of previously
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4471 defined types. This structure differs from an array in that the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4472 various elements may be of different types, and the elements are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4473 accessed by field name instead of an array index.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4474 Here's an example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4475 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4476 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4477 TYPE cust_recd := name,address(3):STRING; balance
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4478 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4479 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4480
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4481 This example creates a new data type called "cust_recd" which has three
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4482 named fields: a field called "name" which is a string, a field
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4483 called "address" which is a vector of three strings; and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4484 a field called "balance" which is a (default) REAL value
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4485 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4486 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4487 The TYPE statement can include previously-defined types so very
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4488 complex non-rectangular data structures can be created such as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4489 lists, trees, etc. This statement does not create any variable storage
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4490 itself; the storage is created when the newly-defined type is used in a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4491 DIM statement.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4492 The example show below creates an array having 250 elements of type
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4493 "cust_recd" that was defined above:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4494
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4495 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4496 DIM customer_file(250):cust_recd
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4497 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4498 To access elements of the array in assignment statements, the field name
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4499 is used as well as the index:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4500 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4501 name$ = customer_file(35).name
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4502 customer_file(N+1).address(3) = "New York, NY"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4503 customer_file(X).balance= 125.98
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4504 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4505
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4506 The complex structure allows creation of data types appropriate to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4507 the job at hand by providing more natural organization and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4508 association of data. Additionally, the position of the desired
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4509 element is known and defined at compilation-time and need not be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4510 calculated at run time, unlike arrays, and can therefore be accessed
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4511 faster than arrays.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4512 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4513 </sect2></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4514 </chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4515
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4516
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4517 <chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4518 <title>Input and Output Operations</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4519
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4520
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4521 <sect1><title>Files and Unified Input/Output</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4522 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4523 A file is a logical concept for a sequence of data which is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4524 saved for convenience in use and storage. File data may be pure
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4525 binary data, textual data (ASCII characters), or any other useful
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4526 information. Hardware input/output ("I/O") devices used by OS-9
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4527 also work like files, so you can generally use any I/O facility
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4528 regardless of whether you are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4529 working with disk files or I/O devices such as printers. This single
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4530 interface standard for any device and simple communication facilities allow
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4531 any device to be used with any other device. This concept is known as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4532 "unified I/O". Note that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4533 unified I/O can benefit routine programming. For example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4534 file operations can be debugged by communicating with a terminal or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4535 printer instead of a storage device, and procedures which normally
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4536 communicate with a terminal can be tested with data coming from and sent
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4537 to a storage device.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4538 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4539 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4540 &b09; normally works with two types of files:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4541 sequential files and random-access files.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4542 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4543 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4544 A sequential file sends or receives (WRITE/READ) textual data only in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4545 order. It is not generally possible to start over at the beginning of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4546 a sequential file once a number of bytes have been accessed (many I/O
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4547 devices such as printers are necessarily sequential). A sequential
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4548 file contains only valid ASCII characters; the READ and WRITE commands
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4549 perform format conversion similar to that done automatically in INPUT and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4550 PRINT commands. A sequential file contains record-delimiter characters
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4551 (carriage return) which separate the data created by different WRITE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4552 operations. Each WRITE command will send a complete sequential-file
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4553 record, which is an arbitrary number of characters terminated by a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4554 carriage return. Each READ reads all characters up to the next carriage
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4555 return.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4556 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4557 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4558 A random-access file sends and receives (PUT/GET) data in binary form
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4559 exactly as it is internally represented in &b09;. This minimizes both the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4560 time involved in converting the data to and from ASCII representation,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4561 as well as reducing the file space required to store the data. It is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4562 possible to PUT and GET individual bytes, or a substructure of many
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4563 bytes (in a complex structure). The GET structure statement merely
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4564 recovers the number of bytes associated with that type of structure.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4565 It is possible to move to a particular byte in a random-access file
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4566 (using SEEK) and to begin to PUT or GET sequentially from that point (in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4567 general, "SEEK #path,0" is equivalent to the REWIND used in some forms
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4568 of BASIC). Since the random-access file contains no record-separators
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4569 to indicate the size of particular elements of the file, the programmer
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4570 should use the SIZE function to determine the size of a single element,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4571 then use SEEK to move to the desired element within the file.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4572 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4573 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4574 A new file is made on a storage device by executing CREATE. Once a file
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4575 exists, the OPEN command is used to notify the operating system to set up
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4576 a channel to the desired device and return that path number to the &b09;
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4577 program. This channel number is then used in file-access operations (e.g.,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4578 READ, WRITE, GET, PUT, SEEK, etc.). When the programmer is finished with
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4579 the file, it should be terminated by CLOSE to assure that the file system
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4580 has updated all data back onto magnetic media.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4581 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4582 <sect1><title>I/O Paths</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4583 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4584 A "path" is a description of a "channel" through which data flows from a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4585 given program outward or from some device inward. In order for data to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4586 flow to or from a device, there must be an associated OS-9 device driver
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4587 &mdash; see the OS9 Users Manual. When a path is created, OS-9 returns
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4588 a unique number to identify the path in subsequent file operations. This
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4589 "path number" is used by the I/O statements to specify the file to be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4590 used. Three path numbers have special meanings because they are "standard
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4591 I/O paths" representing &b09;'s interactive input/output (your terminal).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4592 These are automatically "opened" for you and should not be closed except
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4593 in very special circumstances. The standard I/O path numbers are:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4594 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4595 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4596 <colspec colwidth="0.3in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4597 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4598 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4599 <entry>0</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4600 <entry>Standard Input (Keyboard)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4601 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4602 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4603 <entry>1</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4604 <entry>Standard Output (Display)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4605 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4606 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4607 <entry>2</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4608 <entry>Standard Error/Status (Display)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4609 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4610 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4611 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4612 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4613 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4614 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4615 The table below is a summary of the I/O statements within &b09; and their
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4616 general usage. This reflects typical usage; most statements can be used
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4617 with any I/O device or file. Sometimes certain statements are used in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4618 unusual ways by advanced programmers to achieve certain special effects.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4619 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4620 <tgroup cols="3">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4621 <colspec colwidth="0.8in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4622 <thead>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4623 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4624 <entry>Statement</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4625 <entry>Generally Used With</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4626 <entry>Data Format (File Type)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4627 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4628 </thead>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4629 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4630 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4631 <entry>INPUT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4632 <entry>Keyboard (interactive input)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4633 <entry>Text (Sequential)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4634 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4635 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4636 <entry>PRINT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4637 <entry>Terminals, Printers</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4638 <entry>Text (Sequential)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4639 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4640 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4641 <entry>OPEN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4642 <entry>Disk Files and I/O Devices</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4643 <entry>Any</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4644 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4645 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4646 <entry>CREATE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4647 <entry>Disk Files and I/O Devices</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4648 <entry>Any</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4649 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4650 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4651 <entry>CLOSE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4652 <entry>Disk Files and I/O Devices</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4653 <entry>Any</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4654 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4655 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4656 <entry>DELETE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4657 <entry>Disk Files</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4658 <entry>Any</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4659 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4660 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4661 <entry>SEEK</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4662 <entry>Disk Files</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4663 <entry>Binary (Random)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4664 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4665 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4666 <entry>READ</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4667 <entry>Disk Files</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4668 <entry>Text (Sequential)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4669 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4670 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4671 <entry>WRITE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4672 <entry>Disk Files</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4673 <entry>Text (Sequential)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4674 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4675 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4676 <entry>GET</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4677 <entry>Disk Files and I/O Devices</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4678 <entry>Binary (Random)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4679 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4680 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4681 <entry>PUT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4682 <entry>Disk Files and I/O Devices</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4683 <entry>Binary (Random)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4684 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4685 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4686 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4687 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4688
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4689 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4690 <sect2><title>INPUT Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4691 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4692 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4693 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4694 <command>INPUT [#&lt;int expr>,] ["&lt;prompt>",] &lt;input list></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4695 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4696 This statement accepts input during the execution of a program. The
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4697 input is normally read from the standard input device (terminal)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4698 unless an optional path number is given. When the INPUT statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4699 is encountered, program execution is suspended and a "?" prompt is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4700 displayed. If the optional prompt string is given, it is displayed
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4701 instead of the normal "?" prompt. This means that the INPUT statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4702 is really <emphasis>both</emphasis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4703 an input and outout statement. Therefore, if a path other than the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4704 default standard input path is used, the path should be open in UPDATE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4705 mode. This makes INPUT dangerous if used on disk files, unless you like
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4706 prompts in your data (use READ).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4707 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4708 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4709 The data entered is assigned in order to the variable names in the order
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4710 they appear in the input list. The variables can be of any atomic type,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4711 and the input data must be of the same (or compatible) type. The line
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4712 is terminated by a carriage return. There must be at least as many input
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4713 items given as variables in the input list. The length of the input line
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4714 cannot exceed 256 characters.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4715 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4716 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4717 If any error occurs (type mismatch, insufficient amount of data, etc.),
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4718 the message:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4719 <screen>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4720 **INPUT ERROR - RETYPE**
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4721 </screen>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4722 is displayed, followed by a new prompt. The entire input line must
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4723 then be reentered.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4724 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4725 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4726 The INPUT statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4727 uses OS-9's line input function (READLN) which performs line
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4728 editing such as backspace, delete, end-of-file, etc. To perform input
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4729 WITHOUT editing (i.e., to read pure binary data), use the GET statement.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4730 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4731 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4732 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4733
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4734 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4735 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4736 INPUT number,name$,location
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4737
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4738 INPUT #14, "What is your selection", choice
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4739
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4740 INPUT "What's your name? ",name$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4741 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4742 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4743 Here's how to read a single character (without editing) from the terminal
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4744 (path #0):
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4745 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4746 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4747 DIM char:STRING[1]
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4748 GET #0,char
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4749 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4750 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4751 For a function to test if data is available from the keyboard without
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4752 "hanging" the program, see the "INKEY" assembly language program included
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
4753 in <xref linkend="sample-programs"/>.
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4754 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4755 <sect2><title>PRINT Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4756 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4757 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4758 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4759 <command>PRINT &lt;output list></command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4760 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4761 <command>PRINT #&lt;int expr>, &lt;output list></command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4762 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4763 <command>PRINT USING &lt;str expr>, &lt;output list></command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4764 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4765 <command>PRINT #&lt;int expr>, USING &lt;str expr>, &lt;output list></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4766 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4767 This statement outputs the values of the items given in the output list
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4768 to the standard output device (path #1, the terminal) unless another
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4769 path number is specified.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4770 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4771 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4772 The output list consists of one or more items separated by commas or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4773 semicolon characters. Each item can be a constant, variable, or expression
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4774 of any atomic type. The PRINT statement evaluates each item and converts
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4775 the result to corresponding ASCII characters which are then displayed.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4776 If the separator character following the item is a semicolon, the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4777 next item will be displayed without any spacing in between. If a comma
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4778 is used, spaces are output so the next item starts at the next "tab"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4779 zone. The tab zones are 16 characters long starting at the beginning of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4780 the line. If the line is terminated by a semicolon, the usual carriage
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4781 return following the output line is inhibited.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4782 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4783 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4784 The "TAB(expr)" function can be used as an item in the output list, which
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4785 outputs the correct number of spaces to cause the next item to start
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4786 in the print column specified by the result of the expression. If the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4787 output line is already past the desired tab position, the TAB is ignored.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4788 A related function, "POS", can be used in the program to determine
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4789 the output position at any given time. The output columns are numbered
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4790 from one to a maximum of 255. The size of &b09;'s output buffer varies
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4791 according to stack size at the moment. A prectical values is at least
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4792 512 characters.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4793 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4794 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4795 The PRINT USING form of this statement is described at the end of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4796 this chapter.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4797 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4798 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4799 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4800
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4801 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4802 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4803 PRINT value,temp+(n/2.5),location$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4804
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4805 PRINT #printer_path,"The result is "; n
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4806
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4807 PRINT "what is " + name$ + "'s age? ";
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4808
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4809 PRINT "index: ";i;TAB(25);"value: ";value
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4810
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4811 PRINT USING "R10.2,X2,R5.3",x,y
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4812
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4813 PRINT #outpath USING fmt$,count,value
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4814
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4815 (* print an 80-character line of all dashes *)
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4816 REPEAT
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4817 PRINT "-";
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4818 UNTIL POS >= 80
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4819 PRINT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4820 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4821 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4822
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4823 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4824 <sect2><title>OPEN Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4825 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4826 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4827 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4828 <command>OPEN #&lt;int var>,"&lt;str expr>" [ : &lt;access mode> ]</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4829 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4830 <command>&lt;access mode> := &lt;mode> ! &lt;mode> + &lt;access mode></command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4831 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4832 <command>&lt;mode> := READ ! WRITE ! UPDATE ! EXEC ! DIR</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4833 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4834 This statement issues a request to OS-9 to open an I/O path to an existing
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4835 file or device. The STRING expression is evaluated and passed to OS-9 as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4836 the descriptive pathlist.The variable name specified must be DIMensioned
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4837 as type INTEGER or BYTE and is used "receive" the "path number" assigned
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4838 to the path by OS-9. This path number is used to reference the specific
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4839 file/device in subsequent input/output statements.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4840 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4841 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4842 The OPEN statement may also specify the path's desired "access mode" which
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4843 can be READ, WRITE, UPDATE, EXEC, or DIR. This defines which direction I/O
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4844 transfers will occur. If no access mode is specified, UPDATE is assumed
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4845 and both reading and writing are permitted. The DIR mode allows OS-9
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
4846 directory type-files to be accessed but should <emphasis>not</emphasis> be used in combination
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4847 with WRITE or UPDATE modes. The EXEC mode causes the current execution
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4848 directory to be used instead of the current data directory. Refer to the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4849 "OS-9 User's Guide" for more information on how files access modes.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4850 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4851 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4852 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4853
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4854 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4855 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4856 DIM printer_path:BYTE; name:STRING[24]
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4857 name="/p"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4858 OPEN #printer_path,name:WRITE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4859 PRINT #printer_path,"Mary had a little lamb"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4860 CLOSE #printer_path
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4861
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4862 DIM inpath:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4863 dev$="/winchester/"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4864 INPUT name$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4865 OPEN #inpath,dev$+name$:READ
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4866
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4867 OPEN #path:userdir$:READ+DIR
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4868
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4869 OPEN #path,name$:WRITE+EXEC
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4870 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4871 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4872
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4873 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4874 <sect2><title>CREATE Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4875 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4876 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4877 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4878 <command>CREATE #&lt;int var>,"&lt;str expr>" [ : &lt;access mode> ]</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4879 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4880 <command>&lt;access mode> := &lt;mode> ! &lt;mode> + &lt;access mode></command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
4881 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4882 <command>&lt;mode> := WRITE ! UPDATE ! EXEC</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4883 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4884 The CREATE statement is used to create a new file on a multifile mass storage
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4885 device such as disk or tape. If the device is not of multifile type,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4886 this statement works like an "OPEN" statement.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4887 The variable name is used to receive the path number assigned by
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4888 OS-9 and must be of BYTE or INTEGER type. The STRING expression is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4889 evaluated and passed to OS-9 to be used as the descriptive pathlist.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4890 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4891 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4892 The "access mode" defines the direction of subsequent I/O transfers and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4893 should be either WRITE or UPDATE. "UPDATE" mode allows the file to be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4894 either read or written.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4895 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4896 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4897 OS-9 has a single file type that can be accessed both sequentially OR at
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4898 random. Files are byte-addressed, so no explicit "record" length need be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4899 given (see GET and PUT statements). When a new file is created, it has an
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4900 initial length of zero. Files are expanded automatically by PRINT, WRITE,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4901 or PUT statements that write beyond the current "end of file".
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4902 File size may be set explicitly using the OS9 statement.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4903 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4904 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4905 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4906 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4907 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4908 CREATE #trans,"transactions":UPDATE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4909
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4910 CREATE #spool,"/user4/report":WRITE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4911
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4912 CREATE #outpath,name$:UPDATE+EXEC
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4913 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4914 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4915 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4916 <sect2><title>Close Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4917 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4918 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4919 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4920 <command>CLOSE #&lt;int expr> {,#&lt;int expr>}</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4921 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4922 The CLOSE statement notifies OS-9 that one or more I/O paths are no longer
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4923 needed. The paths are specified by their number(s). If the path closed
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4924 used a non-sharable device (such as a printer), the device is released
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4925 and can be assigned to another user. The path must have been previously
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4926 established by means of the OPEN or CREATE statements.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4927 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4928 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4929 Paths #0, #1, and #2 (the standard I/O paths) should never be closed
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4930 unless the user immediately opens a new path to take over the Standard
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4931 Path number.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4932 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4933 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4934 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4935
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4936 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4937 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4938 CLOSE #master,#trans,#new_master
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4939
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4940 CLOSE #5,#6,#9
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4941
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4942 CLOSE #1 \(* closes standard output path *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4943 OPEN #path,"/T1" \(* Permanently redirects Std Output *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4944
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4945 CLOSE #0 \(* closes standard input path *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4946 OPEN #path,"/TERM" \(* Permanently redirects Std Input *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4947 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4948 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4949 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4950 <sect2><title>DELETE Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4951 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4952 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4953 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4954 <command>DELETE &lt;str expr></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4955 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4956 This statement is used to delete a mass storage file. The file's name
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4957 is removed from the directory and all its storage is deallocated, so any
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4958 data on the file is permanently lost. The string expression is evaluated
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4959 and passed to OS-9 as the descriptive pathlist of the file.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4960 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4961 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4962 The user must have write permission for the file to be deleted. See
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4963 the "OS-9 User's Guide" for more information.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4964 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4965 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4966 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4967
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4968 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4969 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4970 DELETE "/D0/old_junk"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4971
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4972 name$="file55"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4973 DELETE name$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4974 DELETE "/D2/"+name$ (deletes file named "/D2/file55")
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4975 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4976 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4977
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4978
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4979 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4980 <sect2><title>SEEK Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4981 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4982 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4983 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4984 <command>SEEK #&lt;int expr num>,&lt;real expr></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4985 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4986 SEEK changes the file pointer address of a mass storage file,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4987 which is the address of the next data byte(s) that are to be read or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4988 written next. Therefore, this statement is essential for random access
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4989 of data on files using the GET and PUT statements.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4990 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4991 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4992 The first expression specifies the path number of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4993 the file and must evaluate to a byte value. The second expression specifies
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4994 the desired file pointer address, and must evaluate to a REAL
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4995 value in the range 0 &lt;= result &lt;= 2,147,483,648. Any fractional
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4996 part of the result is truncated. Of course, the actual maximum file size
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4997 depends on the capacity of the device.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4998 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
4999 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5000 Although SEEK is normally used with random-access files, it can be used
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5001 to "rewind" sequential files. For example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5002
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5003 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5004 SEEK #path,0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5005 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5006 is the same as a "rewind" or "restore" function. This is the only form of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5007 the SEEK statement that is generally useful for files accessed by READ
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5008 and WRITE statements. These statements use variable-length records, so
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5009 it is difficult to know the address of any particular record in the file.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5010 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5011 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5012 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5013
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5014 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5015 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5016 SEEK #fileone,filptr*2
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5017
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5018 SEEK #outfile,208894
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5019
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5020 SEEK #inventory,(part_num - 1) * SIZE(inv_rcd)
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5021 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5022 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5023
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5024 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5025 <sect2><title>WRITE Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5026 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5027 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5028 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5029 <command>WRITE #&lt;int expr>,&lt;output list></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5030 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5031 This statement writes data in ASCII character format on a file/device. The
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5032 first expression specifies the number of a path that was previously
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5033 opened by a OPEN or CREATE statement in WRITE or UPDATE mode.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5034 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5035 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5036 The output list consists of one or more expressions separated by commas.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5037 Each expression can evaluate to any expression type. The result is then
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5038 converted to an ASCII character string and written on the specified path
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5039 beginning at the present file pointer which is updated as data is written.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5040 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5041 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5042 If the output list has more than one item, ASCII null characters ($00)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5043 are written between each output string. The last item is followed by a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5044 carriage return character.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5045 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5046 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5047 Note that this statement creates variable-length ASCII records.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5048 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5049 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5050 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5051
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5052 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5053 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5054 WRITE #outpath,cat,dog,mouse
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5055
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5056 WRITE #xfile,LEFT$(A$,n),count/2
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5057 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5058 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5059 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5060 <sect2><title>READ Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5061 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5062 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5063 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5064 <command>READ #&lt;int expr num>,&lt;input list></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5065 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5066 This statement causes input data in ASCII character format to be read
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5067 from a file or device. The first expression specifies a path number.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5068 The path number which must have been previously opened by an OPEN or CREATE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5069 statement in READ or UPDATE access mode (except the standard input path #0).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5070 Data is read starting at the path's current file pointer address which
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5071 is updated as data is read.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5072 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5073 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5074 This statement calls OS-9 to read a variable length ASCII
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5075 record. Individual data items within the record are converted to &b09;'s
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5076 internal binary format. These results are assigned in order to the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5077 variables given in the input list. The input data must match the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5078 number and type of the variables in the input list.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5079 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5080 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5081 The individual data items in the input record are separated by ASCII
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5082 null characters. Numeric items can also be delimited by commas or space
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5083 characters. The input record is terminated by a carriage return character.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5084 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5085 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5086 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5087
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5088 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5089 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5090 READ #inpath,name$,address$,city$,state$,zip
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5091
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5092 PRINT #1,"height,weight? "
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5093 READ #0,height,weight
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5094 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5095 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5096
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5097 <note>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5098 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5099 READ is also used to read lists of expressions in the program.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5100 See the DATA statement section for details.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5101 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5102 </note>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5103 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5104 <sect2><title>GET/PUT Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5105 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5106 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5107 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5108 <command>GET #&lt;expr>,&lt;struct name></command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5109 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5110 <command>PUT #&lt;expr>,&lt;struct name></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5111 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5112 The GET and PUT statements read and write fixed-size binary data records
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5113 to files or devices. These are the primary I/O statements
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5114 used for random access input and output.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5115 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5116 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5117 The first expression is evaluated and used as the number of the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5118 I/O path which must have previously been opened by an OPEN or CREATE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5119 statement. Paths used by PUT statements must have been opened in WRITE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5120 or UPDATE access modes, and paths used by GET statements must be in READ
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5121 or UPDATE mode.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5122 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5123 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5124 The statement uses exactly one name which can be the name of a variable,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5125 array, or complex data structure. Data is written from, or read into, the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5126 variable or structure named. The data is transferred in &b09;'s internal
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5127 binary format without conversion which affords very high throughput
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5128 compared to READ and WRITE statements. Data is transferred beginning
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5129 at the current position of the path's file pointer (see SEEK statement)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5130 which is automatically updated.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5131 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5132 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5133 OS-9's file system does not inherently impose record structures on
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5134 random-access files. All files are considered to be continuous sequences of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5135 addressable binary bytes. A byte or group of bytes located anywhere in the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5136 file can be read or written in any order. Therefore the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5137 <emphasis>programmer</emphasis> is free to use the basic file access
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5138 system to create any record structure desired.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5139 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5140 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5141 Record I/O in &b09; is associated with data structures defined by DIM
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5142 and TYPE statements. The GET and PUT statements write entire data
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5143 structures or parts of data structures. A PUT statement, for example,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5144 can write a simple variable, an entire array, or a complex data structure
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5145 in one operation. To illustrate how this works, here is an example
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5146 based on a simple inventory system that requires a random access file
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5147 having 100 records. Each record must include the following information:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5148 the name of the item (a 25-byte character string), the item's list price
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5149 and cost (both real numbers), and the quantity on hand (an integer).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5150 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5151 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5152 First it is necesary to use the TYPE statement to define a new
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5153 data type that describes such a record. For example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5154 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5155 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5156 TYPE inv_item=name:STRING[25];list,cost:REAL;qty:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5157 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5158 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5159 This statement describes a new record type called "inv_item" but does not
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5160 cause variable storage to be assigned for it. The next step is to create
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5161 two data structures: an array of 100 "records" of type "inv_item" to be called
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5162 "inv_array" and a single working record called "work_rec":
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5163 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5164 DIM inv_array(100):inv_item
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5165 DIM work_rec:inv_item
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5166 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5167 You can manually count the number of bytes assigned for each type to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5168 calculate the total size of each record. Sometimes these can become
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5169 complicated and error-prone. Also, any change in a TYPE definition
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5170 could require recalculation. Fortunately, &b09; has a built-in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5171 function:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5172
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5173 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5174 SIZE(&lt;name>)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5175 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5176 that returns the number of bytes assigned to any variable, array, or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5177 complex data structure. In our example, SIZE(work_rec) will return the number
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5178 37, and SIZE(inv_array) will return 3700. The size function is often
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5179 used in conjunction with the SEEK statement to position a file pointer
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5180 to a specific record's address.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5181 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5182 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5183 The procedure below creates a file called "inventory" and initializes it
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5184 with zeroes and nulls:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5185
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5186 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5187 PROCEDURE makefile
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5188 TYPE inv_item = name:STRING[25]; list,cost:REAL; qty:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5189 DIM inv_array(100):inv_item
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5190 DIM work_rec:inv_item
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5191 DIM path:byte
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5192 CREATE #path,"inventory"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5193 work_rec.name = ""
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5194 work_rec.list := 0.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5195 work_rec.cost := 0.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5196 work_rec.qty := 0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5197 FOR n = 1 TO 100
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5198 PUT #path,work_rec
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5199 NEXT n
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5200 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5201 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5202
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5203 Notice that the assignment statements referenced each named "field" of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5204 work_rec by name, but PUT referenced the record as a whole.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5205 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5206 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5207 The subroutine below asks for a record number, then asks for data, and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5208 writes it in the file at the specified record:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5209
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5210 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5211 INPUT "Record number ?",recnum
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5212 INPUT "Item name? ",work_rec.name
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5213 INPUT "List price? ",work_rec.list
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5214 INPUT "Cost price? ",work_rec.cost
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5215 INPUT "Quantity? ",work_rec.qty
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5216 SEEK #path, (recnum - 1) * SIZE(work_rec)
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5217 PUT #path,work_rec
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5218 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5219 This routine below uses a loop to read the entire file into the array
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5220 "inv_array":
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5221
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5222 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5223 SEEK #path,0 \ (* "rewind" the file *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5224 FOR k = 1 TO 100
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5225 GET #path,inv_array(k)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5226 NEXT k
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5227 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5228
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5229 Because ENTIRE STRUCTURES can be read, we can eliminate the FOR/NEXT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5230 loop and do exactly the same thing by:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5231
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5232 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5233 SEEK #path,0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5234 GET #path,inv_array
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5235 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5236
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5237 The above example is a very simple case, but it illustrates the combined
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5238 power of &b09; complex data structures and the random access I/O
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5239 statements. When fully exploited, this system has the following important
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5240 characteristics:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5241 <orderedlist numeration="arabic">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5242 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5243 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5244 It is self-documenting. You can clearly see what a program does because
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5245 structures have descriptive, named sub-structures.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5246 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5247 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5248
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5249 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5250 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5251 It is extremely fast.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5252 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5253 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5254
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5255 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5256 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5257 Programs are simplified and require fewer statements to perform I/O
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5258 functions than in other BASICs.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5259 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5260 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5261
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5262 <listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5263 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5264 It is versatile. By creating appropriate data structures you can read
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5265 or write almost any kind of data in any file, including files created by
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5266 other programs or languages.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5267 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5268 </listitem>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5269 </orderedlist>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5270
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5271 These advantages are possible because a single GET or PUT statement can
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5272 move any amount of data, organized any way you want.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5273 </para></sect2></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5274 <sect1><title>Internal Data Statements</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5275 <sect2><title>DATA/READ/RESTORE Statements</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5276 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5277 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5278 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5279 <command>READ &lt;input list></command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5280 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5281 <command>DATA &lt;expr> , { &lt;expr> }</command>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5282 <sbr/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5283 <command>RESTORE [ &lt;line number> ]</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5284 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5285 These statements provide an efficient way to build constant tables
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5286 within a program. DATA statements provide values, the READ statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5287 assign the values to variables, and RESTORE statements can be used to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5288 set which data statement is to be read next.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5289 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5290 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5291 The DATA statements have one or more expressions separated by commas.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5292 They can be located anywhere in a program. The expressions are evaluated
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5293 each time the data statements are read and can evaluate to any type.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5294 Here are some examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5295 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5296 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5297 DATA 1.1,1.5,9999,"CAT","DOG"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5298 DATA SIN(temp/25), COS(temp*PI)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5299 DATA TRUE,FALSE,TRUE,TRUE,FALSE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5300 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5301 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5302 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5303 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5304 The READ statement has a list of one or more variable names. When
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5305 executed, it gets "input" by evaluating the current expression in the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5306 current data statement. The result must match the type of the variable. When
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5307 all the expressions in a DATA statement have been evaluated, the next
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5308 DATA statement (in sequential order) is used. If there are no more DATA
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5309 statements following, processing "wraps around" to the first data statement
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5310 in the program.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5311 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5312 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5313 The RESTORE statement used without a line number causes the first DATA
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5314 statement in the program to be used next. If it is used with a line
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5315 number, the data statement having that line number is used next.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5316 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5317 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5318 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5319 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5320 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5321 DATA 1,2,3,4
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5322 DATA 5,6,7,8
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5323 100 DATA 9,10,11,12
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5324 FOR N := 1 TO X
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5325 READ ARRAY(N)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5326 NEXT N
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5327 RESTORE 100
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5328 READ A,B,C,D
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5329 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5330 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5331 </para></sect2></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5332 <sect1><title>Formatted Output: The Print Using Statement</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5333 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5334 &b09; has a powerful output editing capability useful for report generation
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5335 and other applications where formatted output is required. The
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5336 output editing uses the PRINT USING statement which has the following
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5337 syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5338 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5339 <command>PRINT [&lt;expr#>,] USING &lt;str expr> , &lt;output list></command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5340 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5341 The optional path number expression can be used to specify the path
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5342 number of any output file or device. If it is omitted, the output is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5343 written to the standard output path (usually the terminal).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5344 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5345 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5346 The string expression is evaluated and used as a "format specification"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5347 which contains specific formatting directives for each item in the "output
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5348 list". The items in the output list can be constants, variables, or
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
5349 expressions of any atomic type. <emphasis>Blanks are not allowed in format strings!</emphasis>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5350 As each output item is processed, it is matched up with a specification
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5351 in the format list. The type of each expression result must be compatible
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5352 with the corresponding format specification. If there are fewer format
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5353 specifications than items in the output list, the format specification
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5354 list is repeated again from its beginning as many times as necessary.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5355 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5356 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5357 A format string has one or more format specifications which are separated
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5358 by commas. There are two kinds of specifications: ones that control
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5359 output editing of an item from the output list, and ones that cause an
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5360 output function by themselves (such as tabbing and spacing). There are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5361 six basic output editing directives. Each has a corresponding one-letter
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5362 identifier:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5363
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5364 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5365 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5366 <colspec colwidth="0.6in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5367 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5368 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5369 <entry>R</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5370 <entry>real format</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5371 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5372 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5373 <entry>E</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5374 <entry>exponential format</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5375 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5376 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5377 <entry>I</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5378 <entry>integer format</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5379 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5380 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5381 <entry>H</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5382 <entry>hexadecimal format</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5383 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5384 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5385 <entry>S</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5386 <entry>string format</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5387 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5388 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5389 <entry>B</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5390 <entry>boolean format</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5391 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5392 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5393 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5394 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5395 The identifier letter is followed by a constant number called the "field
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5396 width". This number indicates the exact number of print columns the
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
5397 output is to occupy and must allow for the data <emphasis>and</emphasis> "overhead" character
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5398 positions such as sign characters, decimal points, exponents, etc.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5399 Some formats have additional mandatory or optional parameters that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5400 control subfields or select editing options. One of these options is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5401 "justification" which specifies whether the output is to "line up" on
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5402 the left, right side, or center of the output field. Fields are commonly
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5403 right-justified in reports because it arranges them into neat columns
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5404 with decimal points aligned in the same position.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5405 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5406 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5407 The abbreviations and symbols used in the syntax specifications are:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5408
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5409 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5410 <tgroup cols="3">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5411 <colspec colwidth="0.4in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5412 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5413 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5414 <entry>w</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5415 <entry>Total field width</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5416 <entry>1 &lt;= w &lt;= 255</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5417 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5418 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5419 <entry>f</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5420 <entry>Fraction field</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5421 <entry>1 &lt;= w &lt;= 9</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5422 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5423 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5424 <entry>j</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5425 <entry>OPTIONAL justification</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5426 <entry>&lt; (left) > (right) ^ (center)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5427 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5428 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5429 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5430 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5431
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5432 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5433 <sect2><title>Real Format</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5434 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5435 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5436 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5437 <command>Rw.fj</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5438 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5439 This format can be used for numbers of types REAL, INTEGER, or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5440 BYTE. The total field width specification must include two overhead
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5441 positions for the sign and decimal point. The "f" specifies how many
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5442 fractional digits to the right of the decimal point are to be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5443 displayed. If the number has more significant digits than the field
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5444 allows for, the undisplayed places are used to round the displayed digits. For
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5445 example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5446
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5447 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5448 PRINT USING "R8.2", 12.349 gives 12.35
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5449 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5450
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5451 The justification modes are:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5452
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5453 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5454 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5455 <colspec colwidth="0.3in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5456 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5457 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5458 <entry>&lt;</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5459 <entry>Left justify with leading sign and trailing spaces. (default if
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5460 justification mode omitted)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5461 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5462 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5463 <entry>></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5464 <entry>right justify with leading spaces and sign.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5465 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5466 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5467 <entry>^</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5468 <entry>right justify with leading spaces and trailing sign
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5469 (financial format)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5470 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5471 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5472 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5473 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5474
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5475
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5476 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5477
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5478 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5479 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5480 PRINT USING "R8.2&lt;",5678.123 5678.12
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5481 PRINT USING "R8.2>",12.3 12.30
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5482 PRINT USING "R8.2&lt;",-555.9 -555.90
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5483 PRINT USING "10.2^",-6722.4599 6722.46-
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5484 PRINT USING "R5.1","9999999" *****
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5485 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5486 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5487 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5488 <sect2><title>Exponential Format</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5489 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5490 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5491 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5492 <command>Ew.fj</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5493 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5494 This format prints numbers of types REAL, INTEGER, or BYTE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5495 in the scientific notation format using a mantissa and decimal exponent.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5496 The syntax and behavior of this format is similar to the REAL format
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5497 except the "w" field width must allow for eight overhead positions for the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5498 mantissa sign, decimal point, and exponent characters.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5499 The "&lt;" and "&gt;" justification modes are allowed and work the same way.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5500 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5501 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5502 Example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5503
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5504 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5505 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5506 PRINT USING "E12.3",1234.567 1.235E+03
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5507
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5508 PRINT USING "E12.6>",-0.001234 -1.234000E-3
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5509 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5510 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5511
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5512 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5513 <sect2><title>Integer Format</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5514 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5515 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5516 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5517 <command>Iwj</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5518 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5519 This format is used to display numbers of types INTEGER or BYTE,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5520 and REAL numbers that are within range for automatic type conversion.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5521 The "w" field width must allow for one position overhead for the sign.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5522 The justification modes are:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5523
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5524 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5525 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5526 <colspec colwidth="0.3in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5527 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5528 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5529 <entry>&lt;</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5530 <entry>left justify with leading sign and trailing spaces (default)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5531 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5532 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5533 <entry>></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5534 <entry>right justify with leading spaces and sign</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5535 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5536 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5537 <entry>^</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5538 <entry>right justify with leading spaces and zeroes</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5539 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5540 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5541 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5542 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5543 Example:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5544 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5545 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5546 PRINT USING "I4&lt;",10 10
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5547
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5548 PRINT USING "I4>",10 10
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5549
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5550 PRINT USING "I4^",10 010
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5551 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5552 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5553
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5554
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5555 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5556 <sect2><title>Hexadecimal Format</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5557 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5558 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5559 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5560 <command>Hwj</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5561 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5562 This format can be used to display the internal binary representation
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5563 of ANY data type, using hexadecimal characters. The "w" field width
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5564 specification determines the number of hexadecimal characters to
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5565 output. Justification modes are:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5566
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5567 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5568 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5569 <colspec colwidth="0.3in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5570 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5571 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5572 <entry>&lt;</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5573 <entry>left justify with trailing spaces</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5574 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5575 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5576 <entry>></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5577 <entry>right justify, leading spaces</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5578 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5579 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5580 <entry>^</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5581 <entry>center justify</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5582 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5583 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5584 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5585 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5586
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5587 Because the number of bytes of memory used to represent data varies
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5588 according to type, the following specification make the most sense for
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5589 each data type:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5590
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5591 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5592 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5593 <colspec colwidth="0.5in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5594 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5595 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5596 <entry>H2</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5597 <entry>boolean, byte (one byte)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5598 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5599 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5600 <entry>H4</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5601 <entry>integer (two bytes)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5602 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5603 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5604 <entry>H10</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5605 <entry>real (five bytes)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5606 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5607 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5608 <entry>Hn*2</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5609 <entry>string of length n</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5610 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5611 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5612 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5613 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5614
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5615
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5616 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5617
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5618 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5619 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5620 PRINT USING "H4",100 00C4
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5621
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5622 PRINT USING "H4",-1 FFFF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5623
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5624 PRINT USING "H10",1.5 01D0000000
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5625
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5626 PRINT USING "H8","ABC" 414243
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5627 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5628 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5629 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5630 <sect2><title>String Format</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5631 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5632 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5633 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5634 <command>Swj</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5635 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5636 This format is used to display string data of any length. The "w" field
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5637 width specifies the total field size. If the string to be displayed is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5638 shorter than the field size, it is padded with spaces according to the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5639 justification mode. If it is too long, it will be truncated on the right side.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5640 The format specifications are:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5641
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5642 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5643 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5644 <colspec colwidth="0.3in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5645 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5646 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5647 <entry>&lt;</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5648 <entry>Left justify (default if mode omitted)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5649 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5650 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5651 <entry>></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5652 <entry>right justify</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5653 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5654 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5655 <entry>^</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5656 <entry>Center justify</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5657 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5658 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5659 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5660 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5661
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5662 Examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5663
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5664 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5665 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5666 PRINT USING "S8&lt;","HELLO" HELLO
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5667
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5668 PRINT USING "S8>","HELLO" HELLO
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5669
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5670 PRINT USING "S8^","HELLO" HELLO
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5671 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5672 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5673
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5674
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5675 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5676 <sect2><title>Boolean Format</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5677 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5678 Syntax:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5679 <cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5680 <command>Bwj</command>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5681 </cmdsynopsis>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5682 This format is used to display boolean data. The result of the boolean
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5683 expression is converted to the strings "TRUE" and "FALSE".
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5684 The specification is otherwise identical to the STRING format.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5685 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5686 <sect2><title>Control Specifications</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5687 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5688 Control specifications are useful for horizontal formatting of the output
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5689 line. They are not matched with items in the output list and can be used
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5690 freely. The control formats are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5691
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5692 <informaltable frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5693 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5694 <colspec colwidth="0.5in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5695 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5696 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5697 <entry>Tn</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5698 <entry>Tab to column n</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5699 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5700 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5701 <entry>Xn</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5702 <entry>Space n columns</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5703 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5704 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5705 <entry>'str'</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5706 <entry>Include constant string. The string must not include single or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5707 double quotes, backslash or carriage return characters.</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5708 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5709 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5710 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5711 </informaltable>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5712 Warning: Control specifications at the end of the format
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
5713 specification list will <emphasis>not</emphasis> be processed if all output items have
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5714 been exhausted.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5715 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5716 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5717 Example
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5718
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5719 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5720 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5721 PRINT USING "'addr',X2,H4,X2,'data',X2,H2",1000,100 prints
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5722
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5723 addr 03E8 data C4
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5724 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5725 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5726 </para></sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5727 <sect2><title>Repeat Groups</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5728 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5729 Many times identical sequences of specifications are repeated in format
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5730 specification lists. The repeated groups can be enclosed in parentheses and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5731 preceded by a repeat count. These repeat groups can be nested.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5732 Here are some examples:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5733
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5734 <informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5735 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5736 "2(X2,R10.5)" is the same as "X2,R10.5,X2,R10.5"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5737
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5738 "2(I2,2(X1,S4))" is the same as "I2,X1,S4,X1,S4,I2,X1,S4,X1,S4"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5739 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5740 </informalexample>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5741 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5742 </sect2>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5743 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5744 </chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5745
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5746 <chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5747 <title>Program Optimization</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5748 <sect1><title>General Execution Performance of &b09;</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5749 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5750 The &b09; multipass compiler produces a compressed and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5751 optimized low-level "I-code" for execution. Compared to other BASIC
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5752 languages program storage is greatly decreased and execution speed
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5753 is increased.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5754 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5755 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5756 High-level language interpreters have a general reputation for slowness
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5757 which is probably not deserved. Because the &b09; I-code is kept at
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5758 a powerful level, a single, fast I-code interpretation will so that
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5759 there is often result in many MPU instruction cycles (such as execution
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5760 of floating-point arithmetic operations). Thus, for complex programs
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5761 there is little performance difference between execution of I-code and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5762 straight machine-language instructions. This is generally not the case
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5763 with traditional BASIC interpreters that have to "compile" from text as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5764 they run or even "tokenized" BASICs that must perform table-searching
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5765 during execution. &b09; I-code instructions that reference variable
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5766 storage, statements, labels, etc., contain the actual memory addresses
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5767 so no table searching is ever required. Off course, &b09; fully exploits
1015
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
5768 the power of the &CPU;'s instruction set which was optimized for efficient
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5769 execution of compiler-produced code.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5770 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5771 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5772 Because the &b09; I-code is interpreted, a variety of entry-time
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5773 tests and run-time tests and development aids are available to help
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5774 in program development; aids not available on most compilers.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5775 The editor reports errors immediately when they are entered,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5776 the debugger allows debugging using the original program source
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5777 statements and names, and
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5778 the I-code interpreter performs run-time error checking of things such
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5779 as array bound errors, subroutine nesting, arithmetic errors, and other
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5780 errors that are not detected (and usually crash) native-compiler-generated
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5781 code.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5782
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5783 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5784 <sect1><title>Optimum Use of Numeric Data Types</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5785 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5786 Because &b09; includes several different numeric representations
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5787 (i.e., REAL, INTEGER, and BYTE) and does "automatic type conversions"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5788 between them, it is easy to write expressions or loops that take at
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5789 least ten times longer to execute than is necessary. Some particular
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5790 &b09; numeric operators (+, -, *, /) and control structures (FOR..NEXT)
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5791 include versions for both REAL and INTEGER values. The INTEGER versions,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5792 off course, are much faster and may have slightly different properties
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5793 (e.g., INTEGER divides discard any remainder). Type conversions takes
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5794 time so expressions whose operands and operators are of the same type
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5795 are more efficient.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5796 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5797 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5798 &b09;'s REAL (floaing point) math package provides excellent
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5799 performance. A special 40-bit binary floating point representation
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5800 designed for speed and accuracy was developed especially for &b09;
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5801 after exhaustive research. The new CORDIC technique is used to derive
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5802 all transcendental functions (SIN, TAN, LOG, EXP, etc.). This integer
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5803 shit-and-add technique is faster and more consistantly accurate than
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5804 the commonly used series-expansion approximations.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5805 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5806 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5807 Nonetheless, INTEGER operations are faster because they generally have
1015
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
5808 corresponding &CPU; machine-language instructions. Overall program speed
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5809 will increase and storage requirements will decrease if INTEGERs are used
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5810 whenever possible. INTEGER arithmetic operations use the same symbols as
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5811 REAL but &b09; automatically selects the INTEGER operations when working
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5812 with an integer-value result. Only if all operands of an expression are
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5813 of types BYTE or INTEGER will the result also be INTEGER.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5814 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5815 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5816 Sometimes, similar or identical results can be obtained in a number
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5817 of different ways at various execution speeds. For example, if the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5818 variable "value" is an integer, then "value*2" will be a fast integer
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5819 operation. However, if the expression is "value*2.0" the value "2.0"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5820 will be represented as a REAL number, and the multiplication will be a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5821 REAL multiplication. This will also require that the variable "value"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5822 will have to be transformed into a REAL value, and finally the result of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5823 the expression will have to be transformed back to an INTEGER value if
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5824 it is to be assigned to a variable of that type. Thus a single decimal
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5825 point will slow this particular operation down by about ten times!
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5826 <table frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5827 <title>Arithmetic Functions Ranked by Speed</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5828 <tgroup cols="2">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5829 <colspec colwidth="3in"/>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
5830 <colspec colwidth="2in"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5831 <thead>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5832 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5833 <entry>Operation</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5834 <entry>Typical Speed (MPU Cycles)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5835 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5836 </thead>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5837 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5838 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5839 <entry>INTEGER ADD OR SUBTRACT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5840 <entry>150</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5841 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5842 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5843 <entry>INTEGER MULTIPLY</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5844 <entry>240</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5845 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5846 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5847 <entry>REAL ADD</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5848 <entry>440</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5849 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5850 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5851 <entry>REAL SUBTRACT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5852 <entry>540</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5853 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5854 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5855 <entry>INTEGER DIVIDE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5856 <entry>960</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5857 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5858 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5859 <entry>REAL MULTIPLY</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5860 <entry>990</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5861 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5862 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5863 <entry>REAL DIVIDE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5864 <entry>3870</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5865 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5866 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5867 <entry>REAL SQUARE ROOT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5868 <entry>7360</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5869 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5870 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5871 <entry>REAL LOGARITM OR EXPONENTIAL</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5872 <entry>20400</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5873 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5874 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5875 <entry>REAL SINE OR COSINE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5876 <entry>32500</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5877 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5878 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5879 <entry>REAL POWER (^)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5880 <entry>39200</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5881 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5882 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5883 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5884 </table>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5885 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5886 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5887 This table can be used to deduce some interesting points. For
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5888 example, "value*2" is not optimum - "value+value" can produce the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5889 same result in less time because multiplication takes longer than
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
5890 addition. Similarly, "value*value" or "SQ(value)" is <emphasis>much</emphasis> faster
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5891 than the equivalent "value^2". Another interesting case is "x/2.0".
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5892 The REAL divide will cost 3870 cycles, but REAL multiplcation takes
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5893 only 990 cycles. The mathematical equivalent to division by a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5894 constant is multiplication by the inverse of the constant.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5895 Therefore, using "X*0.5" instead is almost four times faster!
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5896 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5897
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5898 <sect1><title>Looping Quickly</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5899 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5900 When &b09; identifies a FOR..NEXT loop structure with an INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5901 loop counter variable, it uses a special integer version of the FOR..NEXT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5902 loop. This is much faster than the REAL-type version and is generally
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5903 preferable. Other kinds of loops also run faster if INTEGER type variables
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5904 are used for loop counters.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5905 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5906 <para>
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
5907 When writing program loops, remember that statements <emphasis>inside</emphasis> the loop
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
5908 may be executed many times for each single execution <emphasis>outside</emphasis> the loop.
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5909 Thus, any value which can be computed before entering a loop will increase
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5910 program speed.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5911 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5912 <sect1><title>Optimum Use of Arrays and Data Structures</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5913 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5914 &b09; internally uses INTEGER numbers to index arrays and complex data
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5915 structures. If the program uses subscripts that are REAL type variables
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5916 or expressions, &b09; has to convert them to INTEGERs before they can
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5917 be used. This takes additional time, so use INTEGER expressions for
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5918 subscripts whenever you can.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5919 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5920 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5921 Note that the assignment statement (LET) can copy identically sized data
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5922 structures. This feature is much faster than copying arrays or structures
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5923 element-by-element inside a loop.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5924 </para></sect1>
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
5925 <sect1 id="pack" xreflabel="PACK"><title>The PACK Command</title>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5926 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5927 The PACK command produces a compressed version of a &b09;
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5928 procedure. Depending on the number of comments, line numbers, etc.,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5929 programs will execute from 10% to 30% faster after being packed. Minimizing
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5930 use of line numbers will even speed up procedures that are unPACKed.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5931 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5932 <sect1><title>Eliminating Constant Expressions and Sub-Expressions</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5933 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5934 Consider the expression:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5935 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5936 x = x+SQRT(100)/2
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5937 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5938
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5939 is exactly the same as the expression:
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5940 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5941 x = x+5
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5942 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5943 The subexpression "SQRT(100)/2" consists of constants only, so its result
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5944 will not vary regardless of the rest of the program. But every time the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5945 program is run, the computer must evaluate it. This time can be significant,
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5946 especially if the statement is within a loop. Constant expressions or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5947 subexpressions should be calculated by the programmer while writing the program
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5948 (using DEBUG mode or a pocket calculator).
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5949 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5950 <sect1><title>Fast Input and Output Functions</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5951 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5952 Reading or writing data a line or record at a time is much faster than a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5953 character at a time. Also, the GET and PUT statements are much faster
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5954 than READ and WRITE statements when dealing with disk files. This is
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5955 because GET and PUT use the exact binary format used internally by
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5956 &b09;. READ, WRITE, PRINT, and INPUT must perform binary-to-ASCII or
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5957 ASCII-to-binary conversions which take time.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5958 </para></sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5959 <sect1><title>Professional Programming Techniques</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5960 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5961 One sure way to make a program faster is to use the most
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5962 efficient algorithms possible. There are many good programming
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5963 "cookbooks" that explain useful algorithms with examples in BASIC or PASCAL.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5964 Thanks to &b09;'s rich vocabulary you can use algorithms written in either
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5965 language with little or no adaptation.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5966 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5967 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5968 &b09; also eliminates any possible excuse for not using good
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5969 structured programming style that produces
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5970 efficient, reliable, readable, and maintainable software. &b09; generates
1015
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
5971 optimized code to be executed by the &CPU; which is the most
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5972 powerful 8-bit processor in existence at the time of this writing.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5973 But a computer can only execute what
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5974 it is told to execute, and no language implementation can make up for an
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5975 inefficient program. An inefficient program is evidence of a lack of
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5976 understanding of the problem. The result is likely to be hard to understand
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5977 and hard to update if program specifications change (they always do). The
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5978 identification of efficient algorithms and their clear, structured
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5979 expression is indicative of professionalism in software design and is a goal
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5980 in itself.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5981 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5982 </sect1>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5983 </chapter>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5984
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5985
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5986
1094
958740284209 Use <emphasis> instead of CAPITALS
roug
parents: 1015
diff changeset
5987 <appendix id="sample-programs">
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5988 <title>Sample Programs</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5989 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5990 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5991 PROCEDURE fibonacci
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5992 REM computes the first ten Fibonacci numbers
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5993 DIM x,y,i,temp:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5994
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5995 x:=0 \y:=0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5996 FOR i=0 TO 10
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5997 temp:=y
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5998
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
5999 IF i&lt;>0 THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6000 y:=y+x
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6001 ELSE y:=1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6002 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6003
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6004 x:=temp
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6005 PRINT i,y
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6006 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6007 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6008
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6009 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6010 PROCEDURE fractions
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6011 REM by T.F. Ritter
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6012 REM finds increasingly-close rational approximations
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6013 REM to the desired real value
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6014 DIM m:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6015
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6016 desired:=PI
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6017 last:=0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6018
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6019 FOR m=1 TO 30000
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6020 n:=INT(.5+m*desired)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6021 trial:=n/m
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6022 IF ABS(trial-desired)&lt;ABS(last-desired) THEN
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6023 PRINT n; "/"; m; " = "; trial,
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6024 PRINT "difference = "; trial-desired;
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6025 PRINT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6026 last:=trial
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6027 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6028 NEXT m
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6029 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6030
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6031 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6032 PROCEDURE prinbi
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6033 REM by T.F. Ritter
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6034 REM prints the integer parameter value in binary
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6035 PARAM n:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6036 DIM i:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6037
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6038 FOR i=15 TO 0 STEP -1
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6039 IF n&lt;0 THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6040 PRINT "1";
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6041 ELSE PRINT "0";
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6042 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6043 n:=n+n
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6044 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6045 PRINT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6046
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6047 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6048 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6049
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6050 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6051 PROCEDURE hanoi
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6052 REM by T.F. Ritter
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6053 REM move n discs in Tower of Hanoi game
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6054 REM See BYTE Magazine, Oct 1980, pg. 279
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6055
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6056 PARAM n:INTEGER; from,to_,other:STRING[8]
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6057
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6058 IF n=1 THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6059 PRINT "move #"; n; " from "; from; " to "; to_
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6060 ELSE
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6061 RUN hanoi(n-1,from,other,to_)
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6062 PRINT "move #"; n; " from "; from; " to "; to_
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6063 RUN hanoi(n-1,other,to_,from)
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6064 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6065
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6066 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6067 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6068
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6069 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6070 PROCEDURE roman
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6071 REM prints integer parameter as Roman Numeral
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6072 PARAM x:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6073 DIM value,svalu,i:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6074 DIM char,subs:STRING
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6075
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6076 char:="MDCLXVI"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6077 subs:="CCXXII "
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6078 DATA 1000,100,500,100,100,10,50,10,10,1,5,1,1,0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6079
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6080 FOR i=1 TO 7
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6081 READ value
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6082 READ svalu
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6083
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6084 WHILE x>=value DO
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6085 PRINT MID$(char,i,1);
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6086 x:=x-value
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6087 ENDWHILE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6088
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6089 IF x>=value-svalu THEN
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6090 PRINT MID$(subs,i,1); MID$(char,i,1);
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6091 x:=x-value+svalu
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6092 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6093
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6094 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6095 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6096 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6097
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6098 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6099 PROCEDURE eightqueens
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6100 REM originally by N. Wirth; here re-coded from Pascal
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6101 REM finds the arrangements by which eight queens
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6102 REM can be placed on a chess board without conflict
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6103 DIM n,k,x(8):INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6104 DIM col(8),up(15),down(15):BOOLEAN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6105 BASE 0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6106
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6107 (* initialize empty board *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6108 n:=0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6109 FOR k:=0 TO 7 \col(k):=TRUE \NEXT k
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6110 FOR k:=0 TO 14 \up(k):=TRUE \down(k):=TRUE \NEXT k
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6111 RUN generate(n,x,col,up,down)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6112 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6113
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6114 PROCEDURE generate
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6115 PARAM n,x(8):INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6116 PARAM col(8),up(15),down(15):BOOLEAN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6117 DIM h,k:INTEGER \h:=0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6118 BASE 0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6119
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6120 REPEAT
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6121 IF col(h) AND up(n-h+7) AND down(n+h) THEN
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6122 (* set queen on square [n,h] *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6123 x(n):=h
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6124 col(h):=FALSE \up(n-h+7):=FALSE \down(n+h) := FALSE
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6125 n:=n+1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6126 IF n=8 THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6127 (* board full; print configuration *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6128 FOR k=0 TO 7
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6129 PRINT x(k); " ";
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6130 NEXT k
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6131 PRINT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6132 ELSE RUN generate(n,x,col,up,down)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6133 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6134
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6135 (* remove queen from square [n,h] *)
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6136 n:=n-1
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6137 col(h):=TRUE \up(n-h+7):=TRUE \down(n+h):=TRUE
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6138 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6139 h:=h+1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6140 UNTIL h=8
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6141 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6142 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6143
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6144 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6145 PROCEDURE electric
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6146 REM re-programmed from "ELECTRIC"
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6147 REM by Dwyer and Critchfield
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6148 REM Basic and the Personal Computer (Addison-Wesley, 1978)
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6149 REM provides a pictorial representation of the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6150 REM resultant electrical field around charged points
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6151 DIM a(10),b(10),c(10)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6152 DIM x,y,i,j:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6153 xscale:=50./78.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6154 yscale:=50./32.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6155
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6156 INPUT "How many charges do you have? ",n
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6157 PRINT "The field of view is 0-50,0-50 (x,y)"
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6158 FOR i=1 TO n
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6159 PRINT "type in the x and y positions of charge ";
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6160 PRINT i;
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6161 INPUT a(i),b(i)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6162 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6163 PRINT "type in the size of each charge:"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6164 FOR i=1 TO n
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6165 PRINT "charge "; i;
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6166 INPUT c(i)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6167 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6168
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6169 REM visit each screen position
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6170 FOR y=32 TO 0 STEP -1
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6171 FOR x=0 TO 78
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6172 REM compute field strength into v
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6173 GOSUB 10
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6174 z:=v*50.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6175 REM map z to valid ASCII in b$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6176 GOSUB 20
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6177 REM print char (proportional to field)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6178 PRINT b$;
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6179 NEXT x
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6180 PRINT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6181 NEXT y
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6182 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6183
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6184 10 v=1.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6185 FOR i=1 TO n
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6186 r:=SQRT(SQ(xscale*x-a(i))+SQ(yscale*y-b(i)))
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6187 EXITIF r=.0 THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6188 v:=99999.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6189 ENDEXIT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6190 v:=v+c(i)/r
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6191 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6192 RETURN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6193
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6194 20 IF z&lt;32 THEN b$:=" "
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6195 ELSE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6196 IF z>57 THEN z:=z+8
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6197 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6198 IF z>90 THEN b$:="*"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6199 ELSE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6200 IF z>INT(z)+.5 THEN b$:=" "
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6201 ELSE b$:=CHR$(z)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6202 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6203 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6204 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6205 RETURN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6206 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6207
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6208 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6209 PROCEDURE qsort1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6210 REM quicksort, by T.F. Ritter
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6211 PARAM bot,top,d(1000):INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6212 DIM n,m:INTEGER; btemp:BOOLEAN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6213
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6214 n:=bot
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6215 m:=top
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6216
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6217 LOOP \REM each element gets the once over
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6218 REPEAT \REM this is a post-inc instruction
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6219 btemp:=d(n)&lt;d(top)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6220 n:=n+1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6221 UNTIL NOT (btemp)
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6222 n:=n-1 \REM point at the tested element
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6223 EXITIF n=m THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6224 ENDEXIT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6225
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6226 REPEAT \REM this is a post-dec instruction
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6227 m:=m-1
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6228 UNTIL d(m)&lt;=d(top) OR m=n
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6229 EXITIF n=m THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6230 ENDEXIT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6231
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6232 RUN exchange(d(m),d(n))
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6233 n:=n+1 \REM prepare for post-inc
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6234 EXITIF n=m THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6235 ENDEXIT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6236
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6237 ENDLOOP
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6238
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6239 IF n&lt;>top THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6240 IF d(n)&lt;>d(top) THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6241 RUN exchange(d(n),d(top))
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6242 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6243 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6244
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6245 IF bot&lt;n-1 THEN
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6246 RUN qsort1(bot,n-1,d)
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6247 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6248 IF n+1&lt;top THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6249 RUN qsort1(n+1,top,d)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6250 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6251
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6252 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6253
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6254 PROCEDURE exchange
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6255 PARAM a,b:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6256 DIM temp:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6257
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6258 temp:=a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6259 a:=b
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6260 b:=temp
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6261
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6262 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6263
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6264 PROCEDURE prin
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6265 PARAM n,m,d(1000):INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6266 DIM i:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6267
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6268 FOR i=n TO m
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6269 PRINT d(i);
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6270 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6271 PRINT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6272
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6273 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6274
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6275 PROCEDURE sortest
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6276 REM This procedure is used to test Quicksort
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6277 REM It fills the array "d" with randomly generated
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6278 REM numbers and sorts them.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6279 DIM i,d(1000):INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6280
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6281 FOR i=1 TO 1000
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6282 d(i):=INT(RND(100))
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6283 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6284
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6285 RUN prin(1,1000,d)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6286
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6287 RUN qsort1(1,1000,d)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6288
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6289 RUN prin(1,1000,d)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6290
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6291 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6292 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6293
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6294 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6295 PROCEDURE structst
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6296
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6297 REM example of intermixed array and record structures
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6298 REM note that structure d contains 200 real elements
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6299
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6300 TYPE a=one(2):REAL
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6301 TYPE b=two(10):a
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6302 TYPE c=three(10):b
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6303 DIM d,e:c
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6304
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6305 FOR i=1 TO 10
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6306 FOR j=1 TO 10
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6307 FOR k=1 TO 2
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6308 PRINT d.three(i).two(j).one(k)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6309 d.three(i).two(j).one(k):=0.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6310 PRINT e.three(i).two(j).one(k)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6311 PRINT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6312 NEXT k
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6313 NEXT j
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6314 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6315
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6316 REM this is a complete structure assignment
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6317 e:=d
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6318
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6319 FOR i=1 TO 10
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6320 FOR j=1 TO 10
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6321 FOR k=1 TO 2
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6322 PRINT e.three(i).two(j).one(k);
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6323 NEXT k
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6324 PRINT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6325 NEXT j
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6326 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6327
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6328 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6329 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6330
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6331 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6332 PROCEDURE pialook
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6333 REM display PIA at address (T.F. Ritte)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6334 REM made understandable by K. Kaplan
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6335
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6336 DIM address:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6337 INPUT "Enter PIA address: "; address
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6338 RUN side(address)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6339 RUN side(adress+2)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6340 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6341
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6342 PROCEDURE side
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6343 REM display side of PIA at address
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6344 PARAM address:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6345 DIM data:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6346
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6347 (* loop until control register input strobe
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6348 (* flag (bit 7) is set
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6349 REPEAT \ UNTIL LAND(PEEK(address+1),$80) &lt;> 0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6350 (* now read the data register
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6351 data := PEEK(address)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6352 (* display data in binary
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6353 RUN prinbyte(data)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6354 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6355
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6356 PROCEDURE prinbyte
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6357 REM print a byte as binary
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6358 PARAM n: INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6359 DIM i: INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6360
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6361 n:= n*256
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6362 FOR i = 7 TO 0 STEP -1
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6363 IF n &lt; 0 THEN PRINT "1";
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6364 ELSE PRINT "0";
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6365 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6366 n:= n + 1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6367 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6368
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6369 PRINT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6370 END
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6371 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6372
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6373 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6374 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6375 The following procedures demonstrate multiple-precision arithmetic, in
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6376 this case using five integers to represent a twenty decimal digit number, with
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6377 four fractional places.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6378 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6379 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6380
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6381
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6382 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6383 PROCEDURE mpadd
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6384 REM a+b=>c:five_integer_number (T.F. Ritter)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6385 PARAM a(5),b(5),c(5):INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6386 DIM i,carry:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6387
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6388 carry:=0
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6389 FOR i=5 TO 1 STEP -1
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6390 c(i):=a(i)+b(i)+carry
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6391 IF c(i)>=10000 THEN
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6392 c(i):=c(i)-10000
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6393 carry:=1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6394 ELSE carry:=0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6395 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6396 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6397 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6398
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6399 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6400
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6401 PROCEDURE mpsub
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6402 PARAM a(5),b(5),c(5):INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6403 DIM i,borrow:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6404
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6405 borrow:=0
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6406 FOR i=5 TO 1 STEP -1
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6407 c(i):=a(i)-b(i)-borrow
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6408 IF c(i)&lt;0 THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6409 c(i):=c(i)+10000
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6410 borrow:=1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6411 ELSE borrow:=0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6412 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6413 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6414 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6415
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6416 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6417
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6418 PROCEDURE mprint
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6419 PARAM a(5):INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6420 DIM i:INTEGER; s:STRING
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6421
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6422 FOR i=1 TO 5
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6423 IF i=5 THEN PRINT ".";
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6424 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6425 s:=STR$(a(i))
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6426 PRINT MID$("0000"+s,LEN(s)+1,4);
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6427 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6428 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6429
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6430 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6431 PROCEDURE mpinput
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6432 PARAM a(5):INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6433 DIM n,i:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6434
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6435 INPUT "input ultra-precision number: ",b$
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6436 n:=SUBSTR(".",b$)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6437
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6438 IF n&lt;>0 THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6439 a(5):=VAL(MID$(b$+"0000",n+1,4))
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6440 b$:=LEFT$(b$,n-1)
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6441 ELSE a(5):=0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6442 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6443
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6444 b$:="00000000000000000000"+b$
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6445 n:=1+LEN(b$)
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6446 FOR i=4 TO 1 STEP -1
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6447 n:=n-4
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6448 a(i):=VAL(MID$(b$,n,4))
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6449 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6450 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6451
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6452 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6453
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6454 PROCEDURE mptoreal
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6455 PARAM a(5):INTEGER; b:REAL
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6456 DIM i:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6457
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6458 b:=a(1)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6459 FOR i=2 TO 4
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6460 b:=b*10000
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6461 b:=b+a(i)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6462 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6463 b:=b+a(5)*.0001
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6464 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6465
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6466 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6467 PROCEDURE Patch
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6468 (* Program to examine and patch any byte of a disk file *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6469 (* Written by L. Crane *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6470 DIM buffer(256):BYTE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6471 DIM path,offset,modloc:INTEGER; loc:REAL
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6472 DIM rewrite:STRING
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6473 INPUT "pathlist? ",rewrite
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6474 OPEN #path,rewrite:UPDATE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6475 LOOP
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6476 INPUT "sector number? ",rewrite
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6477 EXITIF rewrite="" THEN ENDEXIT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6478 loc=VAL(rewrite)*256
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6479 SEEK #path,loc
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6480 GET #path,buffer
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6481 RUN DumpBuffer(loc,buffer)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6482 LOOP
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6483 INPUT "change (sector offset)? ",rewrite
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6484 EXITIF rewrite="" THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6485 RUN DumpBuffer(loc,buffer)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6486 ENDEXIT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6487 EXITIF rewrite="S" OR rewrite="s" THEN ENDEXIT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6488 offset=VAL(rewrite)+1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6489 LOOP
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6490 EXITIF offset>256 THEN ENDEXIT
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6491 modloc=loc+offset-1
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6492 PRINT USING "h4,' - ',h2",modloc,buffer(offset);
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6493 INPUT ":",rewrite
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6494 EXITIF rewrite="" THEN ENDEXIT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6495 IF rewrite&lt;>" " THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6496 buffer(offset)=VAL(rewrite)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6497 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6498 offset=offset+1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6499 ENDLOOP
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6500 ENDLOOP
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6501 INPUT "rewrite sector? ",rewrite
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6502 IF LEFT$(rewrite,1)="Y" OR LEFT$(rewrite,1)="y" THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6503 SEEK #path,loc
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6504 PUT #path,buffer
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6505 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6506 ENDLOOP
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6507 CLOSE #path
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6508 BYE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6509
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6510 PROCEDURE DumpBuffer
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6511 (* Called by PATCH *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6512 TYPE buffer=char(8):INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6513 PARAM loc:REAL; line(16):buffer
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6514 DIM i,j:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6515 WHILE loc>65535. DO
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6516 loc=loc-65536.
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6517 ENDWHILE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6518 FOR j=1 TO 16
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6519 PRINT USING "h4",FIX(INT(loc))+(j-1)*16;
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6520 PRINT ":";
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6521 FOR i=1 TO 8
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6522 PRINT USING "X1,H4",line(j).char(i);
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6523 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6524 RUN printascii(line(j))
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6525 PRINT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6526 NEXT j
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6527
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6528 PROCEDURE PrintASCII
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6529 TYPE buffer=char(16):BYTE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6530 PARAM line:buffer
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6531 DIM ascii:STRING; nextchar:BYTE; i:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6532 ascii=""
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6533 FOR i=1 TO 16
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6534 nextchar=line.char(i)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6535 IF nextchar>127 THEN
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6536 nextchar=nextchar-128
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6537 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6538 IF nextchar&lt;32 OR nextchar>125 THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6539 ascii=ascii+" "
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6540 ELSE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6541 ascii=ascii+CHR$(nextchar)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6542 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6543 NEXT i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6544 PRINT " "; ascii;
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6545 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6546
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6547 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6548 PROCEDURE MakeProc
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6549 (* Generates an OS-9 command file to apply a command *)
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6550 (* Such as copy, del, etc., to all files in a directory *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6551 (* or directory system. Author: L. Crane *)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6552
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6553 DIM DirPath,ProcPath,i,j,k:INTEGER
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6554 DIM CopyAll,CopyFile:BOOLEAN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6555 DIM ProcName,FileName,ReInput,ReOutput,response:STRING
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6556 DIM SrcDir,DestDir,DirLine:STRING[80]
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6557 DIM Function,Options:STRING[60]
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6558 DIM ProcLine:STRING[160]
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6559
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6560 ProcName="CopyDir"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6561 Function="Copy"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6562 Options="#32k"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6563 REPEAT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6564 PRINT "Proc name ("; ProcName; ")";
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6565 INPUT response
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6566 IF response&lt;>"" THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6567 ProcName=TRIM$(response)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6568 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6569
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6570 ON ERROR GOTO 100
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6571 SHELL "del "+ProcName
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6572 100 ON ERROR
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6573 INPUT "Source Directory? ",SrcDir
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6574 SrcDir=TRIM$(SrcDir)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6575 ON ERROR GOTO 200
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6576 SHELL "del procmaker...dir"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6577 200 ON ERROR
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6578 SHELL "dir "+SrcDir+" >procmaker...dir"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6579 OPEN #DirPath,"procmaker...dir":READ
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6580 CREATE #ProcPath,ProcName:WRITE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6581 PRINT "Function ("; Function; ")";
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6582 INPUT response
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6583 IF response&lt;>"" THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6584 Function=TRIM$(response)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6585 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6586 INPUT "Redirect Input? ",response
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6587 IF response="y" OR response="Y" THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6588 ReInput="&lt;" \ ELSE \ReInput=""
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6589 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6590 INPUT "Redirect Output? ",response
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6591 IF response="y" OR response="Y" THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6592 ReOutput=">" \ ELSE \ReOutput=""
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6593 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6594 PRINT "Options ("; Options; ")";
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6595 INPUT response
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6596 IF response&lt;>"" THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6597 Options=TRIM$(response)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6598 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6599 INPUT "Destination Directory? ",DestDir
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6600 DestDir=TRIM$(DestDir)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6601 WRITE #ProcPath,"t"
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6602 WRITE #ProcPath,"TMode .1 -pause"
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6603 READ #DirPath,DirLine
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6604 INPUT "Use all files? ",response
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6605 CopyAll=response="y" OR response="Y"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6606 WHILE NOT(EOF(#DirPath)) DO
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6607 READ #DirPath,DirLine
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6608 i=LEN(TRIM$(DirLine))
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6609 IF i>0 THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6610 j=1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6611 REPEAT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6612 k=j
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6613 WHILE j&lt;=i AND MID$(DirLine,j,1)&lt;>" " DO
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6614 j=j+1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6615 ENDWHILE
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
6616 FileName=MID$(DirLine,k,j-k)
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6617 IF NOT(CopyAll) THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6618 PRINT "Use "; FileName;
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6619 INPUT response
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6620 CopyFile=response="y" OR response="Y"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6621 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6622 IF CopyAll OR CopyFile THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6623 ProcLine=Function+" "+ReInput+SrcDir+"/"+FileName
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6624 IF DestDir&lt;>"" THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6625 ProcLine=ProcLine+" "+ReOutput+DestDir+"/"+FileName
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6626 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6627 ProcLine=ProcLine+" "+Options
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6628 WRITE #ProcPath,ProcLine
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6629 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6630 WHILE j&lt;i AND MID$(DirLine,j,1)=" " DO
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6631 j=j+1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6632 ENDWHILE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6633 UNTIL j>=i
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6634 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6635 ENDWHILE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6636 WRITE #ProcPath,"TMode .1 pause"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6637 WRITE #ProcPath,"Dir e "+SrcDir
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6638 IF DestDir&lt;>"" THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6639 WRITE #ProcPath,"Dir e "+DestDir
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6640 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6641 CLOSE #DirPath
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6642 CLOSE #ProcPath
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6643 SHELL "del procmaker...dir"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6644 PRINT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6645 INPUT "Another ? ",response
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6646 UNTIL response&lt;>"Y" AND response&lt;>"y"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6647 IF response&lt;>"B" AND response&lt;>"b" THEN
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6648 BYE
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6649 ENDIF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6650 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6651
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6652 <programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6653 ***************
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6654 * INKEY - a subroutine for BASIC09 by Robert Doggett
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6655
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6656 * Called by: RUN INKEY(StrVar)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6657 * RUN INKEY(Path, StrVar)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6658 * Inkey determines if a key has been typed on the given path
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6659 * (Standard Input if not specified), and if so, returns the next
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6660 * character in the String Variable. If no key has been type, the
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6661 * null string is returned. If a path is specified, it must be
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6662 * either type BYTE or INTEGER.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6663
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6664 0021 TYPE set SBRTN+OBJCT
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6665 0081 REVS set REENT+1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6666
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6667 0000 87CD005E mod InKeyEnd,InKeyNam,TYPE,REVS
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6668 ,InKeyEnt,0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6669 000D 496E6B65 InKeyNam fcs "Inkey"
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6670 D 0000 org 0 Parameters
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6671 D 0000 Return rmb 2 Return addr of caller
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6672 D 0002 PCount rmb 2 Num of params following
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6673 D 0004 Param1 rmb 2 1st param addr
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6674 D 0006 Length1 rmb 2 size
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6675 D 0008 Param2 rmb 2 2nd param addr
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6676 D 000A Length2 rmb 2 size
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6677 0012 3064 InKeyEnt leax Param1,S
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6678 0014 EC62 ldd PCount,S Get parameter count
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6679 0016 10830001 cmpd #1 just one parameter?
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6680 001A 2717 beq InKey20 ..Yes; default path A=0
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6681 001C 10830002 cmpd #2 Are there two params?
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6682 0020 2635 bne ParamErr No, abort
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6683 0022 ECF804 ldd [Param1,S] Get path number
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6684 0025 AE66 ldx Length1,S
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6685 0027 301F leax -1,X byte available?
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6686 0029 2706 beq InKey10 ..Yes; (A)=Path number
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6687 002B 301F leax -1,X Integer?
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6688 002D 2628 bne ParamErr ..No; abort
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6689 002F 1F98 tfr B,A
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6690 0031 3068 InKey10 leax Param2,S
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6691 0033 EE02 InKey20 ldu 2,X length of string
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6692 0035 AE84 ldx 0,X addr of string
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6693 0037 C6FF ldb #$FF
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6694 0039 E784 stb 0,X Initialize to null str
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6695 003B 11830002 cmpu #2 at least two-byte str?
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6696 003F 2502 blo InKey30 ..No
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6697 0041 E701 stb 1,X put str terminator
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6698 0043 C601 InKey30 ldb #SS.Ready
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6699 0045 103F8D OS9 I$GetStt is there an data ready?
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6700 0048 2508 bcs InKey90 ..No; exit
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6701 004A 108E0001 ldy #1
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6702 004E 103F89 OS9 I$Read Read one byte
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6703 0051 39 rts
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6704 0052 C1F6 InKey90 cmpb #E$NotRdy
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6705 0054 2603 bne InKeyErr
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6706 0056 39 rts (carry clear)
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6707 0057 C638 ParamErr ldb #E$Param Parameter Error
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6708 0059 43 InKeyErr coma
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6709 005A 39 rts
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6710 005B 1A6926 emod
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6711 005E InKeyEnd equ *
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6712 </programlisting>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6713
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6714 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6715 </appendix>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6716 <appendix>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6717 <title>Quick Reference</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6718 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6719
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6720
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6721 <table frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6722 <title>System Mode Commands</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6723 <tgroup cols="5">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6724 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6725 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6726 <entry>$</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6727 <entry>CHX</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6728 <entry>EDIT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6729 <entry>LOAD</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6730 <entry>RENAME</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6731 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6732 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6733 <entry>BYE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6734 <entry>DIR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6735 <entry>KILL</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6736 <entry>MEM</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6737 <entry>RUN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6738 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6739 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6740 <entry>CHD</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6741 <entry>E</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6742 <entry>LIST</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6743 <entry>PACK</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6744 <entry>SAVE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6745 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6746 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6747 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6748 </table>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6749
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6750
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6751 <table frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6752 <title>Edit Mode Commands</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6753 <tgroup cols="5">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6754 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6755 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6756 <entry>+</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6757 <entry>&lt;cr></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6758 <entry>c*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6759 <entry>l*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6760 <entry>r*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6761 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6762 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6763 <entry>+*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6764 <entry>&lt;line #></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6765 <entry>d</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6766 <entry>q</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6767 <entry>s</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6768 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6769 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6770 <entry>-</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6771 <entry>&lt;space></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6772 <entry>d*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6773 <entry>r</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6774 <entry>s*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6775 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6776 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6777 <entry>-*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6778 <entry>c</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6779 <entry>l</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6780 <entry></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6781 <entry></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6782 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6783 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6784 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6785 </table>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6786
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6787
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6788 <table frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6789 <title>Debug Mode Commands</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6790 <tgroup cols="5">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6791 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6792 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6793 <entry>$</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6794 <entry>DEG</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6795 <entry>LET</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6796 <entry>Q</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6797 <entry>STEP</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6798 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6799 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6800 <entry>BREAK</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6801 <entry>DIR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6802 <entry>LIST</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6803 <entry>RAD</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6804 <entry>TROFF</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6805 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6806 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6807 <entry>CONT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6808 <entry>END</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6809 <entry>PRINT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6810 <entry>STATE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6811 <entry>TRON</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6812 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6813 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6814 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6815 </table>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6816
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6817
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6818
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6819 <table frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6820 <title>Program Reserved Words</title>
535
30480200b0f1 Some attributes were not quote, so xmlto complained about them
roug
parents: 101
diff changeset
6821 <tgroup cols="5">
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6822 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6823 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6824 <entry>ABS</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6825 <entry>DIR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6826 <entry>INT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6827 <entry>PEEK</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6828 <entry>SQR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6829 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6830 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6831 <entry>ACS</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6832 <entry>DO</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6833 <entry>INTEGER</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6834 <entry>PI</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6835 <entry>SQRT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6836 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6837 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6838 <entry>ADDR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6839 <entry>ELSE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6840 <entry>KILL</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6841 <entry>POKE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6842 <entry>STEP</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6843 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6844 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6845 <entry>AND</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6846 <entry>END</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6847 <entry>LAND</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6848 <entry>POS</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6849 <entry>STOP</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6850 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6851 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6852 <entry>ASC</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6853 <entry>ENDEXIT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6854 <entry>LEFT$</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6855 <entry>PRINT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6856 <entry>STR$</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6857 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6858 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6859 <entry>ASN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6860 <entry>ENDIF</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6861 <entry>LEN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6862 <entry>PROCEDURE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6863 <entry>STRING</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6864 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6865 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6866 <entry>ATN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6867 <entry>ENDLOOP</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6868 <entry>LET</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6869 <entry>PUT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6870 <entry>SUBSTR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6871 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6872 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6873 <entry>BASE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6874 <entry>ENDWHILE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6875 <entry>LNOT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6876 <entry>RAD</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6877 <entry>TAB</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6878 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6879 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6880 <entry>BOOLEAN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6881 <entry>EOF</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6882 <entry>LOG</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6883 <entry>READ</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6884 <entry>TAN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6885 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6886 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6887 <entry>BYE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6888 <entry>ERR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6889 <entry>LOG10</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6890 <entry>REAL</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6891 <entry>THEN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6892 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6893 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6894 <entry>BYTE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6895 <entry>ERROR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6896 <entry>LOOP</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6897 <entry>REM</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6898 <entry>TO</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6899 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6900 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6901 <entry>CHAIN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6902 <entry>EXEC</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6903 <entry>LOR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6904 <entry>REPEAT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6905 <entry>TRIM$</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6906 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6907 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6908 <entry>CHD</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6909 <entry>EXITIF</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6910 <entry>LXOR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6911 <entry>RESTORE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6912 <entry>TROFF</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6913 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6914 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6915 <entry>CHR$</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6916 <entry>EXP</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6917 <entry>MID$</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6918 <entry>RETURN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6919 <entry>TRON</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6920 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6921 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6922 <entry>CHX</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6923 <entry>FALSE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6924 <entry>MOD</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6925 <entry>RIGHT$</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6926 <entry>TRUE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6927 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6928 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6929 <entry>CLOSE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6930 <entry>FIX</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6931 <entry>NEXT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6932 <entry>RND</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6933 <entry>TYPE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6934 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6935 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6936 <entry>COS</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6937 <entry>FLOAT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6938 <entry>NOT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6939 <entry>RUN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6940 <entry>UNTIL</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6941 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6942 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6943 <entry>CREATE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6944 <entry>FOR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6945 <entry>ON</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6946 <entry>SEEK</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6947 <entry>UPDATE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6948 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6949 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6950 <entry>DATA</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6951 <entry>GET</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6952 <entry>OPEN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6953 <entry>SGN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6954 <entry>USING</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6955 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6956 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6957 <entry>DATE$</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6958 <entry>GOSUB</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6959 <entry>OR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6960 <entry>SHELL</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6961 <entry>VAL</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6962 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6963 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6964 <entry>DEG</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6965 <entry>GOTO</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6966 <entry>PARAM</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6967 <entry>SIN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6968 <entry>WHILE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6969 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6970 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6971 <entry>DELETE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6972 <entry>IF</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6973 <entry>PAUSE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6974 <entry>SIZE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6975 <entry>WRITE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6976 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6977 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6978 <entry>DIM</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6979 <entry>INPUT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6980 <entry></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6981 <entry>SQ</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6982 <entry>XOR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6983 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6984 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6985 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6986 </table>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6987
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6988
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6989 <table frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6990 <title>&b09; Statements</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6991 <tgroup cols="5">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6992 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6993 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6994 <entry>BASE 0</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6995 <entry>ELSE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6996 <entry>GOTO</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6997 <entry>OPEN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6998 <entry>RETURN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
6999 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7000 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7001 <entry>BASE 1</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7002 <entry>END</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7003 <entry>IF/THEN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7004 <entry>PARAM</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7005 <entry>RUN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7006 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7007 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7008 <entry>BYE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7009 <entry>ENDEXIT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7010 <entry>INPUT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7011 <entry>PAUSE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7012 <entry>SEEK</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7013 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7014 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7015 <entry>CHAIN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7016 <entry>ENDIF</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7017 <entry>KILL</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7018 <entry>POKE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7019 <entry>SHELL</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7020 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7021 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7022 <entry>CHD</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7023 <entry>ENDLOOP</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7024 <entry>LET</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7025 <entry>PRINT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7026 <entry>STOP</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7027 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7028 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7029 <entry>CHX</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7030 <entry>ENDWHILE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7031 <entry>LOOP</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7032 <entry>PUT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7033 <entry>TROFF</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7034 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7035 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7036 <entry>CLOSE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7037 <entry>ERROR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7038 <entry>NEXT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7039 <entry>RAD</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7040 <entry>TRON</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7041 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7042 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7043 <entry>CREATE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7044 <entry>EXITIF/THEN</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7045 <entry>ON ERROR GOTO</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7046 <entry>READ</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7047 <entry>TYPE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7048 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7049 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7050 <entry>DATA</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7051 <entry>FOR/TO/STEP</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7052 <entry>ON/GOSUB</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7053 <entry>REM</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7054 <entry>UNTIL</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7055 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7056 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7057 <entry>DEG</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7058 <entry>GET</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7059 <entry>ON/GOTO</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7060 <entry>REPEAT</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7061 <entry>WHILE/DO</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7062 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7063 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7064 <entry>DELETE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7065 <entry>GOSUB</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7066 <entry></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7067 <entry>RESTORE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7068 <entry>WRITE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7069 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7070 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7071 <entry>DIM</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7072 <entry></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7073 <entry></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7074 <entry></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7075 <entry></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7076 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7077 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7078 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7079 </table>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7080
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7081
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7082 <table frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7083 <title>Transcendental Functions</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7084 <tgroup cols="4">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7085 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7086 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7087 <entry>ACS (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7088 <entry>COS (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7089 <entry>LOG10 (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7090 <entry>SIN (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7091 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7092 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7093 <entry>ASN (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7094 <entry>EXP (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7095 <entry>PI</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7096 <entry>TAN (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7097 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7098 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7099 <entry>ATN (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7100 <entry>LOG (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7101 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7102 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7103 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7104 </table>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7105
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7106
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7107 <table frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7108 <title>Numeric Functions</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7109 <tgroup cols="4">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7110 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7111 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7112 <entry>ABS (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7113 <entry>LAND (m,n)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7114 <entry>MOD (m,n)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7115 <entry>SQ (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7116 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7117 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7118 <entry>FIX (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7119 <entry>LNOT (m,n)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7120 <entry>RND (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7121 <entry>SQR (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7122 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7123 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7124 <entry>FLOAT (m)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7125 <entry>LOR (m,n)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7126 <entry>SGN (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7127 <entry>SQRT (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7128 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7129 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7130 <entry>INT (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7131 <entry>LXOR (m,n)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7132 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7133 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7134 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7135 </table>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7136
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7137 <table frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7138 <title>String Functions</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7139 <tgroup cols="4">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7140 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7141 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7142 <entry>ASC (char$)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7143 <entry>LEFT$ (str$,m)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7144 <entry>RIGHT$ (str$,m)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7145 <entry>TRIM$ (str$)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7146 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7147 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7148 <entry>CHR$ (m)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7149 <entry>LEN (str$)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7150 <entry>STR$ (x)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7151 <entry>VAL(str$)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7152 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7153 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7154 <entry>DATE$</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7155 <entry>MID$ (str$,m,n)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7156 <entry>SUBSTR(st1$,st2$)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7157 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7158 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7159 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7160 </table>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7161
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7162 <table frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7163 <title>Miscellaneous Functions</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7164 <tgroup cols="4">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7165 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7166 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7167 <entry>ADDR (var)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7168 <entry>FALSE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7169 <entry>POS</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7170 <entry>TAB (m)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7171 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7172 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7173 <entry>EOF (#path)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7174 <entry>PEEK (addr)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7175 <entry>SIZE (var)</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7176 <entry>TRUE</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7177 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7178 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7179 <entry>ERR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7180 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7181 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7182 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7183 </table>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7184
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7185 <table frame="none">
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7186 <title>Operator Precedence</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7187 <tgroup cols="7">
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7188 <colspec colname="c1"/>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7189 <colspec colname="c2"/>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7190 <colspec colname="c3"/>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7191 <colspec colnum="7" colname="c7"/>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7192 <spanspec spanname="firstop" namest="c2" nameend="c2"/>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7193 <spanspec spanname="secondop" namest="c3" nameend="c7"/>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7194 <spanspec spanname="onlyop" namest="c2" nameend="c7"/>
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7195 <spanspec spanname="all" namest="c1" nameend="c7"/>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7196 <tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7197 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7198 <entry>highest -></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7199 <entry spanname="firstop">NOT</entry>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7200 <entry spanname="secondop">-(negate)</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7201 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7202 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7203 <entry spanname="firstop">^</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7204 <entry spanname="secondop">**</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7205 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7206 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7207 <entry spanname="firstop">*</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7208 <entry spanname="secondop">/</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7209 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7210 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7211 <entry spanname="firstop">+</entry>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7212 <entry spanname="secondop">-</entry>
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7213 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7214 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7215 <entry spanname="firstop">></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7216 <entry>&lt;</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7217 <entry>&lt;></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7218 <entry>=</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7219 <entry>>=</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7220 <entry>&lt;=</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7221 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7222 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7223 <entry spanname="onlyop">AND</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7224 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7225 <row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7226 <entry>lowest -></entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7227 <entry spanname="firstop">OR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7228 <entry spanname="secondop">XOR</entry>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7229 </row>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7230 </tbody>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7231 </tgroup>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7232 </table>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7233
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7234
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7235 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7236 </appendix>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7237 <appendix>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7238 <title>&b09; Error Codes</title>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7239 <para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7240 <literallayout>
649
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7241 10 - Unrecognized Symbol
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7242 11 - Excessive Verbage (too many keywords or symbols)
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7243 12 - Illegal Statement Construction
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7244 13 - I-code Overflow (need more workspace memory)
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7245 14 - Illegal Channel Reference (bad path number given)
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7246 15 - Illegal Mode (Read/Write/Update/Dir only)
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7247 16 - Illegal Number
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7248 17 - Illegal Prefix
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7249 18 - Illegal Operand
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7250 19 - Illegal Operator
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7251
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7252 20 - Illegal Record Field Name
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7253 21 - Illegal Dimension
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7254 22 - Illegal Literal
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7255 23 - Illegal Relational
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7256 24 - Illegal Type Suffix
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7257 25 - Too-Large Dimension
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7258 26 - Too-Large Line Number
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7259 27 - Missing Assignment Statement
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7260 28 - Missing Path Number
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7261 29 - Missing Comma
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7262
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7263 30 - Missing Dimension
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7264 31 - Missing DO Statement
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7265 32 - Memory Full (need more workspace memory)
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7266 33 - Missing GOTO
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7267 34 - Missing Left Parenthesis
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7268 35 - Missing Line Reference
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7269 36 - Missing Operand
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7270 37 - Missing Right Parenthesis
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7271 38 - Missing THEN statement
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7272 39 - Missing TO
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7273
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7274 40 - Missing Variable Reference
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7275 41 - No Ending Quote
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7276 42 - Too Many Subscripts
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7277 43 - Unknown Procedure
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7278 44 - Multiply-Defined Procedure
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7279 45 - Divide by Zero
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7280 46 - Operand Type Mismatch
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7281 47 - String Stack Overflow
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7282 48 - Unimplemented Routine
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7283 49 - Undefined Variable
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7284
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7285 50 - Floating Overflow
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7286 51 - Line with Compiler Error
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7287 52 - Value out of Range for Destination
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7288 53 - Subroutine Stack Overflow
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7289 54 - Subroutine Stack Underflow
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7290 55 - Subscript out of Range
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7291 56 - Parameter Error
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7292 57 - System Stack Overflow
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7293 58 - I/O Type Mismatch
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7294 59 - I/O Numeric Input Format Bad
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7295
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7296 60 - I/O Conversion: Number out of Range
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7297 61 - Illegal Input Format
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7298 62 - I/O Format Repeat Error
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7299 63 - I/O Format Syntax Error
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7300 64 - Illegal Path Number
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7301 65 - Wrong Number of Subscripts
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7302 66 - Non-Record-Type Operand
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7303 67 - Illegal Argument
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7304 68 - Illegal Control Structure
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7305 69 - Unmatched Control Structure
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7306
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7307 70 - Illegal FOR Variable
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7308 71 - Illegal Expression Type
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7309 72 - Illegal Declarative Statement
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7310 73 - Array Size Overflow
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7311 74 - Undefined Line Number
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7312 75 - Multiply-Defined Line Number
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7313 76 - Multiply-Defined Variable
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7314 77 - Illegal Input Variable
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7315 78 - Seek Out of Range
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7316 79 - Missing Data Statement
28d9e5a4ef52 XMLified
roug
parents: 535
diff changeset
7317 80 - Print Buffer Overflow
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7318 </literallayout>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7319
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7320 Error codes above 80 are those used by OS-9 or other external programs.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7321 Consult the "OS-9 User's Guide" for a list of error codes and explanations.
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7322 </para>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7323 </appendix>
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7324
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7325
1015
08fcfa9b150a The gfx module is now in a seperate file
roug
parents: 973
diff changeset
7326 &gfxapp;
973
07a25643d033 Added gfx2 information
roug
parents: 649
diff changeset
7327 &gfx2app;
24
01a6e267aa38 Added the Basic09 Reference Manual
roug
parents:
diff changeset
7328 </book>