Professional Documents
Culture Documents
ECMA-116 Full Basic
ECMA-116 Full Basic
CO
ER
ANU
CTU
ERS
June 1986
ASSOCI
ON
I H Rue dn Hhi'me
BRIEF HISTORY
The f irst version of the language BASIC, acronym for Beginner 1 s A l l -purpose
Instruction Code , was produced in June 1965 at the Dartmouth Co l lege in the USA .
Symbo l ic
In January 197 8 , ECMA publ ished a Standard for Minimal BASIC, ECMA- 5 5 , prepared in coopera
tion with ANSI X3J2 and ful ly compatible with the corresponding ANSI standard . This Stan
dard ECMA - 5 5 served as a bas is for the ISO Standard on Minimal BASIC.
With the continuation of the work , a draft Standard for ful l BASIC was agreed by ANSI X3J2 ,
EWICS TC2 and ECMA / TC2 1 in January 1985 . This draft is composed of a mandatory Core module
and f ive optional modules .
Starting from this draf t , ECMA / TC2 1 prepared a Standard for ful ly def ined subsets of the
language . These subsets , cal led ECMA BASIC-! and ECMA BASIC- 2 , are des igned for business
app l ications , requiring extended f i le fac i l ities . ECMA BASIC- 1 has no exception hand l ing
fac i l ities and a reduced set of f i le operations . In add ition, a l l the keywords in
ECMA BASIC-1 are reserved word s , reducing the comp lexity of the interpreter or comp i ler
needed . ECMA BASIC-2 provides ful l exception handl ing capab i l ities , ful l f i le operations
and f ixed decimal capab i l ities . The set of reserved words is minimal . Both subsets provide
the full f l ow control capab i l ities provided in the ANSI standard . An additional module
( ECMA GRAPHICS ) provides a minimum of graphic capab i lities and can be used with either
subset .
Compatibi l ity with the ANSI standard has been a primary design obj ective , and the ECMA
Standard i s ful ly upward compatible with corresponding imp lementations of the ANSI
Standard .
- i -
TABLE OF CONTENTS
1.
2.
3.
INTRODUCTION
1.1
1.2
2
2
Scope
Related Standards
CONFORMANCE
2. 1
2.2
2.3
2.4
2.5
4
4
5
5
5
Program Conformance
Imp lementation Conformance
Errors
Exceptions
Relationship to the ANSI Standard
4.
5.
BASIC
Batch-mode
Can
End - of - line
Error
Exception
External
Identi fier
Interactive mode
Internal
Keyword
Line
Machine Infinitesimal
May
Native
Overf l ow
Print Zone
Program Unit
Reserved Word
Rounding
Sha l l
S ignificant Digits
Truncation
Underf low
8
8
9
9
9
10
10
10
10
10
10
10
11
11
11
11
11
11
11
12
12
12
12
13
13
13
13
PROGRAM ELEMENTS
15
4.1
4.2
4.3
4.4
15
16
19
19
Characters
Programs, Lines and B locks
Program Annotation
Identif iers
NUMBERS
23
5.1
5.2
5.3
5.4
5.5
23
24
25
26
31
Numeric Constants
Numeric Variables
Numer ic Express ions
Imp lementation-Suppl ied Numeric Functions
Numeric Assignment Statement
- ii -
5.6
6.
7.
8.
9.
31
STRINGS
35
6.1
6.2
6.3
6 .4
6.5
6.6
35
35
37
38
41
42
String Constants
String Variables
String Express ion
Implementation- Supp l ied String Functions
String Ass ignment Statements
String Declarations
ARRAYS
45
7.1
7 .2
7.3
45
47
50
Array Declarations
Numeric Arrays
String Arrays
CONTROL STRUCTURES
53
8.1
8.2
8.3
8.4
53
54
56
58
PROGRAM SEGMENTATION
63
9.1
9.2
9.3
63
68
73
Internal Data
Input
Output
Formatted Output
Array Input and Output
F i le
F i le
F i le
File
F i le
76
77
80
84
88
93
1 1 . FILES
11 . 1
11 . 2
11. 3
11.4
11 . 5
76
Operations
Pointer Manipulation
Data Creation
Data Retrieval
Data Modi f ication ( BASIC-2 only )
98
108
111
1 18
125
130
130
135
138
138
141
143
146
147
149
152
- iii -
155
APPENDICES
159
160
162
163
167
APPENDIX 5 -
183
194
196
General Description
Syntax
Examples
Semantics
Exceptions
Remarks
- 1 -
1.
I N T RO D UCT I O N
- 2 -
1.
INTRODUCTION
This Standard is des igned to promote the interchangeab i l ity of BASIC programs among a var i
ety of automatic data process ing systems . Programs conforming t o this Standard wil l b e said
to be written in ECMA BASIC .
Two leve l s of the language are specified in this Standard: ECMA BASIC - 1 and ECMA BASIC-2 .
In addition this Standard def ines an optional Graphics module .
1.1
Scope
This Standard estab lishes:
The syntax of programs written in ECMA BASIC .
- The formats of data and the min imum precis ion and range of numeric representations
and the minimum length and set of characters in strings which are acceptable as input
to an automatic data process ing system being contro l led by a program written in
ECMA BASIC .
- The fo rmats of data and the min imum prec1s1on and range of numeric representations
and the min imum length and set of characters in strings which can be generated as
output by an automatic data process ing system being contro l led by a program written
in E CMA BASIC .
- The s emantic rules for interpreting the meaning of a program written in ECMA BASIC .
- The errors and exceptional c ircums tances which sha l l be detected .
A lthough the BASIC language was origina l ly designed pr imar i ly for interactive use , this
Standard describes a language that is not so restricted . This Standard is not meant to
preclude the use of any particular imp lementation technique , for examp le interpreters ,
incremental or one-pass compilers .
1.2
Related S tandards
ECMA-6
ECMA- 3 5
E CMA - 5 3
E CMA - 5 5
ISO 2014
ISO 2 7 1 1
ISO 3 307
ISO 7942
IEC 559
ANSI X3 . 113 - 198X
- 3 -
2.
CONF O RMANCE
- 4 -
2.
CONFORMANCE
This Standard speci f ies two levels of the language: ECMA BASIC - 1 and ECMA BASIC- 2 . In addi
tion this Standard defines a Graphics modu l e .
ECMA BASIC-1 includes a l l the parts defined i n Section 4 t o 12 , with the exception of those
portions of Section 11 that describes enhanced files and Section 12 . 1 , Exception Handling .
A l l the keywords , l isted i n 3.2 . 19 under the heading BASIC-1 are reserved words .
ECMA BASIC-2 includes a l l the parts defined in Section 4 to 12 and in Section 15 . The key
words , l isted in 3 . 2 . 19 under the heading BASIC-2 are reserved words .
The graphics module is specified in section 13. It is optional , and it can be used together
either with ECMA BASIC-1 or ECMA BASIC- 2 .
There are two aspects of the confo rmance to the language defined in this Standard: confor
mance by a program written in the ECMA BASIC language , and conformance by an imp lementation
which processes such programs .
Broad ly speaking , the confo rmance requirements are structured so that any program conform
ing to this standard wil l produce the same results when executed by any implementation con
forming to the standard ( though some implementation-defined features are noted in Appendix
3).
2.1
Program Conformanc e
A program conforms t o this Standard only when
- the program and each statement or other syntactic e l ement contained therein is syntac
tica l ly valid according to the syntactic rules specified by this Standard as belonging
to that leve l , and
- the program as a who le vio lates none of the g lobal constraints imposed by this level
of the Standard on the app l ication of the syntactic rules .
2.2
- 5 -
2.3
Errors
This Standard does not include spec ific requirements for reporting
syntactic errors in
Exceptions
- 6 -
The reverse wi l l not always be true . In view of the modular nature of the ANSI standard ,
programs conforming to the ANSI standards w i l l run on an ECMA BASIC imp lementations only
if they use the set of fac i l ities defined in the ECMA BASIC Standard . Rea l -time programs
w i l l not
run
A further d ifference exists in reserved words . A l l keywords defined in ECMA BASIC- 1 are
reserved and cannot be used as identifiers . Only a l imited number of keywords is re
served in the ANSI Standard . Thus programs written in ECMA BASIC- 1 w i l l run on an ANSI
implementation, with the l imitations defined above . A program written in ANSI BASIC , and
which uses only the fac i litites defined in ECMA BASIC- 1 , is not granted to run on an
ECMA BASIC- 1 imp lementation, unless the l imitations on identifiers have been observed .
The ECMA graphics module is a subset of the ANSI one . Thus programs conforming to the
ECMA module wi l l run on an ANSI implementation, but programs conforming to the ANSI mod
ule w i l l not run on an ECMA imp lementation unless they use only the fac i l ities defined
in ECMA BASIC .
- 7 -
3.
S YN TAX
S P E C I F I CAT I O N AN D
DEF I N I T I ONS
- 8 -
3.
3.1
period integer
o I 1 I 2 I 3 I 4 I 5 I 6 I 7 I 8 I 9
E s ign? integer
indicates tl1at an exrad cons ists of the letter E or e followed by an optional s ign fol
lowed by an integer .
Parentheses may be used to group sequences of metanames together. For example ,
variable-list = variable ( comma variable ) l'<
- 9 -
is equivalent to
s ignif icand = ( integer (period ) ? ) I ( ( intege r ) ? fraction)
Spaces in the syntax are used to separate terms in a production from each other . Special
conventions are observed regarding spaces in BASI C programs ( see 4.1).
Some syntactic objects are defined by more than one production . For
example , in 5.2 we f ind
s imple-variable > s imple-numeric-variable
and in 6 . 2 we f ind
s imple-variable > s imple-string-variable .
Those two productions are equivalent to the s ingle production below (provided no other
definition of s imple-variable exists )
s imple-variable = s imple-numeric-variable I s imple- string-variable .
In all cases , a greater-than-s ign is used in place of an equals - s ign to indicate a mul
tiple definition , such definitions are equivalent to a s ingle definition containing the
various right-hand s ides separated by slants .
In order to maintain the same numbering of productions in the ECMA and ANSI standards
productions not used in the ECMA Standard are identified by the construct: [deleted] .
As an illustration of the method of syntax specification, following is a description of
the syntax of this method . The terminal metanames occurring below are defined in 4. 1 .
1 . production
2. metaname
3. metacharacter
4.
5.
6.
7.
8.
spaces
syntax-expression
s yntax- te rm
syntax- factor
syntax-primary
9 . repetition
3.2
- 10 -
3. 2. 1
BASIC
A term applied as a name to members of a special class of languages which possess
similar syntaxes and seman tic meanings, acronym for Beginner's All-purpose Symbolic
Instruction Code.
3. 2. 2
Batch-mode
The processing of programs in an environment where no provision is made for user in
teraction.
3. 2. 3
Can
End-of-line
The character(s) or indicator which identifies the termination of a line. Lines of
three kinds may be identified in BASIC: program lines, print lines, and input-reply
lines. End-of-lines may vary between the three cases and may also vary depending upon
context. Thus, for example, the end-of-line in an input-reply may vary on a given
system depending on the source for input being used in interactive or batch mode.
Typical examples of end-of-line are carriage-return, carriage-return line-feed, and
end of record (such as end of card).
3. 2. 5
Error
A flaw in the syntax of a program which causes the program to be incorrect.
3. 2. 6
Exception
A circumstance arising in the course of executing a program when an implementation
recognizes that the semantic rules of this Standard cannot be followed or that some
resource constraint is about to be exceeded. Certain exceptions (nonfatal exceptions)
may be handled by automatic recovery procedures specified in this Standard. These and
other exceptions may also be handled by recovery procedures specified in the program
(see 12. 1, BASIC-2 only). If no recovery procedure is given in this Standard (fatal
exceptions) or if restrictions imposed by the hardware or operating environment make
it impossible to follow the given procedure, and if no recovery procedure is speci
fied in the program, then the way in which the exception is handled depends on the
context. If the exception occurred in an invocation of a function, picture, or sub
program, then the exception is 'propagated back' to the invoking statement of the in
voking program unit (see 12. 1, BASIC-2 only). If this propagation procedure reaches
the main program, or if the exception occurred in the main program, then the excep
tion shall be handled by terminating the program.
3. 2. 7
External
With respect to procedures, refers to a procedure lexically not contained within a
larger program-unit.
3. 2. 8
Identifier
A character string used to name a variable, an array, an array-value, an exception
handler, a function, subprogram, or a program.
3. 2. 9
Interactive mode
The processing of programs in an environment which permits the user to respond di
rectly to the actions of individual programs and to control the initiation and termi
nation of these programs.
- 11 -
3.2.10 Internal
With respect to record-type, refers to data representations such that both the type
and exact value of the written data are preserved and retrievable by subsequent read
operations.
With respect to procedures, refers to a procedure lexically
larger program: unit and sharing data with that unit.
contained within a
3.2.ll Keyword
A character string, usually with the spelling of a corrunonly used or mnemonic 1vord,
which provides a distinctive identification of a
statement or a component of a
statement of a prograrruning language.
The keywords in ECMA BASIC are:
ACCESS, AND, ANGLE, AREA, ARITID1ETIC, ARRAY, ASK, AT, BASE, BEGIN, BREAK, CALL, CASE,
CAUSE, CHAIN, CLEAR, CLIP, CLOSE, COLLATE, COLOR, DATA, DATUM, DEBUG, DECIMAL,
DECLARE, DEF, DEGREES, DELETE, DEVICE, DIM, DISPLAY, DO , ELAPSED, ELSE, ELSEIF, END,
ERASE, ERASABLE, EXIT, EXLINE, EXTERNAL, EXTYPE, FILETYPE, FIXED, FOR, FUNCTION, GO,
GOSUB, GOTO, HANDLER, IF, IMAGE, IN, INPUT, INTERNAL, IS, KEY, KEYED, LENGTH, LET,
LINE, LINES, LOOP, MARGIN, MAT, MISSING, NAME, NATIVE, NEXT , NOT, NUMERIC, OF, OFF,
ON, OPEN, OPTION, OR, ORGANIZATION, OUTIN, OUTPUT, POINT, POINTER, POINTS, PRINT,
PROGRAM, PROMPT, RADIANS, RANDOMIZE, READ, RECORD, RECSIZE, RECTYPE, RELATIVE, REM ,
REST, RESTORE, RETRY, RETURN, REWRITE, SAME, SELECT, SEQUENTIAL, SET, SETTER, SIZE,
SKIP, STANDARD, STATUS, STEP, STOP, STRING, STYLE, SUB, TAB, TEMPLATE, TEXT, THEN ,
THERE , TIME, TIMEOUT, TO, TRACE, UNTIL, USE, USING, VARIABLE, VIEWPORT, WHEN, WHILE,
WINDOW, WITH, WRITE, ZONEWIDTH.
Keywords may also be spelled using lower-case letters or mixed upper-case and lower
case letters.
3.2.12 Line
Two types of lines are described in the Standard, a physical line and a logical line.
A physical line is an ordered sequence of characters which terminates with an end-of
line. A physical line starts with a line-number or with an ampersand. A logical line
consists of a line-number followed by an ordered sequence of text where each line
continuation has logically been replaced by a space.
3.2.13 Machine Infinitesimal
The smallest positive value (other than zero) which can be represented and manipu
lated by a BASIC implementation.
3.2.14 !::!2Y
The word "may" is used in a permissive sense to indicate that a standard-conforming
implementation may or may not provide a particular feature.
3.2.15 Native
With respect to record-type, refers to a record with a specified structure for the
fields within the record, so as to be compatible with records generated by other lan
guages on the same system. With respect to numeric or string data, refers to data for
which certain
semantic rules are left implementation-defined (e.g. collating se
quence, precision) so as to be directly implementable on the host hardware.
3.2.16 OVerflow
With respect to numeric operations, the term applied to the condition which exists
when a prior operation has attempted to generate a result which exceeds MAXNUM (see
5.4.4), or which exceeds the maximum value that can be represented by the declared
- 12 -
the
term applied to the condition which exists when a prior operation has attempted to
generate a result which has more characters than can be contained in a string of max
imal length, as determined by the language processor. With respect to string assign
ment, the term applied to the condition which exists when a prior operation has at
tempted to assign a value that is longer than the declared or default maximum of a
string-variable or string-defined-function.
3.2.17 Print Zone
A contiguous set of character positions in a printed output line which may contain an
evaluated print-statement element.
3.2.1 8 Program Unit
A self-contained part of a BASIC program consisting either of the main-program, which
is the sequence of lines up to and including tl1e line containing an END statement, or
of an external-sub-de or external-function-de.
3.2.1 9 Reserved Hord
BASIC-1
A character string whose usage as a routine-identifier,
string-identifier or
DATE,
EXLINE,
EXTYPE, MAXNUM ,
PI,
ACCESS, AND,
BEGIN,
BREAK,
CALL, CASE,
DATUM,
DEBUG,
DECIMAL, DECLARE,
DO,
ELAPSED,
FOR,
ELSE,
FUNCTION,
LENGTH,
LET,
LINE,
NOT, Nill1ERIC,
RECTYPE, REM,
TEXT,
THEN ,
ELSEIF,
LINES,
DEF,
END,
GOSUB,
GOTO,
LOOP,
CLEAR,
CLIP,
DEGREES,
ERASE,
CLOSE,
DEVICE,
ERASABLE,
GRAPH,
1ARGIN,
IF,
MAT,
COLLATE,
EXIT,
IMAGE,
COLOR,
DATA,
INPUT,
MISSING,
NAME,
FILETYPE,
INTERNAL,
NATIVE,
IS,
NEXT,
POINTER, POINTS,
SIZE, SKIP,
GO,
CHAIN,
PRINT, PROGRAM,
PROMPT,
REST, RESTORE,
RETURN,
STANDARD, STATUS,
STEP,
THERE,
TIMEOUT,
TO,
RADIANS,
SAt1E,
STOP,
TRACE,
RANDOMIZE, READ ,
SELECT,
STREAM,
UNTIL,
RECSIZE,
SEQUENTIAL, SET,
STRING,
USING,
STYLE,
VARIABLE,
SETTER,
SUB,
TAB,
VIEWPORT,
but are
string-identifier or
DATE,
EXLINE,
EXTYPE,
MAXNUM ,
PI,
- 13 -
3.2. 21 Shall
The word "shall" is used in an imperative sense to indicate that a program is re
quired to be constructed , or that an implementation is required to act , as specified
in order to meet the constraints of s tandard conformance .
3. 2. 22 Significant Digits
The contiguous sequence of digits between the high-order nonzero digit and the low
order d igit , without regard for the location of the radix point . Commonly , in a nor
malized floating point internal representation , only the significant d igits of a rep
resentation are maintained in the s ignificand . In fixed-point representation, the low
order d igit i s the rightmost one explicitly spec i f ied , and non-significant high order
d igits may be maintained .
3. 2. 23 Truncation
The process by which a representation of a value with lower precision is generated
from a representation of higher precis ion by merely deleting the unwanted low-order
digits of the original representation .
3. 2. 24 Underflow
With respect to numeric operations , the terms applied to the condition which exists
when a prior operation has attempted to generate a result , other than zero , which is
les s in magnitude than machine infinitesimal .
- 14 -
4.
P ROGRAM E L E ME N T S
- 15 -
4.
PROGRAM ELEMENTS
A BASIC program i s a sequence of l ines containing statements . Each l ine i s itself a se
quence of character s .
4.1
Characters
4 . 1.1
General Description
The character set for ECMA BASIC is contained in the Standard ECMA-6 .
4 . 1. 2
Syntax
1 . character
2. quoted- string-character
3 . non-quote-character
4. double-quote
5. unquoted - string-character
6. p lain- string-character
7 . digit
8.
9.
10 .
11 .
letter
upper- case- letter
lower-cas e - l etter
other character
quotation-mark I non-quote-character
double-quote I non-quote-character
ampersand I apostrophe I asterisk I c ircumflex-accent
I colon I comma I dol lar - sign I equal s - s ign I
exc lamation-mark I greater-than-s ign I
left-parenthesis I les s - than - s ign I
number- s ign I percent- s ign I question-mark
right-parenthes is I semicolon I s lant I
underl ine I unquoted- s tring-character
quotation-mark quotation-mark
space I p lain-str ing-character
minus- s ign
d igit I letter I period I p lus- s ign
4
3
01 1121 1 1 516171819
upper-case- letter I lower-case- letter
AIBICIDIEIFIGIHI I IJIKILIMINIOIPIQIRISIT IUIVIWIXIY IZ
alblcl dlelflglhliljlkl l lmlnlo lpl qlrlsltlulvlwlxlylz
[ imp lementation-defined]
The s yntax as described generates programs which contain no spaces other than those
occurring in remark-strings , in certain quoted- strings , unquoted- strings , and
l iteral-strings , or where the presence o f a space is exp l icitly indicated by the
metaname space.
Special conventions sha l l be observed regarding spaces . With the f o l l owing excep
tions , spaces may occur anywhere in a BASIC program without affecting the execution
of that program and may be used to improve the appearance and readab i lity of the pro
gram . Spaces sha l l not appear :
-
In addition, spaces which appear in quoted - s tring s , unquoted- strings , and format
str ings sha l l be s ignif icant ( though spaces which precede or fol low an unquoted
string are not part of that string ) .
A l l keywords in a program , when used as suc h , shal l be p receded and f o l lowed by some
character other than a letter, d igit , underl ine or dol lar - s ign. A keyword may also be
f o l l owed by an end - of - l ine .
4. 1.3
Examp les
None .
- 16 -
4. 1. 4
Semantics
The letters sha l l be the set of capital ( upper-case) and sma l l ( lower-case) latin
letters contained in the character set in pos itions 411 to 5110 and 611 to 7110 , re
spectivel y .
The digits sha l l be the set of Arabic d igits contained in the character set in posi
tion 310 to 319 .
The remaining characters sha l l correspond to the rema1n1ng graphic characters in po
s i t ion 210 to 211 5 , 3110 to 311 5 , 5114 , and 5115 of the ECMA character set .
The names of the characters are specified in Table 1 . Table 1 shall app ly when the
standard c o l lating sequence is in effect , either by default or by exp licit use of a
COLLATE option ( see 6. 4 , 6. 6 , and 8. 1 ) . The coding for the native col lating sequence
s ha l l be imp lementation-defined .
A l l characters other than letters denote themselves . Letters denote
themse lves
within quoted-strings , unquoted- strings and l ine- input-rep l ies . Corresponding upper
case-letters and lower-case- letters shal l be equivalent when used in identifiers and
keywords . Quoted- string-characters also denote themse lves , except for the double
quote, which denotes one occurrence of the quotation-mark in the value of the string .
4. 1 . 5
Exceptions
None .
4 . 1. 6
Remarks
Other-characters may be defined by an imp lementation to be part of the character set
for BASIC . These characters may be used in strings and may be accepted as characters
in data supp l ied in response to a reques t for input or generated as the value of the
CHR$ function ( see 6. 4 ) . The effects of these other-characters are imp l ementation
defined .
Programs written us ing other-characters ( except for end-of - l ine characters ) are not
themselves standard-conforming programs .
General Description
A BASIC program is a sequence of l ines . Each l ine contains a unique l ine-number which
fac i litates program editing and serves as a label for the s tatement contained in that
l ine .
A BASIC
program is d ivided logica l ly into a number of program-units The f irst of
these i s the main-program, which is terminated by an end - l ine . Fo l l owing the main
program may be zero or more external - sub-def or external -function-def . Certain
logical groupings of l ines within a BASIC program are cal led blocks .
4. 2. 2
Syntax
The syntax eleEDts available only in ECHA BASIC-2
1. program
2. program-name- l ine
3.
4.
5.
6.
program-name
main-program
unit-block
internal -proc- def
are
printed in bold.
- 17 -
7 . block
8. statement-line
9 . line - number
10 . statement
11 . declarative-statement
12 . imperative-statement
13.
14.
15.
16.
17 .
18.
19 .
20 .
21.
stop-s tatement
conditional-statement
tail
end-of-line
end-line
end-statement
procedure-part
procedure
remark-line
22. line
23 . program-unit
24 . l ine- continuat ion
A program shall be composed of a sequence of lines . Exactly one of these lines shall
be an end-line ; the lines up to and including this end-line constitutes the main
program.
- 18 -
in
ascending
line-number
order .
All
references t o
Lines shal l
line-numbers within
Examples
2 . 100 PROGRAM Graphic
&
( x,
&
y)
18 . 999 END
4.2.4
&
&
Semantics
The program-name- l ine is the operand of the chain-statement ( see 9 . 3 ) . The
relationship between the progranJ-name and the program-designator in a program
executing a chain-statement is imp lementation-defined . Parameters in the program
name-l ine are evaluated as described in 9 . 1 . Their scope is the main-program . For a
program executed in iso lation, tJ1e program-name has no effect . The effect of a
parameter - l ist in a program-name-line for a program executed in iso lation is
implementation-defined .
Line s in a program sha l l be executed in sequential order,
line, until
of
stop-statement
shal l
a l so
cause
termination
of
execution
of
the
Exceptions
None .
4.2.6
Remarks
References to non-existent line-numbers in a program-unit are sY11tax errors.
Imp lementations may therefore treat them as exceptions, if they are documented as
such .
- 19 -
Program Annotation
4.3.
4.3.1
General Description
BASIC programs may be annotated by comments at the end of program
separate remark-statements .
4.3 .2
l ines
or by
Syntax
REM remark- st ring
character'
tai l -comment
exc lamation-mark remark-string
1 . remark- statement
2 . remark-string
3 . nul l - s tatement
4 . tai l -comment
Examples
1. REH FINAL CHECK
4 . ! COMPUTE AVERAGE
4.3.4
Semantics
I f the execution of a program reaches a l ine containing a remark-statement or nul l
statement, then it sha l l proceed to the next l ine with no other effect .
A tail - comment has no effect upon the execution of the l ine in which it occurs. The
remark-string in the tai l -comment serves solely as a comment about the l ine.
4.3 . 5
Exceptions
None.
4.3.6
Remarks
None.
4.4
Identifiers
4.4.1
General Description
Identif iers are used to name variab les , arrays, array-values, functions, programs,
subprograms and exception-hand lers.
1. identif ier
>
An identifier s ha l l contain at most 31 characters , inc luding the do l lar- s ign in the
case of a string identifier.
A given numeri c - identi f ier may name a s imp le-numeric-variable, a one-dimens ional ,
two- d imensional or three-dimensional numeri c -array, a numeri c - function, or a numeric
array-value, but not more than one of these in a program-unit. Likewise, a given
string - identif ier may name a s imp le-str ing-variable, a one-d imensional, two
d imens ional or three- d imensional string-array, a string-function, or a string-array
value, but not more than one of these in a program-unit.
A given identifier may name an internal- subprogram, an internal - function-de or a
detached-handler but not more than one of these in a program-unit.
- 20 -
A given routine- identifier shal l not name more than one of an externa l -function-def,
an external - sub- def or a main-program in a program .
A numeric - identi fier
routine- identifier .
be used
as
The names of the no -argument supplied functions or array-values CON, DATE, EXLINE,
EXTYPE, IDN, MAXNUM, PI, RND, TIME, TRANSFORM and ZER shal l not be used as numeric
identifiers to name any other entity .
The names of the no-argument supp l ied
functions or array-values
DATE$ ,
NUL$, and TIME$ shal l not be used as string
identifiers to name any other entity . The keywords l is ted in 3 . 2 . 19 sha l l not be used
as identifiers . Note that the list in
4 4.3
.
Exles
2. X
sum
4 . A$
last_names$
5 . INVERT
4.4.4
Semantics
Each program-unit is a distinct entity in that identifiers used to name variables,
arrays,
detached-handlers, internal-function-definitions,
or internal-procedures
defined within p rogram-units sha l l be local to each invocation of the program-unit in
which they occur; i . e . , they sha l l name different objects in different program-units
and in different invocations of the same program-unit . Identifiers used to name
supp l ied-functions or program-units, however, shal l be global to the entire program;
i . e . , they sha l l name the same object wherever they occur .
If the name of imp lementation- supp lied function or the keyword TAB is imp l icitly or
exp l ic itly defined or dec lared as the identifier of a user-defined function, array,
or variab le, then the defined dec lared interpretation of the identifier sha l l
override the interpretation specif ied b y the Standard within the scope of the
definition or declaration . Therefore, within that scope, the imp lementation- supp lied
function or the tab-cal l sha l l be unavai lable .
Within any program-un it, identifiers which differ only in the cases of the letters
they contain shal l denote the same objects ( e . g . , Xl identifies the same obj ect as
x l ) . Identifiers which differ in any other respect shall denote different obj ects .
4.4.5
Exceptions
None .
4.4.6
Remarks
No imp lementation-defined enhancement to this Standard may extend the l ist of words
unavailable for use as s imp le-variables. Since a l l arrays must be dec lared ( see
7 . 1 . ) , and s ince all defined-functions must be declared or def ined in the program
unit in which they are referenced, imp lementations may supp ly buil t - in functions
other than those specified in this Standard provided that any declaration for such
identifiers within a program overrides the imp l ementation-supp l ied interpretation .
Note, however, that in some cases the use of a parameter less function supp l ied by an
implementation as an enhancement would be syntactical ly indistinguishable from a
- 21 -
variabl e
having
the
same
name .
Therefore,
implementations
which
provide
such
functions must also provide a syntactic means for identifying them as functions .
Examples of such syntax are a requirement to declare such functions exp l icitly in any
program-unit where they are used or requiring the use of empty parentheses ( e . g .
"NEWFUNCTION ( ) ") with reference to such functions .
An operating system may impose additional restrictions on the length and form or
identifiers for procedures which are compi led independently of the main-program .
A supp lied-funct ion may be overridden by defining a user-defined function or s imp le
variable with the same name .
In ECMA BASIC- 2 , an identifier may have the same spe l l ing as a keyword ( o ther than
PRINT, ELSE, REM or NOT ) .
- 22 -
5.
N UMB E RS
- 23 -
5.
NUMBERS
Numbers const i tute one of two primitive data types in BASIC ( the other is strings ) . With
numbers are associated constants, variables, and imp lementation-suppl ied functions , from
which express ions can be formed .
5.1
Numeric Constants
5.1.1
General Description
Numeric-constants
denote
scalar numeric
values .
numeric-constant
is
a decimal
imp l ic i t
exp l ic i t
exp l ic i t
imp l icit
po int
po int
po int
point
unsealed representation
unsealed representation
scaled representation
scaled representation
d. .
ds .
sd .
sd .
.d
. drd . . . d
. . drd . . . dEsd . . . d
. . dEsd . . . d
Syntax
1 . constant
2 . numeric-constant
3 . s ign
4 . numeri c -rep
5 . s igni f icand
6 . integer
7 . fraction
8 . exrad
5.1.3
> numeric-constant
s ign? numeric-rep
p lus - s ign I minus- s ign
s ignificand exrad ?
integer period? I integer? fraction
d igit d igit,'<
period integer
E s ign? integer
Exles
2 . -21
4 . 1E10
5e- 1
. 4E +1
5 . 500 .
1.2
7 . . 2 55
5 . 1.4
Semantics
The value of a numeric-constant is the number represented by that constant . "E" and
"e" stand for " t imes ten to the power" ; if no s ign fol lows the s ymbo ls E and e, then
a p lus -s ign is understood .
A p rogram can contain numeric-constants which have an arbitrary number of digits . An
imp lmentation must retain either the exact value of a numeric-constant, or that value
rounded to an imp lementation-def ined precis ion . The impl ementation-def ined precis ion
for numeric constants sha l l not be less than ten or s ix s ignificant dec imal digits,
depending on upon whether the ari thmetic option in force is DECIMAL or NATIVE
respectively . Numeric-constants can also have an arbitrary number of digits in the
exrad, though nonzero constants whose magnitude is outs ide an imp lementation-defined
range may be treated as exceptions ( see 5 . 6 ) . Nonzero constants whose magnitudes are
less than machine infinites imal sha l l be replaced by zero, whi l e constants whose
magnitudes are larger than MAXNUM sha l l be reported as causing an overf low .
- 24 -
5.1.5
Exceptions
- The evaluation of a numeric-constant causes an overflow (1001, fatal).
5.1.6
Remarks
It is recorrnnended that implementations report constants whose magnitudes are less
than machine infinitesimal as underflows (1501, nonfatal replace by zero and
continue). In BASIC-2 implementation, this permits interception by exception
handlers.
Although this Standard contains no prov1s1on for named constants, their effect can be
achieved through no-argument defined-functions (see 9.1).
5.2
Numeric Variables
5.2.1
General Description
Numeric-variables may be either simple-numeric-variables or references to elements of
numeric-arrays.
5.2.2
Syntax
1.
2.
3.
4.
5.
6.
variable
numeric-variable
simple-numeric-variable
numeric-array-element
numeric-array
subscript-part
7 . subscript
8 . index
9. simple-variable
10. array-name
> numeric-variable
simple-numeric-variable I numeric-array-element
numeric-identifier
numeric-array subscript-part
numeric-identifier
left-parenthesis subscript (comma subscript)'''
right-parenthesis
index
numeric-expression
> simple-numeric-variable
> numeric-array
Examples
3. X
sum
4. V(4)
table(i, j+l)
5.2.4
Semantics
At any instant in the execution of a program, a numeric-variable is associated with a
single numeric value. The value associated with a numeric-variable may be changed by
the execution of statements in tl1e program.
Simple-numeric-variables are declared implicitly through their appearance in a
program-unit. The scope of a numeric-variable shall be the program-unit in which it
appears, unless it is a parameter of an internal-function-definition (see 9. 1).
An index is a numeric-expression whose value shall be rounded to the nearest integer;
the rounded value of X is defined to be INT(X+.5).
A numeric-array-element is called a subscripted numeric-variable and refers to the
element in the array selected by the value(s) of the subscript(s). The acceptable
range of values must be explicitly declared in a dimension-statement or a declare
statement (see 7 .1). Subscripts shall have values within the appropriate range.
At the initiation of execution the values associated with all numeric-variables shall
be implementation-defined.
- 25 -
5.2.5
Exceptions
- A subscript is not in the range of the declared bounds (2001, fatal) .
5.2.6
Remarks
Since initialization of variables is not specified , and hence may vary from
implementation to implementation, programs that are intended to be transportable
should explicitly assign a value to each variable before any expression involving
that variable is evaluated.
There are many co1IIIl1 only used alternatives for associating implementation-defined
initial values with variables; it is reco1IIIl1 ended that all variables be recognizably
und efined in the sense that an exception will result from any attempt to access the
value of any variable before that variable is explicitly assigned a value (3101 ,
nonfatal: supply an implementation-defined value and continue) .
5 .3
Numeric Expressions
5.3.1
General Description
Numeric- expressions may be constructed from numeric- variables, numeric-reps, and
n umeric- function- refs using the operations of add ition , subtraction , multiplication ,
d ivision , and exponentiation (i.e., raising to a power) .
5.3.2
Syntax
1.
2.
3.
4.
5.
expression
numeric- expression
term
factor
primary
6. numeric- function-ref
7 . numeric- function
8 . function- arg- list
9 . function- argument
10. actual- array
11. multiplier
The number and types of arguments in a numeric- function - ref shall agree with the
number and types of corresponding parameters in the d efinition of the numeric
function. An actual-array shall have the same number of d imensions as the
corresponding parameter.
Whenever numeric arguments are passed to an external- function-definition , the
ARITHMETIC options in effect for the external- function-definition and the invoking
program - unit must agree.
Each numeric- function referenced in an expression within a program-unit shall either
be implementation- supplied , or shall be d efined in an internal- function-def or
declared in a declare- statement occuring in a lower-numbered line, within the same
program- unit, than the first reference to that numeric- function.
5 .3 .3
Examples
2. 31''X - Y - 2
costl''quantity + overhead
4. 2 - (- X )
5. SQR(X - 2+Y - 2 )
6 . value(X , Y , a$ )
- 26 -
5. 3. 4
S emantics
The formation and evaluation of numeric-express ions fol lows the normal algebraic
rules. The symbo l s circumf lex-accent ( - ) , asterisk ( *) , s lant ( / ) , p lus - s ign ( + ) , and
minus- s ign ( - ) represent the operations of exponentiation , multipl ication , d ivis ion ,
addition, and subtraction or negation , respectively. Unless parenthesis dictate
otherwise , exponen-tiations sha l l be performed f irst, then multip l ications and
divisions , and fina l ly additions , subtractions , and negations. In the absence of
parenthesis , operations of the same precedence sha l l be evaluated from left to right.
- - Thus A-B-C sha l l be interpreted as (A-B ) - C ; A B C , as (A B ) C ; A / B / C , as (A/B) / C ;
-A+B a s ( -A)+B; and -A B as - ( A B ) .
If a n underflow occurs i n the evaluation of a numeric-express ion, then the value
generated by the operation which resulted in the underf low sha l l be replaced by zero.
For those mathematical operators which are associative , commutative , or both , full
use of these properties may be made in order to revise the order of evaluation of the
numeric-expression except where constrained by the use of parenthesis.
o- o is defined to be 1.
A numeric-function-ref is a notation for the invocation of a predefined algorithm,
into which the argument values , if any , sha l l be substituted for the parameters ( see
5. 4 , 6. 4 and 9. 1 ) used in the function-definition. The result of evaluating a
numeric-function , achieved by the execution of the defining algorithm, sha l l be a
scalar numeric value which replaces the numeric-function-ref in the numeric
express ion.
5. 3. 5
Exceptions
Evaluation of a numeric-expression results in d ivis ion by zero ( 3001 , fata l ) .
Evaluation o f a numeric -expression results i n an overflow ( 1002 , fata l ) .
- Eva luation of the operation o f exponentiation results i n a negative number being
raised to a non-integral power ( 3002 , fata l ) .
Evaluation o f the operation o f exponentiation results i n zero being raised t o a
negative power ( 3003 , fata l ) .
5. 3. 6
Remarks
The accuracy with which the evaluation of a numeric expression takes p lace may vary
from implementation to imp lementation , subj ect to the constraints of 5. 6.
It is recommended that imp l ementations report underflow as an exception ( 1502 ,
nonfatal : replace by zero and continue ) . In BASIC-2 implementation , this permits
interception by exception handlers.
Imp lementations may evaluate primaries and operations within a numeric-express ion in
any order which is cons istent with the semantics of 5. 3. 4. Of course , an operation
must be evaluated after its operands. For examp le, in the expression "A+B+C+D>'<E11 , the
primaries and additions may be evaluated in any order. However , the multipl ication
must be performed before the addition imp l ied by the third p lus-sign , s ince the
product "D>'<E" is one of the operands of that addition.
5. 4
5. 4. 1
General Description
Predefined algorithms are supp lied by the imp lementation for the evaluation of
commonly used numeric functions. Additional functions related to other features of
this Standard are defined in 6. 4 , 7. 1 and 7. 2.
- 27 -
5.4.2
Syntax
1. numeric-supplied-function > ABS I ACOS I ANGLE I ASIN I ATN I CEIL I COS I COSH
COT I esc I DATE I DEG I EPS I EXP I FP I
MAXNUM I INT I IP I LOG I LOGlO I LOG2 I MAX I
MIN I MOD I PI I RAD I REMAINDER I RND I
ROUND I SEC I SGN I SIN I SINH I SQR I TAN I
TANH I TIME I TRUNCATE
2 . randomize-statement
RANDOMIZE
5.4.3
Examples
2 . RANDOMIZE
5.4.4
Semantics
The values of the numeric-supplied functions, as Hell as the number of arguments
required for each function, shall be as described beloiV. In all cases, X and Y stand
for numeric-expressions, and N stands for an index, i.e., the rounded integer value
of a numeric-expression. Each function accepts numeric arguments Hithin the range of
the negative number with the largest magnitude to the largest positive number, except
where noted. For functions which return a value in angle measure (ACOS, ANGLE, ASIN
and ATN), the value shall be in radians unless OPTION ANGLE DEGREES is in e ffect (see
5 . 6 ) , when the value shall be in degrees. In the semantics below, " pi" (lower-case)
stands for the true value of that constant.
Function
Function value
ABS(X)
The absolute value of X.
ACOS(X)
The arccosine of X in radians or degrees (see 5.6), Hhere 0 s ACOS(X) s pi; X
shall be in the range - 1 s X s 1.
ANGLE(X, Y)
The angle in radians or degrees (see 5 . 6 ) between the positive x-axis and the
vector joining the origin to the point with coordinates (X , Y), where -pi <
ANGLE(X, Y) s pi. X and Y must not both be 0. Note that counterclockHise is
positive, e.g., ANGLE(l,l)
45 degrees.
=
ASIN(X)
The arcsine of X in radians or degrees (see 5.6),
pil 2 ; X shall be in the range -1 s X s 1.
ATN(X)
The arctangent of X in radians or degrees (see 5. 6 ) , i.e., the angle whose
tangent is X , where -(pil 2 ) < ATN(X) < (pil 2 ).
CEIL(X)
The smallest integer not less than X.
COS(X)
The cosine of X, where X is in radians or degrees (see 5 . 6 ) .
COSH(X)
The hyperbolic cosine of X.
- 28 -
COT(X)
The cotangent of X, where X is in radians or degrees (see 5 . 6 ) .
CSC(X)
The cosecant of X, where X is in radians or degrees (see 5 . 6 ) .
DATE
The current date in decimal form YYDDD, where YY are the las t two digits of
the year and DDD is the ordinal number of the current day of the year; e . g . ,
the value of DATE on May 9, 1977 was 7 7 129. If there is no calendar
available, then the value of DATE shall be - 1 .
DEG(X)
The number of degrees in X radians .
EPS(X)
The maximum of (X- X ' , X " - X , s igma) where X ' and X" are the predecess or and
successor of X and sigma is the s mallest positive value representable . If X
has no predecessor then X ' = X and if X has no successor then X"=X" . Note
EPS(O) is the s malles t positive number representable by the implementation,
and is therefore implementation- defined. Note also t hat PS may produce
different results for different arith metic options (see 5 . 6 ) .
EXP(X)
The exponential of X , i. e . , the value of the base of natural logarithms
(e = 2 . 7 1828 . . . ) raised to the power X ; if EXP(X) is less than machine
infinitesimal, then its value shall be replaced by zero.
FP(X)
The fractional part of X, i . e . , X - IP(X ) .
INT(X)
The larges t integer not greater than X ; e . g . , INT(1 . 3)= 1 and INT(- 1 . 3 )= - 2 .
IP(X)
The integer part of X , i . e . , SGN(X)>'ciNT(ABS(X)).
LOG(X)
The natural logarithm of X ; X shall be greater than zero.
LOG10(X)
The common logarith m of X ; X shall be greater than zero .
LOG2 (X)
The bas e 2 logarithm of X ; X shall be greater than zero.
MAX(X, Y)
The larger (algebraically) of X and Y .
The largest finite pos itive number representable and manipulable by the
implementation;
implementation- defined .
MAXNUM
may represent different
numbers for different arithmetic options (see 5 . 6 ) .
- 29 -
MIN(X, Y)
The smaller (algebraically) of X and Y .
MOD(X, Y)
X modulo Y , i . e . , X-Yi<INT(X/Y). Y shall not equal zero.
PI
The c onstant 3 . 14159 . . . which is the ratio of the c ircumference of a c ircle
to its diameter.
RAD(X)
The number of radians in X degrees.
REMAINDER(X, Y)
The remainder f unction, i . e . , X-Yi<IP(X/Y). Y shall not equal zero.
RND
of
ROUND(X, N)
The value of X rounded to N decimal digits to the right of the decimal point
(or -N digits to the left if N < 0); i . e . , INT(Xl'<10-N+ . 5)/ 10-N .
SEC(X)
The secant of X , where X is i n radians o r degrees (see 5 . 6) .
SGN(X)
The sign of X : -1 if X < 0, 0 if X
0, and +1 if X > 0.
SIN(X)
The sine of X, where X is in radians or degrees (see 5 . 6).
SINH(X)
The hyperbolic sine of X .
SQR(X)
The non-negative square root of X ; X shall be non-negative .
TAN(X)
The t angent of X, where X is in radians or degrees (see 5 . 6) .
TANH(X)
The hyperbolic tangent of X .
TIME
The time elapsed since the previous midnight, expressed in seconds; e . g . , the
value of TIME at 11 : 15 AM is 405 00. If there is no clock available, then the
value of TIME shall be -1. The value of TIME at midnight shall be zero (not
86400) .
TRUNCATE(X, N)
The value of X truncated to N decimal digits to the right of the
point (or -N digits to the left if N < 0); i . e . , IP(Xl'<lO -N)/ 10- N .
dec imal
- 30 -
I f OPTION ANGLE DEGREES is in effect, the term "in radians or degrees " in the above
list of function values sha l l mean degrees . If OPTION ANGLE RADIANS is in effect, the
term "in radians or degrees " sha l l mean radians . The accuracy requirements ( see
5 . 6 . 4 ) for the periodic trigonometric funct ions SIN, COS, TAN, SEC, CSC, COT are
l imited to providing ful l accuracy of m+1 decimal d igits only for arguments n the
range of - 2)'<pi to 2<pi . Los s of accuracy outside this range is l imited to the resul t
of loss of prec is ion i n performing those range reductions o n arguments necessary to
compute values o f these functions, i . e . , "SIN ( x ) " may be evaluated as if it were
written "SIN ( MOD ( x, 2)'<pi ) ) " and s imi larly for the other functions .
If no randomize-statement is executed, then the RND function sha l l generate the same
sequence of pseudo- random numbers each t ime a program is run . Execution of a
randomize-statement sha l l override this imp l ementation- supp l ied sequence of pseudo
random numbers, generating a new ( and unpredictabl e ) starting point for the list of
pseudo-random numbers used subsequently by the RND function . The sequence of pseudo
random numbers sha l l be g lobal to the entire program, not local to individual
program-units .
5.4.5
Exceptions
The value of the argument of the LOG, LOG10, or LOG2 function is zero or negative
( 3004, fatal ) .
- The value of the argument of the SQR function is negative ( 3005, fata l ) .
- The magnitude of the value of a numeric- supp l ied-function is larger than MAXNUM or
is mathematical infinity ( 1003, fatal ) .
The value of the second argument of the MOD or REMAINDER function is zero ( 3006,
fatal ) .
The value of the argument of the ACOS or ASIN function is less than - 1 or greater
than 1 ( 3007 , fatal ) .
R emarks
In the case of imp lementations which do not have access to a randomizing device such
as a real-time c l ock, the randomize - s tatement may be implemented by means of an
interaction with the user .
This S tandard requires that overf l ows be reported only for the final values of
numeric- supp l ied-functions ; exceptions which occur in the evaluation of these
functions need not be reported, though imp lementations sha l l take appropriate actions
in the event of such exceptions to insure the accuracy of the final values . When
overf lows are reported for the f inal values of numeric- supp l ied- functions, it i s
recommended that the name of the function generating the overf low be reported also .
It is recommended that, if the magnitude of the value of a numeric-supp lied - funct ion
is nonzero, but less than machine inf ini tes imal, imp lamentations report this as an
underf low, set the value to zero ( 1503, nonfatal : return zero and continue ) .
BASIC- 2 imp lementations, this permits interception by exception hand lers .
In
- 31 -
5. 5
5. 5. 1
General Description
A let- statement provides for the simultaneous assignment of the computed value of a
numeric-expression to a list of numeric- variables .
5. 5 . 2
Syntax
1 . let- statement
2 . numeric- let- statement
3 . numeric- variable- list
5. 5 . 3
Examples
2 . LET
LET
LET
LET
5. 5 . 4
P = 3 . 14159
A(X , 3) = SIN(X))'cy + 1
A, Y(l), Z
I+l
T(I,J), I, J = I + J
Semantics
The subscripts, if any, of variables in the numeric- variable- list shall be evaluated
in sequence from left to right . Next the numeric-expression on the right of the
equals- sign shall be evaluated (see 5 . 3 ) . Finally, the value of that numeric
expression, if necessary rounded to the nearest value which can be retained by the
variable , shall be assigned to the numeric- variables in the numeric- variable- list in
order from left to right .
5.5.5
Exceptions
None .
5. 5.6
Remarks
Note that :
is not equivalent to :
5.6
LET A = 1
LET A, B(A)
LET A = l
LET A = 2
LET B(A) = 2
5.6.1
General Description
Unless specified otherwise , the values of all numeric- variables shall behave
logically as f loating-point decimal numbers with an implementation-def ined precision
of at least ten decimal digits . By use of an option- statement, a program may choose
to take advantage of a more eff icient, but possibly less accurate , representation for
numeric values.
Unless specified otherwise the trigonometric functions (see 5 . 4) require arguments or
generate values in radian measure . By use o f an option- statement, a program may
change the angle measure of all such functions to degrees.
5. 6 . 2
Syntax
1 . option- statement
2 . option- list
3 . option
- 32 -
4. declare- statement
5. type- declaration
6. numeric- type
7 . numeric- declaration
Examples
1. OPTION ARITHMETIC DECIMAL, ANGLE DEGREES
5.6.4
Semantics
The ARITHMETIC option controls the logical behavior of numeric entities within the
program- unit containing the option.
If OPTION ARITHMETIC DECIMAL is specified, or if no ARITHMETIC option is specified,
then the values of the numeric- variables shall behave logically as decimal floating
point numbers, with an implementation-defined precision, say m, of at least ten
significant decimal digits and with an implementation- defined range of at least lE- 38
to 1E+38.
The results of decimal computations can be described in terms of floating- point
decimal intermediate results with at least m+l decimal digits of precision (but may
be implemented in some other equivalent fashion). The value of a numeric- variable
shall be assumed to be exact. Numeric- constants shall be evaluated accurately to at
least m decimal digits of precision. Numeric operations and functions shall also be
evaluated accurately to at least m+l decimal digits of precision with respect to the
computed value of their operands and arguments (which may themselves be intermediate
results). In all cases, the intermediate result of an evaluation shall be represented
as a floating- point decimal number with at least m+l decimal digits of precision,
thus, when the true result can be expressed as a decimal number with m+l significant
digits, the computed result shall be exact. In no case shall t he error for evaluation
of an individual constant, operation, or function be greater t han 5 in the (m+2)nd
significant digit. Implementations are free to use any method of numeric evaluation
which always yields results whose absolute error (with respect to the true result) is
no greater than the absolute error of the results generated by the preceding
specification.
If OPTION ARITHMETIC NATIVE is specified, then the values of numeric variables and
constants shall be represented and manipulated in an implementation- defined fashion,
with an implementation- defined precision of at least six decimal digits and with an
implementation- defined range of at least 2E- 38 to 1E+38 . Decimal values need not be
represented exactly, as long as the error is within the limits of this precision.
- 33 -
The ANGLE option contro ls the evaluation of the trigonometric functions within the
program-unit containing the option . I f OPTION ANGLE RADIANS is specif ied, or if no
ANGLE option is specified, then the numeric-supp l ied- functions COS, COT, CSC, SEC,
SIN, and TAN use arguments in radian measure, and the numeric-supp l ied-functions
ACOS, ANGLE, ASIN and ATN generate results in radian measure .
If OPTION ANGLE DEGREES is specified, then the numeric-supp l ied- functions COS, COT,
esc , SEC, SIN, and TAN use arguments in degree measure, and the numeric - suppl ied
functions ACOS, ANGLE, ASIN, and ATN generate results in degree measure .
If the execution of a program reaches a line containing an option-statement, then it
sha l l proceed to the next l ine with no further effec t .
A s imple-numeric-variable that appears
variable as a s imp le-numeric-variabl e .
in
numeric-type
sha l l
establ ish
that
I f execution reaches a l ine containing a dec lare- s tatement, i t sha l l proceed t o the
next l ine with no further effect .
5.6.5
Exceptions
None .
5.6 . 6
Remarks
The representations chosen for numeric values when OPTION ARITHMETIC
specified may be the same as that for OPTION ARITHMETIC DECIMAL .
NATIVE
is
No minimum accuracy is specified for the evaluation of numeric express ions and
functions when OPTION ARITHMETIC NATIVE has been chosen . However, it is recommended
that imp lementations maintain at least s ix decimal d igits of precis ion .
The value 2E- 38 is specified for the maximum value of the lower bound of positive
numbers to al low an imp lementation emp loying the IEC 559 f loating point binary
arithmetic to be standard conforming .
- 34 -
6.
S TR I NG S
- 35 -
6.
STRINGS
Character strings constitute one of two p rimitive data types in BASIC (the other is num
bers). Strings consist of arbitrary sequences of characters. Their lengths are variable,
not fixed, although a maximum length for a string may be specified . With strings are asso
ciated constants, variables, and implementation-supplied functions, from which expressions
can be formed .
6.1
String Constants
6.1.1
General Description
A string-constant is a character string of fixed length enclosed within quotation
marks. A quotation-mark itself may be included in a string-constant by representing
it by two adjacent quotation-marks.
6 . 1. 2
Syntax
1 . constant
2 . string-constant
3 . quoted-string
> string-constant
quoted-string
quotation-mark quoted-string-character)'(
quotation-mark
Examples
2 . "XYZ"
"1E10"
"He said, ""Don ' t"" "
6 . 1. 4
Semantics
The value of a string-constant shall be the sequence of all quoted -string-characters
between the initial and final quotation-marks. The dou ble-quote, when appearing in
side a quoted -string, shall d enote a single quotation-mark. Spaces in string
constants, including trailing spaces, shall be significant . A string consisting only
of two quotation-marks shall represent the null string . Upper-case-letters and lower
case-letters shall be d istinct within string-constants.
6.1.5
Exceptions
None.
6.1.6
Remarks
The maximum length of a string-constant is constrained by the maximum length of a
physical line . The maximum length of the constant would therefore be 3 less than that
for the line, allowing for a continuation character ("&"), and the leading and trail
ing quotation-mark, e . g . :
100 LET A$ = &
&"abc . . . unseen characters here . . . xyz"
As the maximum p hysical line length must be at least 132 , the maximum string-constant
length must be at least 129 .
6.2
String Variables
6.2.1
General Description
String-variables may be either simple-string-variables or references to elements of
one-dimensional, two-dimensional, or three-dimensional string-arrays.
- 36 -
Exp l ic i t declarations of
A do l lar-s ign
Syntax
1 . variable
2 . string-variabl e
3.
4.
5.
6.
7.
8.
6.2. 3
> string-variab l e
( s imple- string-variable I string-array-element)
substring-qualifier?
string-identifier
string-array subscript-part
string- identifier
left-parenthesis index colon index right-parenthesis
> s imp le- string-variable
> string-array
Examples
2 . K$
name$ ( X : Y )
ITEM$ ( 1 ,n ) ( z : z+ 5 )
4 . A$ ( 4 )
table$ ( I , J )
6.2.4
Semantics
At any instant in the execution of a program , a string-variable is associated with a
s ingle string-value . The value associated with a string-variable may be changed by
the execution of statements in the program.
The length of the character string assoc iated with a string-variable can vary during
the execution of a program from a length of zero characters ( s ignifying the nu l l or
empty string) to the maximum allowed for that string-variable ( see 6 . 6 . 4) .
Simple-string-variables may be dec lared exp l ic itly ( see 6 . 6) o r may b e dec lared im
p l icitly through their appearance in a program-unit . The scope of a string-variab le
sha l l be the program-unit in which it appears , unless it is a parameter of an
internal - proc-def , in which case its scope is that definition .
A string-array element is cal led a subscripted string-variable and refers to the ele
ment in the one-dimensiona l , two-dimensional or three-dimens ional array selected by
the value ( s ) of the subscript ( s ) . Subscripts shal l have values within the appropriate
range ( see 7 . 1 ) .
The substring-qualifier provides a means for specifying a portion of the value asso
c iated with a string-variab le . A$ ( M : N ) sha l l specify that substring of the value as
sociated with A$ from its Mth through Nth characters ( M and N are indices ) .
Characters in a string sha l l be numbered from the left starting with one . There are
no exceptions assoc iated with substring-qual ifiers ; if either M or N is not in the
range from 1 to LEN( A$ ) , the M sha l l be considered to be MAX ( M , l ) and N sha l l be con
s idered to be MIN( N , LEN( A$ ) ) . If M > N, even after this adjustment , then A$ ( M : N )
sha l l b e the nul l string occuring before the Mth character o f A $ i f M < LEN(A$ ) or
- 37 -
the null string iiiDll ediately following A$ if M > LEN( A$ ) . For example, if A$ =
1 11 . 2 34" , then A$ (1 : 1) = 1111 1 , A$ (1 : 3 ) = 1112 3 " , A$ (0 : 3 ) = 1112311 , A$ (2 : 5 ) = " 2 34" ,
A$ (3 : 2) is the null string preceding the third character of A$ , and A$ (5 : 7 ) is the
null string following A$ . At the initiation of execution the values associated with
all string-variables shall be implementation-defined.
6.2.5
Exceptions
- A subscript is not in the range of the declared bounds (2001, fatal) .
6.2.6
Remarks
Since initialization of variables is not specified, and hence may vary from implemen
tation to implementation, programs that are intended to be transportable should ex
plicitly assign a value to each variable before any expression involving that vari
able is evacuated.
There are many coiiUll only used alternatives for
tial values with variables; it is recoiiUll ended
defined in the sense that an exception will
value of any variable before that variable is
fatal: supply an implementation-defined value
6.3
String Expressions
6.3.1
General Description
String-expressions are composed of string- variables ,
function-references, or a concatenation of these .
6.3.2
string- constants,
string
Syntax
1 . expression
2 . string-expression
3 . string-primary
4 . string-function-ref
5 . string-function
6 . concatenation
> string-expression
string-primary (concatenation string-primary)l'<
string-constant I string- variable I
string-function-ref I left- parenthesis
string-expression right-parenthesis
string- function function- arg-list?
string-defined- function I string- supplied-function
ampersand
The number and types of arguments in a string-function- ref shall agree with the num
ber and types of the corresponding parameters specified in the definition of the
string-function. An actual- array shall have the same number of dimensions as the cor
responding parameter .
Each string- function referenced in an expression within a program- unit shall either
be implementation-supplied, or shall be defined in an internal- function-de or de
clared in a declare- statement occurring in a lower- numbered line, within the same
program-unit, than the first reference to that string-function .
6.3.3
Examples
2 . A2$ & B$(4 : 22) & 1 1 2 2 311
3 . X$(1, 3 )(I : J)
6 . 3 . 4 Seman tics
The value of a string-expression shall be the concatenation of the values of the
string-primaries in the expression (e . g . , if A$ = " COME " and B$ = "IN" , then A$ & B$
= " COME IN" and B$ & A$ = "INCOME " ) .
- 38 -
Exception
6.3.6
6.4
6 . 4. 1
General Description
Predefined algorithms are supplied by the implementation for the evaluation of com
monly used string-valued functions and numeric-valued functions whose arguments are
strings .
6 . 4. 2
Syntax
> (CHR I DATE I LCASE I LTRIM I REPEAT I RTRIM I STR I
TIME I UCASE I USING) dollar-sign
2 . numeric-supplied-function > LEN I ORD I POS I VAL
> MAXLEN left-parenthesis (simple-string-variable
3 . numeric-function-ref
string-array) right-parenthesis
1. string-supplied-function
6 . 4. 3
Examples
None .
6.4.4
Semantics
The values of the implementation-supplied functions, as well as the number and types
of arguments required for each function, are described below. In all cases, M repre
sents an index, i. e . , the rounded integer value of some numeric-expression; X stands
for a numeric-expression;
V$ represents a simple-string-variable or string-array;
and A$ and B$ stand for string-expressions .
Function
Function value
CHR$ (M)
The one-character string consisting of the character occupying ordinal posi
tion M+1 in the collating sequence for the declared character set, i . e . , the
first character is returned for an argument of zero. M shall be at least zero
and less than the number of characters in the declared character set (see
table 1) . For example, for the standard character set, CHR$ (53) = 1 1 51 1 , and
CHR$ (65)
"A" . The values of CHR$ for the native character set are
implementation-defined.
- 39 -
DATE$
The date in the string representation " YYYYMD
MD " according to ISO 2 014 . For
example, the value of DATE$ on May 9 , 197 7 was 1 1 19 7 7 05 09 1 1 If there is no
calendar available, then the value of DATE$ shall be 1 1 0000000011
LCASE$ (A$ )
The string of c haracters resulting from the value associated with A$ by re
placing each upper-case-letter in the string by its lower-case versi on.
LEN(A$)
The number of c haracters in the value associated with A$ . Note that LEN ( " " " " )
= 1, since the value o f the string c onstant c onsists of precisely one
quotation-mark.
LTRIM$(A$)
The string of c haracters resulting from the value
deleting all leading space c haracters.
associated with A$
by
MAXLEN(V$ )
The maximum length associated with the simple-string-variable or string-array
(see 6. 6 ) . If there is no effective limit on string length, the value re
turned shall be MAXNUM .
ORD(A$ )
The ordinal position of the c haracter named by the string assoc iated with A$
in the c ollating sequence of the declared c haracter set, where the first mem
ber of the c haracter set is in ordinal position zero . The acceptable values
of A$ are single c haracters in the c haracter set and two-character or three
c haracter mnemonics for c haracters in the c haracter set . Values of A$ with
two or more cha racters shall be treated with upper-case-letters and lower
case-letters equivalent. The acceptable values for the standard character set
are shown in Table 1. The acceptable values for the native character set are
implementation-define d . For example,
for the standard c haracter set,
ORD("BS")
8, ORD("A") = 65 , ORD(" a") = 9 7 , ORD(" S " )
53 , ORD("SOH11)
1,
ORD(" Soh") = 1 , and ORD("ABC" ) c auses an exception.
=
POS(A$ ,B$)
The c haracter position, within the value associated with A$, of the first
c haracter of the first occurrence of the value associated with B$ . If there
is no such ocurence , then POS(A$, B$ ) shall be zero . POS(A$ , "" ) shall be one,
for all values of A$ .
POS(A$, B $ ,M)
The c haracter position, within the value assoc iated with A, of the first
character of the first ocurence of the value associated with B$ , starting at
the Mth c haracter of A$ . If the value associated with B$ does not occur
within the designated portion of the value associated with A$ , or if M is
greater than LEN(A$), the value returned is zero. Otherwise, the value re
turned is equivalent to
- 40 -
LET tempi
LET temp 2 $
LET temp3
IF temp3
LET POS
ELSE
LET POS
END IF
Exceptions
- The value of the argument of VAL is not a val id numeric-constant (400 1 , fata l ) .
- The value of the argument of VAL is a val id numeric-constant, but evaluating this
constant results in an overf low ( 1004 , fata l ) .
- 41 -
- The value of the argument of CHR$ is not in the appropriate range ( 4002 , fatal ) .
- The value of the argument of ORD i s neither a valid s ing le character nor a val id
mnemonic ( 4003 , fata l ) .
- The value of the second argument of REPEAT$ is not > 0 ( 4010, fatal ) .
6.4.6
Remarks
I t is recommended that if the magnitude of the value of the VAL function is less than
machine infinites imal , imp lementations report this as an exception ( 1504 , nonfatal :
replace with zero and continue ) . In BASIC-2 imp lementations , this permits intercep
tion by exception handlers .
The time zone used for DATE$ and TIME$ is imp lementation-defined .
The effect of the functions UCASE$ , and LCASE$ is fully defined only for the ECMA
character set as defined in 4 . 1 . 4 . For other-characters , such as accented letters ,
the effect is imp lementation-defined , and may be specified in other national version
of thi s Standard to accommodate the needs of local a lphabets .
6.5
6.5.1
6.5.2
Syntax
1 . let-statement
2 . string- let-statement
3 . string-variable- l ist
6.5.3
Examples
2 . LET A$ = "ABC"
LET A$ ( I ) = B $ ( 3 : 4 )
LET A$ , B$ = "NEGATIVE DISCRIMINANT"
LET C$ ( 7 : 10 ) = "wxyz"
LET A$ = "ABCD" &&.
& "XYZ"
6.5.4
Semantics
The subscripts and substring-qua l ifiers , if any , of variables in the string-variable
l ist sha l l be evaluated in sequence from left to right . Next the string-express ion on
the right of the equals- s ign sha l l be evaluated ( see 6 . 3 ) . Fina l l y , the value of that
s tring-'express ion sha l l be ass igned to the string-variab les in the string-variab le
list in order from left to right .
When a value is ass igned to a string-variab le with a substring-qua l if ier , it sha l l
replace the substring of the value of the string-variable specif ied b y the substring
qualifier . The length of the value of the string-variable may change as a result of
this rep lacement . For examp l e , if A$ = 1 1 12 34" , then ass igning 1 13211 to A$ ( 2 : 3 ) results
in 1 11324" , ass igning 1 1 1 1 to A$ ( 2 : 3 ) results in 1 1 14" , ass igning A$ ( 1 : 2 ) to A$ ( 2 : 3 ) re
sults in 1 1 1 124" , and ass igning 11511 to A$ ( 2 : 1 ) results in 1 1 1523411
6.5.5
Exceptions
- The ass ignment of a value to a string-variable causes a string overflow ( 1 10 6 ,
fatal ) .
- 42 -
6.5.6
Remarks
The order of ass ignment of values to string-variables in the string-variable- l ist is
important in statements such as
LET A$ ( 1 : 2 ) , A$ ( 2 : 3 )
"X"
6.6.1
General Description
An option-statement may be used to define an ordering on the set of a l l str ing char
acters .
A dec lare-statement may be
variables in a program-unit .
6 . 6 .2
used
to
set a maximum
length
for
specified
string
Syntax
l . option
2 . type-declaration
3 . string-type
Examples
1. COLLATE NATIVE
3 . STRING\'<8 last_name$l'<20 , f irst_name$ , midd le_name$
6. 6.4
Semantics
The COLLATE option identifies the c o l lating sequence to be used within a program-unit
for comparing strings ( see 8 . 1 ) and for computing values of the CHR$ and ORD func
tions ( see 6 . 4 ) . OPTION COLLATE NATIVE specifies that the native col lating sequence
of the host system sha l l be used . OPTION COLLATE STANDARD specifies that the col lat
ing sequence shal l correspond to the order of the characters in Tab le l . If no
COLLATE option appears in a program-unit then the STANDARD col lating sequence sha l l
be used within that program-unit .
S imp le-string-variab les whose string-identifiers appear in string-types may have a
maximum length less than or equal to the imp lementation-def ined default value . The
maximum is determined , in descending order of precedence, from :
- the length-max in the string-dec l aration for that variabl e ;
the length-max
variab l e , or
in
the
string-type
of
the
dec lare-statement
containing
that
- 43 -
ception . The imp lementation-defined maximum string length default sha l l be at least
13 characters .
A l ength-max of 0 in a string-type sha l l estab l ish the associated string-variab le as
having a maximum length of zero ; i . e . , the nul l string .
6.6.5
Exceptions
None .
6.6.6
Remarks
The native c o l lating sequence may be the standard col lating sequenc e .
The COLLATE option may be extended , on national
accommodate spec if ic needs of l ocal alphabets .
versions of
this
Standard ,
to
- 44 -
7 .
ARRAYS
- 45 -
7.
ARRAYS
Arrays are indexed c o l lections of numbers or strings . Array elements can be manipulated by
scalar numeric and string operations ( see 5 and 6 ) . In add ition , entire arrays may be ma
nipulated by matrix statements .
7.1
Array Declarations
7 . 1. 1
General Description
An option in the option- s tatement may be used to def ine the lower bound for a l l array
subscripts within a program-unit which are not exp l ic itly stated . By use of an
option-statement the subscripts of al l such arrays may be dec lared to have a lower
bound of zero or one ; if no such dec laration occurs , the lower bound sha l l be one .
Arrays may have one , two , or three d imens ions . The number of d imens ions and subscript
bounds for each d imens ion are dec lared in the dec lare-statement or d imens ion
statement . Al l array-names , except those appearing in a function-parm- l ist or a
procedure-parm- l is t , must be dec lared in one and only one such statement . If not ex
p l icitly dec lared , the lower subscript bound for a given d imens ion is one or zero ,
depending on the BASE option. Upper bounds must a lways be exp l icitly declared .
A one-dimens ional array with subscripts 1 to 10 or 1980 to 1989 or -9 to 0 contains
10 elements . A two-dimensional array with subscript bounds 1 to 10 for each d imens ion
contains 100 e lements . S imilarly, a three-d imens ional array with subscript-bounds 1
to 10 for each d imension contains 1000 e lements .
A declare-statement can be used to d imens ion numeric-arrays as wel l as to dec lare
maximum lengths for string-variables and string-arrays , and to dimension string
arrays . A dimension-statement can be used to d imension arrays , but not to dec lare the
maximum length of strings in string-arrays .
7 .1.2
Syntax
1.
2.
3.
4.
5.
6.
7.
8.
9.
10 .
11 .
12 .
d imension-statement
d imens ion- l is t
array-dec laration
numeric-array-dec laration
bounds
bounds - range
s igned- integer
string-array-declaration
option
string-dec laration
numeric -dec laration
numeric-function-ref
13 . maxs i ze-argument
14 . bound-argument
>
>
>
>
- 46 -
Examples
1. DIM A ( 6 ) , B ( 10 , 10 ) , B$ ( 100 ) , D( 1 TO 5 , 1980 TO 1989 )
DIM A$ ( 4 ,4 ) , C ( - 5 TO 10)
10 . A$ ( 3 TO 21) * 8
12 . SIZE ( A , l )
SIZE( B$ , 2 )
SIZE( X )
LBOUND ( A )
UBOUND ( C$ , 2 )
7 . 1.4
S emantics
Each array-dec laration dec lares the named array to be either one-dimensiona l , two
d imensional , or three- dimens ional , according to whether one , two , or three bounds
ranges are speci f ied in the bounds f o r the array . In addition, the bounds specify the
maximum and optiona l l y minimum values that subscripts for the array sha l l have . If a
minimum subscript is not exp l icitly dec lared and no BASE option occurs within the
program-uni t , then it sha l l be imp l icitly dec lared to be one .
The BASE option in an option-statement is local to the program-unit in which it oc
curs and declares the minimum value for all array subscripts in that program-unit
which are not exp l icitly declared .
I f the execution of a program reaches a l ine containing a dimens ion-statement , then
it sha l l proceed to the next l ine with no further effect .
String-array-dec l arations appearing in a string-dec l aration may include a length-max ,
which sets the maximum length of each element of the string-array . As with s imp le
string-variab les , if there is no length-max in the string-dec laration, then the
length-max , if any , of the string-type takes effect . If there is no length-max in ei
ther , then the imp l ementation-def ined length-max, if any , sha l l take effect .
The value of SIZE( A , N ) where A is an actual -array and N is an index , shal l be the
current number or permissible values for the Nth subscript of the array named by A
( the value of N is rounded to the nearest integer , and the subscripts of A are in
dexed from left to right , starting at one ) . The value of SIZE ( A ) sha l l be the current
number of elements in the entire array A .
The value of MAXSIZE ( A ) sha l l b e the total number o f elements o f the entire array
named by A permitted by the array-dec laration .
The value of LBOUND ( A , N ) , where A is an actual -array and N is an index, sha l l be the
current minimum value a l l owed for the Nth subscript of the array named by A . The
value of UBOUND ( A , N) sha l l be the current maximum value a l l owed for the Nth subscript
of array A . As in the SIZE function, the value of N is rounded to the nearest inte-
- 47 -
ger, and the subscripts of array A are indexed from l eft to right, starting at one.
The LBOUND and UBOUND functions may be cal l ed with a single arguments provided that
arguments is a vector, in which case the value of LBOUND and UBOUND are the current
minimum and maximum values al l owed for the subscript of the vector. (Here, and in the
fol l owing sections, the word "vector" shal l mean a " one-d imensional array" and the
word " matrix" shal l mean a " two-dimensional array").
7 .1.5
Exceptions
- The value of the index in a SIZE reference is l ess than one or greater than the
number of d imensions in the array ( 4004 , fatal).
- The value of the index in an LBOUND reference is l ess than one or greater than the
number of d imensions in the array ( 4008 , fatal).
- The value of the index in a UBOUND reference is less than one or greater than the
number of d imensions in the array ( 4009 , fatal).
7 . 1.6
Remarks
The dimension statement is retained for c ompatibil ity with Minimal BASIC. Al l its ca
pabil ities are inc l uded within the decl are-statement.
I f an impl ementation supports more than three dimensions, SIZE, LBOUND , and UBOUND
should work for those extra dimensions, and an exception should be generated on ly
when an attempt is made to inquire about a dimension beyond those d ec l ared.
7.2
Numeric Arrays
7.2.1
General Description
Numeric-arrays in BASIC may be manipul ated el ement by element. However, it is often
more c onvenient to regard numeric-arrays as entities rather than as indexed col l ec
tions of entities, and t o manipulate the entire entity at once. BASI C provides a num
ber of standard operations to facil itate such manipul ations.
7 .2.2
Syntax
1 . array-assignment
2 . numeric-array-assignment
3.
4.
5.
6
7.
8.
9
10 .
- 48 -
Examples
In the f o l l owing examp les A, B and C are doub ly-subscripted numeric-arrays , X, Y, and
Z are s ingly- subscripted numeric -arrays , and W is a numeric-express ion .
2 . MAT A
MAT A
MAT A
MAT A
MAT A
MAT A
10. DET ( B )
7.2.4
B
B + c
B>'IC
w ,., B
ZER ( 4 , 3 )
INV ( B )
y
MAT X
y - z
MAT X
N'<Y
1AT X
w ,., CON
HAT X
MAT X
ZER
MAT A
TRN ( B )
DOT( X , Y )
1AT X
y ) IA
'
Semantics
Array Ass ignments and Redimensioning
Execution of a numeric -array-ass ignment shal l cause the numeric-array-express ion to
be evaluated and its value as s igned to the array named to the left of the equals
s ign . I f necessary , this array shal l have its s i ze changed dynamica l l y ; i . e . , its
number of d imens ions shall be unchanged , but its s i ze in each d imens ion sha l l be
changed to conform to the s ize of the array which is the value of the numeric -array
express ion .
When the s ize of a numeric-array is changed dynamically, the current upper bounds for
its subscripts sha l l be changed to conform to the new s i zes . That is ,
new_lower_bound
new_upper_bound
o l d_lower_bound
old_lower_bound + new_s ize - 1
The new s izes need not individua l ly be less than or equal to the s izes determined in
the array-dec laration for that numeric -array , as long as the new total number of ele
ments for the numeric-array does not exceed the total number of e lements determined
by the array-dec laration for that array .
Array Express ion
The evaluation of numeric-array-express ions sha l l fol low the normal rules of matrix
algebra . The symbo ls asterisk ( >'< ) , p lus ( +) , and minus ( - ) sha l l represent the opera
tions of multipl ication , add ition , and subtraction respectively .
The d imensions of numeric -arrays in numeric-array-express ions sha l l conform to the
rules of matrix algebra . The numeric-arrays in a sum or difference sha l l have the
same s izes in each dimens ion . The numeric-arrays in a product sha l l have s izes L x H
and H x N for some L , H and N ( in which case the product shal l have s ize L x N ) , or
an H e l ement vector and a s ize H x N matrix ( in which case the product sha l l be an N
element vector ) , or a s ize L x H matrix and an M element vector ( in which case the
product sha l l be an L element vector ) . A l l e l ements in a numeric-array sha l l be used
when evaluating a numeric-array-expre s s ion ; i . e . , each numeric-array sha l l be treated
as an entity .
- 49 -
When a scalar-mu ltip l ier is present in a numer ic-array-expre s s ion , the primary sha l l
b e evaluated , and then each e l ement o f the numeric-array sha l l b e multip l ied by this
value .
If an underf low occurs in the evaluation of a numeric-array-express ion, then the
value generated by the operation which resul ted in the underf low shal l be rep laced by
zero .
Array Values
Numeric-array-values s ha l l be assigned to the numeric-array on the left of the equal s
sign . If n o redim is present , the size of the numeric-array generated sha l l b e the
same as the size of the numeric-array to which it is to be assigned . If a redim is
present, a numeric-array of the d imens ions spec if ied sha l l be generated , and the
numeric-array to which it is ass igned sha l l be redimensioned as described above . In a
redim-bounds , the values of the indices are the lower and upper bounds of the corre
sponding d imens ion in the assoc iated array-value . If the redim-bounds consi sts of a
s ingl e index , its value sha l l be the upper bound , and the lower bound sha l l be the
current default lower bound in effect . I f a redim is used with the IDN constant , then
it sha l l produce a square matrix ; i . e . , the number of rows sha l l equal the number of
columns . If a redim is not used with the IDN constant , the numeric-array being as
s igned to sha l l be square .
The ZER constant sha l l generate a numeric-array, a l l of whose e lements are zero . The
CON constant sha l l generate a numeric -array , a l l of whose e lements are one . The IDN
constant sha l l generate an identity matrix , i . e . , a square matrix with ones on the
main diagonal and zeros e l sewhere . If only one redim-bounds is used with IDN, then
the effect is j ust as if that redim-bounds had been specified twice .
If a scalar-mu lt ip l ier is used with an IDN , ZER or CON constant , then the primary
( see 5 . 3 ) is evaluated and each non-zero e lement of the IDN , ZER or CON constant is
rep laced by the value of the primary .
Array Functions
The function TRN sha l l produce the transpose of its argument . An N x M matrix is re
turned for an M x N argument .
The function I NV sha l l produce the inverse of its argument . The argument must be a
square matrix .
The function DET shal l return the determinant of its argument . The argument must be a
s quare matr i x .
The value of DOT ( X , Y ) sha l l result i n a scalar value , which is the resul t of the in
ner product multip l ication of the one-d imens ional numer ic-vectors X and Y .
7 .2.5
Exceptions
The sizes of numeric-arrays in a numeric-array-expression do not conform to the
rules of matrix algebra ( 6001 , fatal ) .
- The total number of e lements required for a redimensioned array exceeds the number
of elements reserved by the array ' s original d imensions ( 5001 , fata l ) .
The f irst index in a redim-bounds is greater than the second ( 6005 , fata l ) .
- A red im-bounds cons ists of a s ingl e index which is less than the defau l t lower
bound in effect ( 6005 , fata l ) .
- The redim f o l lowing IDN does not spec ify a square matri x , or no redim is present
and the receiving matrix is not square ( 6004 , fatal ) .
- The argument o f the DET function is not a s quare numeric matrix ( 6002 , fata l ) .
- so -
The argument of the INV function is not a s quare numeric matrix ( 600 3 , fatal ) .
- Evaluation of a numeric-array-express ion results in an overflow ( 1005 , fata l ) .
- Evaluation of DET or DOT results in an overf low ( 1009 , fatal ) .
- App l ication of INV to a s ingular matri x , or loss of a l l s ignificant d igits ( 3009 ,
fatal ) .
7 .2.6
Remarks
It is recommended that imp l ementations report underf l ow as an exception ( 1505 , nonfa
tal : rep lace by zero and continue ) . In BASIC-2 imp lementation , this permits intercep
tion by exception hand lers .
7.3
String Arrays
7.3.1
General Description
As with numeric-arrays , string - arrays may be regarded as entities rather than as in
dexed c o l lections of entities . BASIC provides the abi l ity to concatenate and assign
entire arrays of strings .
7 .3.2
Syntax
1 . array-ass ignment
2 . string-array-ass ignment
3 . String-array-express ion
4 . string-array-primary
5 . string-array-value
> string-array-assignment
MAT string-array substring-qualifier? equa l s - s ign
string-array-express ion
string-array-primary ( concatenation
string-array-primary) ? I string-primary
concatenation string-array-primary I
string-array-primary concatena-tion
string-pr imary I string-array-value
string-array substring-qualifier?
( string-primary concatenation) ? NUL dol lar - s ign
redim?
A string-array being ass igned a value by a string-array-ass ignment sha l l have the
same number of d imensions as the value of the string-array-express ion .
Two string-arrays being concatenated sha l l have the same number of d imens ions .
7.3.3
Examples
2 . MAT
MAT
MAT
MAT
7 .3.4
A$ & B$
A$
A$
NUL$ ( 5 , 6 )
( "Number" ) & B$
A$
A$ ( 4 : 6 ) = ( " ") & B$
Semantics
Execution of a string-array-ass ignment sha l l cause the string-array-express ion to be
evaluated and its value ass igned to the array named to the left of the equals - s ign .
If appropriate , this array sha l l have its s ize changed dynamica l ly ; i . e . , its number
of dimensions sha l l be unchanged , but its s ize in each dimension sha l l be changed to
conform to the s i ze of the array which is the value of the string-array-express ion .
When the s ize of a string-array is changed dynamical ly , the current upper bounds for
its subscripts sha l l be changed to conform to the new s izes . That is ,
new_lower_bound
new_upper_bound
o ld_lower_bound
o ld_lower_bound + new_size - 1
The new s izes need not individua l ly be less than or equal to the s izes determined in
the string-array-dec laration for that string-array , as long as the new total number
- 51 -
of e l ements for the s tring-array does not exceed the total number of e l ements deter
mined by the array-dec laration for that array .
When a s tring-array on the left of a string-array-ass ignment has a substring
qualifier , the ass ignment to each element of the string-array sha l l replace the sub
string of the value of each element
specif ied
by
the substring-qualifier . The
substring-qua l i f ier on the left sha l l be evaluated before the string-array
express io n .
String-array-expressions involve the operations of concatenation and substring ex
traction . Two string-arrays being concatenated sha l l have the same s i ze in each d i
mens ion; the concatenation sha l l b e performed e l ement b y e l ement . When concatenation
is by scalar , this scalar sha l l be prefixed or suffixed , as appropriate , to every e l
ement o f the string- array . When a substring-qua l if ier i s app l ied t o a string-array,
then the spec i f ied substring sha l l be extracted from each e l ement in the array .
The order of evaluation and assignment sha l l be as f o l lows :
- evaluate the substring-qualif iers in the string-array on the left ;
- evaluate the string-array-expression from left to right , by evaluating
each
string-primary or string-array-primary as f o l lows : evaluate first the subscripts ,
if any , then the substring qualif iers , and then the value of the primary itself ;
- concatenate ;
- make the assignment .
The string-array-value NUL$ is an array a l l of whose e l ements are the nul l string . If
a red im is not present , the s i ze of the string-array generated sha l l be the same as
the s i ze of the string-array to which it is to be ass igned . If a redim is present , a
string-array of the d imensions specified sha l l be generated and the string-array to
which it is ass igned sha l l be redimensioned as described above . The rules in 7 .2 .4
for redims with numeric-array-values app ly to NUL$ as wel l .
7 . 3.5
Exceptions
- The arrays in a string-array-expres sion have different s i zes ( 6101 , fatal ) .
- The first index in a redim-bounds is greater than the second ( 6005 , fatal ) .
- A redim-bounds cons ists of a s ingle index which is less than the default lower
bound in effect ( 6005 , fatal ) .
- The total number of elements required for a redimensioned array exceeds the number
of elements reserved by the array ' s original dimensions ( 5001 , fatal ) .
- Evaluation of a string-array-express ion results in a string overf low ( 1052 , fata l ) .
- Assignment of a value to a string-array causes a string overflow ( 1106 , fata l ) .
7.3.6
Remarks
None .
- 52 -
8 .
CO N T RO L
S T RUCT UR E S
- 53 -
8.
CONTROL STRUCTURES
Contro l structures govern the order of execution of l ines in a program , both by statements
which make exp l ic i t reference to l ine-numbers and also by exp l ic it ly-constructed loops and
decis ion mechanisms which make no reference to l ine-numbers .
8.1
Relational Expressions
8.1.1
General Description
Relationa l - expressions enable the values of express ions to be compared in order to
inf luence the f low of control in a program .
8.1.2
Syntax
1.
2.
3.
4.
5.
relational-expression
disjunction
conjunction
relationa l - term
relationa l -primary
6. comparison
7 . relation
8 . equal ity-relation
9 . not-equals
10 . not - less
1 1 . not-greater
8.1.3
Examples
2 . NOT X < Y OR
3 . A < = X AND X
1 <= I AND I
I < N AND ( J
8.1.4
d isj unction
conjunction ( OR conjunction) >'c
relationa l -term ( AND relational-term)>'c
NOT? relational-primary
comparison I left-parenthesis relational-express ion
right-parenthesis
numeric-express ion relation numeric-expres s ion
string-express ion relation string-express ion
equa l ity-relation I greater-than-sign I
less-than - s ign I not-greater I not - less
equa l s - s ign I not-equals
less-than-s ign greater-than-s ign I greater- than-s ign
less-than-s ign
greater-than-s ign equa l s - s ign I equals- s ign
greater- than- s ign
less -than-s ign equa l s - s ign I equal s - s ign
less -than - s ign
A$ = B$ AND B$
C$
<= B
<= 10 AND A ( I ) = X
> M OR A ( I ) < B ( J ) )
Semantics
The relation " less than or equal to" i s denoted by not-greater . The relation "greater
than or equal to" is denoted by not- less . The relation "not equal to" is denoted by
not-equa l s . The relations "greater than" , " less than" , and "equals" are denoted by
the corresponding syntactic s ign .
The relation of equal ity sha l l ho ld between two numeric-expressions if and only if
the two numeric-express ions have the same value .
The relation of equality shal l ho ld between two string-expressions if and only if the
values of the two string-express ions have the same length and contain identical se
quences of characters .
In the evaluation of relational-express ions invo lving string-express ions , the rela
tion " less than" sha l l be interpreted to mean "earl ier in the co l lating sequence
than" , and the other relations sha l l be def ined in a corresponding manner . More pre
cisely, if two unequa l strings in a relationa l -express ion have the same length , then
one sha l l be " less than" the other i f , in the leftmost character pos ition in which
they differ , the character in that string precedes the character in the other accord
ing to the establ ished col lating sequence ( see 6.6). If the two strings in a
relationa l - expression have different lengths and one has zero length or is an initial
- 54 -
leftmost segment of the other , then the shorter string sha l l be " less than" the
other . Otherwise the relationship between two strings of unequal length sha l l be de
termined by the contents of the shorter string and the leftmost portion of the longer
string which is of the same length as the shorter string .
The precedence of the operators AND , OR , and NOT sha l l be as imp l ied by the formal
syntax . That is , NOT operates only on the relational-pr imary innne diately fol lowing
it , AND app l ies to the relationa l -terms innne diately preceding and fol lowing i t , and
OR app l ies to the conjunctions immediately preceding and fo l lowing i t .
The order of evaluation of relational-express ions sha l l b e a s fol l ows . The
relationa l -express ion sha l l take on the truth-value of the d i sjunction which consti
tutes it . The conjunctions immediately contained in the disjunction sha l l be evalu
ated from left to right until a true conjunction is found or none are lef t . As soon
as a true conjunction is found , the who le disjunction is evaluated as true , and any
remaining conjunctions are not evaluated . If no true conjunctions are found , the d is
j unction i s false . For each conj unction, the relational-terms innne diately contained
in it are evaluated from left to right unt i l a false relational- term is found or none
are left . As soon as a false relational- term is found , the who le conjunction is eval
uated a s false and any remaining relational-terms are not evaluated . I f a l l the
relationa l - terms are true , then the conjunction is true . For each relational-term,
the relationa l -primary immediately contained in it is evaluated , its truth value re
versed if and only if NOT is also immediately contained in the term, and the result
ing value assigned to the relational-term . A relational-primary sha l l be evaluated
according to the description above of the various relations , if it is a compar ison .
Otherwise , it sha l l take on the value of the relational-expression immediately con
tained within it . This relational-express ion sha l l be evaluated by re-applying the
rules of this paragraph to it .
8.1.5
Exceptions
None .
8.1.6
Remarks
The spec ification for evaluation of relational-expressions guarantees that certain
parts of the express ion will not be evaluated if not necessary . For instance, if an
array A has subscripts from 1 to 10 :
1 < X AND X < 10 AND A ( X )
KEY
Control Statements
8.2.1
General Description
Control s tatements al low for the interruption of the normal sequence of execution of
statements by causing execution to continue at a specified line , rather than at the
one with the next higher l ine- number .
The goto- statement al lows for an unconditional transfer . The on-goto-statement al lows
control to be transferred to a selected l ine . The gosub-statement and return
statement allow for subroutine cal ls . The on-gosub - statement and return-statement al
low for s elected subroutine cal ls .
8.2 .2
Syntax
1 . contro l - transfer
2 . goto- s tatement
- 55 -
3 . on-goto- s tatement
4 . gosub-statement
5 . return-statement
6 . on-gosub-statement
8.2.3
Examples
2 . GO TO 999
GOTO 999
3 . ON 1+1 GO TO 400 , 400 , 500
ON X GO TO 100 , 200 , 150 , 9999 ELSE LET A
1
4 . GO SUB 5000
GOSUB 5 160
6 . ON A+7 GOSUB 1000 , 2000, 7000 , 4000
ON Fl-2 GOSUB 4360 , 446 0 , 4660 ELSE PRINT F$
8.2.4
Semantics
Execution of a goto-statement sha l l cause execution of the program to be continued at
the l ine with the spec ified l ine-number .
The index in an on-goto-statement sha l l be evaluated and its value rounded to obtain
an integer , whos e value shal l be used to select a l ine-number from the l ist f o l lowing
the GOTO ( the l ine-numbers in the l ist are indexed from left to right , starting with
1 ) . Execution of the program sha l l continue at the l ine with the selected l ine
number . If the on-goto-statement contains an ELSE clause , and the value of the index
in the on-goto-statement is less than one or greater than the number of l ine-numbers
in the l i s t , then the imperative - statement fol lowing the ELSE sha l l be executed ; if
the imperative-statement in the ELSE part does not transfer contro l to another l ine ,
then execution sha l l be continued in sequence , i . e . , with the l ine f o l lowing that
containing the on-goto- s tatement .
The execution of the gosub-statement or on-gosub-statement and the return- statement
can be described in terms of stacks of l ine-numbers , one associated with each invoca
t ion of a program-unit or internal -proc- def ( but may be imp lemented in some other
fashion ) . ( The s tack is conceptual ; the S tandard does not require that this method be
used ) . Prior to execution of the f irst gosub - s tatement or on-gosub- s tatement in the
invocation of a program-unit or internal-proc-def , the stack in that entity s ha l l be
empty . Each time a gosub-statement i s executed , the l ine- number of the gosub
s tatement sha l l be p laced on top of this stack and execution of the program-unit o r
internal -proc-def sha l l b e continued a t the l ine specified in the gosub-statement .
The index in a on-gosub-statement sha l l be evaluated by rounding to obtain an inte
ger , whose value sha l l be used to s elect a l ine-number from the l i s t f o l lowing the
GOSUB ( the numbers in the l ist are indexed from left to right , starting w ith 1 ) . The
l ine-number of the on-gosub statement sha l l be p laced on top of the stack for the ap
propriate program-unit or internal-proc-def , and execution sha l l continue at the l ine
with the l ine-number selected by the index . If the on-gosub-statement contains an
ELSE c lause , and the value of the index in the on-gosub-statement is less than one o r
greater than the number of l ine-numbers in the l i s t , then the imperative- statement
fo l lowing the ELSE sha l l be executed and the stack of l ine- numbers sha l l not be
changed ; if the imperative-statement in the ELSE part does not transfer contro l to
another l ine , execution sha l l then continue in sequenc e , i . e . , with the l ine fol low
ing that containing the on-gosub-statement .
Each time a return- statement is executed , the l ine-number on top of the s tack sha l l
b e removed from the s tack and execution o f the program-uni t o r internal -proc-def
shal l continue at the l ine fol lowing the one with that l ine-number .
- 56 -
Exceptions
- The value of the index in an on-goto-statement or an on-gosub - statement without an
ELSE c lause is less than one or greater than the number of l ine-numbers in the
l ist ( 1000 1 , fata l ) .
- An attempt i s made to execute a return-statement without having executed a corre
sponding gosub-statement or on-gosub-statement within the same program-unit or
internal -proc-def ( 10002 , fata l ) .
8.2.6
Remarks
The syntactic element contro l -transfer is defined solely to permit describing l imita
tions on transfers to l ine numbers . It is not generated by o ther productions .
References to nonexistent l ine- numbers in a program-unit , inc luding those in contro l
transfers , are syntax errors ( see 4 . 2 ) . There is , therefore , n o exception defined in
this Standard for such references . Imp lementations may , however , choose to treat them
as exceptions , if they are so documented , s ince the effect of non- standard programs
is imp lementation-defined .
8.3
Loop Structures
8.3.1
General Description
Loops provide for the repeated execution of a sequence of s tatements . Do- loops pro
vide for the construction of loops with arbitrary exit cond itions . The for-statement
and next- s tatement provide for the construction of counter-contro l led loop s .
8.3.2
Syntax
l.
2.
3.
4.
5.
6.
7.
8.
9.
10 .
11.
12 .
loop
do- loop
do- l ine
do-statement
exit-condition
do-body
exit-do- s tatement
loop - l ine
loop - statement
for- loop
for- l ine
for- s tatement
13 .
14 .
15 .
16 .
17 .
18 .
19 .
control -variable
initial-value
l imit
increment
for-body
exit-for-statement
next- l ine
- 57 -
20 . next-statement
The contr o l - variabl e in the next- statement which terminates a for- loop sha l l be the
same as the control -variable in the for-statement which begins the for- loop .
A for- loop contained in the for-body of another for- loop sha l l not emp loy the same
control -variabl e as that other for- loop . No l ine-numbers in a contro l -transfer out
side a for - l oop or do- loop sha l l refer to a l ine in the for-body of that for - l oop or
in the do-body of that do- loop .
An exit-do- s tatement may only occur in a do- loop . An exit-for-statement may only oc
cur in a for - l oop .
8.3.3
Examples
10 DO WHILE I <= N AND A( I ) <> 0
LET I = I + 1
20
30 LOOP
2 . 100 DO
LET I = I + 1
l lO
120
PRINT "MORE ENTRIES ( ENTER ' NO ' I F NONE) "
130
I NPUT A$ ( I )
140 LOOP UNTIL A$ ( I ) = "NO"
2 . 10 DO
20
I NPUT X
3 0 I F 0 < X AND X < = 7 AND X = INT ( X ) THEN EXIT DO
40
PRINT " I NPUT AN INTEGER BETWEEN 1 AND 7 1 1
50 LOOP
10 . 100 FOR I = 1 TO 10
150
LET A( I ) = I
200 NEXT I
12 . FOR I = A TO B STEP - 1
20 . NEXT C 7
2.
8 . 3 .4
Semantics
An exit-condition sha l l be said to require exi t from a loop if the value of the
relationa l - expression f o l lowing the keyword WHILE is false or if the value of the re
lational expression f o l lowing the keyword UNTIL i s true .
If execution of a program reaches a do- l ine , then the exit-cond it ion, if any , in that
do- l ine sha l l be evaluated . If there is no exit- cond ition, or if it does not require
exit from the loop , then execution sha l l proceed to the next l ine . If the cond ition
requires exit from the loop , then execution sha l l continue at the l ine f o l l owing the
associated loop - l ine . If execution of a program reaches a loop- l ine , then the exit
condition in that loop - l ine , if any , sha l l be evaluated . If there is no exit cond i
tion, or if it does not require exit from the loop , then execution sha l l resume at
the associated do- l ine ; if the condition requires exit from the loop , then execution
sha l l continue at the l ine f o l l owing the loop - l ine .
The action of the for-statement and the next-statement is defined in terms of other
statements , as f o l l ows .
- 58 -
1 10 FOR v
150 NEXT v
sha l l be equivalent to
l lO
120
130
140
150
160
LET own1
l imit
LET own2
increment
LET v
initial -value
DO UNTIL (v-own1 ) l'< SGN( wn2 ) > 0 ( l ines )
LET v
v + own2
LOOP
=
Here v is any s imple-numeric-variab l e , and own1 and own2 are variables associated
with the particular for- loop and not accessible to the programmer . The variables
ownl and own2 sha l l be distinct from s imi lar variab les associated with other for
loops . In the above equivalenc e , a contro l- transfer to the for - l ine sha l l be inter
preted as a contro l - transfer to the f irst let-statement , and a contro l-transfer to
the next- l ine sha l l be interpreted as a contro l - transfer to the last let-statement .
In the absence of a STEP c lause in a for-statement , the value of the increment sha l l
be +1 .
Execution of an exit-do-statement sha l l cause execution to continue the l ine f o l l ow
ing the loop - l ine of the smal lest do- loop in which the exit-do-statement occurs . Exe
cution of the exit-for-statement sha l l cause execution to continue at the l ine fo l
lowing the next- l ine o f the smal lest for- loop i n which the exit-for-statement occurs .
8.3.5
Exceptions
None .
8.3.6
Remarks
On exit from a for- loop through the next-statement , the value of the contro l -variable
is the first value not used ; on a l l other exits from a for - loop the contro l -variable
retains its current value .
General Description
An if-statement al lows for conditional transfers , for the conditional execution o f a
s ing le imperative-statement , or for the execution of one of two alternative
imperative-statements .
An if-block a l lows for the conditional execution of a sequence of l ines or for the
execution of one of several alternative sequences of l ines .
A se lect-b lock al lows for the conditional execution of any one of a number of alter
native sequences of l ines , based on the value of an expression .
8.4.2
Syntax
2 . if-c lause
3 . if-block
4.
5.
6.
7.
8.
9.
10 .
if-then- l ine
then-block
elseif-block
elseif-then- l ine
else-block
e lse- l ine
end- if- l ine
imperative-statement I l ine-number
if-then- l ine then-b lock elseif-blockl'< e lse-block?
end- if- l ine
l ine-number IF re lational-expression THEN tai l
blockl'<
else if - then- l ine b lockl'<
l ine-number ELSEIF relational-expression THEN tai l
e lse- l ine b lockl'<
l ine-number ELSE tai l
l ine- number EN D I F tai l
- 59 -
1 1 . select-block
12 .
13 .
14 .
15 .
16 .
17 .
18 .
19 .
20 .
21 .
22 .
se lect- l ine
se lect- statement
case-block
cas e - l ine
case-statement
case- list
case- item
range
case-else-b lock
case-else- l ine
end - select - l ine
Examples
1 . IF X = > Y2 THEN GOSUB 900 ELSE GOSUB 2000
I F X$ = "NO" OR X$ = " STOP" THEN LET A = 1
IF A = B THEN 100
IF A$ = B$ THEN 200 ELSE 300
3 . 10 IF X = INT ( X ) THEN
20
PRINT X ; " I S AN INTEGER"
30 ELSE
40
PRINT X ; " I S NOT AN INTEGER"
50 END I F
1 0 0 IF A = 0 THEN
1 10
PRINT "ONE ROOT"
120 ELSEIF DISC < 0 THEN
130
PRINT "COMPLEX ROOTS"
140 ELSE
150
PRINT "REAL ROOTS"
160 END IF
1 1 . 10 SELECT CASE A$ ( 1 : 1 )
20 CASE "A" TO "Z" , "a" TO " z"
30
PRINT A$ ; " starts with a letter"
40 CASE 11 0 11 TO 11 911
50
PRINT A$ ; "starts with a d igit"
60 CASE ELSE
70
PRINT A$ ; "doesn ' t start with a letter or a d igit"
80 END SELECT
- 60 -
8.4.4
10
SELECT CASE X
20
30
40
50
60
70
80
CASE IS < 0
PRINT X ; " is negative"
CASE IS > 0
PRINT X ; " is pos itive"
CASE ELSE
PRINT X ; " is zero"
END SELECT
Semantics
I f the value o f the relational-express ion in an if-statement is true and an
imperative-statement f o l l ows the keyword THEN , then this imperative-statement sha l l
b e executed ; if a l ine- number follows the keywork THEN , then execution of the program
sha l l be continued at the l ine with that l ine-number . If the value of the relational
expres s ion i s false and an imperative-statement fo l low the keyword ELSE , then this
imperative-statement sha l l be executed ; if a l ine-number f o l lows the keyword ELSE ,
then execution of the program sha l l be continued at the l ine with that l ine-number ,
if no ELSE is present , then execution sha l l be continued in sequenc e , i . e . , with the
l ine f o l l owing that containing the if-statement .
I f - blocks sha l l be executed as fol lows . If a then-block, e l seif-block, or else-block
does not contain a block, the effect i s as if it d id contain a b lock consisting of a
remark- l ine . If the value of the relational-express ion in the if-then - l ine is true ,
then execution sha l l continue at the f irst l ine of the corresponding then-block . If
false, then the relational-express ions of each corresponding elseif- then- l ine , i f
any , sha l l b e evaluated i n order . A s soon a s a true relational-express ion is found ,
execution sha l l continue at the f irst l ine of the blocks of that elseif-block . If no
true relational-express ion is found in the elseif-then- l ines , then, if an else-block
is present , execution sha l l continue at the first l ine of the block of that else
b lock . I f there i s no e lse-block , execution sha l l continue at the l ine f o l lowing the
end - if - l ine . When execution reaches the end of a then-block, an elseif-block, or an
e lse-b lock , it sha l l continue at the line following the corresponding end - if - l ine .
The express ion in a se lect- statement in a select-block sha l l be evaluated and its
value compared with the case- items in the case s tatements until a match is found . A
match sha l l occur when
- the value of the express ion equals that of a constant appearing as a case-item, or
- the value is greater than or equal to that of the f irst constant appearing in a
range containing the word TO , but less than or equal to the second , or
- the value satisf ies the relationship indicated by the relation appearing before the
constant in a range .
If and when a match is found , the rest of the case-block headed by the case-statement
in which the match was found shall be executed . If no case- item is matched , then the
case-else-block, if it is present , sha l l be executed . When execution reaches the end
of a case-block or case-e lse-block, it sha l l continue at the l ine fol lowing the end
s e lect- l ine .
Nesting of b locks is permitted subj ect to the same nesting constraints as for- loops
( i . e . no overlapping b locks ) .
- 61
8.4.5
Exception
A select-block without a case-else-block is executed and no case-block is selected
( 10004 , fata l ) .
8.4.6
Remarks
None .
- 62 -
9.
- 63 -
9.
PROGRAM SEGMENTATION
BASIC provides three mechanisms for the segmentation of programs. The first provides for
user-defined functions, whose values may be used in numeri c-expressi ons and string
exp ressions. The second enables subprograms to be defined, which communicate via p arameters
and which can be invoked via a call-statement. The third enables separate programs to be
executed sequentially without user intervention.
F uncti ons and subprograms (which we refer to collectively as " routi nes" ) are of two types:
internal and external . External routines are independent program-units lexically f ollowing
the main-program. I nternal routines are contained within a program-unit (the main-program
or an external routine) and are considered to be part of that program-unit. An internal
routine cannot contain another internal routine.
In general, an external routine does not share anything (i ncluding, but not limi ted to,
variables, DATA statements, internal routines, OPTIONs, and DEBUG status) with other
program-units. I nformation is exchanged between external routines and other program-units
by means of parameters and, in the case of external functions, returned values. In general,
an internal routine shares everything with its surrounding program- unit, with the exception
of its parameters. There are no local variables for internal routi nes. See Appendix 2 for
more detai l on scope rules.
\Vi thin a program-uni t, a routine must always be defined or declared in a line lexically
preceding its first invocation in that program-unit. It is not an error for a routine to be
defined or declared without being invoked. An external routine may be invoked throughout
the p rogram; an internal routine may be invoked only from within its containing program
unit.
No control- transfer within an internal or external routine may refer to a line-number
outside that routine, nor may a control-transfer outside a routine refer to a line-number
within it.
9.1
9.1.1
General Description
I n addition to the i mp lementati on-supp lied functions provided for the convenience of
the programmer (see 5 . 4 , 6 . 4 and elsewhere), BASI C allows the programm er to define
new f unctions w i thin a program-uni t or program.
9.1.2
Syntax
1. function-de
2 . internal-function- de
3 . i nternal-def-line
4 . def-statement
5 . numeric-def- statement
6. numeri c-defi ned-function
7 . string-def-statement
8. string-defined-function
9. functi on-parm-list
10. functi on-parameter
11. formal-array
12 . internal-function- line
internal-function-de I external-function-de
internal-de -line I internal-function-line block>'<
end-functi on-line
line-number def-statement tail
numeric-def-statement stri ng-def-statement
> DEF numeric-defined-function f unction-parm-list?
equals-sign numeric-expression
numeri c-identi fier
DEF string-def ined-function length-max?
f unction-parm-list? equals-sign
stri ng-expression
string-identifier
left-parenthesis f unction-parameter (comma
functi on-parameter)>'< right-p arenthesis
> simple-variable I f ormal-array
array-name left-parenthesis comma' right-parenthesis
> line-number FUNCTION (numeric-defined-function I
(stri ng-defi ned-function length-max? ))
function-parm-list? tail
- 64 -
14 . external- function- de
15 . external- function- line
16.
17 .
18.
19.
20 .
21.
22.
23 .
24.
- 65 -
Argument
The number of d imens ions of an actual - array sha l l be one more than the number of com
mas in the correspond ing formal-array . A f o rma l -array sha l l have no more than three
dimensions ( two commas ) .
Whenever a numeric argument is passed to a corresponding numeric parameter in a d i f
ferent program-unit , the ARITHMETIC options i n effect f o r the two program-units must
agree .
The ARITHMETIC option externa l -function-de of numeric type must agree with that of
the invoking program-unit .
A given function-parameter sha l l occur only once in function-pam- list . Function
parameters sha l l not be exp l ic itly dec lared or d imensioned within the internal
function-de or externa l - function-de .
A def ined- function appearing in a def-type or interna l - function-type sha l l be defined
e l s ewhere in the same program-unit by an interna l -def - l ine or interna l - function-de
( other than an internal -def - l ine ) , respectivel y .
A def ined- function appearing i n an externa l -function- type sha l l b e defined e l sewhere
in the program by an externa l - function-de .
9.1.3
Ex2!!!Q l es
5 . DEF E = 2 . 7 182818
DEF AVERAGE( X , Y ) = ( X+Y ) / 2
7 . DEF FNA$ ( S$ , T$) = S$ & T$
DEF Right $ ( A$ , n ) = A$ ( Len(A$) - n+1
14 . 100 EXTERNAL FUNCTION ANSWER(A$)
SELECT CASE UCASE$ (A$ )
120
CASE " YES"
130
LET ANSWER= 1
140
CASE "NO"
150
LET ANSWER=2
160
CASE ELSE
170
LET ANSWER=3
180
END SELECT
190
200 END FUNCTION
2 1 . FUNCTION AVERAGE , REVERSE$
Len ( A $ ) )
- 66 -
9 . 1 .4
Semantics
- 67 -
The treatment of variables and arrays which are not named as funct ion-parameters in a
function-def sha l l depend upon whether the function-def is internal or external . If
the function-def is external , then such variables and arrays sha l l be local to each
invocation of that program-unit , i . e . , they shal l be distinct from objects with the
same names outside that function-def or within other invocations of that function
def ; in add ition , they s ha l l be initia l i zed or not initial ized in a manner cons istent
with the imp l ementation-defined pol icies for the main-program each time the function
def is invoked . If the function-def i s interna l , then those variables and arrays
sha l l be g l obal to the containing program-unit and s ha l l retain their assigned values
each t ime the funct ion-def is invoked ; if these values are changed during the course
of executing the interna l - function-def , the changes remain in effect when execution
is returned to the surrounding program-unit .
With one exception, the scope of channe l - numbers ( see 9 . 2 ) is a lways the program
unit . Nonzero channel - numbers within a function-def sha l l be local to each invocation
of that function-def if it is external , and sha l l be g l obal to the containing
program-unit in which it occurs if it is interna l . Channe l zero shal l be global to
the entire program . Fi les sha l l be ass igned to nonzero channel s within a program-unit
by means of an open-statement before use . Fi les ass igned to channel s local to a
function-def sha l l be c losed upon exit from that function-def .
The scope of internal data is a lways the program-unit . Thus , data within an externa l
function-def s ha l l b e local t o each invocation of that program-unit . Hence read
statements and restore - statements within such a function-def sha l l refer only to data
in data-statements within that function-de and not to data in other program-units .
Upon invocation of such a function-def , the po inter for the data within that
function-def sha l l be reset to the beginning of the data ( see 10 . 1 ) . Data within an
internal- function-def sha l l be part of the data sequence for the containing program
unit , and read- statements and restore- s tatements within such a function-de s hal l re
fer to the entire sequence of data in that program-unit .
9.1.5
Exception s
A string- function- let- s tatement attempts to assign a value whose length exceeds the
maximum for the s tring-def ined-function ( 1 106 , fata l ) .
9.1.6
Remarks
Incompatible COLLATE options are a l l owed between an invoking and invoked program-unit
( even if they communicate via string parameters ) because COLLATE does not d ictate the
internal representation of strings , but only their order in a string comparisons and
the values of the CHR$ and ORO functions .
It is not an error for an internal-function-def to appear before a declare-statement
with def- type or interna l -funct ion-type containing the name of that internal func
tion . It is not an error for a function to be defined by an internal- function-def or
to appear in a dec l are - s tatement , but not to be referred to in that progran1-unit .
An internal - function- type or def- type may be omitted if the corresponding definition
appears before first reference . An external- function- type is always required when an
external-function is referenced in a program-unit .
It is not an error for a function to be def ined by an interna l - function-def or to ap
pear in a dec lare - s tatement , but not to be referred to in that program-unit .
It is not an error for an interna l - function-def to appear before a declare-statement
with def - type or interna l - function- type containing the name of that internal func
tion .
- 68 -
An internal- function- type or def- type may be omitted if the corresponding definition
appears before the f irst reference to that functio n . An external- function-type is a l
ways required when a n external - function i s referenced in a program-unit o ther than
its own.
The requirement that both internal and external functions be dec lared or defined be
fore they are used al lows several program-units within a program each to contain an
internal function with the same name as an external functio n . This facilitates the
use of function libraries where the programmer may not know the names of a l l the
externa l - funct ion-defs in the l ibrary .
9.2
Subprograms
9.2.1
General Description
Subprograms provide a mechanism for the logical segmentation o f programs, allowing
parameter s to be passed between program segments. Subprograms, like defined
functions, may be internal or external to a program-unit .
9.2.2
Syntax
1.
2.
3.
4.
5.
6.
subprogram-de
interna l - sub-de
interna l - sub- l ine
sub- statement
subprogram-name
procedure-parm- list
7 . procedure-parameter
8 . channel-number
9 . end - sub - l ine
10 . end - sub- statement
11 . exit - sub- statement
12 . external - sub-de
1 3 . externa l - sub - l ine
14 . cal l - statement
15 . procedure-argument- list
16 . procedure-argument
17 . type-dec laration
18 . inte rna l - sub- type
19 . externa l - sub- type
20 . sub- l ist
A l ine-number in a contro l - transfer inside an externa l - sub-de shal l not refer to the
associated externa l - sub- l ine .
If a subprogram-name is defined by an external - sub-de, it sha l l not be defined more
than once in the program . If a subprogram-name is defined by an interna l - sub-de, it
shal l not be defined more than once in the containing program-unit .
Within a program-unit, no more than one subprogram ( internal or external ) of a given
name shal l be dec lared or defined .
- 69 -
Argument
simple-numeric-variable
simple-string-variable
formal-array (numeric)
formal-array (string)
channel-number
numeric-expression
string-expression
actual-array (numeric)
actual-array (string)
channel-expression
An actual-array shall have the same number of dimensions as the corresponding formal
array. The number of dimensions in a formal-array is one more than the number of com
mas in the formal-array.
Whenever a numeric argument is passed to a corresponding numeric parameter in a dif
ferent program-uni t, the ARITHMETIC option in effect for the two program-uni ts must
agree.
A given procedure-parameter shall occur only once in a procedure-parm-list.
P rocedure-parameters shall not be explicitly declared or dimensioned within the
internal-sub-def or external-sub-def.
The channel-number zero shall not be used as a procedure-parameter.
A subprogram-name appearing in an i nternal-sub-type shall be defined elsewhere in the
same program-unit by an internal-sub-def.
A subprogram-name appearing in an external-sub-type shall be defined elsewhere in the
program by an external-sub-def.
9.2.3
Examples
2 . 100 SUB exchange(a, b)
LET t = a
l lO
120
LET a
b
LET b
130
t
140 END SUB
4 . SUB CALC(X , Y , Z$ )
SUB SORT(A(), B(, ) , A$ , #3 )
- 70 -
S emantics
When a cal l - statement i s executed , contro l sha l l be transferred to the subprogram
named in to cal l - s tatement . Execution of the subprogram sha l l begin at the l ine fol
lowing the sub- l ine and sha l l continue in sequential order until
- some other action is d ictated by execution of a l ine , or
- a fatal exception occurs , or
- a chain-statement is executed , or
- a stop- statement or exit- sub-statement is executed , or
- an end-sub - l ine i s reached .
The end- sub- l ine serves both to mark the textual end of a subprogram and , when exe
cuted , to terminate execution of the subprogram . The exit- sub-statement , when exe
cuted , sha l l terminate the execution of the innermost subprogram in which it is con
tained . When execution of a subprogram terminates , execution sha l l continue at the
l ine fo l lowing the cal l - s tatement which initiated execution of the subprogram .
Execution of a stop- s tatement in a subprogram sha l l terminate execution of the entire
program .
A subprogram may cal l its e l f , either d irectly or indirectly through another proce
dure ; i . e . , recurs ive subprogram invocations are permitted .
Lines in a subprogram-de sha l l not be executed unless the subprogram it defines is
referenced through a cal l - s tatement . If execution reaches an interna l - sub - l ine , it
s ha l l proceed to the l ine fo l lowing the assoc iated end-sub- l ine without further ef
fec t .
Subprogram parameters
When a cal l - s tatement is executed , its procedure-arguments sha l l be ident ified , from
left to right , with the corresponding procedure-parameters in the sub-statement for
the subprogram .
Procedure-arguments
which
are
numeric -variab les
or
string-variables
without
substring-qual ifiers sha l l be passed by reference , i . e . , any reference to the corre
sponding procedure-parameter within the subprogram sha l l result in a reference to the
procedure-argument , and any ass ignment to the procedure-parameter shal l result in an
assignment to the correspond ing procedure-argument .
If a procedure-argument is an array e l ement , its subscripts sha l l be evaluated once
at each entry to the subprogram .
A procedure-argument which is an express ion , but not a numeric -variab le or a string
variab l e without a substring-qua l if ier , sha l l be evaluated once at each entry to the
subprogram and the value so obtained s hal l be ass igned to a location local to the
subprogram. This local value sha l l be used in any reference to the correspond ing
procedure-paramete r , and this local location sha l l be used as the destination of any
assignment to the procedure-parameter . Any necessary evaluation of procedure
arguments sha l l take p lace from left to right .
References within a subprogram to the procedure-parameters which are formal-arrays
s ha l l result in interferences to the corresponding arrays in the procedure-argument
l i s t ; ass ignments to or redimensioning of such arrays sha l l resul t in assignments to
or redimensioning of the corresponding arrays in the procedure-argument- l ist . Upon
entry to the subprogram , a forma l -array as a procedure-parameter has the same bounds
as the corresponding procedure-argument .
- 71 -
- 72 -
invocation of such a subprogram-de , the pointer for the data within that subprogram
de sha l l be reset to the beginning of the data ( see 10 . 1 ) . Data within an internal
sub-de sha l l be part o f the data sequence for that program-unit, and read- s tatements
and restore-statements within such a subprogram-de sha l l refer to the entire se
quence of data in that program-unit .
9.2.5
Exceptions
None .
9.2.6
Remarks
Imp lementations may extend the l anguage by making the use of an interna l - sub-type op
tiona l , even when the internal - sub-defs occur after the ca l l - s tatements referring to
them .
An a l ias is said to exist for an object whenever two or more distinct names exist for
the object within the same scope . When parameters are passed by reference , a l iases
may be created in certain circumstances . Parameter pass ing by value does not create
a l iases , s ince distinct objects are created for each parameter .
Any cal l - statement creates a l iases whenever
- channel -expressions which round to the same integer value are passed to different
formal channe l -numbers ,
- the same actual -array is passed to different forma l -arrays ,
the same s imp l e variab le or array e l ement is passed to different formal s imp le
variables ,
- an array is passed to a forma l -array and an e l ement of that array is passed to a
formal s imp le-variab l e ,
a channel -expression is passed t o an internal subprogram , o r
- an argument which is not a channe l -expression is passed by reference t o an internal
subprogram .
In the f irst four cases , the a l ias arises because two or more formal parameters name
the same obj ect , or parts of the same obj ec t . In the latter two cases , the a l ias
arises because an obj ect is "visible" to an internal subprogram , both as a parameter
and as an obj ect g l obal to the entire program-unit .
When the state of an obj ect referred to by an a l iased procedure-parameter is changed ,
that change must be immed iately effective in every subsequent reference to the ob
ject, regard less of which of the object 1 s names is used in the reference . Events
which potentia l ly affect the state of the obj ect referred to by a procedure-parameter
include ass ignment , input/ output operations , and array redimensioning .
Thus , the program :
100 DECLARE INTERNAL SUB S
l lO LET A = 0
120
130
140
150
160
170
180
190
200
210
CALL S ( A, A )
SUB S ( B , C )
1
LET A
LET B
2
LET C
3
IF A <> B OR B <> C OR A <> C THEN
PRINT "This shouldn ' t happen . "
END IF
END SUB
END
- 73 -
be decl ared
Chaining
9.3.1
General Description
The chain-statement a l lows separate programs to be executed seria l l y without program
mer intervention . Such a fac i l ity is useful for segmenting large programs .
9.3.2
Syntax
1 . chain-statement
2 . program-des ignator
Examples
1 . CHAIN "PROG2"
CHAIN A$ WITH ( X , FILENAMES$ )
9.3.4
S emantics
A chain- statement sha l l terminate execution of the current program , c lose a l l fi les ,
and initiate execution of the program des ignated by the program-des ignator . The way
in which a program is associated with its program-des ignator is imp lementation
def ined .
I f the program being chained to contains a program-name- l ine , then the arguments of
the chain-statement are evaluated and assigned to the corresponding parameters in the
program-name- l ine ( i . e . , parameters are passed by value ) . The bounds of a forma l
array sha l l therefore b e adjusted t o equal those o f the corresponding actual -array ,
in accordance with the rules for pass ing array parameters to functions ( see 9 . 1 ) .
I t is imp lementation-defined whether upper- case- letters and lower-case- l etters are
treated as equivalent in a program-des ignator .
The initial values of variables in a chained- to program are imp l ementation-defined .
9.3.5
Exceptions
- The program identified by the program-des ignator is not avail ab l e ( 10005 , fatal ) .
- The number and type of arguments in a chain-statement do not agree with the number
and type of the corresponding parameters in the program-name- l ine of the program
being chained to , or a program-name - l ine with a function-parm- l is t is not present
( 4301 , fata l ) .
- An actua l -array does not have the same number of d imensions as the corresponding
forma l -array ( 4302 , fatal ) .
- Numeric parameters are passed between programs with a chain- statement and the
ARITHMETIC options of the program-units d isagree ( 4303 , fata l ) .
- 74 -
9.3.6
Remarks
I n a typical impl ementation a program-des ignator wi l l be the name of a f i le contain
ing that program . The program chained to need not be a BASIC program .
I f exception 4 30 1 , 4302 , or 4303 occur s , it may be reported by the chained- from pro
gram, the chained-to program, or some intermediate system p rogram .
- 75 -
10.
I N P U T AND
OUTPUT
- 76 -
read - statement
variab le- l is t
miss ing-recovery
io-recovery-action
restore-statement
data - statement
data- l ist
datum
unquoted-string
as
the
the
the
- 77 -
each var i
ab l e i n the variab le- l ist i n sequence is ass igned the value o f the datum ind icated by
the po inter and the po inter advanced to point beyond that datum .
If an attempt is made to read data beyond the end of the data sequence , an exception
s ha l l occur unless a m i s s ing-recovery is present in the read - s tatement .
the
specified
i o - recovery-action
sha l l
be
taken .
If
the
I n that cas e ,
io- recovery-action
is
an
exit- d o - s tatement or exit-for-statement , that statement sha l l have its normal effect
( see 8 . 3 ) .
l ine- number ,
to be
as s igned ;
string-variables
i.e. ,
require
string-constants
or
unquoted - s trings
as
data .
An
and
in
the
shal l
(i.e. ,
be
evaluated
after
of
restore - s tatement
program-unit containing
the
resets
the
restore-s tatement
If
a l ine -number
is present,
to
read
the
for
the
data
beginning
sequence
of
the
l ine-number ,
so
in
sequenc e ,
po inter
of
the
sequence
the
so
se
in the
read data from the beginning o f the des ignated data-s tatement .
10 . 1 . 5
Exceptions
The variab le- l is t
remainder
of
and a
not been
specified
in
the
( 8001 ,
fatal ) .
- An
attempt
is made
to assign a value
n o t a numeric- constant
( 8 10 1 ,
is
fatal ) .
( 1006 ,
fatal ) .
- The ass ignment of a datum to a string-var iab le results in a string overf low
( 10 5 3 ,
fatal ) .
10 . 1 . 6
Remarks
Imp lementations may choose to treat underflows as exceptions
zero and cont inue ) .
I n BASIC-2
this permits
( 15 0 6 ,
nonfata l :
supp ly
interception by excep
10 . 2
I nput
10 . 2 . 1
General Description
Input-s tatements provide for user interaction with a program by al lowing var iables to
be
ass igned
values
supp l ied
from
source
external
to
the
program .
The
input
separated by commas .
A prompt
for
p l ementation .
input may be specified to replace the usual prompt supp l ied by the
im
- 78 -
The l ine- input- statement enables an entire l ine of input , including embedded spaces
and commas , to be assigned as the value of a string-variable .
10 . 2 . 2 Syntax
1.
2.
3.
4.
5.
6.
7.
8.
9.
10 .
11.
input-statement
input-modif ier- list
input-modifier
prompt-speci f ier
t imeout-expression
numeric-time-express ion
t ime - inquiry
l ine- input-statement
input-prompt
input-rep ly
l ine- input- rep ly
At mos t one prompt-specifier , one timeout- express ion, and one time- inquiry sha l l oc
cur in an input-modifier- l i s t . These may occur in any sequence .
10 . 2 . 3 Examples
1. I NPUT X
INPUTA$ Y ( 2 )
INPUT PROMPT "What i s your name? " : N$
INPUT TIMEOUT 31'N, ELAPSED T, PROMPT Pstring$ : N$
8 . LINE I NPUT A$
LINE INPUT PROMPT 1 1 1 1 : A$ , B$
10 . 2 , SMITH , - 3
2 5 , o, - 10 . 2
11 . He said , "Don ' t" .
10 . 2 . 4 Semantics
Execution of input- statement sha l l cause execution of the program to be suspended un
t i l a val id input-rep l y , as specified below , has been supp l ied . An input- statement
sha l l cause variables in the variable- l is t to be ass igned , in order , values from the
input- rep ly .
I n interactive mode , the user o f the program sha l l be informed o f the need to supply
data by the output of an input-promp t .
Input modifier l is t
I f a prompt- specifier is present in the input- statement , then the imp lementation
defined input-prompt shal l not be outpu t ; instead , the value of the string-expression
in the prompt-specifier sha l l be output ( unless the input -rep ly is terminated by a
comma , s ee below ) . In batch mod e , the input -rep ly sha l l be requested from the exter
nal source by an imp lementation-def ined means .
If a timeout-express ion is present in an input-mod ifier- list , then the numeric - t ime
expre s s ion contained therein sha l l be evaluated to obtain a (poss ibly fractional )
number S of seconds . If no va l id input -rep ly or l ine- input- rep ly has been supp l ied
within S second s , then an exception sha l l occur . A time- inquiry returns the ( possibly
fractiona l ) number of seconds elapsed between the issuance of the input-prompt and
the reception of the end - of - l ine of the last input-rep ly for this input- statement .
This value is ass igned to the numeric -variable in the time - inquiry . If no c lock is
provided by an imp lementation , then a timeout-expression sha l l have no effect . If a
- 79 -
If no c lock is
provided , a time-inquiry result sha l l be - 1 . The values (minimum and maximum) and
reso lution of both timeout express ions and time- inquiries are imp l ementation-defined .
Ass ignment of Values
The ass ignment of a value from the input-reply to the corresponding variable sha l l
take p lace as soon as an item o f data i n the input-rep ly has been val idated with re
spect to the type of the datum and the al lowable range of values for that datum .
Subscripts and substring-qual ifiers in a variable- l ist or string -variab le- l ist sha l l
be evaluated after values have been ass igned t o the variab les preceding them ( i . e . ,
to the left of them) in the variable- l ist or string-variable- l is t .
TI1e type of each datum in the input-rep ly sha l l correspond to tBe type of the vari
able to which it is to be ass igned ; i . e . , numeric-cons tants sha l l be supp l ied as in
put for numeric -variables , and either string-constants or unquoted -strings sha l l be
supp l ied as input for s tring-variab les . An unquoted-string which is also a numeric
constant may be ass igned to either a string-variabl e or a numeric-variable by an
input- statement .
If the evaluation of a numeric datum causes an underf l ow, then its value sha l l be re
p laced by zero .
If an input- reply supp l ied in response to a reques t for input does not end with a
comma , then the number of data in a l l the input- rep l ies submitted s ha l l equa l the
number of variables requiring values .
If the last character other than a space before the end-of - l ine in an input-rep ly is
a comma , then this sha l l be taken to s ignify that further data are to be supp l ied . As
many values as are contained in that input-rep ly sha l l be ass igned to variables in
the variable- l ist . The input-prompt ( but not the string-express ion of the prompt
specifier, if there is one ) sha l l then be reissued , and execution of the program
sha l l remain suspended unt i l another val id input-rep ly has been supp l ied , from which
further data sha l l be obtained .
When a line - input-statement is executed , a l ine- input-reply sha l l be requested for
each string-variabl e in the string-variable- l ist in the same fashion as an input
rep ly is requested . That is , the value of the f irst line- input-rep ly sha l l be as
s igned to the first var iable in the variable- l i s t . If there are further variables in
the variable- l ist , the input-prompt ( but not the string-expression of the prompt
spec if ier , if there is one ) sha l l then be reissued , and execution of the program
shal l remain suspended unti l a second val id l ine- input-reply has been suppl ied and
ass igned to the second variab le in tl1e variable- list . This process continues unti l a
val id l ine- input-rep ly has been supp l ied for each variab le in the variable- l is t . The
characters of each l ine- input-rep l y , including any leading and trail ing spaces , sha l l
b e concatenated to form a s ingle string , which sha l l become the value o f the corre
sponding string-variab le , except tl1at the end - of - l ine , which terminates a l ine- input
rep l y , sha l l not be included . Quotation marks within a l ine- input-rep ly are treated
as actual characters . Thus , two adj acent quotation-marks are taken as two characters ,
not as one .
10 . 2 . 5 Exceptions
- The l ine supp l ied in response to a reques t for an input- rep ly is not a syntact i
c a l ly correct input-rep ly ( 8 102 , nonfata l : request that a new input-reply b e sup
p l ied ) .
- A datum supp l ied as input for a numeric -variabl e is not a numeric-constant ( 8103 ,
nonfatal : reques t that the current input-rep ly be resupp l ied ) .
- 80 -
- There are insuffic ient data in an input- rep ly not containing a f inal comma ( 8002 ,
nonfatal : request that the current input- rep ly be resupp l ied ) .
There are too many data in an input- rep ly or there are just enough data and the
input-rep ly ends with a comma ( 8003 , nonfatal : reques t that the current input
rep ly be resupp lied ) .
- The evaluation of a numeric datum causes an overflow ( 1007 , nonfatal : request that
the current input - rep ly be resupp l ied ) .
- The assignment of a dattun or a l ine- input-reply to a string-variab le resul ts in a
string overf low ( 1054 , nonfatal : request that the current input- rep ly or l ine
input- rep ly be resupp l ied ) .
The value of a numeric-time-express ion is less than zero ( 8402 , fatal ) .
- A val id input-rep ly or l ine- input-reply has not been supp l ied within the number of
seconds spec i f ied by a timeout-expression in an input-modifier- l i s t ( 8401 , fatal ) .
10 . 2 . 6 Remarks
This Standard requires that users in the interactive mode always be g iven the option
of resupplying erroneous input-rep l ies ; in batch mode this may be treated as a fatal
exception . This Standard does not require an imp l ementation to provide fac i l ities for
correcting erroneous input- rep l ies , though such fac i l ities may be provided .
It is recommended tat the default input-prompt cons ist of a question-mark fo l lowed by
a s ing l e space .
This Standard does not require an imp l ementation to output ( i . e . echo ) an input- rep ly
or l ine- input-rep ly .
Implementations may choose to treat underf lows as exceptions ( 1 507 , nonfatal : supp ly
zero and continue) . In BASIC-2 imp lementation, this permits interception by exception
hand lers .
If an input datum is an unquoted- string , leading and trail ing spaces are ignored ( see
4 . 1 ) . If it is a quoted-string , then a l l spaces between the quotation-marks are sig
nificant ( see 6 . 1 ) .
10 . 3 Output
10 . 3 . 1 General Description
The p r int- statement is designed for generation of tabular output in a cons istent for
mat . The set-statement with MARGIN can be used to specify the width of output- l ines .
The set-statement with ZONEWIDTH can be used to specify the width of print zones
within a print - l ine . The ask- statement is used to inquire about the current MARGIN
and ZONEWIDTH . General izations of the print- statement are described in 10 . 4 , 10 . 5 ,
and 11 . 3 .
10 . 3 . 2 Syntax
1.
2.
3.
4.
5.
6.
7.
8.
9.
10 .
print - statement
print - l ist
print - i tem
tab-ca l l
print - s eparator
set-statement
set-obj ect
ask-statement
ask- io - l is t
ask- io- item
- 81 -
A g iven ask- io- item must appear at most once in an ask- s tatement .
10 . 3 . 3 Examples
1 . PRINT X
PRINT X , Y
PRINT X , Y , Z ,
PRINT , , X
PRINT
PRINT "X EQUALS" , 10
PRINT X , ( Y+Z ) / 2
PRINT TAB ( 10) ; A $ " I S DONE."
6 . SET MARGIN 120
SET ZONEWIDTH 20
10 . 3 . 4 Seman tics
The execution of a print- statement sha l l generate a string of characters and end-of
l ines for transmission to an external device . This string of characters sha l l be de
termined by the success ive evaluation of each print - i tem and print-separator in the
print- l i s t .
I f a n expression i n a p r int- l ist invokes a function which causes a print-statement to
be executed which transmits characters to the same device as the original print
statement , then the effect is imp l ementation-defined .
Printing numeric values
Numeric- express ions sha l l be evaluated to produce a string of characters cons isting
of a lead ing space if the number is positive , or a leading minus - s ign if the number
is negative , f o l lowed by the decimal representation of the absolute value of the num
ber and a tra i l ing space . The possible decimal representations of a number are the
same as those described for numeric-constants in 5 . 1 and sha l l be used as f o l l ows .
Each imp lementation s ha l l def ine two quantities , a s ignif icance-width d to contro l
the number of s ignif icant decimal d igits printed in numeric representations , and an
exrad-width e to contro l the number of d igits printed in the exrad component of a nu
meric representation . The value of d sha l l be at least s ix and the value of e sha l l
be at l east two .
Each expression whose value is exactly an integer and which can be represented with d
or fewer decimal d igits sha l l be output using the imp l icit po int unsealed representa
tion .
Al l other values s ha l l be output using either exp l icit point unsealed representation
or exp l icit po int scal ed representation . Values which can be represented with d or
fewer d igits in the unsealed representation no less accurately than they can in the
scaled representation sha l l be output using the unsealed representatio n . For examp l e ,
6 , then 10- ( - 6 ) i s output a s . 000001 and 10- ( - 7 ) i s output a s 1 . E- 7 .
if d
=
Values represented in the exp l icit point tmscaled representation sha l l be output with
up to d s ignif icant dec imal digits and a period ; tra i l ing zeros in the fractional
part ny be omitted . A number with a magnitude less than 1 shal l be represented with
no d igits to the l eft of the period . This form requires up to d+3 characters counting
the s ign , the period and the tra i l ing space . Values represented in the exp l icit point
sca led representation s ha l l be output in the format
s ignif icand E s ign integer
where the value x of the s ignif icand is in the range 1 < x < 10 and is to be repre
sented with exactly d d igits of precis ion , and where the exrad component has one to e
digits . Tra i l ing zeros may be omitted in the fractional part of the s ignificand and
- 82 -
leading zeros may be omitted from the exrad . A period sha l l be printed as part of the
s ignif icand . This form requires up to d+e+S characters counting the two s igns , the
period , the "E" and a tra i l ing space .
Printing string values
String-expressions s ha l l be evaluated to generate the corresponding string of charac
ters .
Print separators and tabs
The evaluation of the semico lon separator
string of zero length .
i.e. ,
The evaluation of a tab-ca l l or a comma separator depends upon the string of charac
ters a lready generated by the current or previous print-s tatements . The "current
l ine" is the ( possibly empty ) string of characters generated s ince the beginning of
execution or s ince the last end-of- l ine was generated .
The "co lumnar position" of the current l ine is the print pos ition that wi l l be occu
pied by the next character output to that l i ne . Print positions sha l l be numbered
consecutive ly from the left, starting with pos ition one . Each time a character in po
s it ions 2 / 0 through 7 / 14 of the standard character set is generated , the columnar po
s ition sha l l be increased by one . Each t ime an end - of - l ine is generated , the columnar
position s ha l l be reset to one . The effect of other characters on the columnar pos i
t i o n i s imp lementation-defined .
The "margin" is the max imum columnar pos ition in which a character may appear . Prior
to execution of a set-statement with MARGIN , the margin sha l l be imp lementation
defined , but mus t be not l ess than the defau l t zone width . A marg in of sha l l
indicate that the co lumnar pos ition may b e arbitrari l y large .
Each print - l ine is divided into a fixed number of print zones where the number of
zones and the length of each zone is implementation-def ined . A l l print zones , except
possibly the last one on a l ine , which may be shorter , sha l l have the same width . The
defau l t width of a zone sha l l be at least d+e+6 print positions . The zone width may
be changed by the execution of a set-s tatement with ZONEWIDTH . ZONEWIDTH may be set
to any value greater than zero , but not greater than the current marg in .
The purpose of the tab-ca l l is to set the co lumnar posit ion of the current line to
the specif ied value prior to printing the next print- item. More prec ise l y , the argu
ment of the tab-ca l l sha l l be evaluated and rounded to the nearest integer n . If n is
l ess than one , an exception sha l l occur . If n is greater than the margin m, then n
sha l l be reduced by an integral multip l e of m so that it is in the range 1 < n < m ;
i . e . , n sha l l b e s e t equal t o MOD ( n- l , m ) + l .
I f the columnar pos ition o f the current l ine is less than or equal to n , then spaces
sha l l be generated , if necessary , to set the columnar pos ition to n; if the co lumnar
pos ition of the current l ine is greater than n , then an end-of - l ine sha l l be gener
ated f o l l owed by n- 1 spaces to set the columnar pos ition of the new current l ine
to n .
The evaluation o f the comma print-separator depends upon the columnar pos ition . If
this pos ition is neither in the last print zone on a l ine nor beyond the margin, then
one or more spaces sha l l be generated to set the columnar pos ition to the beginning
of the next print zone on the l ine . If the initial co l umnar posit ion is in the last
print zone on a l ine , then an end - of - l ine sha l l be generated . Fina l l y , if the initial
columnar position is beyond the margin ( as it wou ld be if evaluat ion of the last
print- item exact ly f i l led the l ine ) , then an end-of- l ine sha l l be generated .
- 83 -
- 84 -
Imp lementations may choose to use a lower-case "e" in printing numerical values us ing
the exp l icit point scaled representation .
The print- separator fo l lowing a tab-cal l is s ignificant in the same manner that it is
s ignificant f o l lowing an express ion .
10 . 4 Formatted Output
10 . 4 . 1 General Description
A print- statement may control the format of output by specifying an image to which
tl1at output must conform . The image is specif ied either within the print-statement or
in a separate image - l ine .
10 . 4 . 2 Syntax
1.
2.
3.
4.
5.
6.
7.
8.
print- statement
formatted-print- l ist
image
output - l ist
image- l ine
format- string
l itera l - string
l itera l - item
9 . format- item
10 . justif ier
11 . f l oating-characters
12 . i-format- item
13 . digit-place
14 . - format- item
15 . e-format- item
>
An image which is a l ine- number sha l l refer to an image- l ine in the same program
unit . Any l eading spaces fo l lowing the co lon in an image- l ine are part of the format
string .
Al l digit-places in an i - format- item sha l l be the same characte r , i . e . , a l l sha l l be
number- s igns , a l l sha l l be percent- s igns , or a l l sha l l be asteri sks .
10 . 4 . 3 Examples
10 LET sum
20
20 PRINT USING "The answer is #tNI . tl" : sum
produces
"The answer is 20 . 01 1
=
- 85 -
produces
10 . 4 . 4 Semantics
A print-statement with a formatted-print- l ist identifies a format- s tring to be used
to contro l the output generated by the evaluation of the output - l i s t . If the image is
specified via a l ine-number , then the format- s tring is contained in the image- l ine
with the indicated l ine-number ; otherwise , it is the value of the string-expres s ion .
Format string analys i s
The selected format- string sha l l b e analyzed a s a number of format- i tems separated by
possibly zero - length l itera l - s tr ings .
Format- items sha l l be found within the format-string by scanning the latter from left
to right . A search sha l l be made for the f irst character which is the start of a syn
tactica l ly correct format- item, and the longest such format- item starting at that
character identif ied . The scan for format- items shal l continue in this way up to the
end of the format-string , the search for the start of each new format- item beginning
at the character immediately beyond the previous ly identified format- item . Corre
sponding to each format-item sha l l be an output field whose length equa l s the number
of characters in the format- item ( inc luding the justifier , f loating-characters ,
digit-p laces , commas , period , number-s igns , and circumf lex-accents ) . Characters which
are not part of any format- item s ha l l be l iteral - items .
Format-strings which are defined in image- l ines sha l l be interpreted as ending with
the last character in the l ine which is not a space or end-of- l ine .
Literal strings and output fields
A sequence of values to be output sha l l be generated by evaluating each expression in
the output - l ist in sequence . As each value is generated , the l iteral - string preceding
the next format- item in the format- string sha l l first be cop ied unchanged into the
string of characters being generated . Then a number of cl1aracters equal to the l ength
of the output field determined by that format-item sha l l be generated , as fo l l ows .
Formatted numeric output
Numeric values
format- item used . If a j ustif ier is present in the format- item , it shal l be replaced
by the character immediately to its right . If , however , the character to its right is
a period , or if there is no character to its right , then the justifier sha l l be re
p laced by a number - s ign .
First , a representation for the magnitude of the value sha l l be generated .
- For an i-format- item , the value sha l l be rounded to the nearest integer and repre
sented using imp l icit po int unsealed notation .
- 86 -
For an f - format- item , the value sha l l be represented us ing exp l icit point unsea led
notation, rounding the representation or extending it on the right with zeros in
accordance with the number of number - s igns fo l l owing the period in the format
item .
- For both i - format- items and f - format- items , leading zeros to the left of the im
p l icit or exp l icit decimal point s ha l l not be generated , unless this resu lts in no
d igits being generated . In that cas e , the character 1 10 11 sha l l be generated immedi
ately to the left of the exp l icit or imp l icit decimal point . After this , if there
remain unf i l led digit-p laces , then leading zeros sha l l be generated in the integer
or to the left of the period when a percent-s ign is used as a d igit-p lace , lead ing
asterisks when an asterisk is used as a d igit-p lac e , and leading spaces when a
number-s ign is used as a d igit-p lace , such that the number of characters to the
left of the imp l icit or exp l icit decimal po int is equa l to the number of digit
p laces in the format - item .
For an e- format- item , the value sha l l be represented us ing exp l icit or imp l icit
point scaled notation, corresponding to the use of an f - format- item or i - format
item , respectivel y , within the e-format- item . The s ignif icand for nonzero values
sha l l be scaled by powers of ten such that the leftmost d igit-place or number- s ign
pos ition is occupied by a nonzero digit . In a l l other respects , the s ignificand
sha l l be generated according to the above rules for i - format- items and - format
items . The number of circumf lex-accents in an e- format- item sha l l determine the
number of characters in the exrad . The f irst of these characters s ha l l be the let
ter E, the next a mandatory s ign, and the remaining characters the representation
of the magnitude of the exrad , with leading zeros being generated so that the num
ber of characters in the exrad equa ls the number of circumf lex-accents in the
format- item . If the exponent is zero , the mandatory s ign is positive ; the exponent
of zero is zero .
Second , commas sha l l be inserted in the numeric representation wherever a comma oc
curs in the format- item , provided at least one d igit has been generated to the left
of the point of insertion; if no d igit has been generated to tl1e left of th is point ,
then an asterisk sha l l be inserted if the digit-p lace immediately to the left is an
asterisk, and a space inserted if the d igit-p lace immediately to the left is a
number- s ign .
Third , leading characters composed of s ign , dol l ar - s ign , and space s ha l l be generated
according to the fol lowing table :
Floating - characters
Firsu'<
Non-negative
I I $ 11
I I$ I I
II II
1 1 +$ 11
I I $+"
11 +11
1 1 $ 11
1111
Last
$
$
+
$
+
$
none
none
$
+
none
none
none
Negative
1 1 _ $ 11
11 $ _ 1 1
"-"
" - $"
11 $ - "
"-"
"$-"
11_11
- 87 -
be added o n the l eft ( for right-justif ication ) if the format- item begins with a
greater- than - s ign , on the right ( for left-justif ication) if it begins with a less
than- s ign, and equa l ly on e i ther s ide ( for centering ) otherwise ; if the number of
spaces required in the last case is odd , the extra space sha l l be added on the right .
Formatted Output Completion
If the number of values to be output exceeds the number of format- items in the
format- s tring , an end-of- l ine sha l l be generated each time the end of the format
string is reached and the format- string reused for the remaining expressions . I f
format- i tems remain i n the format-string after a l l values have been output , then the
next l itera l - s tring , if any , sha l l be output . Generation of characters is a lways ter
minated beginning at the first unused format- item . Fina l l y , an end-of- l ine sha l l be
generated after a l l other character generation is completed , unless the output- l is t
ends with a semico lon , in which case n o such end - of - l ine sha l l b e generated .
The current margin sha l l not affect the output ; in particular , no end-of - l ine sha l l
b e generated upon formatted output j ust because the margin i s exceeded . If the execu
tion of a program reaches an image- l ine , it sha l l proceed to the next l ine with no
further effec t .
10 . 4 . 5 Exceptions
- An inva l id format- string is specif ied in a formatted-print- l is t ( 82 0 1 , fatal ) .
- A formatted -print - l ist contains an output- l i s t , but there is no format- item in the
format-string ( 8202 , fatal ) .
- 88 -
7.
8.
9.
10 .
11.
A red im and the array in its redim-array s ha l l have the same number of dimens ions .
A variab l e - length-vector must be one-d imensiona l .
10 . 5 . 3 Examples
1 . MAT
MAT
4 . MAT
MAT
MAT
8 . MAT
9 . MAT
READ A
READ A ( M , N ) , B
INPUT A$ ( 3 , 4 )
INPUT X ( ? )
INPUT PROMPT "Enter data :
LINE INPUT A$
PRINT A ; B , C ;
"
X( ? )
1 0 . 5 . 4 Semantics
The array read s tatement
Execution of an array- read - s tatement s ha l l cause arrays in the redim-array- l is t to be
ass igned , in order , values from the data sequence created by data-statements in the
program-unit containing that statement . Values sha l l be ass igned to a l l e lements in
each array in row maj or order , ( i . e . , the last subscript varying most rap i d l y , then
the next to last subscrip t , if any , etc . ) with each success ive value being obtained
from the datum in the data sequence indicated by the po inter for the sequence and the
pointer being advanced beyond that datum .
The type of each datum in the data sequence sha l l correspond to the type of the
array-element to which it is to be ass igned ( see 10 . 1 ) .
I f a redim is present then dynamic redimensioning sha l l take p l ace before values are
ass igned to the redimensioned array . The redimens ioning sha l l be done accord ing to
the rules for bounds in array-dec l arations . The values of the indices sha l l be used
as the new lower and upper bounds for the array . If an exception occurs when attempt
ing to redimens ion an array , it sha l l retain its o l d d imens ions . Redims in the redim-
- 89 -
array-list shal l be evaluated after values have been ass igned to the arrays preceding
them (i . e . , to the l eft of them) in the redim-array-lis t .
The handl ing o f insufficient data with o r without a miss ing-recovery shal l work as
des cribed in 10 . 1 .
If the evaluation of a numeric datum causes an underfl ow then its value shal l be re
pl aced by zero .
The array input statement
Execution of an array-input-statement shal l cause execution of the program to be sus
pended until a valid input-reply, as s pecified bel ow, has been supplied. An array
input-statement shal l cause arrays in the redim-array-list to be ass igned, in order,
values from the input-repl y . Values shal l be ass igned to al l el ements in each array
in row maj or order .
In the interactive mode, the user of the program sha l l be informed of the need to
supply data by the output of an input-prompt . The prompt is identical to that of the
input-prompt of the input-statement .
The input-modifier-list, if present, s hal l work as described in 10 . 2 .
The type of each datum in the input-reply shall correspond to the type of the array
element to which it is to be ass igned .
If a redim is present then dynamic redimensioning shal l take pl ace as described above
for the array-read-statement before values are ass igned to the redimensioned array .
Redims in the redim-array-list sha l l be evaluated after values have been ass igned to
the redim-arrays preceding them (i . e . , to the l eft of them) in the redim-array-l is t .
I f the recovery procedure for an input exception causes input data t o b e re-supplied
to an array which was redimensioned after tl1e original ass ignment of data to it, but
before the exception occurred, the effect is implementation-defined . Data in res ponse
to a request for array input need not be supplied in a single input-reply. If the
array-list has not been completely supplied with data and the input-reply contains a
final comma , then the input-prompt shal l be issued and a further input-reply shal l be
requested to obtain more data.
If the evaluation of a numeric datum causes an underfl ow then its value shal l be re
pl aced by zero .
Input of variable l ength vectors
If a variabl e-length-vector occurs in an array-input-statement, then as many data as
are present in the input-reply (or sequence of input-repl ies up to and incl uding the
first which does not end with a comma) shal l be s uppl ied as input for that vector.
As s ignment of data shal l begin with the current l ower bound for the vector . After as
s ignment, the vector shal l be redimens ioned dynamically by s etting the upper bound
for its s ubs cript equal to the subs cript of the element receiving the l ast datum. The
number of data values ass igned to the variable-l ength-vector shal l not exceed the
original s ize for that vector as s pecified in its array-decl aration.
The type of each datum in the input-reply sha l l correspond to the type of the array .
The array-l ine-input-statement
When an array-l ine-input-statement is executed, a l ine-input-reply shal l be requested
for each element of each string-array in the string-array-list in the same fashion
that an input reply is requested and shal l assign the entire contents of successive
l ine-input-repl ies (excluding their end-of-l ines ) in row major order to el ements of
the string-arrays in the string-array-l is t . The number of l ine-input-repl ies re
quested shal l equal the number of elements requiring values .
- 90 -
In the
interactive mod e ,
the user
of
the program
shal l
be
informed
of
the
need
to
if present,
10 . 2 .
If a redim is present then dynamic redimensioning sha l l take p lace as described above
for the array-read - s tatement before values are ass igned to
Redims
in
the redim-string-array- l i s t
sha l l be
(i.e. ,
to the
in the
of a l l elements
in a l l
red im-string-array - l is t .
The array print s tatement
Execution of
an array-print - s tatement
sha l l
cause
An
the values
the characters
generated
for
transmi s s ion to an exte rna l device by the printing of a two - d imensional array are a l
most prec i s e l y those that would be generated
l isted , row by row ,
if the e l ements
( or separated by a co mma if
b e a n end - of - l ine each time a row of the array has been printed
l ine has not a lready been generated ) . A three - d imens ional array sha l l be printed l ike
a series
of two - d imensional
arrays ,
one
with
an extra end - o f - l ine generated between each value of the f irst subscrip t . When a one
dimens ional array
if it were a
Final l y ,
an
is printed ,
it sha l l
be treated
l ike a row-vector ,
and printed as
x N array .
extra
end - of - l ine
sha l l
be
generated
between
the output
for
success ive
arrays in an array-print - l i s t .
For a n array-print - s tatement with a n array- output- l is t ,
transmis s ion to an external device are
elements
of
output - l is t
statement .
using an
each array
of
No
had been
a print - s tatement ,
l i sted
us ing
image ,
if
there
is
by array ,
same
image
in
as
sha l l be generated .
row-maj or
that
in
order ,
if the
in
the
the array-print
a f inal
end - of - l ine sha l l be generated after a l l other output from the array-print - s tatement .
If there is such a semicolon ,
10 . 5 . 5
Exceptions
The redim- array- l i st in an array - read - s tatement requires more data
in the remainder of the data sequence and no
( 8001 ,
- An
than
are present
been
specified
fata l ) .
( 810 1 ,
fatal ) .
( 10 5 3 ,
l ine
supp l ied
datum
nonfata l :
supp l ied
as
in a
fatal ) .
( 8102 ,
input
nonfata l :
for
( 1006 ,
fata l ) .
is not a syntactica l ly
numeric-array
is
not
( 8 103 ,
- 91 -
- There are insufficient data in an input- rep l y not containing a final comma ( 8002 ,
nonfatal : request that the current input-rep l y be resupp l ied ) .
- There are too many data in an input-rep ly or there are j ust enough data and the
input- rep l y ends with a comma ( 8003 , nonfatal reques t that the current input-repl y
be resupp l ied ) .
The evaluation of a numeric datum in an input-rep ly causes an over f l ow ( 1007 ,
nonfata l : reques t that the current input-rep l y be resupp l ied ) .
- The assignment of a string datum during execution of an array- input-statement or an
array- l ine- input-statement causes a string overf low ( 1054 , nonfatal : request that
the current input-rep ly or l ine- input-rep ly be resupp l ied ) .
- The total number of e l ements required for a redimensioned array exceeds the number
of e l ements reserved by the array ' s origina l d imensions ( 5001 , fatal ) .
The f irst index in a redim-bounds is greater than the second index ( 6005 , fata l ) .
- A redim-bounds cons ists of a s ingl e index which is less than the defau l t lower
bound in effect ( 6005 , fata l ) .
- A val id input-rep ly or l ine- input-rep ly has not been supp l ied within the number of
seconds specified by a t imeout- expression in an input-mod if ier - l is t ( 8401 , fata l ) .
- The value of numeric-expression used as a time-expres sion is less than zero ( 8402 ,
fatal ) .
- An invalid format-string is specif ied in an array-print-statement ( 8201 , fata l ) .
- An array-print-statement contains an array-output - l is t , but there is no format- item
in the format-string ( 8202 , fata l ) .
10 . 5 . 6 Remarks
This S tandard does not require an imp l ementation to output ( i . e . , echo ) the input
rep l y or l ine- input-rep l y .
This S tandard does not require an imp lementation t o provide fac i l ities for correcting
erroneous input-rep l ies , though such fac i l ities may be provided .
Implementations may choose to treat underflows as exceptions ( 1507 , nonfatal : supp ly
zero and continue ) . I n BASIC-2 imp l ementations , this permits interception by
exception hand lers .
- 92 -
1 1.
F I LE S
- 93 -
1 1 . FILES
Two d i fferent leve l s of f i le processing are defined for BASI C - 1 and BASIC- 2 .
combinations
of
f i le organization
and
record
types
permitted
The d i fferent
leve l s
are
de
tailed below.
The production rules pe rmitted
indentation
permits
to
d i stinguish
the
parts
of
the
BAS IC- 1
are
true
subset
of
those
too difficult
permitted
in
to present
text valid
for
BAS IC- 1
only
or
for
BASIC- 2 ,
in a s ingle
when
the
tex t ,
identification
this
text
is
of
repeated
with a means of saving data developed during execution of a program and then retr ieving and
modifying that data during subsequent execution of BASIC programs . The process by which ex
ternal data is transferred to or from a program i s cal led input or output , respective l y .
imp lementat ion-def ined means must be provided
of f i l es .
An
Input and output operations to these f i les must perform as specif ied in this sec
tion .
This
some
cases ,
these
Standard makes
logical appearance
attributes
no
may
presumptions
reflect
of
f i les
physical
characteristics ,
but
representation
in
or
general
In
this
organization
of
f i les or devices .
The meaning
of certain
terms used
throughout this
section is as f o l lows .
value .
Assoc iated
with
Thus ,
each
file
during
execution
is
A " f i le e l ement"
"file
unique ly identifies
a particular
to the end of f i le .
f irst f i l e e l ement ,
if any .
If a f i l e is an empty sequence ,
the
s tatement ,
or
it is
always
points
identifies
the
is made to
For sequentia l ,
ately f o l lowing
location .
any
which
l a s t f i le
e l ement .
F o r relative
files ,
the
" end
of
f i l e"
immediately
fo l lows the last existing record , and thus identifies an empty record area .
BASIC- 1
There are
two
kinds
of
f i l e - organizatio n :
sequential
and
stream .
sequential
of
characters .
An
internal record
is a
is a
Dis
p lay records provide for the exchange of data between systems emp loying d i ffer
ent internal representations for numeric and string values , and also manipulate
data in human- readab le form.
- 94 -
There are f ive statements which operate on the f i l e as a who le and are thus
cal led " f i l e operations" : OPEN , CLOSE , ERASE , SET and ASK . There are f ive
s tatements which app ly to individual f i l e elements and are known as "record
operations" : INPUT , PRINT , READ , WRITE and SET with pointer-contro l , inc luding
the variations using MAT and LINE . References to " INPUT operations" , "WRITE
operations" , and so forth should be understood to inc lude any of the statements
us ing the keyword in question, e . g . "WRITE operations" includes WRITE and
MAT WRITE . The f ive record operations can affect data within a f i l e , variables
within the program and the file pointer .
PRINT and WRITE affect f i le data and the po inter , READ and INPUT affect program
variables and the pointer . SET with po inter-items obvious ly affects only the
pointer .
BASIC-2
There are four kinds of f i le -organization : sequential , stream, relative and
keyed . Sequential and keyed f i les are sequences of records . A relative f i le is a
sequence of record areas , each of which may or may not contain a record . A
stream f i le is a sequence of values .
There are three kinds of record - typ e : disp lay, internal and native . An internal
record is a sequence of typed values . A native record is a sequence of field s ,
a s described by a programme -spec if ied temp late . Disp lay records provide for the
exchange of data between systems emp loying different internal representations
for numeric and string values , and also manipulate data in human- readab le form .
Internal records provide for efficient manipulation o f data within a s ingle sys
tem . Native records provide for the exchange of data among d ifferent language
processors within a s ingle system .
The f o l lowing combinations of f i le-organization and record- type are supported :
-
sequential d isplay
sequential internal
stream internal
relative internal ( enhanced internal )
keyed internal ( enhanced internal )
sequential native ( enhanced native )
relative native ( enhanced native )
keyed re lative ( enhanced native )
- 95 -
Devices
Not all input or output is to or from a f i l e , as defined above . An imp lementation may al low
f i le process ing statements to apply as wel l to devices , such as a termina l , a l ine p rinter
or commun ications l ine .
When the term " f i le" is used throughout chapter 1 1 , it should general ly be understood to
mean any source or destination of external data, i . e . either a true f i l e or a device . In
certain contexts where it is necessary to distinguish between the two , the terms "true
f i le" and "Device"w i l l be used for emphasis .
Devices differ from f i les in the fol lowing ways :
- It is imp lementation-defined whether data written to any given device is stored there and
may later be retrieved by input operations ( see 1 1 . 1 ) .
- It is imp lementat ion-def ined whether a given device is erasab le ( see 11 . 1 ) .
- RELATIVE and KEYED f i le-organizations are not a l l owed for devices ( see 1 1 . 1 ) . ( not re levant to BASIC - 1 )
- A device need not support a l l access modes ( see 1 1 . 1 ) .
- A device need not support the minimum record s ize of 13 2 ( see 11 . 1 ) . However , the
imp lementation must document the minimum record - s i z e for each device supported .
- It is imp lementation-defined whether a given device has record- s etter capabi l ity ( see
11 . 2 ) .
- It is imp l ementation-def ined what condition causes the data-found condition to be set
true or false for a g iven device ( see 1 1 . 2 ) .
- For interactive terminal devices only, the s emantics of the input-contro l - i tems prompt
speci f ier , timeout-express ion, and time enquiry must be supported . The imp lementation
must define which devices , if any , are interactive terminal devices . The effect of these
input-contro l - items on other devices and on true f i les is imp lementation-defined ( see
11.4) .
- I t is imp l ementation-defined whether the f o l lowing cond itions are treated as fatal excep
tions , as defined in 1 1 , or as nonfatal , as defined in 10 ( in which case the recovery
procedure is app l ied ) , when these cond it ions occur within INPUT operations on a device
( see 1 1 . 4 ) .
Section 1 1
Section 10
8105
8101
8102
8103
8012
8013
1008
1 105
8002
8003
1007
1054
Condition
Syntax error in input-rep ly
Datum from a numeric-variable not
a numer i c -constant
Too few data in input - rep ly
Too many data in input-rep ly
Numeric overf low on input
String overflow on input
The f o l l owing tables provide an overview of the various f i l e fac i l ities . For the ful l spec
i f i cations , see 1 1 . 1 through 1 1 . 4 .
- TABLE 1 FILE-ORGANIZATION VERSUS OPERATIONS AND RECORD- SETTERS .
This table i l lustrates which combination of record operations and record-setter are le
gal under a given f i le -organ i zation , thus the organization i s defined by the capab i l i
ties of record manipulation it a l l ows . Combinations of operations and record- setters
which do not appear in the table are syntax errors . Organizations permitted in BASIC- 1
and BASIC-2 are identi fied by l'c , those permitted only in BASIC-2 are identified by **
- 96 -
F i l e Organization
STREAM
RELATIVE
l'<OK
l'<OK 4
lOK
t rD 2
' ID 2
< ID 2
l'<ID 2
l'< ID 2
rlq D 2
l''< ID 2
l''< ID 2
l'm iD 2
r'' ID 2
'n ID
l'n'< ID
'n'< ID
'rl< ID
'rl< ID
2
2
2
2
2
l'<OK
l'<OK
l'<OK
l'<OK
<oK
l'< ID
l'< ID
l'< ID
l'< ID
:'< ID
'< ID
ID
l'<l't i D
l' ID
l'n'< ID
d< ID
l'<l'< ID
:'ti'< ID
l'd< ID
2
2
2
2
2
SEQUENTIAL
Operation
record- s etter
KEYED
INPUT
absent
NEXT
BEGIN
END
SAME
<oK
<oK
PRINT
absent
NEXT
BEGIN
END
SAME
2
2
2
2
2
2
2
2
2
l'ri<ID 2
READ
absent
NEXT
BEGIN
END
SAME
RECORD
KEY
l'<OK
<oK
l'<OK
'oK 4
<oK
'd<
) EX 1
lh'<EX 1
l'<OK
>'<OK
:'<OK
l'<OK 4
l'<OK
,'d<EX 1
,'o'<EX 1
l''<OK
'rl<O K
lh'<OK
h'<OK
>bO K
rl<OK
l''OK
l''OK
:oK
l''OK
:''OK
:''OK
'''OK
l't>'<O K
l'd'OK
lh'< EX 1
l'<l'<OK
:'<l'<OK
l'ri<OK
l'ri<OK
:oK
,'col<EX 1
r:l''O K
WRITE
absent
NEXT
BEGIN
END
SAME
RECORD
KEY ( exact)
l''OK
l''OK
l''OK
,'d<EX 1
,'d<EX 1
l'<l''OK
::'<OK
:''<OK
,'d<EX 1
,'d<EX 1
l'<l''OK
')'d<EX 1
l'(l ID
>'rl' ID
>'t>'' ID
d' ID
>'rl'O K
>'d'O K
:'tl''EX 3
'J'cl<EX 3
lh''EX 3
)'(:'<EX 3
'J'd<EX 3
)'d<EX 1 , 3
,'n'<QK
l'(l ID
>'rl'ID
>'rl' ID
>'<l'< ID
,.,,., ID
5
5
5
5
5
l'(l'< ID 5
>'<>'< ID 5
5
5
5
5
l't>'' ID 5
>'d< ID 5
l'<l'< ID 5
>'<l''OK
>'n''OK 4
>'rl' OK
>'n'<O K
,.,,,,EX 1
l'<OK
:''OK
:''OK
l''OK
,oK
M< EX 1
,'d<EX 1
l'd<OK
:'d<OK
l''<OK
'<>'<OK
n'<OK
i'<OK
')'()'< EX 1
>'<l''OK
>'n'<OK
>'<l''OK
>'d'OK 4
:'d<OK
,'d<EX 1
l'<l'<OK
l'<OK
>''OK
l'<OK
<oK
l''OK
,c;'<EX 1
>'<>EX 1
l'd<O K
>'rl'O K
>'rl<OK
'd<O K
M<OK
M<EX 1
>h'<OK
- 97 -
OK
EX
ID
c
de
Exception
Imp l ementation-defined
BASIC- ! and BASIC-2
BASIC-2 only
other
then
CONTROLS
record- s etter
io-recovery
missing
INPUT
PRINT
cA
cA
'A
READ
WRITE
cA
cA
cA
ricA
>'t'I'< A
l'CA
cl'CA
)'t)'<A
l'CA
REWRITE
DELETE
SET
A
l'c
)'de
interpretation
not
miss ing
cA
image
temp late
)'CA
)'n'cA
ricA
)'CA
-.'cl'<A
l'CA
a l l owed
BASIC - ! and BASIC-2
BASIC-2 only
Record- type
ORGANI ZATION
DISPLAY
SEQUENTIAL
STREAM
RELATIVE
KEYED
A
)'c
l'cic
a l l owed
BASIC-1 and BASIC-2
BASIC-2 only
l'CA
INTERNAL
)'CA
l'CA
'l'dcA
l'ricA
NATIVE
ldtA
'l'o'<A
lc,''A
- 98 -
1 1 . 1 F i le Operations
1 1 . 1 . 1 General Description
There are four statements which affect a f i l e as an entity . The open-statement makes
a f i l e accessible to the program , estab l ishing the connection between the f i le and
the program . S ince the format for identifying f i les may vary with the operating sys
tem , it is as sumed only that with each f i le is assoc iated a string of characters ,
cal led its name , which identif ies the f i le to the operating system . A f i l e is identi
fied within a program by the number of a channel through which it is accessed . The
close-statement terminates the acces s ib i l ity effected by they open-statement . The
erase - statement deletes al l or part of the data within a true f i l e , but may have no
effect on a d evice . The ask- statement is used to inquire about the current status of
the f i l e .
1 1 . 1 . 2 Syntax
BASIC-1 and BASIC-2
1 . open- statement
2.
3.
4.
5.
6.
7.
channel- setter
channel - express ion
f i le-name
f i le-attribute- l ist
f i le-attribute
core - f i le-attribute
>
8 . access-mode
9 . f i le-organization
10 .
11.
12 .
13 .
14 .
15 .
f i le-organization-value
core- file-org-value
record- type
record- type-value
core-record- type-value
record - s ize
16 .
17 .
18 .
19 .
20 .
21.
22 .
c lose- statement
erase-statement
ask-statement
ask- item - l ist
ask- item
ask-attribute-name
core-attribute-name
>
>
>
>
BASIC-2 only
23 .
24 .
N25 .
N26 .
27 .
28 .
29 .
30 .
31.
f i le -organization-value
>
enhanced - f i le-org-value
>
record- type-value
enhanced-record-type-value=
f i le -attribute
>
enhanced - f i le-attribute
col late- sequence
ask-attribute- name
>
enhanced-attribute-name
enhanced- f i le-org-value
RELATIVE I KEYED
enhanced-record- type-value
NATIVE
enhanced- f i le-attribute
col late- sequence
COLLATE ( STANDARD I NATIVE I string-expres s ion)
enhanced-attribute-name
RECORD I KEY I COLLATE
- 99 -
OPEN tiN : NAME A$ , ACCESS OUTIN , ORGANI ZATION STREAM , RECTYPE INTERNAL , RECSIZE
VARIABLE LENGTH N
OPEN I!N+ l : NAME "MY" & F$ , ORGANIZATION ORG$
16 . CLOSE liN
1 7 . ERASE 113
ERASE REST 114
18 . ASK t/3 : ACCESS AC$ , DATUM DT$ , NAME NM$ , ORGANIZATION ORG$ , POINTER P$ , RECSIZE
RS $ NUMCHARS , RECTYP RT$
ASK
liN : KEY K$
1 1 . 1 . 4 S emantics
F i les are accessed through channels to which they may be assigned during execution of
a program-un i t . A channe l is a logical path through which external data may be trans
ferred to or from a BASIC program . Within a program-unit , a channel is identi f ied by
a channel number local to that program-unit . The channel number is an integer from 0
up to and includ ing some imp lementation-defined maximum . This maximum must be at
least 99 . A f i l e , identified by its f i le-name , is open if it is currently ass igned to
a channel and c losed o therwis e . A channe l is active if it currently has some f i l e as
s igned to it and inactive otherw is e . At the initiation of execution of a program , a l l
channe ls except channe l zero sha l l b e inactive . Channel zero shal l always b e active .
Execution of the open-statement , close-statement , or erase- s tatement ( see below) for
channe l zero sha l l cause a nonfatal exception .
Input and output from and to channel zero shal l have the same source and destination
as input-statements and print-statements which do not contain channe l -express ions .
Channe l zero sha l l behave as a device with the f i le-attributes sequential , d isplay ,
and out in , and w i thout record- setter o r erase capab i l ity .
Open-statement
The open-statement makes the f i l e identified by the f i le-name acces s ible to the pro
gram through the channel number spec if ied in the channel -express ion . I t is
imp lementation-defined whether f i le names d i f fering only in the case of the letters
( upper or lower ) denote the same f i l e or d ifferent f i les . Fo l lowing a successful
open-statement , the associated channel sha l l be active and the f i le open . An attempt
to open a f i l e on a chru1ne l which is already active causes an exception . The effect
of attempting to open a f i l e which is a l ready open is imp lementation-def ined . The
number of channel s other than channel zero which may be active s imultaneous l y is at
least one .
After a successful open, a true f i l e shal l be accessible in accordance with the asso
c i ated f i le-attr i butes , whether exp l ic itly speci fied or in effect by defau l t . This
access ib i l ity consists of the abi l ity to perform certain operations and manipulate
the f i le pointer in certain ways . See the preceding section for an overview of which
statements are a l lowed under which attributes . If an attempt is made to OPEN a f i le
which cm1not be made accessible with the requested attributes ( i . e . , if not a l l the
associated operations can be successfully executed for this f i le ) , then an exception
results .
- 100 -
For a devic e , a successful open guarantees that , with two exceptions , al l the f i l e
processing statements w i l l have the same effects a s f o r a true f i le . In particular ,
on output , the same data w i l l be generated , and on input , values and characters wi l l
be interpreted and ass igned to variables in the same way . A device , however , might
not support the s emantics associated with the recorder- setter ( see Section 11 . 2 ) or
the erase- s tatement (below ) . The ask-statement may be used to determine whether a
particular device supports these capab i l ities .
BASIC- 1 only
If a f i l e is opened successfu l ly with a given f i le-organization, record-typ e ,
and record - s i ze , then c l osed , and then opened a t a later time with a different
value for one of these f i l e - attributes , then it is imp l ementation-defined
whether the f i l e is thus acces s i b l e . Also , for f i les with record-type INTERNAL ,
if a d ifferent ARITHMETIC option is in effect for the two executions , it is
imp l ementation-defined whether the file is thus access ible . Conversely, if a
true f i l e is reopened at a later time with the same values for the f i l e
attributes mentioned and , f o r f i les with record-type INTERNAL , the same
ARITHMET I C option is in effect , and the user has emp loyed the imp l ementation
defined means to preserve the f i l e unchanged in the interim, then the f i l e must
be accessible and the contents of the file faithful ly preserved . Devices are not
required to preserve data . In the foregoing , "same ARITHMETIC option" refers to
DECIMAL or NATIVE .
If a f i l e with record- type INTERNAL opened in one program-unit is accessed by
another program-unit with a d i fferent ARITHMETIC option, the results are
imp lementation-defined .
Implementations must provide true f i les for which a l l access-modes are avai l
abl e . Imp l ementations may also support true f i les for which some access -modes
are not availab l e . A device need not support a l l access-modes .
Imp l ementations conforming to this standard need only to accept and process the
f o l lowing combinations of f i l e -organization-value and record- type-value :
- sequential d isplay ,
- sequential internal ,
- stream internal .
The effect of the other combination is imp lementation-defined .
When a string-expression is used as an attribute value , its value must be one of
the assoc iated keywords for that attribut e . Upper-case-characters and lower
case-characters sha l l be treated as equivalent within such string values . Imp le
mentations may def ine additional f i l e attribute values .
BASIC-2 only
If a f i l e is opened successfu l ly with a given fi le-organization, record-typ e ,
and record - s i ze , then c losed , and then opened a t a later time with a different
value for one of these f i l e - attributes , then it is imp lementation-defined
whether the f i l e is thus accessib l e . Also , for fi les with record-type INTERNAL
or NATIVE, if a different ARITHMETIC option is in effect for the two executions ,
it is imp l ementation-defined whether the f i l e is thus accessible . Conversel y , if
a true f i l e is re-opened at a later time with the same values for the f i le
attributes mentioned and , f o r f i les with record- type I NTERNAL or NATIVE , the
same ARITHMETIC option is
in effect , and the user has emp loyed the
imp l ementation-def ined means to preserve the f i l e unchanged in the interim, then
the f i l e must be accessible and the contents of the f i l e faithful ly preserved .
Devices are not required to preserve data . In the foregoing , "same ARITHMETIC
- 101 -
sequential display
sequential internal
s tream internal
relative internal
keyed internal
s equential native
relative native
keyed relative
- 102 -
F i le-organ ization
The f i le-organization specif ies the logical relationship between f i le elements , and
the means by which the f i le pointer can be manipulated to identify the elements . The
organ i zation is spec if ied with one of the keywords SEQUENTIAL , STREAM , RELATIVE or
KEYED , or w ith a string-expression whose value is one of these keywords . Devices are
accessed as e i ther SEQUENTIAL or STRKM1 , RELATIVE and KEYED are al lowed only for true
f i les . RELATIVE and KEYED app ly only to BASIC-2 .
If no f i le-organ i zation is exp l ic itly spec ified in the open-statement , then the orga
nization sha l l be determined from avai lable system information about the f i l e . If
such information is insuffic ient , the sys tem shall attempt to open the f i le as
SEQUENTIAL . Channel zero sha l l behave as if opened with SEQUENTIAL .
A sequential f i le is a sequence of records . The order of the records is establ ished
by the order in which they were wr itten . Records can be added only to the end of
the f i le . The only meru1s for identifying records with the f i l e pointer is relative
to the current pos ition of the pointer , and the two spec ial locations BEGIN ( which
identifies the first record in the sequence , if any ) , and END , immed iately f o l l ow
ing the last record ( the only location where it is pos sible to add records ) . A
s ing le record operation may affect several DISPLAY records , but only one INTERNAL
o r , for BASIC- 2 , NATIVE record .
- A stream f i l e is much l ike a sequential f i l e , except that it is a sequence of indi
vidual values , rather than of records . The order of values is estab l ished b y the
order in which they were written . Values cru1 be added only to the end of the f i le .
The only means for identifying values is relative to the current pointer position ,
or BEGIN and END ( spec ifying respective l y , the f irst value , if any , in the se
quence, and the location immediately fo l lowing the last value ) . One record opera
tion may typ ical ly read or write a contiguous series of values within a stream
f i le .
BASIC- 2 only
- A relative f i l e is a sequence of record-areas , each of which may or may not
contain a record . The record-areas are numbered sequentially beginning with
1 . Thus the order of the record-areas and the records within them is estab
l i shed by the identifying integer associated with each . The f i l e pointer may
be manipulated with the use of this record number as wel l as by those means
provided for sequential f i les . For relative f i les , the beginning of f i l e is
the first record-area, regard less of whether it contains a record . The end of
f i le immed iately f o l lows the last exis ting record . Thus if the highest exist
ing record number is 44 , end of file refers to record-area 4 5 . If there are
no records in the f i le , end of f i l e refers to record-area number 1 . Records
within a relative f i l e may not only be read and written, but also changed
( with REWRITE ) and deleted ( with DELETE ) . Moreover , records may be added , not
only at the end of f i le , but also at any empty record-area , including those
past the end of f i l e . A record operation proces ses at most one record .
A keyed f i l e is a sequence of records , each of which is identified by a string
cal l ed a key . The logical sequence of records is estab l ished by the c o l lating
order of their keys . ( See co l late- sequence , below . ) The f i l e pointer may be
manipulated with respect to the keys , as wel l as by the means provided for
sequential f i les . As with sequential f i les , beginning of f i le refers to the
first existing record in the sequence ( if any ) , and end of f i le refers to the
location immed iately fo l lowing the last record . Records may be added anywhere
within the sequence . An exact key , however , must always be speci f ied for
record creation , and no dup l icate keys are a l lowed . Records may also be read ,
changed or de leted . A record operation processes at most one record .
- 103 -
Record- tyPes
A record- type specifies the logical representation of data within a record or as an
individual f i l e e l ement . The record- type affects how data is interpreted and trans
formed when being transferred between a program and a f i l e . A record- type is speci
f ied with one o f the keywords DISPLAY , INTERNAL or NATIVE or with a string-expression
whose value is one of these keywords . NATIVE app ly only for BASIC - 2 .
If no record- type is exp l ic itly spec if ied on the OPEN, the record-type is determined
from avai lab le system information about the f i l e . If such information is insuf f i
c ient , then the f i le sha l l b e opened a s DISPLAY . Channe l zero behaves a s i f opened
with DISPLAY .
- The disp lay type spec if ies that a record is a sequence of characters . On output ,
the characters are processed in accordance with the semantics of the PRINT
statement , and on input with those of the INPUT statement ( see 10) . READ and WRITE
are also a l l owed for d isp lay records ; they fol low the semantic rules for I NPUT and
PRINT , respective ly .
- The internal type spec ifies that a record is a sequence of typed values ( o r that
each f i l e e l ement is a value ) , in the same sense that a program var iable contains
a value . The essential aspect of internal format is that ( for a true f i l e ) values
are preserved and retrievable . Thus , if a numeric or string value is written from
a program variab l e , and later read into another variabl e , the two variables must
be strictly equal ( assuming the o r iginal variable to be unchanged ) . S ince I NPUT
and PRINT statements are essentially character-oriented , they cause an exception
when used on a f i l e opened as internal .
BASIC-2 only
- The native type spec i f ies that a record is a sequence of f ie lds , as described
by a program- spec if ied TEMPLATE . This TEMPLATE , in conjunction with the l ist
of operands of the associated record operation, speci f ies the s ize , typ e ,
number , and order of f ie lds within the record . This a l lows data i n a f i le to
be put in a form suitable for exchange with other language processors which
have s imilar record speci fication capab i l ities . Values are preserved subj ect
to certain restrictions regarding the s i ze of the f ields in the record . As
with the internal type , INPUT and PRINT cause an exception when used on a
f i l e opened as native .
Record - s i ze
A record - s ize spec i f ies the maximum length of records in a f i l e . It is spec i fied ex
p l i c itly with the keyword LENGTH .
Unless an enhancement to this Standard provides for f ixed- length records , a l l f i les
sha l l be composed of variable- length records , i . e . , of records whose l engths are in
dependent of each other . The length of a record of type DISPLAY sha l l be the number
of characters in that record . The length of records of other types ( INTERNAL o r , for
BASIC-2 only, NATIVE) sha l l be imp lementation-def ined . An attempt to perform a record
operation for a record whose length exceeds the maximum set ( either exp l ic it ly or by
defau l t ) in the OPEN operation sha l l use an exception . A speci fied LENGTH index must
be greater than zero .
If no record - s ize is exp l icitly speci fied in the open- s tatement , then the record - s ize
is determined from available system information about the f i l e . I f such information
is insuf f icient , then the f i l e sha l l be opened as VARIABLE . If the index is omitted ,
then the maximum length of records sha l l be impl ementation-defined . Channe l zero
sha l l behave as if opened with VARIABLE and the length index omitted .
Imp l ementations must support record- s i zes of at least 1 3 2 for true f i les .
- 104 -
An erase-statement executed for channe l zero sha l l cause an exception, but no other
effect sha l l occur .
An erase-statement is al lowed only for a f i l e opened with access -mode OUTIN . For
other access-modes , there is no effect on the f i l e and an exception results .
Ask - s tatement
Execution of an ask-statement sha l l cause the variables in the ask- item- l ist to be
assigned values corresponding to the attributes of the f i le currently ass igned to the
specified channel , as indicated in the fo l lowing table . If the channe l is inactive ,
- 105 -
then a l l such string-variables sha l l be assigned the nul l string , and al l such
numeric variables sha l l be ass igned 0 . In al l cases below , A$ represents a string
variable and N represents a numer ic-variabl e .
I n BASIC-2 the fol lowing responses can b e expected :
Ask-item
Values
ACCESS A$
The access-mode of the f i l e , i . e . , " I NPUT" , "OUTPUT" , or "OUTIN" .
COLLATE A$
The c o l late-sequence assoc iated with a KEYED f i le , i . e . "STANDARD" or
"NATIVE" . For f i le-organizations other than KEYED , the nul l s tring is as
s igned .
DATUM A$
The type of the next datum in the f i l e fol lowing the current pointer pos i
t ion, i . e . , "NUMERIC" , "STRING" , "NONE" ( if n o data fo l low ) , o r "UNKNOWN" ( if
it is impossible to determine the type or whether more data f o l low ) . DATUM is
wel l -defined only for STREAM INTERNAL f i les . For other f i le organizations , it
is imp lementation-defined .
ERASABLE A$
"YES" or "NO" depending on whether or not this f i l e is erasab l e , i . e . , if the
ERASE s tatement can delete f i le e l ements .
FILETYPE A$
"FILE" or "DEVICE" depending on whether this is a true f i le capable of pre
serving data , or is a device .
KEY A$
The key associated with the record identified by the f i le pointer in a keyed
f i le . If the pointer is at the end of f i l e or if this is not a keyed file ,
the nul l string is ass igned .
MARGIN N
The current margin for a d isp lay f i l e ( MAXNUM if the record may be of arbi
trary length ) . If the file is not DISPLAY , zero is ass igned .
NAME A$
The name of the f i le ass igned to the channe l .
ORGANIZATION A$
The f He-organization of the f i l e , i . e . , "SEQUENTIAL" , "STREAM" ,
"RELATIVE"
or "KEYED" .
POINTER A$
The current pointer position for the f i l e , i . e . , "BEGIN" , "MIDDLE" , or "END" ,
where MIDDLE s ha l l mean neither BEGIN nor END, and END shal l be the pointer
pos ition for an f i l e , or a position beyond the end , in the case of a RELATIVE
f i le . UNKNOWN may be returned in the case of devices for which an imp lemen
tation cannot determine which of the above values is correct .
- 106 -
RECORD N
The number of the record-area identi fied
relative f i les , zero is ass igned .
by
the
f i le -po inter .
For
non
RECSIZE A$ N
The record - s i ze of the f i le , i . e . "VARIABLE" and the maximum length for its
records ( MAXNUM if there is no effective l imit on record- length , e . g . , a com
munication line ) .
RECTYPE A$
The record- type for the f i l e , i . e . "DISPLAY" , " INTERNAL" or "NATIVE" .
SETTER A$
"YES" or "NO" depending on whether or not this f i le has record- setter capa
b i l ity .
ZONEWIDTH N
For DISPLAY f i les , the current zonewidth . For non-DISPLAY f i les , zero is re
turned .
In BASIC- 1 , the fol lowing responses can be expected :
ask-attribute
value
ACCESS
COLLATE
DATUM
ERASABLE
FILE TYPE
KEY
MARGIN
NAME
ORGANIZATION
POINTER
RECORD
RECSIZE
RECTYPE
SETTER
ZONEWIDTH
as BASIC-2
nul l string
as BASIC-2
as BASIC-2
as BASIC-2
nul l string
as BASIC-2
as BASIC-2
SEQUENT IAL or STREAM
as BASIC- 2 , except that END means an empty f i le
zero
as BASIC-2
DISPLAY or INTERNAL
as BASIC-2
as BASIC-2
The effect of executing an ask - statement for channe l zero is as fol lows :
ask-attribute
ACCESS
COLLATE
DATUM
ERASABLE
FILETYPE
KEY
MARGIN
NAME
ORGANIZATION
POINTER
RECORD
RECSIZE
RECTYPE
SETTER
ZONEWIDTH
value
OUT IN
nul l string
UNKNOWN
NO
DEVICE
nul l string
current margin
imp lementation-def ined
SEQUENT IAL
UNKNOWN
zero
VARIABLE MAXNUM
DISPLAY
NO
current zonewidth
- 107 -
1 1 . 1 . 5 Exceptions
- The value of a channe l -expression is not between 0 and the implementation-defined
maximum ( 7001 , fatal ) .
- Channe l zero is speci fied in an open-statement , a close-statement , or an erase
s tatement ( 7002 , nonfatal do nothing and continue ) .
- A nonzero channe l specif ied in an open-s tatement is already active ( 7003 , fata l ) .
- A string-express ion used to specify a f i le-attribute does not have a recognizable
value ( 7 100 , fata l ) .
Access to a f i le in an open-statement is not possible in accordance with the spec i
f ied or defau l t f i le-attributes ( 7 1xx fatal : the values and meanings f o r x x are
imp l ementation-defined ) .
- A KEYED f i l e is re-opened with a different col late-sequence from that of an ear l ier
open ( 7050, fatal ) . ( BASIC-2 only)
- A LENGTH index is not greater than zero ( 705 1 , fata l ) .
- A device is opened as RELATIVE or KEYED ( 7052 , fata l ) . ( BASIC-2 only )
- A nonzero channe l spec i f ied in an erase-statement is inactive ( 7004 , fata l ) .
- An erase-statement is used on a f i le which has not been opened as OUTIN ( 7 301 ,
fatal ) .
- An erase-statement is used on a device without erase capab i l ity which has been
opened with OUTIN ( 7 3 1 1 , nonfatal : do nothing and continue ) .
1 1 . 1 . 6 Remarks
It is recommended that implementations recognize as f i le-names at least those strings
of characters cons isting of an upper-case- letter f o l lowed by at most three more
upper-case - l etters or d igits . It is also recommended that information required by the
operating system , for the purpose of protecting the security of fi les be considered
part of the f i le-name .
It is recommended that imp lementations use the f i le-name to distinguish between the
opening of a true f i l e , and opening of non- f i le devices , such as a communications
l ine or a l ine printer .
It is recommended that the number of channel s which may be active s imultaneous ly be
at least four in addition to channel zero .
It is recommended that the default maximum length of records in a f i l e be infinite ,
i . e . , that records be a l lowed to be of any length .
It is also recommended that record - s i ze for I NTERNAL and , for BASIC-2 only , NATIVE
f i les has a meaning comparabl e to that for DISPLAY , i . e . , that it specif ies the maxi
mum number of characters or bytes within the record .
Add itional values may be returned by an ASK statement if an imp lementation supports
access - modes , f i le-organizations , record- types , record- si zes and co l late-sequences in
add ition to those spec if ied in this Standard .
If imp lementations return a status code fo l lowing various f i le operations , it is rec
ommended that this be made accessible through an additional ASK attribute to be
cal led IOSTAT which returns a singl e string value , e . g . , "ASK IOSTAT S$11 returns a
val ue in S$ ref l ecting the status of the f i l e f o l lowing the last attempted operation .
The maximum length of a KEY is imp lementation-defined . ( BASIC-2 only)
- 108 -
1 1 . 2 F i l e Pointer Manipulation
1 1 . 2 . 1 General Description
The pointer for an open f i l e can be altered in certain ways , without also performing
any data transfer . The rules for pointer manipulation with the set - s tatement with
pointer - items also apply when used in conjunction with o ther record operations .
11 . 2 . 2 Syntax
BASIC- 1 and BASIC-2
1 . set-object
2 . pointer-items
3 . pointer-control
4 . record-setter
5 . core -record-setter
6 . io- recovery
7 . not-missing-recovery
11 . 2 . 3 Examples
1 . SET #N : POINTER BEGIN, IF MISSING THEN EXIT DO
SET # 3 : RECORD N+l , IF MISSING THEN 1200
SET #4 : KEY "Jones" , IF THERE THEN EXIT DO
11 . 2 . 4 Semantics
Execution of a set- statement with pointer- items shal l set the pointer for the f i le
assigned to the specified channel . After the pointer has been set , an optional io
recovery may take effect . The semantics assoc iated with the record-setter and when
the io-recovery takes effect are uniform for al l the record operations ( see 11 . 3 ,
11 . 4 and , for BASIC- 2 , 11 . 5 ) . If any of the exceptions l isted below in 11 . 2 . 5 occurs ,
the file pointer remains unchanged from its state before the SET with pointer
contro l . A device may not be able to achieve the effect of a record-setter . The ask
statement may be used to determine whether a device has record-setter capab i l ity .
Record-setters
BASIC- 1
An absent record-setter l eaves the file pointer unchanged from its previous
state . The io- recovery ( see below ) , if present , sti l l has its usual effec t .
A record- s etter of NEXT indicates that the po inter is t o b e s e t to the next
record ( for SEQUENTIAL f i les ) or value ( for STREAM files ) at or beyond the cur
rent location . For a SEQUENTIAL f i l e , the only case in which NEXT would have
some effect is if there were a partial record pending ( see 1 1 . 3 ) . In this case ,
an end-of- record sha l l b e generated and the pointer left a t end o f f i l e .
- 109 -
BASIC-2
An absent record- setter l eaves the f i l e pointer unchanged from its previous
state . The io-recovery ( see below ) , if present , s t i l l has its usual effect .
A record - setter of NEXT indicates that the pointer is to be set to the next ex
isting record ( for non-STREAM f i le s ) or value ( for STREAM f i les ) at or beyond
the current location . In the case of a RELATIVE f i l e , NEXT shall therefore cause
the po inter to skip over any empty record areas to the next existing record . If
the pointer is a lready at or beyond the end of f i l e , or is po inting to an exist
ing record , NEXT sha l l leave the po inter unchanged . This capab i l ity a l l ows
RELATIVE f i les to be processed as if they were SEQUENTIAL . In the case of STREAM
and KEYED f i les , the pointer is a lways pointing to an existing f i l e element or
end of f i l e and so is left unchanged . For a SEQUENTIAL f i l e , the only case in
which NEXT would have some effect is i f there were a partial record pending ( see
Section 1 1 . 3 ) . In this cas e , an end-of- record sha l l be generated and the po inter
left at end of f i l e .
A record - s etter of BEGIN causes the pointer to b e set t o the beginning o f f i le , i . e . ,
to the f irst f i l e element . If the f i l e is emp ty , the location is also the end of
f i le .
A record - s etter of END causes the pointer to be set to end of f i l e , defined as imme
diately beyond the last f i le element ( if any ) in the case of SEQUENTIAL, STREAM , and
KEYED f i les , and as immed iately beyond the last existing record in the case of a
RELATIVE f i l e ( or at record-area number 1 , if no records exist ) .
A record- setter of SAME a l lows the user to access the same f i le-element ( s ) that have
most recently been processed s ince the OPEN for that channe l . Its use is val id only
if the most recently executed record operation which accessed the channel meets these
cond itions : it was not a delete-statement , and no exception occurred during its
execution at least unti l after the f i l e pointer had been set .
If these conditions are not met , no pointer manipulation takes p lace and an exception
results . If they are met and the most recent operation was a READ, INPUT , SET with
pointer- items , or REWRITE , then the f i le po inter is reset to the same f i le e l ement it
was j ust set to by the record- setter of that operation . If this operation had no
record- setter , then SAME resets the pointer to the same location it had at the
beginning of that operat ion . If the most recent operation was a WRITE or PRINT , then
SAME sets the pointer to the f irst f i le element created by that operation .
A record - setter with RECORD is val id only for use with RELATIVE f i les . If an attempt
is made to use this record-setter on a f i le not opened as RELATIVE , the pointer is
left unchanged and an exception results . The index is evaluated by rounding to an
integer, and the pointer set to the correspond ing record-area , whether or not it con
tains a record . If the index evaluates to an integer less than one , the pointer is
left unchanged and an exception is generated .
A record- setter with KEY is va lid only for use with a KEYED f i le . If an attempt is
made to use this record- setter on a f i l e not opened as KEYED , the pointer is left un
changed and an exception results . For an exact- search the pointer is set to the
record whose key equals that of the string - express ion ; if none such exists , the
pointer i s set to the f irst record whose key is greater than the ring-express ion . If
there is no such record , the pointer is set to end of f i le . For an inexact- search
with not- less , the pointer is set exactly as for an exact-search , except for the set
ting of the data- found cond ition ( see below ) . For an inexact-search with greater
than - s ign, the pointer is set to the f irst record whose key is strictly greater than
the string-expression; i f none exists , it is set to end of f i l e .
- l lO -
Io-recovery
At the comp letion o f pointer manipulation there sha l l be set a condition cal led data
found , which is either true or false . If data-found is true , and if a not-miss ing
recovery has been specif ied , then the io-recovery-action takes effect . If the data
found condition is false and a miss ing- recovery has been speci f ied , then the io
recovery-action also takes effec t . Except for these two cases , the io- recovery
action, if any , is ignored . The data-found condition is false if :
- in BASIC-2 only, an exact-search has been specif ied , but no record was found whose
key was equal to the string-expression, or
- after the pointer is set , it points to end of f i l e , or
- in BASIC-2 only, after the pointer is set, it points to an empty record-area, or
- for a device , there is an imp lementation-def ined condition s ignifying that no data
is ava i lable for input ; otherwise, the data-found cond ition is true .
If the io-recovery-action is an exit-do-statement or exit- for-statement , the
statement sha l l have its normal effect ( see 8 . 3 ) . If the io-recovery-action is a
l ine-number then execution shall continue at the speci fied l ine .
11 . 2 . 5 Exceptions
- A set- statement with pointer- items
fatal ) .
- A record - setter
continue ) .
is
used
with
is
channe l
executed
zero
( 7002 ,
nonfatal :
do
( 7 004 ,
nothing
and
A record- s etter is used on a device without record- setter capabi l ity ( 7 20 5 , nonfa
tal : do nothing and continue ) .
- The record- s etter SAME is used , and the most recently executed operation for the
channel was a d elete- statement ( 7 204 , fata l ) . ( BASIC-2 only )
- The record- setter SAME is used , and the most recently executed operation for the
channel caused an exception before po inter manipulation took p lace ( 7 204 , fatal ) .
- The record - s etter SAME is used , and no record operation has been executed on that
channel s ince the OPEN ( 7 204, fatal ) .
- The record - setter RECORD is used on a f i l e opened with a file-organization other
than RELATIVE ( 7 202 , fatal ) . ( BASIC-2 only)
- The record - s etter KEY is used on a f i l e opened with a f i l e -organization other than
KEYED ( 7 203 , fata l ) . ( BASIC-2 only)
- The index of a RECORD record- setter evaluates to an integer less than one ( 7 206 ,
fata l ) . ( BASIC-2 only)
- A record - setter
( BASIC- 2 only)
the nul l
string
( 7 207 ,
fata l ) .
l l . 2 . 6 Remarks
For devices , data-found could be set false by such cond itions as no more cards in a
card reader , control-Z sent from a terminal ( which s igni fies end-of- f i l e for some
systems ) , or that the device is for output only, e . g . , a l ine printer .
- 111 -
BASIC-2
Given a RELATIVE f i l e , with three existing records , numbers 2 , 5 , and 6 :
1
RECORD
RECORD
RECORD
pointer
If READ RECORD 2 has just taken p lace , then the f o l lowing record-setters w i l l
have the described effect :
record- setter
BEGIN
E
s
NEXT
absent
RECORD n
1
7
2
5
3
n
1 1 . 3 F i le Data Creation
1 1 . 3 . 1 General Description
Statements are provided to a l low the user to send data developed within the program
to an external destination . In the case of true f i les , such data can be retrieved and
mod i f ied by later programs . The fac i l ities generalize the output capab i l it ies pre
sented in Section 10 to f i les . New fac i l ities are also defined to a l low output to the
various record-types . The set-obj ects MARGIN or ZONEWIDTH are not part of a data cre
ation statement , but are included in thi s section because of their interaction with
display records .
1 1 . 3 . 2 Syntax
BASIC - 1 and BASIC-2
1 . print-statement
2 . array-print - statement
3 . print-contro l
4 . print-contr o l - item
5 . set-obj ect
6 . write-statement
7 . array-write - statement
8 . write-contro l
9 . write-contr o l - item
10 . express ion- l ist
l l . array- l is t
- 112 -
write-contro l - i tem
template- ident ifier
declarative-statement
temp late-statement
template- e l ement - l ist
template-element
Nl8 .
N19 .
N20 .
N2 1 .
N22 .
N23 .
f ixed-field -count
variable-field-count
f i e ld-spec i f ier
numeric-speci f ier
numeric- f ield- s i ze
f i xed-point-s ize
N24 .
N25 .
N26 .
N27 .
integer- s ize
fraction-size
string- speci fier
string- f ie l d - s ize
the
integer- s ize
or
fraction- s ize
must
be
greater
than
( BASIC-2
- 113 -
on aspects pecul iar to each of the various forms are presented below, under the head
ings of each statement type .
First , the channel to which the data wi l l be sent is determined from the channel
expre s s ion . The f i le-attributes are checked against the intended operations . A l l data
creation s tatements require an access -mode of OUTPUT or OUTIN . If the channel is ac
tive and the f i l e- attributes are compatible with the data creation statement , then
the next phase begins . Otherwise , an exception results and the f i l e , the f i le
pointer , and a l l program variables remain unchanged .
The s econd phase of process ing invo lves setting the f i le pointer , based on the
record-setter ( o r its absence ) . This is done exactly as described in 11 . 2 . The data
found condition is now set , again as described in 11 . 2 . If data-found is true and a
not-miss ing- recovery is present , then the io- recovery-act ion is taken . If data-found
is true , and a not-miss ing-recovery is absent , then an exception results . In either
cas e , no furti1er change is made to the po inter pos ition or the f i l e .
I f data-found is false, then the third phase begins , the actual output o f data a t the
location indicated by ti1e pointer . The operands are evaluated in succession from left
to right until enough data to f i l l a f i le-e lement has been generated . Only then is
the f i le-element actua l ly added to the f i l e and the po inter advanced immed iately be
yond the f i le-element just created . In particula r , this means that an exception dur
ing data transfer w i l l never result in a partial f i le-element being added to the
f i le . However , i f a statement can create several f i le-elements , those which have al
ready been created before the exception occurs continue to exist in the f i le . Fol low
ing ti1e comp letion of data transfer , the f i le po inter is always left pointing at the
next f i le-element ( or end of f i l e if none such exists ) beyond the last one created .
If an exception prevented the creation of any f i l e elements , the pointer is left as
it was set in the second phase .
Print - statement
The transfer of data with the print-statement works just as described in 10 . 3 and
10 . 1 , except that the sequence of characters generated constitutes a record of a
DI SPLAY f i l e , rather ti1an current l ine , and end -of- record is generated in p lace of
end-of - l ine . Note that it is poss ible to create records containing zero characters .
End-of-record is the imp lementation-def ined means whereby it is indicated that the
storage of a f i le-element in a f i l e is completed , i . e . , no change or addition to this
record is possible with a data creation statement . Except for the special case d i s
cussed below, n o data is actua l ly added t o the f i le unti l a va l id end-of- record has
been generated , i . e . , partial records are not added to the f i l e . The effective margin
for ti1e f i l e , which is used to control when end-of-record is generated , is taken from
the value of RECSIZE estab l ished when the f i l e was opened , or from a set-statement
with MARGIN for this channe l executed s ince the open ( see below) .
In one special case , a partial record is added to a f i l e . If the print- list or
output- list contains a tra i l ing print- separato r , then upon successful comp letion of
the statement , a partial record has been created at the end of f i le , with the pointer
left at end of f i l e , i . e . just beyond the partial record . Note that if there is an
exception before comp letion of the statement , then the partial record is not added to
the f i l e , as would also be true of a comp lete record . If and only if the next opera
tion for the channel is a print-statement with an absent record- setter , then the se
quence of characters it generates is appended to the end of the partial record , in
accordance with the usual rules regarding the margin. If the next operation for that
channel is anything other than such a print- statement , then before any other process
ing takes p lace , an end-of-record is added to complete the partial record , and the
po inter left at end of f i l e .
- 1 14 -
Array-print- statement
The transfer of data with the array-print - statement works just as described in 10 . 5 ,
except that the sequence of characters generated constitutes a record of a DISPLAY
f i l e , rather than the current l ine , and end-of-record is generated in p lace of end
of - l ine . Note that by the rules of 10 . 5 , a partial record is never created by the
array-print-statement with an array-print - l is t , but may be created with an array
output- list containing a trai ling semico lon . S ince an array-print-statement always
starts a new l ine , it may not be used to comp lete a partial record . The effective
margin is contro l led as described under print - statement and "Setting the margin"
( below ) .
Setting the margin
Associated with each open DISPLAY f i le . is a margin, the maximum number of characters
which a record can contain . The margin is used by print- statement and array-print
statement to determine when an end-of-record should be generated . Upon open, the ef
fective margin is the LENGTH index in RECSIZE , or the imp lementation-defined length ,
which must be not less than the default zone width , if LENGTH is not specif ied ex
p l ic i t l y . The set-statement with a MARGIN changes the margin for the active channe l
to the specif ied index . If a partial record exists in the f i l e affected by the mar
gin, the new margin is used when subsequently attempting to comp lete the partial
record . A margin of MAXNUM indicates that a record may be arbitrar i ly large . The mar
gin index must evaluate to greater than zero . The effect of a set-statement with
MARGIN ends when the f i l e is c losed .
The maximum margin supported is imp lementation-defined .
Setting the zone width
Assoc iated with each open DISPLAY f i l e is a zone width , which contro ls the effect o f
PRINT a s described i n 10 . 3 . Upon open, the zone width for a f i le is set t o the
implementation-defined default value , which sha l l be at least d + e+ 6 . The set
statement with ZONEWIDTH changes the zone width for the active channe l to the
spec i fied index .
A l l zones are the same width, except possibly the last, which may be shorter . If a
partial record exists in the f i l e affected by the set-statement with ZONEWIDTH, the
new zone width is used when subsequently attempting to comp lete the partial record .
In a set-statement with ZONEWIDTH the index must evaluate to greater than zero . The
effect of the set-statement with ZONEWIDTH ends when the f i le is closed .
The maximum zone width is imp lementation-defined .
Display record- type
DISPLAY records are sequences of characters ; the characters generated by the PRINT
operations are as described in Section 10 . The accuracy of numeric values is l imited
only by the imp lementation-def ined s ignif icance-width or length of the format- item ,
and by the ARITHMETIC option in effect .
Channel zero
PRINT to channel zero works in accordance with the semantics for a device without
record-setter or erase capab i l ity . The destination of the output data is the same as
i f the channe l -expre s s ion had been omitted . Also , i f there is an exception for which
a d if ferent recovery procedure is spec if ied in Section 10 than in 1 1 , the procedure
of Section 10 sha l l be used . A set-statement with MARGIN or ZONEWIDTH specifying
channe l zero has the same effect as if the channe l - s etter were omitted .
- 115 -
Write operation
The write-statement and array-write-statement are used to create records of any type.
Success ive expression values are arranged in corresponding sequences of values or
fields o r characters , and written out to the f i l e . Partial records are never created .
File organization
For STREAM f i les , one statement may create several f i le-elements , spec if ical ly one
f i le - e l ement is created for each express ion or array-e l ement evaluated . If an excep
tion occurs during internal evaluation, previous ly created values remain in the f i l e ,
the pointer is left at end o f f i l e , and any remaining values are ignored .
For INTERNAL SEQUENTIAL or NATIVE f i les , the values or fields generated by the ex
press ions or arrays form one record . Thus , if an exception occurs before the state
ment is completed , no record is added to the f i le , and the f i l e pointer is left un
changed from phase two . NATIVE f i les app ly only to BASIC- 2 .
BASIC-2 only
Since records in a KEYED f i l e are identified by their keys , it is necessary when
creating a new record that an exp l ic it key be assoc iated with i t ; thus when at
tempting to write to a KEYED f i l e , an exact- search must always be spec ified in
the record- setter . If data-found is fals e , then a new record is inserted into
the f i l e , with a key equal to the string-expression of the exact-search .
Display record- type
A WRITE operation type on a d isp lay record generates exactly the same sequence of
records and characters as would a PRINT operation with the same express ion- l ist or
array- l is t . Note , however , that not a l l PRINT fac i l ities are avai labl e for WRITE ,
which is record-oriented , rather than l ine-oriented .
For DISPLAY f i les , one statement may create several fi le-elements in the case of mar
gin overflow . If a fatal exception occurs during generation of an e l ement, any
e l ements previous ly created by that s tatement remain in the f i l e , the pointer i s left
at the end of the f i l e , and any remaining expressions are ignored .
Internal record- type
- 1 16 -
record . The association takes p lace from left to right within the expression - l is t and
te temp lates-element - l is t , each express ion us ing the next avai lable field-speci fier .
If the type of the express i on ( numeric or string ) disagrees with the type of the
spec ifier , an exception results . The number of expressions must not be greater than
the number of speci fiers . Extra spec ifiers beyond the last express ion are ignored .
The contents of the field are determined by the value of the express ion and the s i ze
characteristics of the spec ifier.
For string values , the string-field-size i s the number of characters in the field .
The string value is left-justified within the field . If the value ' s length exceeds
that of the field , an exception results . If shorter , the f ield is padded on the right
with spaces .
Numeric f ields are used to retain numeric values ( both magnitude and s ign ) . The s ign
is a lways stored in the field , but the numeric-field - s i ze exp l ic itly describes only
the storage of the number ' s magnitude . For a numeric-field-size of E, the value is
retained with the imp lementation-defined number of s ignificant digits for the pre
vai l ing ARITHMETIC option . For a f ixed-point- s iz e , the integer- s ize describes the
number of ava i lab le d igit p laces to the left of the dec imal po int , and the fraction
s i z e , to the r ight of the dec imal point . An omitted integer- si z e or fraction- s i ze is
treated as equivalent to zero . The numeric value is stored in accordance with these
s i zes . I f the value contains s ignif icant d ig its to the right of the avai lable field
positions , the value is rounded when stored . This may result in a field with a value
of zero . If the value contains s igni f icm1t d igits to the left of the avai lable f ield
pos itions , an exception results .
The f ixed - field-count in a temp late-statement indicates skipping and /or repetition
for individual specif iers or a series of spec ifiers . The integer of the fixed - f ield
count indicates the number of repetitions and the keyword SKIP indicates that the af
fected spec i fiers sha l l generate skipped fields . A field-count app l ies to the entity
( either a f ie l d - spec i f ier or a parenthesized temp late-element- l is t ) in the same
temp late - e lement . For an integer field-count ( indicating repetition) the effect is
just as i f the entity governed by the field-count had been written out exp l icitly the
equivalent number of times . When SKIP is used within a fie ld-count , it indicates that
the spec i f iers governed by it are not assoc iated with values from the expression - list
or array- list . Ratl1er , as the record is being generated , f ields within the record are
ass igned the value zero if numeric and spaces if string , corresponding to the usual
s ize and type of the field-spec if ier in question . If a field-spec if ier is governed by
several SKIPs ( from various leve ls above it) the effect is just as if it were gov
erned by only one , as described above . For examp l e , given the f o l lowing express ion
l ists and temp lates -element - l ists ,
A, B , C and NUMERIC>'<4 , NUMERIC>'< S , NUMERIC>'<6
D, E
and NUMERIC>'<4, SKIP NUMERIC>'c s , NUMERIC>'<6
A and D w i l l occupy equivalent field locations , as wi l l C and E . The second field in
the second record wi l l be the same s ize as occupied by B in the f irst record , with a
value of zero .
As an i l lustration of the preceding
e l ement - l ists are shown below :
description ,
equivalent
pairs
of
temp late
NUMERIC>'<2 ,
STRING>'<4 ,
NUMERIC>'<2 ,
- 117 -
1 - SKIP
NUMERI0''3 ,
ZONEWIDTH
spec ifies an
inactive channel
( 7 004 ,
- 1 18 -
(7315,
- A write - statement or array-write - statement does not have a temp late- ident if ier when
attempting to access a f i l e opened as NATIVE ( 7 3 1 6 , fatal ) . ( BASIC-2 only)
Phase 2 Exceptions :
- For a data creation statement , the condition data-found is true , and a not-miss ing
recovery has not been specif ied ( 7 308 , fata l ) .
Phase 3 Exceptions :
- An attempt is made to create a record larger than the value of RECSIZE ( 8301 ,
fatal ) .
- An expression or array-e lement does not agree in type ( numeric or string) with its
associated TEMPLATE field - spec i f ier ( 8252 , fatal ) . ( BASIC-2 only)
- A temp late-e lement with a variable-field-count does not coincide with the f irst e l
ement o f an array ( 82 5 3 , fata l ) . ( BASIC-2 only)
- There are not enough field-speci f iers in a temp late - statement
expressions or array-elements (8254, fata l ) . ( BASIC-2 only)
for
all
the
- A numeric value has s ignif icant digits to the left of the ava i lable d igit p l aces in
the f ield of a temp late ( 82 5 5 , fatal ) . ( BASIC-2 only)
- A string value is longer than the length of its f ield in the temp late ( 8256 ,
fata l ) . ( BASIC-2 only)
11 . 3 . 6 Remarks ( BASIC-2 only)
Implementations may provide syntactic enhancements to temp late - e lement- li s t , e . g . , to
a l low for add itional data types . The exception for incorrect syntax then appl ies to
the enhanced definition of temp late-element - l i s t .
The variable- f ield-count i s especial ly useful when writing an array whose s i ze may
change in the program, s ince the use of the f ixed - f ield-count imp l ies knowing the ex
act s i ze in advance .
1 1 . 4 File Data Retrieval
1 1 . 4 . 1 General Description
Statements are provided to a l low the program to retrieve data from a f i l e to which i t
has previous ly been written or from a device . The fac i l ities general ize the input ca
pab i l ities presented in Section 10 to f i les . New fac i l ities are also def ined to a l low
input from the various record-types .
- 119 -
1 1 . 4 . 2 Syntax
BASIC-1 and BASIC-2
1. input- s tatement
2.
3.
4.
5.
6.
7.
8.
9.
10 .
A g iven input-contro l - item must appear at most once in input-contro l . ( BASIC-2 only)
A given read-contro l - item must appear at most once in read-contro l . ( BASIC-2 only)
A variabl e - length-vector must be declared as one-d imens iona l . ( BASIC-2 only)
1 1 . 4 . 3 Examples
1 . I NPUT # 3 : A, B, C, A$
2 . MAT INPUT #W , BEGI N , I F MISSING THEN EX IT DO: A, B$
3 . LINE I NPUT #G , NEXT: A$ , B$ , C$
MAT LINE INPUT #4, IF MISSING THEN 123 4 : A$ , B$ ( N ) , C$ ( 8 )
4 . MAT LINE I NPUT #4 , I F MISSING THEN 123 4 : A$ , B$ ( N ) , C$ ( 8 )
7 . READ # 3 , SAME , WITH 3 3 3 : W$ , SKIP REST
8 . MAT READ #N , RECORD W+2 , IF MISSING THEN 1 1 1 , WITH 222 : N, W ( Q )
1 1 . 4 . 4 . Semantics
A l l data retrieval statements fol low a general pattern, which will be described here .
Deta i l s on the aspects pecul iar to each of the various forms are presented below , un
der the headings for each statement typ e .
Firs t , the channel from which data w i l l b e retrieved i s determined f rom the channel
expre s s ion . Then , the f i le-attributes are checked against the intended operation . Al l
data retrieval s tatements require an access -mode of I NPUT or OUTIN . If the channel is
active and the f i le-attributes are compatible with the data retrieval statement , then
the next phase begins . Otherwise , an exception results and the pointer and a l l pro
gram var i ab les remain unchanged .
The second phase of process ing involves setting the f i le pointe r , based on the
record-setter if present . In the absence of a record-setter the f i l e pointer does not
change . This is done exactly as described in 1 1 . 2 . The data- found condition is now
set , again as described in 11 . 2 . If data- found is false and a miss ing-recovery is
present , then the io- recovery-action is taken, otherwise an exception results . In e i
ther cas e , n o further change is made t o the pointer pos ition .
- 120 -
If data-found is true , then the third phase begins , the actual input of data from the
e l ement indicated by the pointer . Data is transferred from the file element ( s ) to
each of the operands (variables or arrays ) , from left to right , with successive data
or values or fields from the file being ass igned to successive variab les or arrays .
Note in particular that evaluation of subscripts , substring-qualifiers , and redims is
delayed unti l after ass ignment of data to previous operands , but occurs before as
s ignment of data to the operand to which they apply . Note also that assignment of a
string value to a string variable with a substring-qualifier takes place in accor
dance with the usual s emantics of string ass ignment described in 6 . 5 . If an exception
occurs during data transfer , variab les and array-elements for which a legal ass ign
ment has been made retain their new values , but al l subsequent variab les and array
e lements retain their original values . Fol lowing a successfu l data retrieval
operation, the pointer is advanced to the next file element, i . e . , the next record ,
record-area, or value in the file .
One data retrieval operation usua l ly affects only one file element . The three cases
in which several file elements may be processed are :
- LINE or MAT LINE INPUT,
- READ from a STREAM f i l e , and
- INPUT or READ from a DISPLAY f i l e with records with trailing commas ( indicating
continuation of data ) .
The SKIP REST option is allowed only for non-stream files . It causes the remainder of
the record from which the last datum or value or field was taken to be ignored . I t is
s ti l l mandatory that the record contain enough data to satisfy the variables or
arrays in the list.
During this third phase of processing ,
Each such exception is associated with
pointer i s advanced to the file element
exception is associated . The fo l lowing
fi le-element they app ly to .
Exception
Associated file-element
- 121 -
Input- statement
The effect of a prompt-spec if ier , t imeout-express ion , and t ime-enquiry is as de
scribed in 10 . 2 . These input-contro l - items app ly only to interactive terminal
devices . For other devices and true f i les , their effect is imp lementation-defined .
The transfer of data with the input- statement also works just as described in 10 . 2 ,
except that records are treated l ike input- rep l ies , and end-of-record i s treated l ike
end-of- l ine . Each datum ( as defined in 10 . 1 ) is ass igned in order to a variable in
the variable- list . A l l the INPUT operations ( as opposed to the READ operations ) are
val id only for a f i l e opened as DISPLAY . For any other record-typ e , an exception re
sults . The input- statement may process several records if the last non-blank charac
ter in a record is a comma . I f , following a record with a trail ing comma, end of f i le
is encountered before al l variables have been ass igned values , then the remaining
variables sha l l retain their o l d values , the f i l e pointer sha l l be positioned to end
of f i l e , and an exception sha l l resu l t .
When any of te INPUT statements is executed for a device and a phase 3 exception oc
curs , imp lementations may use the recovery procedures speci f ied for true f i les in
this s ection, o r , i f an equivalent exception is speci f ied in Section 10 , that recov
ery procedure may be used instead . This is to allow input from several interactive
devices to use the nonfatal recovery procedures .
Array- input- s tatement
The array- input- statement behaves just l ike the input- statement wou ld if the arrays
were written out exp l ic itly as array-elements in row maj or order ( the last subscript
varying most rapid l y ) . The only additional capabi l ity is that of a l l owing a redim to
change the d imens ions of the array in accordance with the redim rules for the array
input- statement without a channel -express ion ( see 10 . 5 ) . Thus , for examp l e , if "DIM
A( 3 ) 11 and OPTION BASE 1 are in effec t , the f o l lowing two statements are equivalent :
INPUT liN : A
INPUT #N : A ( l ) , A ( 2 ) , A( 3 )
MAT
MAT
INPUT #N : A( 1 ) , B ( A ( l ) )
depends on the first datum encountered , s ince i t contro ls the effective s ize o f array
B . Nonethe les s , it behaves exactly as would an input-statement for which the appro
priate number of array-elements for B had been coded . If an array is encountered
whose redim yields a s ize less than 1 in any d imens ion, then i t , and a l l subsequent
arrays , sha l l retain their o l d values , and an exception sha l l result .
Variab l e - length-vectors
The transfer of data and consequent redimens ioning of the array of a variable- length
vector takes place just as described in 10 . 5 .
Line - input- statement
The l ine- input-statement behaves exactly as described in 10 . 2 , except that records
are treated l ike input- rep l ies , and end-of-record l ike end - of - l ine . The content of
each success ive record i s assigned as the value of success ive string-variab les , in
c luding any leading or trai l ing spaces . A record may contain a nul l string , and it
- 122 -
shal l be ass igned in the normal way . If end of f i l e is encountered before a l l vari
ables have been assigned values , then the remai ning variables sha l l retain their o l d
values , the f i le pointer sha l l b e positioned t o end of f i l e , and a n exception sha l l
result .
Array- l ine- input-statement
The array - l ine- input-statement behaves just as would a l ine- input statement for which
the array-elements had been coded out exp l ic i t l y , instead of as arrays . See semantics
above for array- input-statements . Note that here too , the size of a later array may
depend on the value ass igned to an earl ier array , e . g . :
MAT LINE INPUT #N : A$ ( 1 ) , B$ ( VAL( A$ ( 1 ) ) )
I f the f irst record contained the string 1 1 12 " , then twelve subsequent records would
be read into the array B$ . If an array is encountered whose redim yie lds a s ize less
than 1 in either d imens ion , then i t , and all subsequent arrays , sha l l retain their
old value s , and an exception results .
Input-statements for channe l zero
Input from channel zero works in accordance with the semantics for non - f i l e devices .
For those exceptions for which a d ifferent recovery procedure is speci f ied in Section
10 than in 1 1 , the procedure of Section 10 sha l l be used .
Read-operation
The read - s tatement and array-read- s tatement are used to retrieve data from f i les with
records of any type . Success ive data or values or f ie lds are assigned to success ive
variab les or arrays in the operand list . READ may access several f i l e elements for
SEQUENTIAL or STREAM f i les , but only one for RELATIVE and KEYED f i les . RELATIVE or
KEYED fi les are provided only in BASIC- 2 .
File organi zations
For non- STREAM f i les ( SEQUENTIAL f i les in BASIC- 1 and RELATIVE and KEYED f i les in
BASIC- 2 ) , the variables receive values from the sequence of data or values or fields
within a record . There must be just enough data within the record (or records in the
case of DISPLAY records with trail ing commas ) to satisfy the variable- l ist ( except
for SKIP REST , see above ) . For STREAM f i les , the variables receive thei r values d i
rectly from the sequence that constitutes the f i l e , beginning with the f i le-element
indicated by the pointe r , and so f i le-element boundaries are insignif icant . If end of
f i l e is encountered before al l variables have been ass igned values , then the remain
ing variables sha l l retain their old values , the f i le pointer sha l l be positioned to
end of f i l e , and an exception sha l l result .
Display record- type
Records in DISPLAY f i les are sequences of characters . The retrieval of string data
sha l l take p lace as described in 10 . 2 . Note that retrieving data from a record cre
ated with PRINT does not necessarily preserve the same value , s ince , for instance ,
leading and tra i l ing spaces are not saved in unquoted strings n input. For numeric
data , the accuracy sha l l be cons istent with the usual semantics for assignment of a
numeric-constant to a numeric-variab l e , i . e . at least six s ignif icant d ig its for
OPTION ARITHMETIC NATIVE and at least ten d igits for OPTION ARITHMETIC DECIMAL . For a
numeric-constant with no more s ignif icant d ig its than the imp lementation-def ined pre
c i s ion , the exact value i s ass igned with OPTION ARITHMETIC DECIMAL .
A READ operation on a DISPLAY record ass igns values exactly as would an INPUT opera
tion with the same variable- l ist or redim-array - l is t . Note , however , that not a l l the
INPUT fac i l it ies are available for READ , wl1ich is record-oriented .
- 123 -
Internal record-type
An internal record ( and a stream f i le ) is a sequence of values . There are two types
of value , numeric and string . For INTERNAL f i le e l ements , the values must be re
trieved with a variabl e of the same type as that of the value , otherwi s e an exception
results . Thus , the contents of an INTERNAL f i le e l ement are self-typed . The sequence
of values and thei r types are determined by the record operation which created or
modified the f i l e - e l ement ( s ) . When a value i s retrieve d , the effect is as i f the ex
pression with which it was created were ass igned to the input variable with a let
statement . The length and content of string values are preserved . Numeric values are
also preserved , consistent with the usual l imitations on precis ion and type associ
ated with the preva i l ing ARITHMETIC option .
Native record- type ( BASIC-2 only)
The TEMPLATE describes the location and type of fields within the record . When read
ing from a native record , a TEMPLATE must always be used . It must not be used with
any other record- typ e . A TEMPLATE is assoc iated with a particular data retrieval
statement by means of the temp late- identi f ier in the statement , which specif ies the
temp late - statement to be used , or a string -express ion whose value must be a syntact i
c a l l y correct temp late-e lement- l ist . The string-expression is evaluated before any
input takes p lace and before any redims , substring qua l i f iers , or subscripts are
evaluated . Several s tatements may use the same template-statement .
When retrieving data from a native record , each variab le within the variab l e - l ist is
assoc iated with a f i e l d - specifier within a temp late ; the spec if ier is then used to
return data from a f ield within a record . This association takes p lace from left to
r ight , within the variable- l ist and temp late - e l ement- l is t , each variable using the
next ava i l ab l e f i e l d - speci f ier . A variable is assoc iated with a spec i fier after a
value has been ass igned to the previous variab l e , and any subscripts , substring
qual i f i ers , or redims for this variable have been evaluated . If the type of the vari
ab le ( numeric or string ) disagrees with the type of the spec ifier , a n exception re
sults . The number of spec i fiers must not be less than the number of variables . Extra
spec if iers beyond the variables are ignored . The contents of the next field in the
record is interpreted according to the speci fier , and the resulting value p laced in
the variab l e .
When retrieving data , the spec if iers o f al l fields within a record must b e compatible
with the speci fiers with which they were created , otherwise the results are
implementation-def ined . In order to be compati b l e , the creating and retrieving speci
f iers for a field must both be of type STRING , with equal string - f i e l d - s i zes , or both
NUMERIC with a numeric-field-s ize of E, or both NUMERIC with equal integer- s i zes and
fraction- s i zes . An omitted integer-size or fraction- s i ze is treated as equivalent to
zero .
\fuen the TEMPLATE specif iers are compatible with the record , then the values are re
tr ieved in accordance with the field s izes . For strings , a value is as s igned with
length equal to the string - field- s iz e , and contents as origina l ly stored in the
record , includ ing any spaces used for padding . For numbers , a value is assigned whose
accuracy is l imited only by the numeric - f i e l d - s i ze and ARITHMETIC option . For numbers
stored with a field s ize of E, or with a f ixed-point - s ize and with no more s ignif i
cant d i gits than the imp lementation-def ined prec i s ion, the exact value is retained
under OPTION ARITHMETIC DECIMAL . Otherwise, the numbers are rounded according to the
OPTION in effect and stored in the variable . Section 1 1 . 3 . 4 describes how values are
stored in the fields of native records an the effect of field-counts . The only d i f
ference upon retrieval is that SKIP speci f iers d o not generate f i e l d s of zero or
spaces , but cause the affected f ields s imp ly to be skipped over . As befor e , such
speci f iers are not assoc iated with variab les .
- 124 -
Array-read- statement
In general , an array-read- statement behaves just l ike the read- statement would if the
arrays were written out exp l icitly as array-e lements . As with INPUT , there is delayed
evaluation of redims .
BASIC-2 only
For this reason , when reading from a native record , a variable-field-count is
provided . I f a f ixed -field-count is used , then the number and types of the
specifiers must match the array-e l ements , as with READ . When the first e l ement
of an array is to be associated with the next specifier , however , and if a
t emp late-el ement has just been comp leted ( or if this is the first array in the
l is t ) , and the next temp late-element is a variab l e -field -count , then the associ
ated specif ier is used for a l l the e l ements of the array . When the array has
been f i l led , the next array , if any , uses the next temp late - e lement, which may
or may not also have a variabl e - f i e l d - count . An array must either use a
template - e l ement with a variable-field-count or temp late- e lements with f ixed
f i e l d - counts , but not both .
11 . 4 . 5 Exceptions
The exceptions are grouped according to the phase of process ing during which they are
detected . Phase 1 exceptions imp ly no change to the f i l e pointer or variab les . Phase
2 exceptions imp ly no change to the variab les . Phase 3 exceptions imp ly that some
variables may have received values from the f i l e .
Phase 1 Exceptions :
- A data retrieval attempts to access an inactive channel ( 7004, fata l ) .
- An input-statement , array- input- statement , l ine- input-statement , or array- l ine
input- statement attempts to access a f i l e opened as INTERNAL or , in BASIC-2 only,
NATIVE ( 7 3 18 , fatal ) .
The record-setter cannot be processed correctl y , as described in 11 . 2 . 5 , exceptions
7002 and 7202 - 7 207 ( us e the procedure of 11 . 2 . 5 ) .
- A data retrieval s tatement attempts to access a f i le
fatal ) .
The string-expression o f a temp late- identifier is
temp late- e l ement- l ist ( 8 2 5 1 , fata l ) . ( BASIC- 2 only)
opened
as
OUTPUT
( 7 303 ,
INTERNAL
(7315,
- A read- statement or array-read- s tatement does not have a temp late-identifier when
attempting to access a f i le opened as NATIVE ( 7 3 1 6 , fata l ) . ( BASIC-2 only)
- The SKIP REST option is used on a f i l e opened as STREAM ( 7 3 2 1 , fatal ) .
Phase 2 Exceptions :
For a data retrieval statement , the condition data-found is false and a miss ing
recovery has not been specified ( 7 305 , fata l ) .
Phase 3 Exceptions :
- An attempt is made to access a record l arger than the value of RECSIZE ( 8302 ,
fata l ) .
- The first index in a redim-bounds is greater than the second ( 6005 , fata l ) .
- A s ingl e index used in redim bounds is less than the default lower bound in effect
for the program unit ( 6005 , fatal ) .
- 125 -
- The total number of e l ements required for a redimensioned array exceeds the number
of e l ements reserved by the array ' s original d imensions ( 5001 , fata l ) .
- A variable or array-element does not agree in type ( numeric or string) with its as
sociated TEMPLATE specifier ( 82 5 2 , fata l ) . ( BASIC-2 only)
- A variable- field-count in a template - e l ement does not coincide with the first ele
ment of an array ( 82 5 3 , fata l ) . ( BASIC-2 only)
- There are not enough TEMPLATE specifiers for a l l the variables or array-elements
( 82 5 4 , fatal ) . ( BASIC- 2 only)
- A data retrieval statement , other than a l ine- input- statement or an array- l ine
input-statement , attempts to access a DISPLAY record that is not a syntactically
legal input-rep ly ( 8105 , fata l ) .
The datum of a DISPLAY record to be ass igned to a numeric variab le is not a
numeric-constant ( 8101 , fata l ) .
A value in an I NTERNAL record does not agree in type ( numeric or string ) with the
variabl e to which it is to be ass igned ( 8120, fatal ) .
A value , datum , or field ( for BASIC-2 only) in a f i l e causes numeric overflow upon
ass ignment to the variabl e ( 1008 , fatal ) .
A value , datum , or field ( fo r BASIC-2 only) in a f i le causes string overflow upon
ass ignment to a variabl e ( 1105 , fata l ) .
- There are not enough data, values , or fields ( for BASIC-2 only) within a record of
a non- S TREAM f i l e for the operands of a data retrieval statement and the record is
not DISPLAY with a tra i l ing comma ( 8012 , fata l ) .
- End of f i l e is encountered whi l e seeking further data for the operands of a data of
a data retrieval s tatement ( 8011 , fata l ) .
- There are too many data in a record for the operands of a data retrieval statement
and SKIP REST is not specified ( 8013 , fatal ) .
- There is just enough data in a DISPLAY record with a tra i l ing comma to satisfy a
reques t for input , and SKIP REST is not specified ( 8013 , fata l ) .
1 1 . 4 . 6 Remarks
Impl ementations may choose to treat underf lows as exceptions ( 1508 , nonfatal : supp ly
zero and continue) . In BAS IC - 2 , this permits interception by exception hand lers .
1 1 . 5 F i l e Data Modification (BASIC-2 only)
1 1 . 5 . 1 General Description
Statements are provided to a l low the user to modify data previous ly s tored in a f i le .
Such data can either be changed or deleted . The modifications are always done at the
record leve l .
l l . 5 . 2 Syntax
Core productions
None .
- 126 -
rewrite-control
rewrite-contro l - item
delete-statement
delete-control
delete-contro l - item
rewrite-contro l - item
The l ine-number of a temp late-identifier must refer to a temp late- statement in the
same program-un i t .
A given rewrite-contro l - item must appear at most once in rewrite-contro l .
A given de lete-contro l - item must appear at most once in delete-contro l .
1 1 . 5 . 3 Examples
2 . REWRITE #N , KEY = B$ , IF MISSING THEN 666 : A , B , C$
3 . MAT REWRITE 113 , RECORD N- 1 , WITH 111 : X , Y , Z
6 . DELETE 113 , KE Y "JONES"
1 1 . 5 . 4 Semantics
The data modification statements are modeled c losely on certain aspects of data re
trieval statements and data creation statements . Like the data retrieval statements ,
they operate on existing records . Like the data creation statements , they can alter
the state of a f i le . The data modification statements are specif ied only for f i le
organizations RELATIVE and KEYED . For other f i le-organizations , their effect is
imp lementation-def ined . The data modification statements may be used only with
access -mode OUTIN . Except for access -mode , the f irst and second phase of process ing
( i . e . checking of f i l e attributes and setting the f i l e pointer) for these statements
is exactly l ike that for the data retrieval statements ( see 1 1 . 4 . 4 ) , because they op
erate on existing record s . The third phase of process ing , undertaken only if the op
eration is lega l , the f i le pointer successfully set , and data- found is true , is de
scribed below under the individual headings .
Rewrite - statement
The rewrite-statement generates exactly one record , and that record is identical to
the one that would be generated by a write- statement with the same expression- list or
array- l ist and temp late- identif ier , if any ( see 11 . 3 . 4 ) , with one exception : for a
NATIVE record , fields governed by SKIP are not f i l led with zero or spaces , but rather
the previous contents of the f ields are left unchanged . This effect of SKIP occurs
only if the TEMPLATE used by the REWRITE is compatible with TEMPLATE last used to a l
ter the record ( see 11 . 4 . 4 for the definition o f "compatib l e" ) . The result o f using
an incompatibl e TEMPLATE containing SKIP is imp lementation-def ined . The use of an in
compatible TEMPLATE without SKIP is defined above since the entire record is re
p laced .
If no exceptions occur during the generation of data to be used for modification of
existing data , then the record pointed to by the f i le pointer is replaced by the
record j ust generated , and the f i le pointer advanced to the next f i le-element . This
- 127 -
11 . 5 . 5 Exceptions
The f o l l owing exceptions are grouped according to the phase of processing during
which they are detected . Phase 1 exceptions imply no change to the f i le or f i le
pointer . Phase 2 exceptions imp ly no change to the f i l e . Phase 3 exceptions also im
p ly no change to the f i le .
Phase 1 Exceptions :
- A data modification statement attempts to access an inactive channel ( 7004 , fata l ) .
- A data modification statement attempts to access channe l zero ( 7 32 0 , fatal ) .
- The record- setter cannot be processed correctl y , as described in 1 1 . 2 . 5 , exceptions
7002 and 7202 - 7 207 ( us e the procedure of 11 . 2 . 5 ) .
- A data modification statement attempts to access a f i le opened as INPUT or as
OUTPUT ( 7 322 , fatal ) .
The string-expression of a temp late- identifier
temp late- e lement - list ( 8 2 5 1 , fata l ) .
- A temp l ate- identifier
fatal ) .
is
is used on a f i l e opened as
INTERNAL or DISPLAY
( 7315 ,
- A rewrite - statement or array-rewrite - statement does not have a temp late- identifier
when attempting to access a f i l e opened as NATIVE ( 7 316 , fatal ) .
Phase 2 Exceptions :
- For a data modif ication statement , the condition data- found
miss ing-recovery has not been specified ( 7 305 , fata l ) .
is
fals e ,
and
Phase 3 Exceptions :
- An attempt is made to rewrite a record larger than the value of RECSIZE ( 83 0 1 ,
fatal ) .
An expression or array-element does not agree in type ( numeric or string) with its
associated TEMPLATE specifier ( 82 5 2 , fata l ) .
- A temp late-e l ement with a variable-field-count does not coincide with the f irst e l
ement of an array ( 82 5 3 , fatal ) .
- 128 -
There are not enough TEMPLATE specifiers for a l l the expressions or array-elements
( 82 5 4 , fata l ) .
A numeric value has s ignificant digits to the left of the availabl e digit p laces in
the f i e l d of a template ( 82 5 5 , fatal ) .
- A s tring value i s longer than the l ength o f its field in the template ( 8 2 5 6 , fatal )
1 1 . 5 . 6 Remarks
Note that the DELEIE and REWRITE w i l l affect the record indicated by the f i l e
pointer , even i f the po inter i s s e t with NEXT o r l e f t a s is from previous operation
( i . e . if the record-setter is absent ) .
- 12 9 -
1 2.
E XC E P T I ON
HAN D L I N G AND
D E BU G G I NG
- 130 -
when-use-block I when-use-name-block
when- l ine when- block use - l ine exception-hand ler
end-when- l ine
l ine-number WHEN EXCEPTION IN tail
b lockl't
l ine-number USE tai l
b lockl't
when- l ine
when-block
use- l ine
exception-hand ler
l ine-number END WHEN tai l
end-when- l ine
when-use-name - l ine when-block end-when- l ine
when-use-name- block
l ine- number WHEN EXCEPTION USE handler-name tai l
when-use-name - l ine
routine- identifier
hand ler-name
hand ler-return- s tatement
RETRY I CONTINUE
exit-hand ler-statement
EXIT HANDLER
CAUSE EXCEPTION exception- type
cause - statement
index
exception-type
hand l er - l ine exception-hand ler end-hand ler- l ine
detached - hand ler
l ine-number HANDLER hand ler-name tai l
hand ler- l ine
l ine- number END HANDLER tai l
end-hand ler - l ine
numeric - supp l ied- function > EXLINE I EXTYPE
string-supp l ied-function > EXTEXT do l lar - s ign
Hand ler- return-statements and exit-hand ler-statements sha l l only occur within
exception-hand lers . The no -argument numeric - supp l ied- functions EXLINE and EXTYPE
sha l l be invoked only within exception-hand lers . EXTEXT$ takes a s ing le numeric argu
ment , which is an index .
No l ine-number in a contro l - transfer outside a protection-block sha l l refer to a l ine
in that protection-block other than its when- l ine or when-use-name- l ine . No l ine
number in a contro l -transfer inside an exception-hand ler sha l l refer to a l ine out
side that exception-handler other than its own end- hand ler- l ine or end-when- l ine , nor
sha l l a l ine-number in a contro l -transfer outside an exception-hand ler refer to a
l ine inside that exception-hand ler or to its end-handl er - l ine or end-when- l ine .
A detached-hand ler referred to in a when-use-name- l ine within an internal - proc -def
must be defined in the same internal -proc-def . A detached-hand ler referred to in a
when-use-name- l ine that is not within an internal -proc- def must be defined in the
same program-unit but not within an interna l - proc-def . No two hand ler - l ines in the
same program unit sha l l have the same hand ler-name . A detached-hand ler may not appear
within a protection-b lock .
A protection-block may not appear within an exception-hand ler .
12 . 1 . 3 Examples
Examp l e 1
hand l ing errors in input - rep l ies by a l lowing the input - repl y to be
resupp l ied after issuing a suitabl e message
- 131 -
INPUT a , w
120
IF a > 10 THEN
130
140
PRINT "What is your height"
I NPUT h
150
END IF
160
170 USE
PRINT "Please enter numbers only"
180
190
RETRY
200 END WHEN
Exampl e 2 : dynamic f i le opening
100 HANDLER f i l e_troubl e
LET f i l e_ok$ = " false"
1 10
120
IF EXTYPE = 7 107 THEN
LET message$ = "doesn ' t exist"
130
ELSEIF EXTYPE = 7 102 THEN
140
LET message$
" is the wrong type"
150
ELSE
160
LET message$
"couldn ' t be used"
170
END IF
180
PRINT " f i le" ; f i l ename$ ; message$ ; " try again"
190
200 END HANDLER
500 DO
5 10
INPUT f i l ename$
LET f i l e_ok$ = "true"
520
530
WHEN EXCEPTION USE f i le- troubl e
540
OPEN #n : NAME f i lename$ ! other parameters omitted
550
END WHEN
560 LOOP UNTIL f i l e_ok$ = 11true"
Exampl e 3 : Nested handlers
100 WHEN EXCEPTION IN
1 10
DO
120
READ # 1 , IF MISSING THEN EXIT DO: A
LET I = I+l
130
! I initial ized outside loop
WHEN EXCEPTION IN
140
LET B ( I ) = lOOOiW''A
150
USE
160
! Assume it is numeric overflow
170
LET B ( I ) = MAXNUM
180
CONTINUE
190
200
END WHEN
LOOP
2 10
220 USE
non-numeric data
8101 THEN
230
IF EXTYPE
get next data item
240
RETRY
give up
ELSE
250
260
PRINT "Unabl e to process f ile"
STOP
270
280
END IF
290 END WHEN
13 . CAUSE EXCEPTION I
- 132 -
12 . 1 . 4 S emantics
When an exception occurs during the execution of a program-unit, the action taken
sha l l depend upon whether or not the exception occurs within a when-block . If the ex
ception occurs outside a when-block, then the default exception hand l ing procedures
specif ied in this S tandard sha l l be app l ied ( see 2 . 4 ) . If the exception occurs within
a when - block, then the default exception hand l ing procedures , which require that an
exception be reported , sha l l not be app l ied ; instead , control sha l l be transferred to
the exception-hand ler associated with the inner-most protection-b lock within which
the exception occurred .
When the protection-b lock is a when-use-b lock , the assoc iated exception- handler is
that which f o l lows the use - l ine of the protection-b lock . When the protection-block is
a when-use-name-block, the associated exception-hand ler is the detached-hand ler named
in the when-use-name- l ine of the protection-b lock . In a l l respects , a detached
hand ler behaves semantical ly as though it were an exception-hand ler in the when-use
b lock of the when-block with the exception .
Within an exception-hand ler , the type of the exception which caused that hand ler to
be executed shal l be obtainabl e as the value of the parameter less function EXTYPE .
The values of EXTYPE for a l l exceptions defined in this Standard are specified in
Tab le 2 , along with the description of each exception in this Standard . The l ine-num
ber of the l ine whose execution caused the exception sha l l be obtainabl e as the value
of the parameter less function EXLINE .
There are four means of exiting from an exception-hand ler .
- Execution of the handler-return- statement CONTINUE sha l l cause contro l to be trans
ferred to the statement lexical ly f o l lowing that which caused the exception . If
the exception occurred in a l ine which begins or is part of a structure ( such as a
do- l ine , loop - l ine , for - l ine , if-then- l ine , e l seif-then- l ine , se lect - l ine , or
case - l ine ) , then control sha l l be transferred to the statement lexical ly fol lowing
the entire structure of which the l ine is a part .
- Execution of the hand ler- return- statement RETRY sha l l cause contro l to be trans
ferred to the statement or l ine which caused the exception , causing the statement
or l ine to be re-executed ; if that statement was performing data retrieva l , then
the previous input- rep ly or l ine- input-rep ly sha l l be discarded and a new one re
quested .
- If contro l reaches an end-when- l ine which terminates an exception-hand ler or
reaches an end - hand l er - l ine , then control sha l l be transferred to the l ine fol low
ing the end-when- l ine of the protection-b lock within which the exception occurred
with no further effect .
- Execution of an exit-hand ler- s tatement sha l l cause the exception to be propagated
to the lexical environment surrounding the innermost protection-block containing
the exception ( also note the effect of cal ls and function invocations - see
below ) ; i . e . the effect on handl ing the exception is as if the exception-hand ler
did not exist ( except for the effect of any statements already executed in the
hand l er ) , and the rules for hand l ing the original exception depend upon whether or
not the exception occurs within some outer when-block .
If execution reaches a use - l ine in a when-use-b lock, or an end-when- l ine in a when
use-name- b lock, then control sha l l be transferred to the l ine fo l lowing the
protection-block of which the use - l ine or end-when- l ine is a part . I f execution
reaches an end -hand ler- l ine of a detached-hand ler , control sha l l continue at the l ine
fo l lowing the end-when - l ine of the when-use-name-b lock causing the exception . If exe
cution reaches a hand ler- l ine of a detached-hand ler other than by the occurrence of
an excep t ion , control sha l l then continue at the l ine immed iately fo l lowing the end
hand ler- l ine .
- 133 -
A separate GOSUB stack is associated with each exception-hand ler ( see 8 . 2 ) so RETURN
never attempts to transfer control into or out of an exception handler .
Execution of a cause - statement sha l l result in the occurrence of a fatal exception
and the s etting of EXTYPE to the rounded value of the exception- type .
If an exception is caused by a statement lexical ly within an exception-hand ler , then
this new exception sha l l be hand led by the defau l t exception-hand l ing procedures .
If a fatal exception occurs in a procedure-part or internal-proc- def and either :
- the l ine causing the fatal exception is not contained in a when-block and therefore
no exception-hand ler is entered , or
an exception-hand ler is entered , an exit-hand ler-statement is executed with the
hand ler, and there is no lexically surrounding when-b lock to intercept the
exception ,
then the fatal exception sha l l be propagated back to the l ine that invoked the
procedure-part or internal-proc-def . This propagation sha l l continue to occur until
either :
- a user- def ined exception-hand ler resolves the exception by execution of a handler
return- statement o by causing contro l to pass to an end-hand ler- l ine or to an end
when- l ine which terminates the exception-hand ler , or
the main program or a para l l e l - section is reached , in which case the default
exception-hand l ing procedures are app l ied .
If an exception-hand ler is invoked as a resul t of this process , then the value re
turned by the EXTYPE function sha l l be 100000 p lus the value that wou l d have been re
turned by EXTYPE in the procedure-part or integral -proc-def in which the exception
origina l ly occurred . The value of EXLINE sha l l be the l ine-number of the most recent
l ine to which the exception was propagated , i . e . , the l ine lexical ly within the when
b lock associated with the exception-hand ler, not the l ine of the original exception .
The default exception-hand l ing procedures sha l l always report the EXTYPE and EXLINE
of the original exception .
The value of EXTYPE for exceptions defined by local enhancements to this Standard
s ha l l be negative. When negative values of EXTYPE are propagated , the value sha l l be
- 100000 p lus the value that would have been returned by EXTYPE for the original
exception .
Values of EXTYPE from 1 to 999 wi l l not be used by future enhancements to this
Standard , nor sha l l they be used by local enhancements to this Standard .
The value of EXTEXT$ sha l l be the text part of the error message provided by the sys
tem for the exception number obtained by rounding its argument to an integer . If its
argument is not the exception number of a standard system exceptio n , the value of
EXTEXT$ sha l l be the nul l string .
If the main-program is reached and no exception-hand ler is invoked there as a resul t
of the original exception , then the exception sha l l be hand led b y the default excep
tion hand l ing procedures specif ied in this Standard .
12 . 1 . 5 Exceptions
A cause - statement is executed ( exception-typ e , fata l ) .
12 . 1 . 6 Remarks
Users should note that there are two kinds of exception propagation specified in this
section . First , there is " l exical" propagation, outward to surrounding protection
b l ocks within a program-unit or interna l -proc - de f . If this process propagates the ex
ception outside of any such protection-b lock, "invocation" propagation takes effect,
pass ing the exception back to invoking s tatements .
- 134 -
The function EXLINE should be used with caution , as the use of editing faci l ities
which renumber lines in a program ( see 16 . 2) may inval idate computations invo 1ving
EXLINE . For examp l e , the program fragment
1000 SELECT CASE INT ( EXLINE / 100)
1010 CASE 1, 2
1100 CASE 3 TO 7
would probably behave differently if l ines 100 through 800 were renumbered .
When a fatal exception is propagated back to invoking statements and the default
exception-hand l ing procedure is app l ied as a resul t , only the original exception 1 s
EXTYPE and EXLINE must be reported . Imp l ementations may , however , also report the
l ine-numbers of the l ines through which the exception was propagated , or any other
information deemed usefu l .
It is not pos s ible to pass a nonfatal exception back to a cal l ing routine since it
wi l l be hand l ed either by an exception-handler in the cal led routine or by the system
hand ler . An exception hand ler may, however , cause a fatal exception with a cause
statement .
The cause-statement is
rather to raise a fatal
the spec ified EXTYPE is
not app ly the recovery
curred . It is presumed
receive and process the
A l l positive values of EXTYPE are reserved for future versions of this Standard . Ex
ceptions def ined by local enhancements to this Standard shoul d be identified by nega
tive values for EXTYPE , fo l lowing the categories establ ished in Tab l e 2 . The value
returned by EXTYPE for an exception defined in a local enhancement and occurring in a
procedure-part or interna l -proc-def shoul d be - 100000 p lus the negative value identi
fying that exception . For examp le , if an imp lementation chose an EXTYPE value of
-4029 for an invalid argument in a new built-in function, and if that exception oc
curred in a subprogram , but was not hand led there , then the value of EXTYPE in an
exception-hand ler in a cal l ing program should be - 10402 9 .
It is recommended that imp l ementations use the " zero -th" value in a c lass of EXTYPE
values to represent "other exceptions of this type" . For examp l e , an EXTYPE value of
1000 might represent a l l overf l ows not defined in this Standard .
Values of EXTYPE from 1 to 999 may only occur from cause-statements in app l ication
programs . These values should be encouraged for use , s ince they wi l l not be ass igned
standard meanings in future enhancements to this Standard .
CONTINUE should be used with caution. For instance , if an exception occurs within a
def-statement , on-gosub - s tatement , on-goto- s tatement , or if-statement , CONTINUE w i l l
transfer contro l t o the l ex ical ly fol lowing l ine . Such action may not be equivalent
to resumption of normal f low of control .
- 135 -
The f o l lowing examp l e i l lustrates the effect of CONTINUE with contro l structures :
100 WHEN EXCEPTION IN
INPUT PROMPT "enter your age and weight" : a, w
120
130
DO WHILE a > 1
IF a < 9999999999 THEN
140
INPUT PROMPT "What is your height 11 : h
150
PRINT " Check the f o l lowing : 11
160
PRINT "Age : " ; a , "Weight : " ; w, "Height : " ; h
170
I NPUT PROMPT "Enter your age" : a
200
END IF
2 10
PRINT "Lexical ly fo l lowing IF"
220
230
LOOP
240
PRINT "Lexical ly f o l lowing DO WHILE"
For exception in l ine :
120
130
140
150
The precise format of the values of the EXTEXT$ function is imp l ementation-defined .
In particul ar , imp lementations may choose to omi t , or to mark in a special way , those
fields in an error message that are spec ific to a particular instance of an excep
tion, such as the l ine number at which the exception occurred or the value of an out
of-range subscript .
12 . 2 Debugging ( BASIC- 1 and BASIC- 2 )
12 . 2 . 1 General Description
Debugging
points to
points , to
off within
12 . 2 . 2 Syntax
1 . debug - statement
2 . break-statement
3 . trace-statement
DEBUG ( ON I OFF )
BREAK
TRACE ON ( TO channel - express ion ) ? I TRACE OFF
12 . 2 . 3 Examples
3. TRACE ON
TRACE ON TO 113
12 . 2 . 4 S emantics
Each program-unit sha l l have a debugging status , which is either active or inactive
at any given time . The debugging status of a program-unit sha l l persist between invo
cations of that program-unit ( with the exception of the main program ) . Changes in the
debugging status of one p rogram-unit sha l l not affect the debugging status of any
other program-un i t . At the beginning of execution of the program, debugging sha l l be
inactive for a l l program-units .
Execution of the debug- statement DEBUG ON sha l l cause debugging to become active for
the program-unit in which that debug- statement occurs . Debugging shal l remain active
for the remainder of that invocation of that program-unit , and for each subsequent
invocation of that program-unit , until the debug-statement DEBUG OFF is executed in
that program-unit . Execution of the debug- statement DEBUG OFF sha l l cause debugging
to become inactive for the remainder of that invocation of that program-unit , and for
- 136 -
each subsequent invocation of that program unit , unti l the debug- statement DEBUG ON
is executed in that program-unit .
The execution of a break- statement when debugging is active sha l l cause an exception .
The standard recovery procedure from this exception sha l l be to report the l ine
number of the break-statement and to s ignify to the user that interaction with the
debugging system is pos s ib l e . The actions a l l owed by the debugging system , inc luding
the method for continuing execution or terminating execution of the program, are
imp lementation- def ined . If the execution of a program reaches a l ine containing a
break- statement , and debugging is inactive , then it sha l l proceed to the next l ine
with no other effect .
The execution of a trace-statement when debugging is active shall turn tracing on ( if
ON is speci fied ) or off ( if OFF is speci f ied ) in the program-unit containing the
trace-s tatement . Prior to the execution of any trace- s tatement upon each separate en
try to a program-unit, tracing sha l l be off . If the execution of a program reaches a
l ine containing a trace-statement , and debugging is inactive , then it sha l l proceed
to the next l ine with no other effect .
The execution of a trace- statement sha l l not affect the debugging status , nor sha l l
the execution of a debug- statement affect the tracing status ( ON or OFF ) .
Whenever tracing is on and debugging is active in a program-un i t , the following
actions sha l l occur each time a l ine of the speci f ied type is executed
for any l ine which interrupts the sequential order of execution of l ines in a pro
gram, both the l ine- number of that l ine and the l ine-number of the next l ine to be
executed sha l l be reported ; and
- for any l ine which ass igns a value to a variable or to an element of an array , both
the l ine-number of that l ine and any values assigned by execution of that line
sha l l be reported . Whenever tracing has been turned on via a trace-statement with
a channe l - express ion, trace reports sha l l be d irected to the ( d isp lay format ) f i le
ass igned to the speci fied channel . If no channel - expression has been spec if ied ,
the trace report sha l l be d i rected to the device assoc iated with channel zero .
The contents of the trace report are imp lementation-defined , but sha l l include at
least the name of the variab le traced , as that name lexical ly appears in the state
ment causing the TRACE report , and its value ; if the variable is an array element ,
the value ( s ) of its subscripts sha l l also be included .
12 . 2 . 5 Exceptions
A break - s tatement is executed when debugging is active ( 10007 , nonfatal : the recov
ery procedure is to report the line-number of the statement and to permit interac
tion with the debugging system ) .
- An attempt is made to direct a trace report to an inactive channel . ( 7401 , fatal ) .
- An attempt is made to direct a trace report to a f i le which is not d isp lay format
opened with access OUTPUT or OUTIN ( 7402 , fata l ) .
12 . 2 . 6 Remarks
Since an array-as s igrunent ass igns a value to each element of an array, tracing an
array-ass igrunent causes reporting of a l l new array e l ement values .
The form of a l l trace reports is imp lementation-def ined .
Imp l ementations may provide debugging fac i l ities through commands in add ition to
statements . It is recommended that such command s use the same keywords as the
statements .
- 137 -
13.
G RA P H I C S
- 138 -
1 3 . GRAPHICS
The fac i l ities provided in section 13 . 1 through 13 . 3 are a subset of those provided by
level Ob of the Graphical Kernel System (GKS ) as def ined in ISO 7942 . The values of the
EXTYPE function for exceptions defined in GKS are 11000 p lus the value of the GKS error
number .
In GKS terms , any BASIC program that includes statements from Section 13 of this Standard
has imp l ied c a l l s to the functions OPEN GKS , OPEN WORKSTATION ( tiO , 11Maindev11 , 1 ) , and
ACTIVE WORKSTATION #0 before any graphics statements are executed , and cal l s to the func
tions DEACTIVE WORSTATION #0 , CLOSE WORKSTATION #0 and CLOSE GKS as the program terminates .
13 . 1 Coordinate Systems
13 . 1 . 1 General Description
The coordinates used to produce graphic output may be chosen to suit the app l ication .
The range of this system of "probl em coordinates" ( world coordinate s ) is establ ished
by a SET WINDOW s tatement . This range is mapped into a rectangular portion of an ab
stract viewing surface which can be specified by a SET VIEWPORT statement . It is pos
sible to spec ify what part of this abstract viewing surface will be presented to the
user on the d isp lay surface by a SET DEVICE WINDOW statement . This rectangle , in
turn, may be located on the disp lay surface by a SET DEVICE VIEWPORT s tatement .
No output wi l l be produced outside the device viewport . It is possible to guarantee
that a l l graphic output which l ies outside the viewport w i l l be e l iminated by en
ab l ing c l ipping .
Ask statements are provided to determine the current values for the parameters estab
l ished by execution of one of the set statements or by default .
13 . 1 . 2 Syntax
1 . set-obj ect
2.
3.
4.
5.
6.
boundaries
boundary
ask-statement
statu s - c l ause
ask-object
7 . boundary-variables
13 . 1 . 3 Examples
1. WINDOW O , PP''2 , - 1 , 1
VIEWPORT . 5''width , width, . 5)''height , height
DEVICE WINDOW O, . 8 , O, 1
DEVICE VIEWPORT . 3 , . 5 , . 1 , 1
CLIP "Off"
- 139 -
4 . ASK WINDOW X1 , X2 , Y 1 , Y2
ASK
ASK
ASK
ASK
ASK
VIEWPORT L , R , B , T
DEVICE WINDOW XMIN , XMAX, YMIN , YMAX
DEVICE VIEWPORT LEFT , RIGHT , BOTTOM , TOP
DEVICE SIZE Width, Height , Unit$
CLIP CLIP_STATE$
13 . 1 . 4 Semantics
Graphic output is specif ied in problem coordinates . A normal ization transformation
defines the mapping from the problem coordinate system onto the norma l ized device co
ord inate ( NDC) space which can be regarded as an abstract viewing surface .
The normal i zation transformation is specified by defining the l imits of a rectangular
area, cal led a window , in problem coordinates . The window is mapped l inearly onto a
specified rectangular area, cal led a viewport , in NDC space .
Execution of a set-statement with the keyword WINDOW sha l l estab l ish the boundaries
of the window . The parameters represent the probl em coordinates of the left , right ,
bottom, and top edge s , in that order , of the window rectangl e . At the start of pro
gram execution the window values are ( 0 , 1, 0 , 1 ) .
Execution of a set- statement with the keyword VIEWPORT sha l l establ ish
boundaries . The parameters represent the norma l ized device coordinates
right, bottom , and top edges , in that order , of the viewport rectang le .
ord inates must not be less than zero not more than one . The value of the
nate sha l l be less than the ri1t , and the bottom less than the top . At
program execution the viewport values are ( 0 , 1, o, 1 ) .
the viewport
of the left ,
Viewport co
left coordi
the start of
The viewport may also be used to define a c l ipping rectang l e . Execution of a set
statement with the keyword CLIP sha l l enab le or disable c l ipping to the viewport
boundary ( see Section 13 . 3 ) depending on whether the value of the string-expression
is "ON" or "OFF" . The letters in the value of the string-expression may be any combi
nation of upper-case and lower-case . At the start of program execution, c l ipping
sha l l be enabled .
A device transformation is used to map a rec tang le in NDC space cal led a device win
dow uniformly onto a rectang le on a phys ica l surface cal led a device viewport . This
transformation sha l l perform equal scal ing with a positive scal e for both axes . To
ensure equal scal ing , the device transformation maps the device window onto the
largest rectang le that can f it within the device viewport such that the aspect ratio
of the device window is preserved and the lower- left corner of the device window is
mapped onto the lower- left corner of the device viewport .
Execution of a set-statement with the keyword DEVICE WINDOW sha l l estab l ish the
boundaries of the device window . The parameters represent the norma l ized device coor
dinates of the left , right , bottom, and top edges , in that order , of the device widow
rectang l e . These coordinates sha l l not be less than zero not greater than one . The
value of the left coordinate sha l l be less than the right , and the bottom less than
the top . At the start of program execution , the device window values are ( 0 , 1 , o,
1 ) . To ensure that no output outside the device window is disp layed , c l ipping takes
p l ace at the device window boundaries . This c l ipping may not be disab l ed . Execution
of a set-statement with the keywords DEVICE WINDOW sha l l cause the disp l ay surface to
be c leared if it is not a lready c l ear .
- 140 -
The f i gure below i l lustrates the relationship between the window, the viewport, the
device window, and the device viewport ; c l ipping is assumed "ON" .
\Hndow
V i ewport
Device v i ewport
Device window
Problem coordinates
NDC Space
DC Space
Execution of a set - statement with the keywords DEVICE VIEWPORT sha l l establ ish the
boundaries of the device viewport . The parameters represent the coord i nates of the
left , r i ght , bottom, and top edges , in that order of the device viewport rectangle .
Units for the device viewport shal l be meters on a device capable of producing a pre
cisely scaled image and appropriate device dependent coord inates otherw i s e . The left
and bottom edges of a d isp lay surface are represented by the coordinate value zero .
At the start of program execution, the device viewport is the entire screen . Execu
tion of a set-statement with the keywords DEVICE VIEWPORT sha l l cause the d isp lay
surface to be c leared if it is not a lready c l ear .
If a statu s - c lause is inc luded in an ask-statement , a status assoc iated with the exe
cution of the ask-statement sha l l be returned in the numeric-variable . If the
statement returned meaningful values for the ask-object, a value of zero sha l l be re
turned in the status - c lause . I f the ask-statement could not return meaningful values
for the ask-obj ect a nonzero value shal l be returned in the status - c lause that is de
fined with the semantics of the particular ask-objec t . If an ask- s tatement with a
particular ask-object is always expected to return meaningful values , the semantics
for that ask-object do not spec ify a lternate status values and zero sha l l a lways be
returned .
Execution of an ask- statement with one of the keywords WINDOW, VIEWPORT ,
WINDOW, or DEVICE VIEWPORT sha l l provide the current values for the spec i fied
gle . Values for the left , right , bottom and top s ides , respectively, sha l l
s igned to the boundary-variab les equal to the values last establ ished by
statement , or , if no appropriate set- statement has been executed , equal
default value .
DEVICE
rectan
be as
a set
to the
Execution of an ask-statement with the keywords DEVICE SIZE sha l l ass ign to the f irst
numeric variabl e the s i ze in the hor izontal direction and shal l ass ign to the second
numeric variable the s i ze in the vertical d irection of the ava i lable display surfac e .
The string-variable sha l l b e ass igned the value "METERS" i f the s i zes are i n meters
or the value " OTHER" if the units of measure are device coordinates of other units .
The values "METERS" and "OTHER" sha l l cons ist of upper - case- letters .
Execution of an ask- statement with the keyword CLIP sha l l ass ign the value 110N11 to
the string-variable if c l ipping is enab led and the value 110FF11 if it is d isabled . The
values returned sha l l be al l upper-case- letters .
- 141 -
13 . 1 . 5 Exceptions
The boundaries in a set-statement specify a rectangle of zero width or height
( 1105 1 , nonfata l : continue with current values ) .
- The boundaries in a set-statement with the keywords VIEWPORT , DEVICE WINDOW , or
DEVICE VIEWPORT specify a rectangle of negative width or height ( 1 105 1 , nonfatal :
continue with current values ) .
A boundary of the viewport is not in the range [ 0 , 1 ]
with current values ) .
A boundary of the device window is not in the range [ 0 , 1 ] ( 1105 3 , nonfatal : con
tinue with current value s ) .
A boundary of the device viewport is not in the disp lay space ( 11054 , nonfatal :
continue with current values ) .
The value of the str ing-expression in a set-statement with the keyword CLIP is nei
ther "ON" nor "OFF" after convers ion t o upper-case ( 4101 , nonfatal : continue with
current value) .
13 . 1 . 6 Remarks
The manner in which a particular graphic d isp lay device is selected by a program is
implementation-def ined .
The meaning of a window with the left edge greater than the right or the bottom edge
greater than the top is imp l ementation-def ined . If possible , imp lementations should
provide appropriately inverted images . The effect of a l l graphic output is defined in
terms of the abstract problem space , in which lower values are to the left and down,
and higher values to the right and up . When this problem space is mapped to NDC , it
may be inverted as indicated by the order of the WINDOW boundaries . This relaxes the
GKS rule that s tates that reversal window coordinates causes an error .
SET WINDOW, SET VIEWPORT , SET DEVICE WINDOW , and SET DEVICE VIEWPORT correspond to
the GKS functions SET WINDOW, SET VIEWPORT , SET WORKSTATION WINDOW, and SET
WORKSTATION VIEWPORT , respective ly. The GKS transformation number is one in these
statements as defined above . The GKS workstation number is #0 in these statements .
SET CLIP corresponds to the GKS function SET CLIPPING INDICATOR .
ASK WINDOW and ASK VIEWPORT correspond to the GKS function INQUIRE NORMALIZATION
TRANSFORMATION for norma l i zation transformation one .
ASK CLIP corresponds to the GKS function INQUIRE CLIPPING INDICATOR .
ASK DEVICE WINDOW and ASK DEVICE VIEWPORT correspond to the current workstation win
dow and current workstation viewport parameters , respectively, of the GKS function
INQUIRE WORKSTATION TRANSFORMATION with a workstation identi f ier of one .
ASK DEVICE VIEWPORT before any SET DEVICE VIEWPORT may be used to f ind the device co
ordinates of the ful l ava i labl e device surface .
ASK DEVICE SIZE corresponds to the device coord i nate units and maximum display sur
face s i z e in device coordinate units parameters of the GKS function INQUIRE MAXIMUM
DISPLAY SURFACE SIZE .
1 3 . 2 Attributes and Screen Control
13 . 2 . 1 General Description
A graphical d isp lay device may possess several styles of l ines or points , each with a
particular width or texture . A particular style may be selected for graphic output . A
- 142 -
graphic device also may be abl e to draw lines and / or f i l l areas in a variety of col
ors . Particular co lors may be selected for l ine drawing and screen background .
The current style and co lor of the geometric object may be determined by ask
statements . The number o f colors and the number of l ine or point styles avai lable may
also be determined by ask-statements .
The c lear- s tatement c lears the entire screen , returning it to its background co lor .
For hard- copy devices , the c lear- s tatement causes the paper to advance , the pen to
move aside , or s imi lar action .
This Standard provides text of one style and s ize that sha l l be output horizontal ly
with the initial -po int at the left .
13 . 2 . 2 Syntax
1.
2.
3.
4.
5.
6.
7.
imperative- statement
c l ear- s tatement
set-obj ect
primitive- 2
primitive- 1
rgb- l ist
ask-object
8 . mix- l is t
9 . text-facet
13 . 2 . 3 Examples
3 . LINE STYLE 2
TEXT COLOR 5
7 . Max color color_max
Max point style PtStyles
1 3 . 2 . 4 Semantics
Execution of a c lear- s tatement sha l l c l ear the graphic disp lay if not already clear .
For soft-copy devices , it sha l l erase the screen . For hard-copy devices , it shal l ad
vance the medium or a l low the device operator to change it .
Execution of a set-statement with the keywords LINE STYLE or POINT STYLE sha l l cause
the index to be evaluated by rounding to obtain an integer N and sha l l estab l ish the
style for subsequent l ines or points to be the Nth one of the set of avai lab le line
or point styles . The number of l ine styles avai lable is imp lementation-def ined , but
sha l l be at least three . A l ine style of one mus t correspond to drawing of s o l id
l ines . A l ine style of two sha l l correspond to drawing of dashed l ines . A line style
of three sha l l correspond to dotted l ines . All other values for l ine style are
imp l ementation-defined . At the initiation of program execution , the l ine style sha l l
b e one .
Point styles produce centered symbol s . The number of point styles is imp l ementation
defined , but sha l l be at least three . A point style of one must correspond to a
dot ( . ) , a point style of two to a p lus s ign ( + ) , a point style of three to an
asterisk ( }'< ) . A l l other values for point- style are imp l ementation-def ined . At the
start of program execution , the point styl e sha l l be three .
Execution of an ask- statement with the keywords LINE STYLE or POINT STYLE sha l l as
s ign the number of the actual current l ine style or point style to the numeric
variabl e .
- 143 -
Execution of an ask-statement with the keywords MAX LINE STYLE or MAX POINT STYLE
sha l l ass ign to the numeric-variable the largest value of LINE STYLE or POINT STYLE ,
respective ly, available .
A l l values for style sha l l be val id from one to the number returned by ASK MAX POINT
STYLE or ASK MAX LINE STYLE .
Execution of a set-statement with the one of the keyword pairs POINT COLOR , LINE
COLOR , TEXT COLOR, or AREA COLOR sha l l cause the index to be evaluated by rounding to
obtain an integer N and shall estab l ish the color index of subsequent po ints , lines ,
tex t , or f i l led areas to be the Nth one of the set of co lors , if possible with the
current graphics device . This color is cal led a foreground color . At the initiation
of execution , the color associated with each index is imp lementation-def ined , and the
foreground co lor indi ces sha l l a l l have the value one . The number of co lors avai lable
is imp lementation-def ined .
Execution of an ask-s tatement with one of the keyword pairs POINT COLOR , LINE COLOR ,
TEXT COLOR , or AREA COLOR sha l l ass ign to the numeric-variable the current value of
the color index for points , l ines , text or f i l led areas , as appropriate .
Execution of an ask-statement with the keywords MAX COLOR sha l l ass ign to the
numeric -variab le the largest distinct value ava i lab le as an index for SET POINT
COLOR , SET LINE COLOR, SET TEXT COLOR, or SET AREA COLOR . A l l values for color index
from zero to thi s value should be val id .
13 . 2 . 5 Exceptions
- A co lor index in a set-statement with the keywords POINT COLOR , LINE COLOR , TEXT
COLOR , or AREA COLOR is less than zero or greater than the maximum color index for
the imp l ementation ( 1 108 5 , nonfatal : use the imp lementation defau l t ) .
- The value of the numeric-expression in a set- statement with the keywords LINE STYLE
is less than or equal to zero or greater than the maximum style avai lable ( 1 1062 ,
nonfatal : use the value one ) .
The value of the numeric-expression in a set - statement with the keywords POINT
STYLE is less than or equal to zero or greater than the maximum style avai lable
( 11056 , nonfata l : use the value three ) .
13 . 2 . 6 Remarks
It is recommended that implementations make the value returned by ASK MAX COLOR the
same as the number of co lors ( not counting background color ) avai lable for s imultane
ous d isplay , not the total number of different co lors ava ilable on the device .
The CLEAR statement corresponds to the GKS function CLEAR WORKSTATION ( #0 ,
CONDITIONALLY ) . SET LINE STYLE and SET POINT STYLE corresponds to the GKS functions
SET LINETYPE and SET MARKER TYPE , respectively . SET LINE COLOR, SET POINT COLOR , SET
TEXT COLOR , and SET AREA COLOR correspond to the GKS functions SET POLYLINE COLOUR
INDEX , SET POLYMARKER COLOUR INDEX, SET TEXT COLOUR INDEX, and SET FILL AREA COLOUR
INDEX, respectively .
The f o l lowing ask-objects correspond to various parameters of the GKS function
INQUIRE CURRENT INDIVIDUAL ATTRIBUTE VALUES : LINESTYLE is l inetyp e , POINSTYLE is
marker typ e , LINE COLOR is polyl ine colour index , POINT COLOR is polymarker colour
index , TEXT COLOR is text co lour index and AREA COLOR is f i l l area colour index .
13 . 3 Graphic Output
13 . 3 . 1 General Description
The statements described in this section are used to generate various kinds of
graphic output . The user may cause points , l ine segments , or f i l led- in areas to be
- 144 -
drawn on the screen . There is a faci l ity for including text within the drawing . The
effect of the graphic output statements depends on the current values of the various
set-objects described in section 13 . 1 and 13 . 2 .
1 3 . 3 . 2 Syntax
1.
2.
3.
4.
5.
6.
7.
8.
9.
10 .
11.
imperative- statement
graphic - output- s tatement
geometric- statement
graphic-verb
geometric-object
point - l ist
coordinate-pair
array-geometric-statement
size-select
array-point- l ist
graphic - text- s tatement
12 . initial-point
13 . array-cel ls - statement
14 . point-pair
> graphic-output-statement
> geometric- statement I graphic-text-statement
> graphic-verb geometric -obj ect colon point - l ist
> GRAPH
POINTS I LINES I AREA
coordinate-pair ( semico lon coordinate-pai r ) )''
numeric- expression comma numeric-expression
[ deleted ]
[ de leted ]
[ deleted ]
graphic-verb TEXT initial -point ( comma USING image
co lon express ion- list I colon
string-expression)
comma AT coordinate-pair
[ deleted ]
[ de leted ]
- 145 -
such that any l ine segment beginning at that point and extended indef initely in any
d i rection w i l l cross the po lygon boundary an odd number of times . The f i l l pattern
sha l l be s o l id on devices where this is possib l e .
The graph ic - text-s tatement
The graphic - text- statement draws a label consisting of the string of characters gen
erated by its string-expres s ion, or by its image and express ion- l is t . The characters
used for label s sha l l have an imp lementation-defined size and s tyle . The effect of
c l ipping on characters which lie partly in and partly out of the viewport on the
screen is imp lementation-defined .
1 3 . 3 . 5 Exceptions
- A graphic-output- statement with LINES as the geometric- object specifies fewer than
two points ( 11 100 , fata l )
- A graphic-output- statement with AREA a s the geometric-object specifies fewer than
three points ( 1 1100 , fata l )
1 3 . 3 . 6 Remarks
The graphic- text- statement is des igned to give easy access to a device 1 s hardware
generated character set .
Text is described with respect to problem coordinates and may become distorted when
the aspect ratio of the window and viewport differ .
If a device is unabl e to f i l l a po lygon , it is recommended that the out l ine of the
polygon be drawn and the interior be hashed or shaded in a manner corresponding to
the current color number .
It is recommended that the result of f i l l ing an area cons isting solely of co l inear
points be a l ine segment through those points , that f i l l ing or drawing a l ine through
a s et of coincident points result in a dot being drawn .
GRAPH POINTS correspond to the GKS function POLYMARKER . GRAPH LINES correspond to the
GKS function POLYLINE . GRAPH AREA correspond to the GKS function FILL AREA GRAPH
TEXT is an extension of the GKS function TEXT in that it al lows formatting of text
with USING .
.
- 146 -
15.
F I XE D
D E C I MAL
NUMB E RS
- 147 -
as fo l
of s ig
nonzero
is far-
- 148 -
ther left . The last s ignificant digit is the last exp l icitly written or the digit im
mediatel y to the left of the decimal point , whichever is farther right . In the spe
cial c a s e o f zero , there is a t least o n e s ignificant digit , namely immediately to the
left of the decimal point . A numeric-constant written in scaled notation is inter
preted as i f expressed in the equivalent unsealed notatio n .
F o r examp l e :
constant as written
12 . 34
12 . 300
12 . 300E-4
12 . 300E7
OO . OOE - 3
O . OE3
s ignificant digits
12 . 34
12 . 300
. 0012300
123000000 .
. 00000
0.
I f the number o f s ignificant digits exceeds P , the imp l ementation sha l l round the
value to no fewer than P d igits . If the number of s ignificant digits to the left of
the decimal point exceeds P , an overf low exception results .
Each s imp l e - numeric-variabl e and numeric-array has a precision attribute defined in
terms of the number of digits maintained in the integer part and the fraction part ,
namely integer-size and fraction - s ize . The representation of variables and arrays is
governed by ( in descending order of precedence ) :
- the fixed-point - s ize specified in the fixed - dec l aration of the variabl e or array,
or,
- the f ixed-point-size fol lowing DECLARE NUMERIC in a dec lare-statement containing a
fixed- dec l aration for the variabl e or array, or
- the default f ixed-point- s ize specified in the ARITHMETIC FIXED option .
The precis ion attribute of a numeric-array app l ies to each of its e l ements . The s ig
nificant digits for a numeric-variabl e a r e the same a s if the variabl e were written
out with its ful l precis ion as a numeric-constant .
The semantics of numeric- expressions and numeric- supp l ied- functions are as specified
in 5 . 3 and 5 . 4 , except a fol lows . The precis ion attribute of the resul t obtained by
evaluating a numeric- supp l ied- function or numeric-expression is imp l ementation
defined . The accuracy of such evaluation is also imp lementation-defined .
Ass ignment of a numeric value to a numeric-variabl e , whether done by internal ass ign
ment ( such as with LET ) , or from an external source ( such as with INPUT ) , proceeds as
f o l lows . The integer part and fraction part of the value are moved to the integer
part and fraction part of the variab l e , a l igned on the decimal point . If any nonzero
d igits are truncated on the left of the integer part, an overf low exception results .
If any d igits are truncated on the right of the fraction part , the resul ting value in
the variabl e is rounded to the preci s ion of the variab l e . If necessary, the value is
extended with zeros on the left of the integer part, or the right of the fraction
part so as to f i l l a l l the digit p laces of the receiving variabl e .
The semantics f o r input and output are a s specified i n Section 10 , except a s fo l lows .
When a numeric-expression is used as a print- item in a print-statement , its value is
a lways printed in unsealed representation, either imp l ic it point or exp l icit point .
The digits p r inted are exactly the s ignificant digits , as defined above . Note that
for numeric-expressions other than variab les and constants , significant digits are
imp lementation-defined . Imp l icit point representation sha l l be used when there are no
s ignificant digits to the right of the decimal point ; otherwise exp l icit point repre
sentation sha l l be used .
The semantics for f i l e areas are as specified in Section 1 1 , with the fo l lowing
additions . For DISPLAY records , the rules given above for input , output , and
- 149 -
assignment are used . For INTERNAL records , the values are self-typed , and so input
and output takes p lace as defined above . Thus , the resul t of WRITE A and READ B,
where they access the same value in the file, is the same as LET B = A. Note that it
is imp l ementation-defined whether an INTERNAL f i le accessed with one ARITHMETIC
option is accessible with another . The ARITHMETIC FIXED option with different default
prec1s 1ons is not considered to be a different option for the purposes of
accessibil ity . For NATIVE records , ass ignment of values to and from fie lds of fixed
po int- size takes p lace in accordance with the usual rules for fixed-point ass ignment .
When a value is moved to a field with a size of E ( indicating f loating-point ) , at
least the first P significant digits must be retained exac t l y . When a value obtained
from such a field is ass igned to a variabl e , the field is treated as a scaled
numeric-constant , as described above . Again, note that it is imp l ementation-def ined
whether a NATIVE f i l e accessed with one ARITill1ETIC option is access ible with another .
The ask-attribute DATUM returns the type of the next datum in a file . For numeric
data in STREAM INTERNAL f i les written with the FIXED option , the type returned by the
ask-attribute DATUM sha l l be :
where ii is the two digit number for integer- s ize and ff the two digit number for
fraction- size .
1 5 . 1 . 5 Exceptions
The number of significant
exceeds P ( 1001 , fata l ) .
digits
in
the
integer
part
of
of
numeric-constant
integer-size
and
- Upon ass ignment of a numeric value to a variable , the number of significant digits
in the integer part exceeds the variable ' s integer- s ize ( 1011, fata l ) .
15 . 1 . 6 Remarks
It is recommended that the accuracy of transcendental functions such as LOG , COSH ,
ATN , SIN, and EXP be no less than that specified for OPTION ARITHMETIC DECIMAL . It is
recommended that for non- transcendental functions , such as ABS INT , and f1AX , and for
the operations + , - , ,., , I , and , an intermediate result be maintained as f loating
point decimal with P+2 s ignificant digits . This would imp ly that whenever a l l the
intermediate results of a numeric-expression are exact within P+2 decimal digits and
the final result is exact within P dec imal digits , then the final result is exactly
correct .
-
- 150 -
A numeric -variab le or actual -array appearing in a cal l - statement sha l l have the same
integer - s ize and fraction- s ize as the correspond ing procedure-parameter . For a l l
other numeric function-argument o r procedure-arguments and their corresponding
function-parameters or procedure-parameters , it is necessary only that the ARITHMETIC
options of their respective program-units agree , i . e . , that both be DECIMAL or NATIVE
or FIXED .
An option-statement with an ARITHMETIC FIXED option sha l l occur in a lower-numbered
l ine within the program-unit than any interna l - function-def that dec lares a numeric
defined-function or spec ifies numeric parameters .
A fixed-point- type may appear in an interna l - function- l ine or numeric-def - statement
only if the ARITHMETIC FIXED option has been specified for the program-unit .
A numeric-fixed-parameter may be used only if the ARITHMETIC FIXED option has been
specified for the program-unit .
When a fixed -defined- function is dec lared in a function-typ e , the fixed-point-s i zes
specified either exp l icitly or by default in the declaration and the corresponding
definition must agree .
15 . 2 . 3 Examples
3 . A( ) l'C8 . 2
B( ' ) l'C4 . 4
5 . 123 FUNCTION SUMVECTQRl'c5 . 2 ( V ( ) >'< 5 . 2 )
6 . 234 EXTERNAL FUNCTION ANSWERll ( A$ )
7 . DEF AVERAGEl'c 10 . 3 ( X>'c10 . 3 , Y>'c1Q . 3 )
( X+Y ) / 2
=
15 . 2 . 4 Semantics
When the ARITHMETIC FIXED option is specified for a program-unit , the values of nu
meric procedure-parameters ,
numeric
function-parameters ,
and
numeric-defined
functions sha l l be represented and manipulated as fixed-point decimal numbers . If the
fixed-point-s ize of one of these is not exp l icitly specif ied in the appropriate
procedure-parameter or function-paramete r , internal-def - l ine or interna l -function
l ine or external - function- l ine , then it is assumed to be the default specified in the
ARITHMETIC FIXED option . The fixed -point-size of a normal -array app l ies to each of
its e lements .
The evaluation and ass ignment of the arguments in a function reference to the parame
ters of the function-def proceed as described in 9 . 1 , with the following addition . I n
the case where the f ixed-point - s ize of a n argument differs from that of the corre
sponding parameter , the ass ignment rules given in 15 . 1 . 4 app l y .
The association o f the procedure-arguments i n a ca l l - statement with the procedure
parameters in the corresponding sub - s tatement proceeds as described in Section 9 . 2 ,
with the fo l lowing addition . In the case where the fixed -point-size of a procedure
argument which is a numeric- expression, but not a numeric-variab l e , differs from that
of the corresponding procedure-parameter , the ass ignment rules given in 15 . 1 . 4 app ly .
- 151 -
15 . 2 . 5 Exceptions
- In a numeric - f ixed-parameter or f ixed-defined- functio n , the sum of the integer- si ze
and fraction - s ize in a fixed-point-size exceeds P ( 10 10 , fatal ) .
- Upon ass ignment of a numeric value to a numeric - f ixed-parameter or fixed- defined
function, the number of significant digits in the integer part exceeds the
integer- s ize of the numeric- fixed-parameter of fixed-def ined-function ( 10 1 1 ,
fatal ) .
1 5 . 2 . 6 Remarks
None .
- 152 -
TABLE 1
Standard BASIC Character Set
The name of the characters indicated in the tabl e correspond to the name of the characters in
Standard ECMA- 6 . \fuere different names are used in this Standard for the syntax of BASI C , these
names are indicated between parentheses .
ORDINAL
POSITION
CODE
0.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10 .
11 .
12 .
13 .
14 .
15 .
16 .
17 .
18 .
19 .
20 .
21.
22 .
23 .
24 .
25 .
26 .
27 .
28 .
29 .
30 .
31.
32 .
33 .
34 .
35 .
36 .
37 .
38 .
39 .
40 .
41.
42 .
0/0
0/1
0/2
0/3
0/4
0/5
0/6
0/7
0/8
0/9
0 / 10
0 / 11
0 / 12
0 / 13
0 / 14
0 / 15
1/0
1/1
1/2
1/3
1/4
1/5
1/6
1/7
1/8
1/9
1 / 10
1 / 11
1 / 12
1 / 13
1 / 14
1/15
2/0
2/1
2/2
2/3
2/4
2/5
2/6
2/7
2/8
2/9
2 / 10
GRAPHI C
ACRONYM
NAME
NUL
SOH
STX
NULL
START OF HEADING
START OF TEXT
END OF TEXT
END OF TRANSMISSION
ENQUIRY
ACKNOWLEDGE
BELL
BACKSPACE
HORIZONTAL TABULATION
LINE FEED
VERTICAL TABULATION
FORM FEED
CARRIAGE RETURN
SHIFT OUT
SHIFT IN
DATA LINK ESCAPE
DEVICE CONTROL ONE
DEVICE CONTROL TWO
DEVICE CONTROL THREE
DEVICE CONTROL FOUR
NEGATIVE ACKNOWLEDGE
SYNCHRONOUS IDLE
END OF TRANSMISSION BLOCK
CANCEL
END OF MEDIUM
SUBSTITUTE
ESCAPE
FILE SEPARATOR
GROUP SEPARATOR
RECORD SEPARATOR
UNIT SEPARATOR
SPACE
EXCLAMATION MARK
QUOTATION MARK
NUMBER SIGN
DOLLAR S IGN
PERCENT SIGN
AMPERSAND
APOSTROPHE
LEFT PARENTHESIS
RIGHT PARENTHESIS
ASTERISK
ETX
EOT
ENQ
ACK
BEL
BS
HT
LF
VT
FF
CR
so
SI
DLE
DC1
DC2
DC3
DC4
NAK
SYN
ETB
CAN
EM
SUH
ESC
FS
GS
RS
us
SP
II
II
$
%
&
";''
- 153 -
43 .
44 .
45 .
46 .
47 .
48 .
49 .
50 .
51.
52 .
53 .
54 .
55.
56.
57 .
58 .
59 .
60 .
61 .
62 .
63 .
64 .
65 .
66 .
67 .
68 .
69 .
70.
71.
72.
73.
74.
75.
76 .
77 .
78.
79 .
80 .
81 .
82 .
83 .
84 .
85 .
86 .
87 .
88 .
89 .
90 .
91.
92 .
93.
94 .
95.
96 .
97 .
98.
2 / 11
2 / 12
2 / 13
2 / 14
2 / 15
3/0
3/1
3/2
3/3
3/4
3/5
3/6
3/7
3/8
3/9
3 / 10
3 / 11
3 / 12
3 / 13
3 / 14
3 / 15
4/0
4/1
4/2
4/3
4/4
4/5
4/6
4/7
4/8
4/9
4 / 10
4/11
4/12
4 / 13
4 / 14
4 / 15
5/0
5/1
5/2
5/3
5/4
5/5
5/6
5/7
5/8
5/9
5 / 10
5 / 11
5 / 12
5 / 13
5 / 14
5 / 15
6/0
6/1
6/2
0
1
2
3
4
5
6
7
8
9
<
>
?
@
A
B
c
D
E
F
G
H
I
J
K
L
M
N
0
p
Q
R
s
T
u
v
w
X
y
z
[
\
l
A
b
PLUS SIGN
COMMA
MINUS SIGN
FULL STOP ( Period )
SOLIDUS ( S lant)
DIGIT ZERO
DIGIT ONE
DIGIT TWO
DIGIT THREE
DIGIT FOUR
DIGIT FIVE
DIGIT SIX
DIGIT SEVEN
DIGIT EIGHT
DIGIT NINE
COLON
SEMICOLON
LESS-THAN SIGN
EQUALS SIGN
GREATER-THAN SIGN
QUESTION MARK
COMMERCIAL AT
CAPITAL LETTER ( Upper-case ) A
CAPITAL LETTER ( Upper- case) B
CAPITAL LETTER ( Upper-case ) c
CAPITAL LETTER ( Upper-case ) D
CAPITAL LETTER ( Upper-cas e ) E
CAPITAL LETTER ( Upper-cas e ) F
CAPITAL LETTER ( Upper-cas e ) G
CAPITAL LETTER ( Upper-case ) H
CAPITAL LETTER ( Upper-case) I
CAPITAL LETTER ( Upper-case) J
CAPITAL LETTER ( Upper-cas e ) K
CAPITAL LETTER ( Upper-case ) L
CAPITAL LETTER ( Upper-case ) M
CAPITAL LETTER ( Upper-cas e ) N
CAPITAL LETTER ( Upper-cas e ) 0
CAPITAL LETTER ( Upper-case) p
CAPITAL LETTER ( Upper-case ) Q
CAPITAL LETTER ( Upper-cas e ) R
CAPITAL LETTER ( Upper-cas e ) s
CAPITAL LETTER ( Upper-case ) T
CAPITAL LETTER ( Upper-case ) u
CAPITAL LETTER ( Upper-case ) v
CAPITAL LETTER ( Upper-case ) w
CAPITAL LETTER ( Upper-case ) X
CAPITAL LETTER ( Upper-cas e ) y
CAPITAL LETTER ( Upper-cas e ) z
LEFT SQUARE BRACKET
REVERSE SLANT ( Reverse so l idus )
RIGHT SQUARE BRACKET
CIRCUMFLEX ACCENT
UNDERLINE
GRAVE ACCENT
SMALL LETTER ( Lower-case) a
SMALL LETTER ( Lower-case) b
- 154 -
99 .
100 .
101 .
102 .
103 .
104 .
105 .
106 .
107 .
108 .
109 .
no .
lll .
ll2 .
113 .
ll4 .
ll5 .
ll6.
ll7 .
ll8 .
ll9 .
120 .
12 1 .
122 .
123 .
124 .
125 .
126 .
127 .
6/3
6/4
6/5
6/6
6/7
6/8
6/9
6 / 10
6/11
6 / 12
6 / 13
6 / 14
6 / 15
7/0
7/1
7/2
7/3
7 /4
7/5
7/6
7/7
7/8
7/9
7 / 10
7 / 11
7 / 12
7 / 13
7 / 14
7 / 15
c
d
e
f
g
h
i
j
k
1
m
n
0
p
q
r
s
t
u
v
w
X
{
}
DEL
- 155 -
TABLE 2
Exception Codes
The f o l lowing tab le speci f ies the values of the EXTYPE function corresponding to the exceptions
spec i fied in thi s Standard . Nonfatal exceptions are des ignated by an exc lamation-mark ( ! ) . The
numbers in parentheses f o l l owing each exception refer to the sections in which that exception is
specif ied .
Overf low ( 1000)
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1051
1052
1053
1054
1105
1 106
Overf low
Overflow
Overflow
Overflow
Overflow
Overf low
Overf low
Overflow
Overf low
Too ny
Overf low
Overflow
Overflow
Overflow
Overf low
Overf low
Overf low
Division by zero ( 5 . 3 )
Negative number raised to nonintegral power ( 5 . 3 )
Zero raised to negative power ( 5 . 3 )
Logarithm of zero o r negative number ( 5 . 4 )
Square root o f negative number ( 5 . 4 )
Zero divisor speci fied for MOD o r REMAINDER ( 5 . 4 )
Argument o f ACOS o r ASIN not in range - 1 < = x < = 1 ( 5 . 4 )
Attempt t o evaluate ANGLE ( O , O ) ( 5 . 4 )
Attempt t o invert a s ingular matrix , o r loss of a l l s ignif icance i n such attempt ( 7 . 2 )
- 156 -
Uninitialized numeric-variable ( 5 . 2 )
Uninitial ized string-variable ( 6 . 2 )
4007
4008
4009
4010
4101
4301
4302
4303
Mismatched s izes in
Argument of DET not
Argument of INV not
Arguments to IDN do
numeric-array-expression ( 7 . 2 )
a square matrix ( 7 . 2 )
a square matrix ( 7 . 2 )
not specify square matrix ( 7 . 2 )
6005
First index greater than second in redim, or index less trull1 lower bound ( 7 . 2 , 7 . 3 , 10 . 5 ,
11 . 4 )
6101
7004
7050
7051
7052
7 100
7 1xx
- 157 -
7202
The record- setter RECORD is used on a f i le opened with a f i l e -organization other than
7 3 17
7 3 18
7321
7 322
7203
7204
7205
7206
7207
7 30 1
7 302
7 30 3
7 30 5
7 308
7 3 11
7312
7 3 13
7 3 14
7 3 15
7 3 16
7401
7402
8101
8102
8103
8105
8120
8201
8202
8203
8204
Nonnumeric datum for ( MAT) READ or INPUT o f number from DISPLAY record ( 10 . 1 , 10 . 5 , 11 . 4 )
Syntact ical ly incorrect input-reply from terminal ( 10 . 2 , 10 . 5 )
Nonnumeric datum for ( MAT ) INPUT o f number ( 10 . 2 , 10 . 5 )
Syntac t ically incorrect input reply from f i le ( 11 . 4 )
Type mismatch o n INTERNAL input ( 11 . 4 )
Invalid format-string ( 10 . 4 , 10 . 5 )
No format- item in format- string for output list ( 10 . 4 , 10 . 5 )
Format- item too short for output string ( 10 . 4 )
Exrad overf low ( 10 4 )
8251
The string- expres s ion o f a temp late-identifier is not a s yntactical ly correct temp late
e l ement- l is t ( 11 . 3 , 11 . 4 , 1 1 . 5 ) ( BASIC-2 only)
An expression or array-element does not agree in type ( numeric or string ) with its
associated TEMPLATE field- specifier ( 11 . 3 , 11 . 4 , 1 1 . 5 ) ( BASIC-2 only)
A temp late- e lement with a variable-field-count does not coincide with the first e lement
of an array ( 1 1 . 3 , 11 . 4 , 1 1 . 5 ) ( BASIC-2 only)
There are not enough field- speci fiers in a temp late-statement for all the express ions or
array - elements ( 11 . 3 , 1 1 . 4 , 11 . 5 ) ( BASIC-2 only )
A numer ic value has s ignificant d igits to the left of the avai lable d igit p laces in the
f ield of a temp late ( 11 . 3 , 11 . 5 ) ( BASIC- 2 only)
8252
8253
8254
8255
- 158 -
8256
A string value is longer than the length of its field in the temp late ( 11 . 3 , 1 1 . 5 )
8301
8302
8401
8402
( BASIC - 2 only)
Record length exceeded on output to f i l e ( 11 . 3 , 1 1 . 5 )
Input from a record longer than RECSIZE ( 11 . 4 )
Timeout on (MAT) ( LINE) I NPUT ( 10 . 2 , 10 . 5 )
I l legal numeric value speci fied for time-express ion ( 10 . 2 , 10 . 5 )
- 159 -
AP P END I C E S
- 160 -
APPENDIX 1
ORGANI ZATION OF THE STANDARD
This Standard is organized into a number of sections , each of which covers a group of related
features of BAS I C . Each section is d ivided further to treat particular features of BASIC . The
f inal subdivisions of each section are used as f o l lows .
Subsection 1
General Description
This subsection brief l y describes the features of BASIC to be treated .
Subsection 2
The exact syntax of features of the language is describes in a mod ified context-free
grammar o r Backus -Naur Form . The details of this method of syntax spec ification are
described in 3 . 1 .
In order to keep the s yntax reasonably s imp le the syntax specif ication w i l l al low some
constructions which , strictly speaking , are not legal according to this Standard ; e . g . , it
will al low the generation of the statement
LET X = A ( + l ) + A ( l , 2 )
in which the array A occurs with differing numbers of subscripts . Rather than rul ing such
construct ions out by a more comp l icated formal syntax, this Standard instead rules them out
by p lacing restrictions on that syntax .
The primary goa l of the syntax is to def ine the notion of a program and its constituent
parts . In addition the syntax def ines several other items which are not needed for the
definition of a program . These include the input-prompt , which is output to reques t input ,
the input- rep ly and l ine- input- rep l y , which are strings suppl ied in response to a request
for input .
Subsection 3
Examples
A short l is t of val i d examp les that can be generated by the productions in Subsection 2 is
given . The numbering of the examp les corresponds to the numbering of the productions , and
wi l l not be consecutive if examp les are not given for al l rules .
Subsection 4
Semantics
The semantic rules in this
according to the syntax .
S tandard
ass ign a
meaning to
the constructions
generated
- 161 -
SUbsection
Exceptions
This subsection contains a l i s t of those exception conditions which a s tandard-conforming
implementation must recognize . Exception numbers ( values of the EXTYPE function) are also
given .
SUbsection 6
Remarks
This subsection contains remarks which point out certain features of this Standard as wel l
as remarks which make recollllllendations concerning the implementation of a BASIC l anguage
processor in an operating environment .
- 162 -
APPENDIX 2
SCOPE RULES
The scope of an entity is that part of the program where its name is recognized as referring to
that obj ect ( as opposed to not being recognized at al l , or recognized as referring to some other
object ) . In general , an entity is known by only one name , and so the scope of recognition of its
name is also the scope in which the object itself can be accessed . In the special case of parame
ter pass ing by reference , the same object is known by two different names , and so the object it
self may be accessed outs ide the scope of its name .
In a l l cases , the indicated scope is the scope of the name of the object in question .
Object
1.
2.
3.
4.
5.
6.
7.
8.
9.
10 .
11 .
12 .
13 .
14 .
15 .
16 .
17 .
18 .
19 .
Scope
non-parameter variabl e
non-parameter array
program-unit parameter
program-unit
program-unit
program-unit ( ,'' )
inter-proc -def-parameter
inter-proc - def
program-unit
DATA
channe l -number ( non- zero )
chann e l zero
IMAGE , TEMPLATE
GOSUB stack
OPTIONs
f i lenames
RND sequence
[ deleted ]
[ deleted ]
Graphic and PRINT
set-obj ect
l ine-number
DEBUG and TRACE state
program
program-unit
program-unit
program
program-unit ( BASIC-2 only for TEMPLATE )
smal ler of program-unit , internal-proc-def , when- lock
( BASIC-2 only ) , or exception-hand ler ( BASIC-2
only)
program-unit
program
program
program
program-unit
program-unit
Even though the name is known only to the program-unit or internal -proc -def , when a parameter is
passed by referenc e , the object denoted is common to both the invoked and invoking unit .
- 163 -
APPENDIX 3
IMPLEMENTATION-DEFINED FEATURES
A number of the features defined in this Standard have been left for def inition by the imp le
menter . However , this wil l not affect portab i l ity, provided that the l imits recommended in the
various sections are respected .
The way these features are imp lemented shal l be def ined in the user or system manual of the spe
c ific imp lementation .
The following is a l ist of implementation-defined features .
Subsection 2 . 3
- interpretation of syntactical ly i l legal constructs
- format of error messages
Subs ection 2 . 4
- format o f exception messages
- hardware dependent exceptions
- order of exception detection in a l ine
Subsection 3 . 2
- certain semantic rules for native data
Subsection 4 . 1
- other-character
- coding for the native col lating sequence
Subsection 4 . 2
- end-of- l ine
- maximum physical l ine length
- effect of parameter list in program-name - l ine of program not initiated by a chain-statement
- relationship of program-designator and program-name
- effect of non- standard programs
Subsection 4 . 4
- restrictions on identifiers for procedures comp iled independently from the main program
Subsection 5 . 1
- precision and range of numeric-constants
Subsection 5 . 2
- initial value of numeric variab les
Subsection 5 . 3
- order of evaluation of numeric -expressions
- 164 -
Subsection 5 . 4
-
numeric values
f l oating decimal arithmetic
native arithmetic
of numeric express ions
Subsection 6 . 2
- 165 -
Subsection 10 . 3
- effect of invoking a function which causes printing whi le printing
-
number o f s ignificant d igits for values received from a numeric field in a NATIVE ( for BASIC-2
only) f i le
effect of input-contr o l - items on f i les and nonterminal devices
prec is ion of numeric contents received from disp lay f i les
precis ion of numeric-values that can be retrieved without loss of precis ion from a NATIVE file
( BASIC-2 only)
retrieving a record from a NATIVE file having contents which are incompatible with the TEMPLATE
( BASIC-2 only)
use of fatal or nonfatal exception procedure on i l l egal input- rep ly
- 166 -
the maximum precis ion avai lable for f ixed decimal arithmetic
the precis ion of f ixed decimal expression and function evaluation
the accuracy of fixed decima l express ion and function evaluation
definition of " s ignif icant d igits"
the access ibi l i ty o f an INTERNAL format file to programs having different ARITHMETIC options
- the accessibil ity of a NATIVE format f i l e to programs having different ARITHMETIC options
Tab le 1
- The number of additional other- characters .
It should be noted that implementation-defined features may cause the same program to produce
different results on different imp lementations , for these and possibly other reasons :
- The logical f low of a program may be affected by the algorithm used for the pseudo -random num
ber sequence .
- The logical f low of a program may be affected by the value of machine infinites imal and /or the
value of MAXNUM and / or the precis ion for numeric values .
- The initial value of variables may affect the logical f low of a program which contains logical
errors .
The order of evaluation of numeric-expressions may affect the logical f low of a program .
- 167 -
APPENDIX 4
INDEX OF SYNTACTIC OBJECTS
This Appendix indexes a l l occurences of terminal symbo ls and metanames in the syntax . Each refer
ence has the form cc . s -pp , where cc . s indicates the section and subsection in which the
metaname occurs and pp indicates the number of the production . An asterisk f o l l owing a reference
indicates that the metaname is def ined in that product ion . Symbols and etanaJIIf!s used only in
BASIC-2
are
shown in bold .
0
1
2
3
4
5
6
7
8
9
A
ABS
ACCESS
ACOS
AND
ANGLE
4 . 1-07
4 . 1-07
4 . 1 -07
4 . 1-07
4 . 1-07
4 . 1-07
4 . 1-07
4 . 1-07
4 . 1-07
4 . 1-07
4 . 1-09
5 . 4 -01
11 . 1-08
5 . 4-01
8 . 1-03
5 . 4-01
ASIN
ASK
AT
ATN
13 . 2 -04
5 . 6-03
5 . 4-01
10 . 3 -08
13 . 3 - 12
5 . 4 . 01
B
BASE
BEGIN
BREAK
4 . 1-09
7 . 1-09
11 . 2 - 0 5
12 . 2-02
AREA
ARITHMETIC
c
CALL
CASE
CAUSE
CEIL
CHAIN
CHR
CLEAR
CLIP
CLOSE
COLLATE
COLOR
CON
4 . 1 -09
9 . 2 - 14
8 . 4- 1 3
7 . 1 -09
7 . 1 -09
11 . 1-22
5 . 6-03
13 . 3 -05
15 . 1-01
11 . 1 - 18
13 . 1-04
8 . 4 - 16
8 . 4-21
12 . 1-13
5 . 4-01
9 . 3-01
6 . 4-01
13 . 2-02
13 . 1-01
11 . 1 - 16
6 . 6-01
13 . 2-03
7 . 2 -06
13 . 1-06
11. 1-29
13 . 2-07
11. 1-31
- 168 -
CONTINUE
cos
COSH
COT
esc
12 . 1-11
5 . 4- 0 1
5 . 4- 0 1
5 . 4-01
5 . 4 . 01
D
DATA
DATE
DATUM
DEBUG
DECIMAL
DECLARE
DEF
DEG
DEGREES
DELETE
DET
DEVICE
DIM
DISPLAY
DO
DOT
4 . 1-09
10 . 1-06
5 . 4- 0 1
11 . 1-22
12 . 2-01
5 . 6-03
5 . 6 - 04
9 . 1-05
5 . 4- 0 1
5 . 6- 0 3
11 . 5-06
7 . 2 - 10
13 . 1-01
7 . 1-01
11 . 4- 14
8 . 3-04
7 . 2 - 10
E
ELAPSED
ELSE
ELSEIF
END
4 . 1-09
10 . 2 -07
8 . 2-03
8 . 4-07
4 . 2 - 18
11. 2-05
5 . 4-01
EPS
ERASABLE
ERASE
EXCEPTION
EXIT
EXLINE
EXP
EXTERNAL
EXTEXT
EXTYPE
F
FILETYPE
FIXED
FOR
FP
FUNCTION
G
GO
GOSUB
GOTO
GRAPH
H
11 . 1-22
11. 1-17
12 . 1-03
8 . 3 - 07
12 . 1-18
5 . 4- 0 1
9 . 1 - 15
12 . 1-19
12 . 1-18
6 . 4-01
9 . 1-07
9 . 1-20
15 . 2-07
13 . 1-06
8 . 3 - 07
5 . 1 -08
11.3-N22
8 . 2-06
8 . 4-01
8 . 4-09
8 . 4-21
8 . 4-10
12 . 1-07
8 . 4-22
12 . 1-17
9 . 1 - 13
9 . 2 - 10
12 . 1-09
8 . 3 - 18
12 . 1-13
9 . 1 - 18
9 . 2-11
12 . 1-12
9 . 1-22
9 . 2 - 13
9 . 2 - 19
15 . 2-06
9 . 1 - 13
15 . 2-05
9 . 1 - 15
15 . 2-06
9 . 1 - 18
9 . 1-21
8 . 2-03
8 . 2-04
8 . 2-06
4 . 1-09
1 1 . 1-22
5 . 6- 0 3
8 . 3-12
5 . 4-01
9 . 1 - 12
9 . 1-22
4 . 1 -09
8 . 2-02
8 . 2-04
8 . 2 - 02
13 . 3-04
4 . 1-09
15 . 1-01
8 . 3 - 18
8 . 2 -06
8 . 2 - 03
- 169 -
HANDLER
12 . 1-12
I
IDN
IF
IMAGE
IN
I NPUT
4 . 1-09
7 . 2-06
8 . 4-01
10 . 4-05
12 . 1-03
10 . 2 -01
1 1 . 4-01
5 . 4-01
11 . 1 - 14
INT
INTERNAL
INV
IP
IS
J
L
LBOUND
LCASE
4 . 1-09
7 . 1- 12
6 . 4-01
6 . 4 - 02
1 1 . 1-15
5 . 5 - 02
10 . 2 -08
13 . 3 -05
5 . 4-01
5 . 4-01
5 . 4-01
8 . 3 -09
6 . 4- 0 1
LOG
LOG10
LOG2
LOOP
LTRIM
MIN
MISSING
MOD
4 . 1-09
10 . 3 . 07
7 . 2-02
10 . 5 -09
11 . 4-04
5 . 4- 0 1
6 . 4- 0 3
5 . 4-01
7 . 1- 12
5 . 4-01
10 . 1-03
5 . 4-01
N
NAME
NATIVE
NEXT
4 . 1-09
1 1 . 1-01
5 . 6- 0 3
8 . 3 - 20
M
MARGIN
MAT
MAX
MAXLEN
MAXNUM
MAXSIZE
8 . 4 - 04
8 . 4 - 10
10 . 1-03
1 1 . 2-07
10 . 2 -08
11 . 4-02
10 . 5 - 04
1 1 . 4-03
10 . 5 -06
1 1 . 4-04
11 . 1-08
6 . 5 - 02
10 . 5 -06
9 . 1 - 16
11 . 4-03
9 . 1- 17
11 . 4 - 04
10 . 3 - 10
7 . 3 - 02
11 . 3 -02
1 1 . 4 -08
13 . 2 - 07
11 . 1-22
10 . 5-01
11 . 3 -07
11 . 5-03
11. 3-05
10 . 5 - 04
11 . 4-02
4 . 1-09
4 . 1-09
11 . 1-31
11 . 1-24
LENGTH
LET
LINE
LINES
12 . 1-17
7 . 2 -09
5 . 4-01
8 . 4 - 19
K
KEY
KEYED
LEN
12 . 1-16
11 .2-10
11 . 1-22
6 . 6- 0 1
11. 1-29
1L l-N26
13 . 2-05
10 . 5-06
- 170 -
NOT
8 . 1-04
NUL
NUMERIC
7 . 3 -05
5 . 6-06
0
OF
OFF
ON
OPEN
OPTION
OR
ORD
ORGANI ZATION
OUT IN
OUTPUT
4 . 1 -09
11. 3-Nl8
12 . 2 -01
8 . 2 - 03
11 . 1-01
5 . 6- 0 1
8 . 1-02
6 . 4-02
1 1 . 1-09
11 . 1 -08
11 . 1-08
4 . 1-09
5 . 4-01
13 . 2 -05
11 . 1-22
13 . 3 -0 5
6 . 4-02
10 . 3 -01
4 . 2-02
10 . 2 - 04
PI
POINT
POINTER
POINTS
POS
PRINT
PROGRAM
PROMPT
Q
4 . 1-09
R
RAD
RADIANS
RANDOMIZE
READ
RECORD
RECSIZE
RECTYPE
RELATIVE
REM
REMAINDER
REPEAT
REST
RESTORE
RETRY
RETURN
REWRITE
RND
ROUND
RTRIM
4 . 1 - 09
5 . 4-01
5 . 6-03
5 . 4- 02
10 . 1-01
11 . 1-31
11 . 1 - 1 5
11 . 1 - 12
11 . 1-24
4 . 3 -0 1
5 . 4-01
6 . 4-01
1 1 . 1 - 17
10 . 1-05
12 . 1-11
8 . 2-05
11. 5-02
5 . 4- 0 1
5 . 4-01
6 . 4-01
s
SAME
SEC
SELECT
SEQUENTIAL
SET
SETTER
4 . 1-09
11 . 2 -05
5 . 4-01
8 . 4- 1 3
11 . 1 - 1 1
10 . 3 -06
11 . 1-22
11 . 3 -N21
11 . 3 -N19
12 . 2 - 03
8 . 2 - 06
15 . 1-03
12 . 2-01
12 . 2 -03
10 . 4-01
10 . 5 -09
11 . 3 -0 1
10 . 5 . 0 1
11. 2-10
11 . 1-22
11 . 1-22
11 . 4-07
11 . 4 - 08
11 . 4-01
11 . 4-07
11 . 1-22
11 . 2-03
11. 5-03
8 . 4-22
1 1 . 3-02
- 17 1 -
SGN
5 . 4-01
SIN
SINH
SIZE
SKIP
SQR
STANDARD
STATUS
STEP
STOP
STR
STREAM
STRING
STYLE
SUB
5 . 4-01
5 . 4-01
7 . 1 - 12
11 . 3-N18
5 . 4-01
6 . 6-01
1 3 . 1-05
8 . 3 - 12
4 . 2 - 13
6 . 4-01
1 1 . 1-11
6 . 6-03
13 . 2 - 03
8 . 2 -04
9 . 2 - 18
T
TAB
TAN
TANH
TEMPLATE
TEXT
THEN
THERE
TIME
TIMEOUT
TO
TRACE
TRN
TRUNCATE
4 . 1 -09
10 . 3 -04
5 . 4-01
5 . 4-01
11. 3-N15
13 . 2 -04
8 . 4-01
11 . 2-07
5 . 4-01
10 . 2 . 05
7 . 1-06
8 . 4- 19
12 . 2-03
7 . 2 - 09
5 . 4-01
u
UBOUND
UCASE
UNTIL
USE
USING
4 . 1-09
7 . 1 - 12
6 . 4-01
8 . 3 -0 5
12 . 1-05
6 . 4-01
12 . 1-09
10 . 4-02
4 . 1 -09
6 . 4 - 02
11 . 1 - 15
13 . 1-01
13 . 1-06
VAL
VARIABLE
VIEWPORT
w
WHEN
WHILE
WINDOW
WITH
WRITE
4 . 1-09
12. 1-03
8 . 3 -05
13 . 1-01
9 . 3 -0 1
11 . 3 -06
4 . 1 -09
4 . 1 -09
13 . 1-06
11 . 4-01
11 . 4-07
11. 1-29
11 . 3-N26
13 . 2-07
8 . 2 - 06
9 . 2 - 19
13 . 3 - 11
8 . 4-04
9 . 2-04
9 . 2 - 10
9 . 2-11
8 . 4-07
10 . 1 - 0 3
11 . 2 - 07
8 . 2-02
8 . 2-03
8 . 3 - 12
10 . 5-09
11 . 3 - 04
13 . 3 - 11
6 . 4-01
7 . 2 -08
12 . 2-03
12 . 1-07
1 3 . 1-06
11 . 3-N13
11 . 3 - 07
12 . 1-09
- 172 -
ZER
ZONEWIDTH
a
access-mode
actual-array
ampersand
apostrophe
array-ass ignment
array-declaration
array- input-statement
array- l ine- input-statement
array- l ist
array-name
array-output- l ist
array-print- l ist
array-print-statement
array-read-statement
array-rewrite-statement
array-write-statement
ask-attribute-name
ask- io- item
ask- io- l ist
ask- item
ask-item- list
ask-object
ask-statement
asterisk
b
block
bound- argument
boundaries
boundary
boundary-variables
bounds
bounds-range
break-statement
c
cal l - s tatement
case-block
case-else-block
case-else- l ine
case- item
case- l ine
case- l ist
case-statement
cause-statement
4 . 1-09
7 . 2-06
10 . 3 -07
4 . 1 - 10
1 1 . 1-07
5 . 3 -09
4 . 1-03
4 . 1-03
4 . 2 - 12
7 . 1-02
4 . 2 - 12
4 . 2 - 12
1 1 . 3 -07
5 . 2 - lOl'<
10 . 5 -05
10 . 5 -09
10 . 5 -09
4 . 2- 12
4 . 2 - 12
11 . 5-01
4 . 2 - 12
11 . 1-20
10 . 3-09
10 . 3 -08
11 . 1 - 19
1 1 . 1 - 18
1 3 . 1-04
4 . 2 - 12
4 . 1-03
10 . 4- 1 3
4 . 1 - 10
4 . 2-05
8 . 4-06
9 . 1-02
7 . 1 - 12
13 . 1-01
13 . 1-02
1 3 . 1-06
7 . 1 -04
7 . 1-05
4 . 2 - 12
4 . 1 - 10
4 . 2-12
8 . 4- 1 1
8 . 4 - J.l
4 . 2 - 22
8 . 4- 17
4 . 2 - 22
8 . 4 - 16
8 . 4- 1 5
4 . 2 - 12
10 . 3 - 10
11 . 1-08l'<
5 . 3 - lOl'<
4 . 2 - 24
10 . 4-08
7 . 2 - 0ll'<
7 . l-03l'<
10 . 5 - 04)'(
10 . 5 - 06)'1
11 . 3 - 1 P'<
5 . 3 - 10
10 . 5 - 10
10 . 5 - l P
10 . 5 - lOl'<
10 . 5-09l'<
10 . 5 - 0 P'<
11 . 5-03*
11 . 3- 07l'<
ll . l - 2 ll'<
10 . 3 - 10l'<
10 . 3 -09l'<
11 . 1- 20l'<
ll . 1- l9l'l
11 . 1-22
11 . 3 - 0 5
7 . 1- 13
6 . 3-06
7 . 1 - 14
9 . 2 - 16
9 . 1-11
11 . 3 - 11
10 . 5-03
7 . 3- 0 ll'<
1 1 . 4-02)'(
1 1 . 4-04)'1
11. 5-03
6 . 2 -08)'(
10 . 5 - 1 1
11 . 3-02
11 . 3-02
11 . 3 -02l'<
1 1 . 4-08l'<
11. 1-30*
13 . 1-06'
10 . 3 - 08l'<
5 . 3 - 11
11 . 3-N21
13 . 2-07l'<
ll . l- l8l'l
6 . 6-04
11. 3-N26
4 . 2-07l':
8 . 4 - 08
9 . 2 - 02
7 . 1 - 14)':
13 . l -02l'<
13 . l-03l'<
13 . 1-07l'<
7 . 1-05'
8 . 3-06
8 . 4 - 14
12 . 1-04
7 . 1-08
7 . 1-06'
12 . 2 - 02
9 . 2 - l4l'<
8 . 4- 14'
8 . 4- 20)'(
8 . 4- 2 0
8 . 4- l8l'<
8 . 4- 14
8 . 4 - l 7 l'<
8 . 4- l6l'<
12 . 1-13*
8 . 4- 2 P''
8 . 4- 15:':
13 . l-04l'<
7 . 2 -04
15 . 1-02
8 . 3 - 17
8 . 4- 2 0
12 . 1-06
7 . 2-05
8 . 4-05
- 17 3 -
chain-statement
channe l - expression
channel-number
channel- setter
character
circumf lex-accent
c l ear-statement
close-statement
col late- sequence
colon
comma
4 . 2-12
9 . 2 - 16
11. 3-01
1 1 . 4-01
11 . 4-07
11. 5-06
9 . 2-07
1 1 . 1-01
4 . 1-01>'<
4 . 1-03
13 . 2 - 0 1
4 . 2 - 12
11. 1-28
4 . 1-03
10 . 4-05
1 1 . 1-02
1 1 . 3-07
1 1 . 4-03
11 . 5-02
4 . 1-03
5 . 6-06
7 . 1-05
8 . 2 - 03
9 . 1- 1 1
9 . 2-20
10 . 2- 10
10 . 4-12
1 1 . 1-05
11 . 3 -08
9 . 3 - 0 P'<
1 1 . 1-02
11 . 3 -02
11 . 4-02
11 . 4 - 08
11 . 1-03,
1 1 . 3-06
11-4-03
11. 5-02
1 1 . 1 - 16
1 1 . 3 -07
11 . 4 - 04
11 . 5-03
11. 1-17
11 . 1 - 18
10 . 2 - 1 1
10 . 4- 1 5
11 . 2 -0 1
11. 3-05
10 . 1-01
10 . 5 -01
11 . 3-02
1 1 . 4-01
1 1 . 4-07
13 . 3 -03
5 . 3 -08
6 . 6-03
7 . 2-07
8 . 4 - 17
9 . 2-06
10 . 1-07
10 . 3 -09
10 . 5-07
11 . 2 -02
11 . 3 - 1 1
11 . 4-07
13 . 1-02
13 . 3 - 11
10 . 2 -02
10 . 5 -09
1 1 . 3-06
1 1 . 4-02
1 1 . 4-08
13 . 3 - 1 1
5 . 5-03
7 . 1-02
7 . 2 - 10
9 . 1-09
9 . 2-15
10 . 2-02
10 . 4-04
10 . 5 - 1 1
11 . 3 -0 3
11 . 3 -N16
1 1 . 4-09
13 . 1-06
13 . 3 - 12
10 . 4-02
7 . 3 -0 3
7 . 3 - 05
8 . 4- 18
8 . 4- 19
10 . 1-08
11 . 3 - 04
1 1 . 4-06
12 . 2 - 0 3
9. 2 - 08)'(
11 . 1-02)'(
4 . 3 -02
5 . 3 -04
13 . 2 - 02)'(
1 1 . 1 - 16)'(
11 . 1-29*
6 . 2 - 06
10 . 4-08
11 . 3 - 0 1
11 . 3-N15
1 1 . 4 - 04
11. 5-03
5 . 2 - 06
6 . 5 - 03
7 . 1 - 14
8 . 2 - 06
9 . 1-23
10 . 1-02
10 . 3 - 0 5
10 . 5 - 02
1 1 . 1 - 19
11 . 3 - 10
comparison
concatenation
conditiona l - s tatement
conjunction
constant
contro l - transfer
contro l -variab le
coordinate-pair
core-attribute-name
core - f i le-attribute
core - f ile-erg-value
core-record-setter
core-record- type-value
1 1 . 4-01
11. 5-04
13 . 1-07
15 . 1-03
8 . 1-05
6 . 3 -02
4 . 2 - 10
8 . 1 -02
5 . 1-0 P'<
8 . 2-0P'<
8 . 3 - 12
13 . 3 -06
11 . 1 - 2 1
1 1 . 1-06
1 1 . 1 - 10
1 1 . 2-03
11. 1-13
8 . 3 - 13l'<
13 . 3 -07l'(
11 . 1 - 22'/:
11 . 1- 07>'<
11 . 1- 1P'<
11 . 2-04
11 . 1- 14)'(
8 . 3 - 20
13 . 3 - 12
d
data- list
data-statement
datum
debug-statement
declarative- statement
declare- statement
def- statement
def- type
4 . 1 - 10
10 . 1-06
4 . 2-11
10 . 1-07
4 . 2 - 12
4 . 2 - 10
4 . 2 - 11
9 . 1-03
9 . 1 - 19
10 . 1-07>'<
10 . 1 -06l'<
10 . 1- 08>'<
12 . 2 - 0 P'<
4 . 2 - 1 P'<
5 . 6 - 04)'<
9 . 1- 04>'(
9 . 1- 20)'(
10 . 2 - 10
1 1 . 4-05
11. 5-07
13 . 3 -07
8 . 1- 06>'(
6 . 3 - 06l'<
4 . 2 - 14)'(
8 . 1-03 l'(
6 . 1-01)'(
11 . 2-05>'<
11 . 3-N14*
5 . 6-02
- 174 -
defined-function
delete-control
delete-contro l - item
delete - s tatement
detached-hand ler
d igit
digit - p lace
dimens ion- list
dimens ion- statement
disjunction
do-body
do- l ine
do- loop
do-statement
dol lar - s ign
double-quote
9 . 1-23
11 . 5-06
11. 5-07
11. 5-01
4. 2-06
4 . 1-06
10 . 4-08
10 . 4- 12
7 . 1-01
4. 2-11
8 . 1-01
8 . 3-02
4 . 2-22
8 . 3-01
8 . 3-03
4 . 1-03
12 . 1-19
4 . 1-02
e
e-format- item
else-b lock
else- l ine
e l seif - block
elsei f - then- l ine
end -function- l ine
end-hand ler- line
end- i f - l ine
end - l ine
end - of - l ine
4 . 1 - 10
10 . 4-09
8 . 4-03
4 . 2 - 22
8 . 4-03
4 . 2 - 22
4 . 2 - 22
4. 2-22
4 . 2-22
4 . 2 -04
4 . 2-22
4 . 2 - 17
4 . 2 - 22
9 . 2-09
4 . 2-22
11 . 1-30
11. 1-27
11. 1-23
11. 2-08
11 . 1-N25
8 . 1-07
4 . 1-03
8 . 1-08
9 . 1-05
10 . 4-08
4 . 2 - 12
11. 2-10
12 . 1-02
12 . 1-13
4 . 1-03
8 . 3 - 04
4 . 2 - 12
4 . 2 - 12
4 . 2 - 12
4 . 2-12
erase - statement
exact-search
exception-handler
except ion-type
exclamation-mark
exit-condition
exit-do-statement
exit-for-statement
exi t - function- statement
exit-hand ler-statement
4 . 2-15
10 . 4- 0 5
9. 1 - 24'(
15 . 2-08
11. 5-07*
11 . 5-0S:it
11 . 5- 06*
12 . 1-15*
4 . 1-07)'(
4 . 2 -09
4 . 4-03
5 . 1-06
7 . 3 - 05
10 . 4- 1 1
10 . 4- 13)'(
7 . 1 -02l'(
7 . l - O P''
8 . 1-02)'(
8. 3 -Q6l'C
8 . 3 -02
8 . 3 -02,
8 . 3 - 04,
4 . 4 - 04
8 . 3 - 0 3)'(
6 . 4-01
4 . 1-Q4l'C
10 . 4- 1 5)'(
8 . 4-08)'(
8 . 4-08
8 . 4-06)'(
8 . 4-06
9 . 1-02
12 . 1-15
8 . 4- 0 3
4 . 2- 17)'(
4 . 2 - 16)'(
8 . 4 - 11
4 . 2 - l8l'C
9 . 2 - 02
9. 2 - lQl'C
12 . 1-02
11 . 1-31*
11. 1-28*
11 . 1-24*
11. 2-09
11. 1-N26*
8 . 1-Q8l'C
5 . 5 - 02
8 . 1 - 10
9 . 1-07
11. 2-11
11 . 1- 17'(
11 .2-11*
12 . 1- 06*
12 . 1- 14*
4 . 3 - 04
8 . 3 -05)'(
8 . 3 -07it
8 . 3 - 18
9 . 1- 18)'(
12 . 1-12*
8 . 4- 09)'(
8. 4-07,
9 . l- 13l'C
12. 1-17*
8 . 4- 10)'(
4 . 2-22
4 . 2-21
9 . 1 - 14
10 . 2 - 10
10 . 2- 11
8 . 4- 22)'(
9 . 2- 09)
9 . 2 - 12
12 . 1-07*
12 . 1-08
11 . 2-10*
6 . 5- 02
8 . 1-11
9 . 1 - 16
15 . 2-07
12 . 1-15
10 . 4 - 08
8 . 3 -09
10 . 1 -04
10 . 1 -04
7 . 2 -02
8 . 3 - 12
9 . 1 - 17
7 . 3 -02
- 175 -
exit-sub - statement
express ion
expression - l is t
exrad
externa l -function-de
externa l - function- l ine
externa l - function-type
externa l - sub-de
externa l - sub- line
externa l - sub-type
f
-format- item
factor
field-specifier
f i l e-attribute
f i le-attribute - l is t
f i le-name
f i le-organization
f i le-organization-value
f ixed-dec laration
f ixed-def ined- function
fixed-field-count
f ixed- formal-array
f ixed-point - s ize
f ixed-point-type
f l oating-characters
for-body
for- l ine
for- loop
for - s tatement
formal-array
format- item
format - s tr ing
formatted-print - l i s t
fraction
fraction - s ize
function-arg- list
function-argument
function-de
function- list
function-parameter
function-parm- l is t
g
geometric -obj ect
geometric-statement
gosub-statement
goto -statement
graphic-output- statement
graphic- text- statement
graphic-verb
10 . 3 -03
11 . 3 - 0 6
5 . 1-04
4 . 2 - 20
4 . 2-22
9 . 1 - 19
4 . 2 - 20
4 . 2 - 22
9 . 2 - 17
9 . 2- 1 1'
5 . 3-09
10 . 4-04
11 . 3 - 10l'(
5 . 1- 08l'(
9 . 1-01
9 . 1 - 14
9 . 1- 22l't
9 . 2-01
9 . 2 - 12
9 . 2 - l9l'(
4 . 1 - 10
10 . 4-09
5 . 3-03
10 . 4- l4l'(
5 . 3 -04'
4 . 2 - 12
5 . 3 -01l'(
11 . 3-NH
11 . 1-05
11 . 1-01
11 . 1-01
11 . 1-07
11 . 1-09
15 . 1-03
15 . 2-05
11. 3-N17
15 . 2-03
11. 3-N22
15 . 1-01
15 . 2-04
10 . 4-09
8 . 3 - 10
4 . 2 - 22
8 . 3 -0 1
8 . 3 - 11
9 . 1 - 10
10 . 4 . 06
10 . 4 . 05
10 . 4-01
5 . 1-05
11 . 3-N23
5 . 3 -0 6
5 . 3 -08
9 . 1-0P't
9 . 1-20
9 . 1 -09
4 . 2-02
9 . 1 - 15
4 . 1 - 10
13 . 3-03
1 3 . 3 -02
4 . 2 - 12
4 . 2 - 12
13 . 3 -0 1
1 3 . 3 -02
13 . 3 - 0 3
11 . 3-N20*
11 . 1- 06l't
11 . 1-05l't
11 . 1-04l':
11 . 1-09l':
1 1 . 1- 10l':
15. 1-04*
15. 2-06
11. 3-NlS*
15 . 2-04*
11. 3-R23*
15 . 1-02*
15 . 2-09
10 . 4- l P't
8 . 3 - 17l'(
8 . 3 - 10
8 . 3 - 10l'(
8 . 3 - 12l'(
9 . 1- 1P
10 . 4-09l't
10 . 4 . 06l'(
10 . 4-02l'(
5 . 1-07l':
11. 3-N25l
5 . 3 -08'
5 . 3 -09l't
9 . 1- 2 1
9 . 1- 10l't
9 . 1-05
15 . 2-05
13 . 3 - 05l't
13 . 3 - 03'
8 . 2-01
8 . 2-01
1 3 . 3 -02l'(
13 . 3 - 11'
13 . 3 - 04l't
6 . 3 -0 P't
11 . 3 - 10
11. 5-02
9 . 1- 14l'(
9 . 1- l 5l't
8 . 4- 1 3
9 . 2 - 16
13 . 3 - 1 1
15 .2-06*
9 . 2 - l 2l'(
9 . 2 - 13l't
10 . 4 - 15
11. 1-27*
12 . 1-23*
15 . 2-07
15 . 2-08
15 . 2-09*
15 . 1-02
15 . 1-03
15 . 1-04
15 . 2-03
8 . 3 - 1P't
9 . 2-07
6 . 3 -04
9 . 1-22
15 . 2-01*
9 . 1-07
15 . 2-06
8 . 2 -04l'(
8 . 2 - 02l't
13 . 3 - 11
15 . 2-04
9 . 3-01
9 . 1 - 2 3l't
9 . 1-09l't
15 . 2-07
9 . 1 - 12
- 176 -
greater-than- s ign
4 . 1-03
11.2-12
h
hand ler- l ine
hand ler-name
handler-return-statement
4 . 1 - 10
4 . 2-22
12 . 1-09
4 . 2-12
i
i-format- item
identifier
identifier-character
if-block
if-c lause
if-statement
if-then - l ine
image
image- l ine
imperative-statement
4 . 1 - 10
10 . 4-09
4 . 4- 0P'<
4 . 4-02
4 . 2-07
8 . 4-01
4 . 2 - 14
implementation-def ined
increment
index
inexact-search
initial -point
initial -value
input-contro l
input-control - item
input-modifier
input-modifier- list
input-prompt
input-reply
input- statement
integer
4 . 2-22
10 . 4-02
4 . 2-07
4 . 2 - 10
11 . 5-01*
4 . 1-11
8 . 3 - 12
5 . 2-07
8 . 2-03
11 . 1-03
12 . 1-14
11 . 2-10
13 . 3- 1 1
8 . 3 - 12
11 . 4-01
11 . 4-05
10 . 2-02
10 . 2 -01
10 . 2 - 09)'(
10 . 2 - 10)'(
4 . 2 - 12
5 . 1-05
7 . 1-07
11 . 3 -N25
11 . 3 -N23
8 . 1-07
8 . 1-09
12 . 1-15
12 . 1-10*
12 . 1-11*
12 . 1-16*
12 . 1-16
10 . 4 - 12)'(
10 . 4- 14
10 . 4- 15
4 . 4- 03)'(
8 . 4-03)'(
8 . 4-02)'(
8 . 2-01
8 . 4-03
10 . 4-03)'(
4 . 2-22
4 . 2- 12)'(
13 . 2 - 01)'(
4 . 2 - 16
8 . 3 - 16)'(
5 . 2 -08)'(
8 . 2 -06
11 . 1 - 1 5
13 . 2-03
11 . 2-12*
13 . 3 - 12)'(
8. 3 - 14)'(
4 . 4-04
4 . 4-05
1 1 . 4-02
11 . 4-06)'(
10 . 2-03)'(
10 . 2-02)'(
8 . 4-0P'<
8 . 4-04j(
10 . 5 -09
10 . 4-05)'(
8 . 2-03
13 . 3 -01j(
10 . 2-09
8 . 1 - 10
10 . 4- 10
1 1 . 3 -04
13 . 3- 1 1
8 . 2 -06
8 . 4-02
6 . 2-06
10 . 3 -04
11. 2-10
7 . 1 - 14
10 . 3 -07
1 1 . 3-05
7 . 2 -08
11 . 4-03
11 . 4-04
11 . 4-05)'(
10 . 2-08
10 . 5 -04
10 . 5-06
integer-size
internal -def - l ine
internal - function-def
internal -function - l ine
interna l- function-type
internal -proc-def
internal- sub-def
interna l - sub- line
internal - sub- type
io-recovery
io-recovery-action
4 . 2-22
4 . 2 -06
4 . 2-22
9 . 1 - 19
4 . 2-05
4 . 2-06
4 . 2 - 22
9 . 2 - 17
8 . 2-01
10 . 1-03
10 . 2 -02)'( 11 . 4-0P'<
5 . 1- 06)'(
5 . 1-07
11. 3-N18
9 . 2 -08
11. 3-N27
11. 3-N24*
9 . 1-02
9 . 1-03)'(
9 . 1-01
9 . 1-02)'(
9 . 1- 12)'(
9 . 1-02
9 . 1-2P'<
4 . 2 -06)'(
9 . 2-01
9 . 2-02)'(
9 . 2-02
9 . 2 -03)'(
9 . 2 - 18)'(
1 1 . 2 -02
1 1 . 2 -06)'(
10 . 1-04)'( 1 1 . 2-07
j
justifier
4 . 1 - 10
10 . 4-09
10 . 4- 10)'(
5 . 1-08
11 . 3-N24
15 . 2-05*
6 . 6-04
- 177 -
4 . 1 - 10
4 . 1 - 10
4 . 1-03
6 . 3 -0 3
7 . 1 - 14
8 . 1-05
9 . 2-15
11 . 3-Nl7
6 . 6-03
9 . 1 - 12
4 . 1-03
4 . 2 - 12
4 . 1-06
4 . 4-05
8 . 3 - 12
4 . 2- 22>'(
4 . 2 . 24>'(
4 . 2 - 24>'(
10 . 2 - l l\'(
4 . 2 - 12
4 . 2-02
8 . 2-02
8 . 3 -0 3
8 . 4-02
8 . 4- 10
8 . 4-22
left-parenthesis
length-max
les s - than-s ign
let-statement
letter
l imit
l ine
l ine-continuation
l ine-continuation
l ine- input- rep ly
l ine- input- statement
l ine- number
9 . 1-15
10 . 1-04
l iteral- item
l itera l - string
loop
loop - l ine
loop - s tatement
lower-case- letter
m
main-program
maxs ize-argument
minus- s ign
miss ing-recovery
mul t ip l ier
n
next- l ine
next- s tatement
non-quote-character
not-equals
not-greater
not - less
not-miss ing-recovery
11 . 3-Nl3
12 . 1-09
15 . 2-06
10 . 4-07
10 . 4-06
4 . 2 - 07
4 . 2 - 22
8 . 3 -08
4 . 1 -08
4 . 1 - 10
4 . 2-01
7 . 1- 12
4 . 1-06
10 . 1-01
11 . 4- 10
5 . 3 -03
4 . 1 - 10
4 . 2 - 22
8 . 3 - 19
4 . 1-01
8 . 1 -08
8 . 1-07
8 . 1-07
11 . 2-06
5 . 2-06
6 . 4- 0 3
7 . 2 - 07
9 . 1-09
10 . 3 -04
6. 6-04>'(
9 . 1 - 15
8 . 1-07
5 . 5 -0 P''
4 . 1-08>'(
5 . 3 -0 5
7 . 1-05
7 . 2 -09
9 . 1-11
10 . 4 - 08
5 . 3 -08
7 . 1-13
7 . 2 - 10
9 . 2 -06
10 . 5-05
6 . 2-06
6 . 6-06
7 . 1 - 10
9 . 1-07
8 . 1 -09
6 . 5 - 0 P'c
4 . 4-02
8 . 1 - 11
10 . 4 - 10
4 . 4-03
4 . 4-04
4 . 2 - 17
8 . 2-06
8 . 3 - 19
8 . 4 - 09
8 . 4-21
9 . 1-13
9. 2 - 13
10 . 4-05
12 . 1-07
15 . 2-05
4 . 2-21
1 1 . 2-06
11 . 4-06
10 . 4-08
8 . 3 - 15>'(
10 . 2- 08>'c
4 . 2 - 08
8 . 2-03
8 . 3 - 08
8 . 4-04
8 . 4- 12
9 . 1-03
9 . 2-03
10 . 1-05
12 . 1-03
12 . 1-16
10 . 4- 08>''
10 . 4-07>'(
8 . 3 - 0 l>'c
8 . 3 -06
8 . 3 -09>'(
4 . 1- 10>'c
4 . 2 - 04>'(
7 . 1- 13>'c
5 . 1-03
10 . 1-03>'(
11 . 5-05
5 . 3 - 11>'c
8 . 3 - 17
8 . 3 - 20>'(
4 . 1 -02
8 . 1-09>'c
8 . 1- 111''
8 . 1- 10>'(
11 . 2-07>'(
11 . 4-03>'(
4 . 2 -09>'(
8 . 2 -04
8 . 3 - 11
8 . 4-07
8 . 4- 15
9 . 1 - 12
9 . 2-09
10 . 4-03
12 . 1-05
12 . 1-17
8 . 3 -08>'(
4 . 2-23
10 . 4- 1 1
10 . 5- 0 1
11. 5-08
8 . 3 - 19>'(
4 . 1-03>'(
11. 2-12
11 . 3 -04
11 . 3 -09
- 178 -
nul l -statement
4 . 2-11
4 . 2-21
number- s ign
numeric- array
4 . 1-03
5 . 2 -04
7 . 2- 0 3
9 . 2 - 08
5 . 2-05l'<
numeric-array-ass ignment
numeric-array-dec laration
numeric- array-element
numeric-array-express ion
numeric-array- function-ref
numeric-array-operator
numeric-array-value
numeric- constant
numeric -dec laration
numeric-def-statement
numeric-defined-function
numeric-expression
numeric- f ield-s i ze
numeric - f ixed-parameter
numeric- funct ion
numeric - function- let-statement
numeric- funct ion-ref
numeric- identifier
numeric - let-statement
numeric-rep
numeric- specifier
numeric- supp l ied- funct ion
numeric - t ime-express ion
numeric - type
numeric-variable
numeric-variable- l is t
7 . 2-01
7 . 1-03
5 . 2-02
7 . 2 -02
7 . 2-03
7 . 2- 0 3
7 . 2-03
5 . 1-01
5 . 6-06
9 . 1 -04
5 . 3 -0 7
9 . 1 - 16
5 . 2 - 08
8 . 1-06
9 . 1-05
13 . 3-07
11 . 3-N21
15. 2-01
5 . 3-06
4 . 2 - 12
5 . 3-05
4 . 4 . 01
5 . 5-01
5 . 1-02
11 . 3-N20
5 . 3 -07
10 . 2 -05
5 . 6-05
5 . 2 -01
10 . 3 - 10
13 . 2 - 0 7
5 . 5-02
on-gosub- statement
on-goto- statement
open-statement
option
option- l i s t
option- statement
other-character
output- l i s t
4 . 1 - 10
4 . 2 - 14
4 . 2 - 14
4 . 2- 12
5 . 6-02
5 . 6-01
4 . 2-11
4 . 1- l P''
10 . 4-02
p
percent-s ign
period
p l ain-string-character
p lus - s ign
point- l i s t
pointer-contro l
pointer - items
primary
4 . 1 - 10
4 . 1-03
4 . 1-06
4 . 1-05
4 . 1-06
13 . 3 -0 3
1 1 . 2-02
11 . 2-01
5 . 3 -04
7 . 2 -09
7 . 2 -02l'l
7 . l-04l'(
5. 2 -04l'l
7 . 2-03)'(
7 . 2 -09l'l
7 . 2 - 04l'(
7 . 2 - 06)'(
5 . 1-02)'(
5. 6-07)'(
9 . 1-05)'(
9 . 1-05
4 . 3-0V<
10 . 4- 13
5 . 2 - 10
7 . 2- 10
10 . 4 - 14
7 . 1 -04
7 . 1-11
15 . 1-04
7 . 1- lP'<
15 . 2-07*
9 . 1-06)'(
15 . 2-09
5 . 3 -02)'(
8 . 3 - 15
10 . 2 -06
9 . 1-24
5 . 3 -0 1
8 . 3 - 14
9 . 1 - 16
15 . 2-07
1 1 . 3-N22*
15 . 2-02
15 . 2-03*
5 . 3 - 0 7 )'(
9 . 1- 16)'(
6 . 4- 03l'(
5 . 3 - 06)'(
4 . 4-02)'(
5 . 2-03
5 . 5 - 02)'(
5 . 1- 04l'<
5 . 3-05
1 1 . 3-N21*
6 . 4-02l'(
5 . 4-0ll'l
10 . 2 -06)'(
5 . 6- 06l'l 15 . 1-03
5 . 3-05
5 . 2-02)'(
13 . 1-06
1 3 . 1-05
1 1 . 1-03
7 . 2 -02
9 . 1 - 12
9 . 1 - 15
5 . 3 -05
8 . 3 - 16
13 . 1-03
5 . 5 -02
7 . 1 - 12)'(
5 . 2-05
7 . 2 - 10)'(
9 . 1-06
12 . 1-18*
5 . 5 - 03
13 . 1-07
10 . 2-07
5 . 5-03)'(
8 . 2-01
8 . 2-01
1 1 . 1-0P'<
5 . 6- 03l'l
5 , 6- 02l'C
5 . 6- 0 P'<
10 . 4-04l'l
10 . 4- 13
5 . 1-05
4 . 1- 06l'(
5 . 1-03
1 3 , 3 - 06l'C
11 . 2 - 03)'(
1 1 . 2 - 02)'(
5 . 3 -05l'l
8. 2-06)'(
8 . 2-03l'l
6 . 6-0P''
7 . 1-09)'(
15 . 1 . -01*
11 . 3 - 0 1
5 . 1-07
10 . 1-09
10 . 4- 1 1
11 . 2-0B*
7 . 2-05
10 . 4- 14
11 . 3-N23
- 179 -
primitive - !
13 . 2-03
13 . 2 - 04
13 . 2 - 05l
p r imitive-2
p rint-contro l
print - contro l - item
p rint- item
print - l is t
print- separator
p rint- s tatement
procedure
procedure-argument
procedure-argument- l is t
procedure-parameter
procedure-parrn - l i s t
procedure-part
p rogram
program-des ignator
program-name
program-name - l ine
program-unit
prompt-specifier
protection-b l ock
13 . 2-03
1 1 . 3 -0 1
1 1 . 3 -0 3
10 . 3 . 02
10 . 3 - 0 1
10 . 3 - 02
4 . 2-12
4 . 2 - 19
9 . 2- 15
9 . 2 - 14
9 . 2-06
9 . 2-04
4 . 2-01
4 . 2 - 0 P''
9 . 3 -0 1
4 . 2-02
4 . 2-01
4 . 2 - 23l'(
10 . 2 -0 3
4 . 2-07
13 . 2 - 04l'(
11 . 3 -02
11 . 3 -04l'(
10 . 3 - 0 3>
10 . 3 -02>'(
10 . 3 - 05>'(
10 . 3 - 0 P''
4 . 2 - 20>'(
9 . 2 - 16>'(
9 . 2 - 15>':
9 . 2 - 0 7>'(
9 . 2 -06>':
4 . 2 - 19>'(
13 . 2 - 07
11 . 3 - 0 3l'(
10 . 2 - 04>'(
12 . 1-01*
11 . 4-06
q
question-mark
quotation-mark
quoted- string
quoted -string-character
4 . 1 - 10
4 . 1-03
4 . 1-01
6 . 1-02
4 . 1-02>':
10 . 4 - 08
4 . 1-04
6 . 1-03>'(
6 . 1-03
10 . 5 -05
6 . 1-03
r
randomize-statement
range
read -control
read-contro l - item
read- s tatement
record- setter
record- s ize
record- type
record- type-value
redim
redim-array
redim-array - l is t
redim-bounds
redim- string-array
red im- s tring-array - l i s t
re lation
relat ional-express ion
relationa l -primary
relat iona l -term
remark- l ine
remark- statement
remark-string
restore - s tatement
return- s tatement
rewrite-control
4 . 1 - 10
4 . 2- 12
8 . 4- 18
11 . 4- 0 7
11 . 4-09
4 . 2 - 12
11 . 2 -04>':
11 . 5-08
11 . 1-07
11 . 1-07
11 . 1 - 12
7 . 2-06
10 . 5 - 02
10 . 5 . 01
7 . 2 - 07
10 . 5 -07
10 . 5 -06
8 . 1-06
8 . 1 - 0 P''
8 . 4 -07
8 . 1 -04
8 . 1-03
4 . 2 - 19
4 . 2 - 11
4 . 3-01
4 . 2-12
4 . 2 - 12
11 . 5-02
9 . 3 -02>':
4 . 2 - 03'
4 . 2 - 02>':
5 . 4- 0 2>':
8 . 4- 19>':
11 . 4 - 08
11 . 4- 10>'(
10 . 1 - 01'
11 . 2-09*
11 . 1- 15>'(
1 1 . 1 - 12>'(
1 1 . 1- 1 3>'(
7 . 2 - 0 7>'(
10 . 5- 03>'(
10 . 5 - 02>':
7 . 2 - 08>':
10 . 5- 08>''
10 . 5-07>'(
8 . 1 - 07>'(
8 . 1-05
8 . 1-05>''
8 . 1- 04>'(
4 . 2 - 2 1'
4 . 2-21
4 . 3 -02>''
10 . 1-05>''
8 . 2- 0 5>''
11 . 5 -03
11 . 3 -0 1
10 . 5 - 10
10 . 4- 0 P''
4 . 2-23
13 . 2-07
11 . 3 - 0 P''
15 . 2-02*
4 . 2 - 22
11 . 3-Nl9
11 . 4-09>'(
11 . 4-Nl1*
11 . 4-07
1 1 . 3 -09
11 . 4- 10
11. 5-05
11. 1-N25*
7 . 3 -05
10 . 5 -03
10 . 5-08
10 . 5 - 04
11 . 4-02
11 . 4-08
11 . 4-04
8 . 4- 19
8 . 3 -0 5
8 . 4- 0 1
8 . 4 - 04
4 . 2 - 22
4 . 3 -0 1>'(
4 . 3 -04
11. 5-04*
8 . 4- 1 1
- 180 -
rewrite-control - item
rewrite-statement
right-parenthesis
routine- identifier
s
scalar-multip l ier
select-block
select- line
select-statement
semicolon
set-object
set-statement
s ign
s igned- integer
s ignif icand
s imp l e-numeric-variable
s imple-string-dec laration
s imple-string-variable
simp le-variable
s lant
space
statement
statement- line
status-c lause
stop-statement
string-array
string-array-assignment
string-array-dec laration
string-array-element
string-array-expression
string-array-primary
string-array-value
string-constant
string-dec laration
string-clef -statement
string-defined-function
string-expression
string-field- size
string-function
string-function- let-statement
11. 5-04
11. 5-01
4 . 1-03
6 . 3-03
7 . 1- 14
8 . 1-05
9 . 2- 1 5
11. 3-Nl7
4 . 2-03
4 . 1 - 10
7 . 2-03
4 . 2-07
4 . 2-22
8 . 4- 1 2
4 . 1-03
13 . 3-06
10 . 3 -06
13 . 2-03)'(
4 . 2 - 12
5 . 1-02
7 . 2 -04
7 . 1-06
5 . 1-04
5 . 2-02
15 . 1-04
6 . 6-05
6 . 2 -02
5. 2 - 09)'(
4 . 1 -03
4 . 1-05
4 . 2 -08
4 . 2 -07
1 3 . 1-04
4 . 2 - 12
6 . 2-04
7 . 3-02
7 . 3-01
7 . 1-03
6 . 2 -02
7 . 3-02
7 . 3-03
7 . 3-03
6 . 1-01
6 . 6-03
9 . 1-04
6 . 3-05
9 . 1- 17
6 . 3-01
9 . 1-07
10 . 4-03
11 . 1 - 12
11. 3-Nl3
11 . 3 -N26
6 . 3 - 04
4 . 2 - 12
11 . 5-05*
11. 5-02*
5 . 2 -06
6 . 4-03
7 . 2 -07
9 . 1-09
10 . 3 - 04
11.5-N9*
4 . 4-01
4 . 4-05>'(
7 . 2-05 >'(
8 . 4 - l P''
8 . 4- 1 1
8 . 4- 1 3>'(
7 . 2-06
5 . 3-05
7 . 1-05
7 . 2-09
9 . 1- 11
10 . 4-08
5 . 3 -08
7 . 1 - 13
7 . 2 - 10
9 . 2-06
10 . 5 -05
6 . 2-06
9 . 2-05
12 . 1-10
8 . 4-12:/(
10 . 3-05
10 . 4-04
10 . 4-08
10 . 5 - 1 1
10 . 3-07 >'(
1 1 . 2-0P''
11 . 3- 05:/(
13 . 1-01>'(
10 . 3 -061:
5 . 1-03>'(
5 . 1-08
5 . 3 -02
7 . 1-07
5 . 2-09
5 . 6-07
8 . 3-13
6 . 2-07
9 . 1-10
10 . 4-08
6 . 4-03
9 . 2-07
6 . 6-06
6 . 4-03
7 . 1-08
9 . 1 - 12
9 . 1 - 15
6 . 5-02
10 . 2 -04
1 1 . 1-09
11. 2-10
8 . 1-06
7 . 1-07 >'(
5 . 1-05 >':
5 . 2-03 >'(
15 . 2-03
6 . 6-06>'(
6 . 2-03 >'(
6 . 2 -07)'(
5 . 3 - 11
4 . 2- 24
4. 2 - 10>':
4. 2 -08>'(
10 . 4-08
4 . 2-22
13 . 1-05 >
4 . 2 - 1 3 >':
6 . 2 -05:/(
6 . 2-08
10 . 5-08
7 . 3 -04
7 . 3 -02 >'(
7 . 1-08 >'(
7 . 1- 10
6. 2-04 >'(
7 . 3 -03 >'(
7 . 3 -04>'(
7 . 3-05 >'(
6 . 3-03
6 . 1-02 >'(
6 . 6-05 >'(
7 . 1- 10>'(
9 . 1-0711
9 . 1-07
9 . 1-08:/(
9 . 1-24
6. 3 -02::
6 . 3-03
9 . 1-17
9 . 3-02
11 . 1 -04
11 . 1-08
11 . 1 - 15
11. 1-29
13 . 1-01
13 . 3 - 1 1
11. 3-N27*
6 . 3-05 >'(
9 . 1 - 17 >'(
- 181 -
string- function-ref
string-identifier
string- let-statement
string-primary
string-specifier
string-supp l ied- function
string-type
string-variabl e
string-variable- l ist
sub - l is t
sub - statement
subprogram-def
subprogram-name
subscript
subscript-part
substring-qua l i f ier
t
tab-cal l
tai l
6 . 3-03
4 . 4-01
6 . 5-01
6 . 3 - 02
11 . 3-N20
6 . 3 -05
6 . 6-02
6 . 2-01
6 . 5 - 02
9 . 2 - 18
9 . 2-03
9 . 2-0P'<
9 . 2 -04
5 . 2-06
5 . 2-04
6 . 2 - 02
4 . 1 - 10
10 . 3 -03
4 . 2-02
8 . 3 -0 3
8 . 4 - 04
8 . 4- 12
9 . 1-03
9 . 2 - 03
12 . 1-05
6 . 3 - 041<
6 . 2-03
4 . 4-04)'(
6 . 5- 02)'(
7 . 3 -0 3
6 . 3- 03)'(
11. 3-N26*
6 . 4-0P'< 12 . 1-19*
6 : 6-03)'(
6 . 2-02)'(
6 . 3 -0 3
6 . 5 -03)'( 10 . 2 -08
9 . 2 - 19
9 . 2 - 20)'(
9 . 2 - 04)'(
9 . 2 - 13
9 . 2 - 05)'(
5 . 2 - 07 )'<
5 . 2 -06)'(
6 . 2 - 06)'(
10 . 3 -04)'(
4 . 2-08
8 . 3 -08
8 . 4-07
8 .4-15
9 . 1 - 12
9 . 2 -09
12 . 1-07
15 . 2-05
4 . 3 -0 3
6 . 2-05
7 . 3 -0 5
6 . 5-03
1 1 . 4-03
9 . 2 - 14
9 . 2 - 20
6 . 2 -04
7 . 3-02
7 . 3 -04
4 . 2 - 15)'(
8 . 3-11
8 . 4-09
8 . 4- 2 1
9 . 1-13
9 . 2 - 13
12 . 1-09
15 . 2-06
4 . 3 -04)'(
tai l -comment
temp late- element
temp late-element - l ist
temp l ate- identi f ier
temp late-statement
term
then-block
time-enquiry
timeout-express ion
trace-statement
type-declaration
12 . 1-17
4 . 2-15
11 . 3-N16
11. 3-N15
11. 3-N12
11 . 3-N14
5 . 3 -02
8 . 4-03
10 . 2- 0 3
10 . 2-03
4 . 2 - 12
5 . 6 - 04
11. 3-N17*
11. 3-N16*
11. 3-Nl3*
11. 3-Nl5*
5 . 3 -03)'(
8 . 4- 05)'(
10 . 2-07)'(
10 . 2 - 0 5)'(
12 . 2-03)'(
5 . 6-05l'<
u
underl ine
unit-block
unquoted - s tring
unquoted- s tring-character
upper-case- letter
use- l ine
4 . 1 - 10
4 . 1-03
4 . 2 - 04
10 . 1-08
4 . 1-03
4 . 1 - 08
4. 2-22
4 . 4- 0 3
4 . 2 - 05)'(
10 . 1 -09)'(
4 . 1-05)'(
4 . 1-09)'(
12 . 1-02
v
variable
variable-field-count
variable- length-vector
variable- l is t
4 . 1 - 10
5 . 2 - 01)'<
11. 3-N17
10 . 5 -04
10 . 1-01
6 . 2 -0 11< 10 . 1-02
11. 3-N19*
10 . 5- 05)'( 11 . 4-02
10 . 1-02)'( 10 . 2-01
11 . 3 -Nl7
11 . 4-N11
9 . 1-08
4 . 2 - 17
8 . 3 - 19
8 . 4-10
8 . 4-22
9 . 1 - 15
12 . 1-03
12 . 1-16
13 . 1-06
4 . 2 - 24
11 . 5-N9
11 . 4-06
1 1 . 4-06
6 . 6- 02)'(
10 . 4-08
9 . 1 - 14
9 . 1- 19)'(
9 . 2 - 17)'(
9 . 2 - 12
10 . 1-09
12 . 1-05*
11 . 1-20
11 . 4-01
11 . 4-07
- 182 -
w
when-block
when- l ine
when-use-block
when-use-name- block
when-use-name- l ine
write-control
write-contro l - item
write - statement
4 . 1 - 10
12 . 1-02
4 . 2-22
12 . 1-01
12 . 1-01
4.2-22
11 . 3 -06
11 . 3 -08
4 . 2 - 12
4 . 1 - 10
4 . 1 - 10
4 . 1 - 10
12 . 1-0t.*
12 . 1-02
12 . 1-02*
12 . 1-08*
12 . 1-08
1 1 . 3 -07
1 1 . 3 -09 (
11 . 3 -06)'(
12 . 1-08
12 . 1-03*
12 . 1-09*
1 1 . 3-08(
11 . 3-N12*
- 183 -
APPENDIX 5
COMBINED LIST OF PRODUCTION RULES
access -mode
actual-array
array-ass ignment
array-dec laration
array- input-statement
array- l is t
array-name
array-output- l is t
array-print - l i s t
array-print-statement
ask- s tatement
block
bound-argument
boundaries
boundary
- 184 -
boundary-variables
bounds
bounds -range
break-statement
cal l -statement
case-block
case-else-block
case-else- l ine
case- item
cas e - l ine
cas e - l is t
case-statement
cause-statement
chain- statement
channe l - express ion
channel -number
channel - setter
character
c l ear-statement
c lose-statement
col late- sequence
comparison
concatenation
conditional-statement
ampersand
if-statement I on-gosub-statement I on-goto-statement
relational-term (AND relational-term)''
numeric-constant I string-constant
gosub-statement I goto-statement I if-statement I
io-recovery I on-gosub-statement
conjunction
constant
contro l - transfer
contro l -variable
coordinate-pair
core-attribute-name
core-fi le-attribute
core-f i le-org-value
core-record-setter
core-record-type-value
data- list
data-statement
datum
debug-statement
dec l arative-statement
lon-goto-statement
s imp le-numeric-variable
numeric-express ion comma numeric-express ion
NAME
ACCESS I DATUM I ERASABLE I FILETYPE I MARGIN
I ORGANIZATION I POINTER I RECSIZE I RECTYPE I
SETTER I ZONEWIDTH
access-mode I f i le-organization I record-type I
record- size
SEQUENTIAL I STREAM
BEGIN I END I NEXT I SAME
DISPLAY I INTERNAL
datum ( comma datum ) l't
DATA data- list
constant I unquoted- string
DEBUG ( ON I OFF)
data-statement I declare-statement I
dimens ion-statement I nul l - statement I
option-statement I remark-statement I
temp late-statement
DECLARE type-dec laration
numeric-def - statement I string-def-statement
DEF function- list
numeric-def ined-function I string-defined-function
delete-control
f ixed-defined- function
( comma delete-control - item)''
- 185 -
delete-contro l - item
delete - statement
detached-handler
d igit
d igit- p lace
d imens ion- l ist
d imens ion-statement
d isjunction
do-body
do- l ine
do- loop
do-statement
double-quote
e- format- item
else-block
else- l ine
e l s e i f- block
elseif - then- l ine
end-function- l ine
end-hand ler- l ine
end- i f - l ine
end - l ine
end - of - l ine
end - s e lect- l ine
end - statement
end-sub - l ine
end - sub-statement
end-when- l ine
enhanced-attribute- name
enhanced- f i le-attribute
enhanced - f i le-org-value
enhanced- record-setter
enhanced-record- type-value
equa l i ty-relation
erase-statement
exception-hand ler
exception-type
exit-condition
exit-do-statement
exit-for-statement
exit-function- statement
exit-hand ler-statement
exit-sub-statement
expres s ion
express ion- list
exrad
external - function-de
external -function- l ine
DO exit-condition?
quotation-mark quotation-mark
( i-format- item I - format- item) c ircumflex-accent
circumf lex-accent c ircumf lex-accent
circumflex -accent>'<
e l se - l ine block>'<
l ine- number ELSE tai l
else i f -then- l ine block>'<
l ine-number ELSEIF relational-express ion THEN tai l
l ine- number END FUNCTION tai l
l ine-number END HANDLER tai l
l ine- number END I F tai l
l ine-number end- statement tail
( imp lementation-defined )
l ine- number END SELECT tail
END
l ine- number end - sub- statement tail
END SUB
l ine- number END WHEN tai l
RECORD I KEY I COLLATE
col late- sequence
RELATIVE I KEYED
RECORD index I KEY ( exact-search I inexact-search)
string-expression
NATIVE
equa l s - s ign I not-equals
ERASE REST? channel - express ion
block<
index
( WHILE I UNTIL) relational-express ion
EXIT DO
EXIT FOR
EXIT FUNCTION
EXIT HANDLER
EXIT SUB
numeric-express ion I string-expression
express ion ( comma expression ) >'<
E s ign? integer
externa l - function- l ine unit-block>'< end- function- l ine
l ine- number EXTERNAL FUNCTION
( numeric -def ined- function I
( string-defined-function length-max? ) )
function-parm- l i st ? tai l I l ine-number
EXTERNAL FUNCTION f ixed-def ined- function
function-parm- l ist? tai l
- 186 -
graphic-verb
hand ler- l ine
hand ler-name
- 187 -
handler-return-statement
RETRY I CONTINUE
i- format- i tem
identif ier
identifier- character
if-block
if-c lause
if-statement
if-then - l ine
image
image- line
imperative- statement
increment
index
initia l -number
initial -point
initial -value
input-control
input-contro l - item
input-modifier
input-modifier- l is t
input-prompt
input - rep ly
input- statement
integer
integer-size
internal -def - l ine
- 188 -
internal -function-def
internal-function- l ine
internal - function-type
internal -proc-def
internal - sub-def
interna l - sub - l ine
internal - sub-type
io-qua l if ier
io-recovery
io-recovery-action
justifier
length-max
let- s tatement
letter
l imit
l ine
l ine-continuation
l ine- input- reply
l ine- input - s tatement
l ine-number
l iteral- item
l itera l - string
loop
loop- l ine
loop - s tatement
lower-case- letter
main-program
maxsize-argument
missing-recovery
multip l ier
next- l ine
next-statement
- 189 -
non-quote-character
not-equa l s
not-greater
not- less
not-missing- recovery
numeric-array
numeric-array-ass ignment
numeric-array-dec laration
numeric-array-element
numeric-array-expression
numeric-array-function-ref
numeric-array-operator
numeric- array-value
numeric-constant
numeric-dec laration
numeric-def-statement
numeric-def ined-function
numeric-expression
numeric- f ield-s i ze
numeric-fixed parameter
f ixed-point - s ize I E
s imp le-numeric-variable fixed-point-type I
f ixed- formal -array
numeric- function
numeric-defined- function I numeric-supp l ied- function
numeric - function- let-statement= LET numeric-def ined- function equa l s - s ign
numeric-express ion
numeric- function function-arg- l ist? I MAXLEN
numeric-function-ref
left-parenthesis ( s imp le- string-variable I
string-array) right-parenthesis I MAXSIZE
maxs ize-argument I SIZE bound-argument I
LBOUND bound-argument I UBOUND bound-argument
I DET ( left-parenthes is numeric-array
right-parenthes is ) I DOT left-parenthesis
numeric-array comma numeric-array
right-parenthes i s
letter identifier-characterl'c
numeric- identifier
numeric- let-statement
LET numeric-variab le- l ist equa l s - s ign
numeric-express ion
significand exrad?
numeric-rep
numeric- specif ier
NUMERIC asterisk numeric-field-size
- 190 -
numeric-variable
numeric-variable- list
on-gosub - statement
on-goto- statement
open-statement
option
option- l i st
option-statement
other-character
output- l ist
p lain-string-character
point- l i s t
pointer - i tems
primary
primitive-1
primitive- 2
print-contro l
print-contro l - item
print- item
print- l is t
print-separator
print - statement
procedure
procedure-argument
procedure-argument- l ist
procedure-parameter
procedure-parm- list
procedure-part
program
program- des ignator
EXLINE I EXTYPE
numeric- express ion
NUMERI C numeric-dec laration ( comma
numeric-declaration) >'( I NUMERIC
f ixed-point-type? f ixed-dec laration ( comma
f ixed- dec laration) >'(
s imple-numeric-variable I numeric-array-e lement
numeric-variable ( comma numeric -variabl e ) '''
ON index ( GOSUB I GO SUB) l ine-number ( comma
l ine-number ) >'l ELSE imperative - statement ) ?
ON index ( GOTO I GO TO ) l ine-number ( comma
l ine-number ) >'l ( ELSE imperative-statement ) ?
OPEN channel - setter NA}ffi file-name
f i le-attribute - l ist
ARITHMETIC ( DECIMAL I NATIVE) I ANGLE ( DEGREES I
RADIAN S ) I COLLATE ( NATIVE I STANDARD ) I BASE
( 0 I 1 ) I ARITHMETIC FIXED f ixed-point- type
option ( comma option) >'l
OPTION option- list
[ imp lementation-def ined ]
express ion ( comma expression) >'( semicolon?
d igit I letter I period I p lus - s ign I minus- s ign
coordinate-pair ( s emicolon coordinate-pair ) ''1
( po inter-control I io- recovery I pointer-contro l
comma io-recovery)
numeric-rep I numeric-variable I numeri c - function-ref
I left-parenthesis numeric-expression
right-parenthes is
POINT I LINE
primitive - 1 I TEXT I AREA
( comma print-contro l - item)>'l
core-record- setter I enhanced-record-setter I
not-miss ing-recovery I USING image
express ion I tab - cal l
( print - i tem? print- separator ) >'( print - item?
comma I semicolon
PRINT print - list I PRINT formatted-print - l is t I PRINT
channel -expres s ion print-control ( co l on
( print - list I output- list ) ) ?
external - function-de I externa l - sub- de
express ion I actual -array I channel - express ion
left-parenthesis procedure-argument ( comma
procedure-argument) ''' r ight-parenthesis
s imple-variable I formal-array I channe l - number
numeric- f ixed-parameter
left-parenthesis procedure-parameter ( comma
procedure-parameter ) '''
remark- l ine''1 procedure
program - name- l ine? main-program procedure-part>'l
string-expression
- 191 -
program- l ine
program-name
program-name- l ine
program-unit
prompt-specifier
protection-b lock
quoted- s tring
quoted - s tring-character
randomize - statement
range
read -control
read-contro l - item
read -statement
record- setter
record - s ize
record- type
record - type-value
redim
redim-array
red irn-array- list
red im-bounds
redim-numeric-array
redim- string-array
redim-string-array- list
relation
relationa l - expression
relationa l -primary
relationa l - term
remark- l ine
remark-statement
remark- string
restore- statement
return-statement
rewrite-control
rewrite-contro l - item
rewrite- statement
routine-identifier
scalar-multip lier
select-block
select - l ine
select-statement
- 192 -
set-obj ect
set- s tatement
s ign
s igned- integer
s ignificand
s imp le-numeric-variable
s imp le-string-declaration
s imp le-string-variable
s imp le-variable
s tatement
s tatement- l ine
status - c l ause
stop-statement
string-array
string-array-ass ignment
string-array-dec laration
string-array-element
string-array-express ion
string-array-primary
string-array-value
string-constant
string-declaration
string-def- statement
string-defined- function
string-expression
string- field-s ize
string-function
string- function- let-statement
string-function-ref
string- identifier
string- let - s tatement
string-primary
string-specifier
string-supp l ied-function
- 193 -
string-type
string-variab le
string-variable- l ist
sub - l ist
sub - statement
subprogram-def
subprogram-name
subscript
subscript-part
substring-qualifier
tab-ca l l
tai l
temp late-element
unit-block
unquoted - s tr ing
unquoted- string-character
upper-case- letter
use- l ine
variabl e
variable-field-count
variable- length-vector
variable- l is t
when-block
when- l ine
when-use-block
when-use-name-block
when-use-name- l ine
write-control
write-contro l - item
write - s tatement
- 194 -
APPENDIX 6
DIFFERENCES BETWEEN MINIMAL BASIC AND ECMA BASIC
The differences between Minimal BASIC and ECMA BASIC ( either BASIC-1 or BAS I C - 2 ) may be
c lassified as either s yntactic incompatibil ities or semantic ( run-time ) d i fferences .
Syntactic Differences
With the f o l l owing exception , this Standard forms an upward compatible syntactic extension
of Standard ECMA- 5 5 , Minimal BASIC .
- 195 -
1(
- 196 -
APPENDIX 7
The gosub-statement , on-gosub - s tatement , and the return- statement are under consideration
for future removal . It is recommended that as users write new programs , or maintain exist
ing programs , they refrain from us ing these statements , in order to improve compatibil ity
with future vers ions of this Standard .
The GOSUB fac i l ity is being cons idered for removal because it encourages poor programming
practice by al lowing the construction of subroutines with several entry points . Further
more , these " subroutines" are not delineated by any d istinctive syntax ; any line of a pro
gram may be the beginning of such a subroutine . Users are encouraged to avail themse lves of
the subprogram facil ities ( see 9 . 2 ) described in this Standard when they need subroutines .
Furthermore , the GOSUB fac i l ity interacts in a comp lex way with other aspects of the lan
guage ( e . g . , internal -proc-defs , exception-hand lers ) , thus making it more difficult to un
derstand source cod e , to imp lement conforming language processors , and to describe the lan
guage correct l y . Thus , programmers , imp lementors , teachers , and writers are a l l impeded in
their work with BASIC .