Ecma 116
Ecma 116
Ecma 116
l
June 1986
Free copies of this document are available from EC:lA,
European Computer :\Iannfadnrers Association
I H Rue dn Hhi'me 1201 Geneva (Switzerland)
BRIE HISTORY
The f irst version of the language BASIC, acronym for Beginner 1 s All-purpose Symbol ic
Instruction Code, was produced in June 1965 at the Dartouth Col lege in the USA.
In January 197 8, ECMA publ ished a Standard for Minimal BASIC, ECMA-5 5 , prepared in coopera
tion with ASI X3J2 and ful ly compatible with the corresponding ANSI standard . This Stan
dard ECMA-55 served as a basis 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/TC21 in January 1985 . This draft is composed of a mdatory Core module
and five optional modules .
Starting from this draft, ECMA/TC21 prepared a Standard for ful ly defined subsets of the
language . These subsets , cal led ECMA BASIC-! and ECMA BASIC- 2 , are designed for business
appl ications , requiring extended file facil ities . ECMA BASIC- 1 has no exception handl ing
faci lities and a reduced set of file operations . In addition, all the keywords in
ECMA BASIC-1 are reserved words, reducing the complexity of the interpreter or compiler
needed . ECMA BASIC-2 provides ful l exception handling capabilities , ful l file operations
and fixed decimal capabilities . The set of reserved words is minimal . Both subsets provide
the full flow control capabilities provided in the ANSI standard . A additional module
( ECMA GRAPHICS) provides a minimum of graphic capabilities and can be used with either
subset .
Compatibi lity with the ANSI standard has been a primary design objective, and the ECMA
Standard is ful ly upward compatible with corresponding implementations of the ANSI
Standard .
Approved as an ECMA Standard by the General Assembly of June 26, 1986 .
- i -
TABLE OF CONTETS
1 . INTRODUCTION
1 . 1 Scope
1 . 2 Related Standards
2 . CONFORMANCE
2 . 1 Program Conformance
2 . 2 Implementation Conformance
2 . 3 Errors
2 . 4 Exceptions
2 . 5 Relationship to the ANSI Standard
3 . SYNTAX SPECIFICATION AND DEFINITIONS
3 . 1 Method of Syntax Specification
3 . 2 Definitions of Terms
3 . 2 . 1
3 . 2 . 2
3 . 2 . 3
3 . 2 . 4
3 . 2 . 5
3 . 2 . 6
3 . 2 . 7
BASIC
Batch-mode
Can
End-of - line
Error
Exception
External
3 . 2 . 8 Identifier
3 . 2 . 9 Interactive mode
3 . 2 . 10 Internal
3 . 2 . 11 Keyword
3 . 2 . 12 Line
3 . 2 . 13 Machine Infinitesimal
3 . 2 . 14 May
3 . 2 . 15 Native
3 . 2 . 16 Overflow
3 . 2 . 17 Print Zone
3 . 2 . 18 Program Unit
3 . 2 . 19 Reserved Word
3 . 2 . 20 Rounding
3 . 2 . 21 Shall
3 . 2 . 22 Significant Digits
3 . 2 . 23 Truncation
3 . 2 . 24 Underf low
4. PROGRAM ELS
4 . 1 Characters
4 . 2 Programs, Lines and Blocks
4 . 3 Program Annotation
4 . 4 Identifiers
5 . NUMERS
5 . 1 Numeric Constants
5 . 2 Numeric Variables
5 . 3 Numeric Expressions
5 . 4 Implementation-Supplied Numeric Functions
5 . 5 Numeric Assignment Statement
2
2
2
4
4
4
5
5
5
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
15
15
16
19
19
23
23
24
25
26
31
8
5 . 6 Numeric Arithetic and Angle
6 . STRINGS
6 . 1 String Constants
6 . 2 String Variables
6 . 3 String Expression
- ii -
6 . 4 Implementation-Suppl ied String Functions
6 . 5 String Assignment Statements
6 . 6 String Declarations
7. ARRAYS
7 . 1 Array Declarations
7 . 2 Numeric Arrays
7 . 3 String Arrays
8 . CONTROL STRUCTURES
8 . 1 Relation Expression
8 . 2 Control Statements
8 . 3 Loop Structures
8 . 4 Decision Structures
9 . PROGRAM SEGMNTATION
9 . 1 User-Defined Functions
9 . 2 Subprograms
9 . 3 Chaining
10 . INPUT AND OUTPUT
10 . 1 Internal Data
10 . 2 Input
10 . 3 Output
10 . 4 Formatted Output
10 . 5 Array Input and Output
1 1 . FILES
11 . 1 File Operations
11 . 2 File Pointer Manipulation
1 1 . 3 File Data Creation
1 1 . 4 File Data Retrieval
11 . 5 File Data Modification ( BASIC-2 only)
1 2 . ECEPTION HANLING AND DEBUGGING
12 . 1 Exception Handl ing ( BASIC-2 only)
12 . 2 Debugging ( BASIC-1 and BASIC- 2 )
13 . GRAPHICS
13 . 1 Coordinate Systems
13 . 2 Attributes and Screen Control
13 . 3 Graphic Output
14 . REAL TIM ( not in ECMA BASIC)
15 . FIX DECIMAL NES ( BASIC-2 only)
15 . 1 Fixed Decimal Precision
15 . 2 Fixed Decimal Program Segentation
TABLE 1 - Standard BASIC Character Set
31
35
35
35
37
38
41
42
45
45
47
50
53
53
54
56
58
63
63
68
7 3
7 6
7 6
7 7
80
84
88
93
98
108
111
118
125
130
130
135
138
138
141
143
146
147
149
152
- iii -
TABLE 2 - Exception Codes
APPENDICES
APPENDIX 1 - Organization of the Standard
APPENDIX 2 - Scope Rules
APPENDIX 3 - Implementation-defined Features
APPENDIX 4 - Index of Syntactic Objects
APPENDIX 5 - Combined List of Production Rules
155
159
160
162
163
167
183
APPENDIX 6 - Differences between Minimal BASIC and ECMA BASIC 194
APPENDIX 7 - Language Elements under Consideration for future 196
Removal
Sections 4 to 15 are further subdivised in:
x . y . l
x . y . 2
x . y . 3
x . y. 4
x . y. 5
x . y . 6
General Description
Syntax
Examples
Semantics
Exceptions
Remarks
-
1
-
1 . I NTRODUCT I ON
- 2 -
1 . INTRODUCTION
This Standard is designed to promote the interchgeability of BASIC programs among a vari
ety of automtic data processing systems . Programs conforming to this Standard wil l be said
to be written in EC BASIC.
Two levels of the langge are specified in this Standard: ECMA BASIC-1 and ECMA BASIC-2 .
In addition this Stadard defines an optional Graphics module .
1 . 1 Scope
This Standard establishes:
The syntax of programs written in ECMA BASIC .
- The forts of data and the mini precision and range of numeric representations
and the minim length and set of characters in strings which are acceptable as input
to an automatic data processing system being control led by a program written in
ECMA BASIC.
- The forts of data and the mini prec1s1on and range of numeric representations
and the mini length and set of characters in strings which can be generated as
output by an automatic data processing system being control led by a program written
in EC BASIC .
- The setic rules for interpreting the meing of a program written in ECA BASIC .
- The errors and exceptional circumstces which shall be detected .
Although the BASIC langge was originally designed pririly for interactive use, this
Standard describes a langge tt is not so restricted . This Standard is not meant to
preclude the use of any particular implementation technique, for exale interpreters ,
incremental or one-pass comilers .
1 . 2 Related Stdards
ECMA-6
ECMA-35
EC-53
EC-55
ISO 2014
ISO 2711
ISO 3307
ISO 7942
7-Bit Coded Character Set
Code Extension Techniques
Representation of Source Program for Program Interchge: - APL,
COBOL, FORT, Minimal BASIC and PL/ 1
Miniml BASIC
Writing of Calendar Dates in all-numeric form
Representation of Ordinal Dates
Representation of Time of the Day
GRHICAL K System ( GKS)
IEC 559 Binary Floating Point Aritetic for Microprocessor Systems .
ANSI X3 . 113-198X American National Standard for BASIC
- 3 -
2. CONFORMNCE
- 4 -
2 . CONORCE
This Standard specifies two levels of the language: ECA BASIC-1 and ECA BASIC-2 . In addi
tion this Standard defines a Graphics module.
ECA BASIC-1 includes all the parts defined in Section 4 to 12 , with the exception of those
portions of Section 11 that describes enhanced files and Section 12 . 1 , Exception Handling.
Al l the keywords , listed i n 3.2 . 19 under the heading BASIC-1 are reserved words .
ECMA BASIC-2 includes all the parts defined in Section 4 to 12 and in Section 15 . The key
words , listed 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 ECA BASIC-2 .
There are two aspects of the confoIce to the language defined in this Standard: confor
mance by a program written in the ECMA BASIC language, and conformnce by an implementation
which processes such progras .
Broadly speaking, the confoIce 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 imlementation-defined features are noted in Appendix
3 ) .
2 . 1 Program ConfoIce
A program confors to this Standard only when
- the program and each statement or other syntactic element contained therein is syntac
tically valid according to the syntactic rules specified by this Standard as belonging
to that level , and
- the program as a whole violates none of the global constraints imposed by this level
of the Standard on the application of the syntactic rules .
2 . 2 Imlementation ConfoIce
A implementation conforms to a level of this Standard only when
- it accepts and processes all programs conforming to that level of this Standard ,
- it reports reasons for rejecting any program which does not conform to this Standad,
- it interprets errors and exceptional circumstances according to the specifications of
this Standard,
- it interprets the semntics of each statement of a conforing program according to the
specifications in this Standard ,
- it interprets the semantics of a conforming program as a whole according to the speci
fications in this Standard,
- it accepts as input, manipulates , and can generate as output numbers of at least the
precision and range specified in this Standard ,
- it accepts as input, manipulates , and can generate as output strings of at least the
length and composed of at least those characters specified in this Standard,
- it is accompanied by documentation available to the user that describes the actions
taken in regard to features referred to as "undefined" or "implementation-defined" in
this Standard, and
- it is accompanied by documentation available to the user that describes and identifies
all enhancements to the language defined in this Standard .
This Standard makes no requirement concering the interpretation of the sttics of any
statement or program as a whole that does not conform to this Standard .
- 5 -
2 . 3 Errors
This Standard does not include specific requirements for reporting syntactic errors in
the text of a program.
Implementations conforming to this Standard may accept programs written in an enhanced
language without having to report all constructs not conforming to this Standard .
Whenever a statement or other program element does not conform to the syntactic rules
given herein, and that statement or other program element, does not have a clear, well
documented implementation-defined meaning, an error shall be reported . Errors shall be
reported in a clear and well documented way and whenever feasible the implementation
should indicate the erroneous statement and the position of the error within the
statement .
2 . 4 Exceptions
A exception is a circumstance ar1s1ng in the course of execution of 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 . All exceptions described in this
Standard shall be detected , reported and processed when they occur, unless some mecha
nism provided in 12 . 1 ( BASIC-2 only) or an enhancement to this Standard hs been invoked
by the user to handle exceptions .
In the absence of programer-specified recovery procedures , exceptions shall be handled
by the recovery procedures specified in this Standard . If no recovery procedure is spec
ified in this Standard , or if restrictions imposed by the hardware or the operating en
vironment make it impossible to follow the procedure specified in this Standard, then
the way in which the exception is handled depends on the context . If the exception oc
curred in the invocation of a function or subprogram, then the exception is "propagated
back" to the invoking statement in the invoking program unit ( see 12 . 1) . If this propa
gation procedure reaches the main-program, or if the exception occurred in the main
program, then the exception shall be handled by terminating the program.
The way in which
implementation-defined ,
the exception code and
curred .
the exception handling mechanism reports an exception is
except that the contents of the report shall identify at least
the line number of the line in which the original exception oc-
Except in the case of files , when several exception are caused by the execution of a
single statement of a program, this Standard does not specify an order in which these
exceptions shall be detected or reported . If an implementation determines that a partic
ular statement in a conforming program will always cause an exception when executed , the
implementation may issue a warning to the user . Nonetheless , the implementation must ac
cept and execute the program, according to the normal semantic rules specified herein.
2 . 5 Relationship to the ANSI Standard
This Standard ECMA BASIC defines a subset of the ANSI BASIC Standard, ANSI X3 . 113-198X.
The ANSI standard defines a set of modules , only one of which ( the Core module) is
mandatory. On the other hand , only the graphics module is optional in the ECMA standard .
Programs written in ECMA BASIC- 1 will 1 on implementations conforming to the ANSI
standard if the implementation implements at least the Core module. Provided that the
implementation-defined elements are defined in a compatible way in the two implementa
tions , the programs will act in the same way and give the same results .
Programs written in BASIC-2 will 1 on implementations conforming to the ANSI Standard
if the implementation implements at least the Core module and the Enhanced Files module.
Provided that the implementation-defined elements are defined in a compatible way in the
two implementations , the program will act in the same way and give the same results .
-
6
-
The reverse wil l not always be true . In view of the modular nature of te ANSI standard ,
programs conforming to the ANSI standards will 1 on an ECA BASIC implementations only
if they use the set of facilities defined in the ECMA BASIC Standard. Real-time programs
will not 1 on ECMA BASIC implementations .
A further difference exists in reserved words . All keywords defined in ECMA BASIC- 1 are
reserved and cannot be used as identifiers . Only a limited number of keywords is re
served in the ANSI Standard . Thus programs written in ECMA BASIC- 1 will 1 on an ANSI
implementation, with the limitations defined above . A program written in ANSI BASIC, and
which uses only the facilitites defined in ECA BASIC-1 , is not granted to 1 on an
ECMA BASIC- 1 implementation, 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
ECA module wil l 1 on an ANSI implementation, but programs conforing to te ANSI mod
ule will not 1 on an ECMA implementation unless they use only the facilities defined
in ECMA BASIC .
- 7 -
3. SYNTAX S PEC I F I CAT I ON AND DEF I N I T I ONS
3. SYNTAX SPECIFICATION A DEFINITIONS
3.1 Method of Sytax Specification
- 8 -
The syntax, through a series of rewriting rules known as "productions" , defines syntac
tic objects of various types , such as a program or expression, and describes which
strings of symbols are objects of these types .
In the syntax, upper-case-letters , digits , and ( possibly hyphenated) lower-case words
are used as "metanames" , i . e . as names of syntactic objects . Most of these metes are
defined by productions in terms of other metanames . In order that this process termi
nates , certain metanames are designated as "terminal" metanames , and productions for
them are not included in the syntax . With the exception of the construct
11
[implementation-defined]" , all terminal metes occur for the first time and are de
fined in 4.1. It should be noted in particular that all upper-case-letters are terminal
metanames which denote both themselves and their lower-case equivalents ( except in the
productions defining upper-case-letters and lower-case-letters , in which the letters de
note only themselves ) . The digits are terminal metanames which denote themselves . In ad
dition, the construct "[implementation-defined]" is not a unique syntactic obj ect , but
each occurrence of it is defined by each implementation in an appropriate fashion for
the object in question. In some cases a recomendation as to the representation of the
object is given in the corresponding remarks section.
\-e illustrate further details of the syntax by considering some examples from 5 .1. The
production
fraction period integer
indicates that a fraction is a period followed by an integer . Since "period" is a termi
nal mete ( i . e . , it does not occur on the left-hand side of any production) , the se
mantics in 4.1 identify the particular character denoted by a period .
What is integer? The production
integer = digit digit>'<
indicates that an integer is a digit followed by an arbitrary number of other digits . A
asterisk is a syntactic operator indicating that the object it follows may be repeated
any number of time , including zero times .
\fuat is a digit? In 4.1 the production
digit = o I 1 I 2 I 3 I 4 I 5 I 6 I 7 I 8 I 9
indicates tat a digit is either a o, a 1, . . . , or a 9 . The slant is a syntactic opera
tor meaning "or" and is used to indicate that a metaname can be rewritten in one of sev
eral ways .
Since the digits are terinal metanames , our decipherment of the syntax for a fraction
comes to an end . The semantics in 4.1 identify the digits in terms of the characters
they represent .
A question-mark is a syntactic operator like the asterisk, indicating that the object it
follows may be omitted . For example , the production
exrad E sign? integer
indicates tl1at an exrad consists of the letter E or e followed by an optional sign fol
lowed by an integer .
Parentheses my be used to group sequences of metes together. For exaple,
variable-list = variable ( coma variable)
l
'<
- 9 -
defines a variable-list to consist of a variable followed by an arbitrary number of
other variables separated by comas . If we wish parentheses actually to appear in syn
tactic objects, rather than just wish to use them to describe syntactic objects , then we
indicate their presence by the metanames 11left-parenthesis11 and "right-parenthesis" .
When several syntactic operators occur in the same production, the following order of
precedence is employed . The operators 11?11 and 11)
'<
11 apply only to the word or parenthe
s ized expression they imediately follow. The operator 11111 applies to the sequence of
words and express ions , separated by spaces , which occur since the beginning of the en
tire expression, the last 11 I" , or the last tched left parenthesis . Thus , for
example,
significand integer period? I integer? fraction
is equivalent to
significand = ( integer (period) ? ) I ( ( integer) ? fraction)
Spaces in the syntax are used to separate terms in a production from each other . Special
conventions are observed regarding spaces in BASIC programs ( see 4.1).
Some syntactic objects are defined by more than one production. For
example, in 5.2 we find
simple-variable > s imple-numeric-variable
and in 6 . 2 we find
s imple-variable > simple-string-variable .
Those two productions are equivalent to the single production below (provided no other
definition of simple-variable exists )
simple-variable = s imple-numeric-variable I s imple- string-variable .
In all cases , a greater-than-sign is used in place of an equals-sign to indicate a mul
tiple definition, such definitions are equivalent to a single definition containing the
various right-hand sides 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 metmes occurring below are defined in 4.1.
1. production
2. metme
3. metacharacter
4. spaces
5 . syntax-expression
6. syntax-term
7 . syntax-factor
8 . syntax-primary
9 . repetition
3.2 Definitions of Terms
metmes spaces ( equals-sign I greater-than-sign)
spaces syntax-expression
lower-case-letter metacharacters)'
<
lower-case-letter I hyphen
space)
'< end-of-line? space)
'< space
syntax-term ( spaces ? slant spaces? syntax-term))'<
syntax- factor ( spaces syntax-factor) )
'<
syntax-primary repetition?
metaname I digit digit)
'<
I upper-case-letter
upper-case-letter
i<
I left-parenthesis space)
'<
syntax-expression space)
'<
right-parenthesis
asterisk I question-mark
For the purpose of this Standard , the following terms have the meanings indicated .
- 10 -
3. 2. 1 BASIC
A ter applied as a name to members of a special class of languages which possess
similar syntaxes and sttic 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 C
The word "can" is used in a descriptive sense to indicate that standard-conforming
programs are allO\ved to contain certain constructions and that standard-conforming
implementations are required to process such programs correctly.
3. 2. 4 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 ad 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-retur, carriage-retur 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 Exterl
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 Interl
With respect to record-type, refers to data representations such that both the type
ad 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.
3 . 2 . ll Keyord
contained within a
A character string, usually with the spelling of a coronly used or mnemonic 1vord,
which provides a distinctive identification of a statement or a component of a
statement of a prograring language.
The keywords in ECMA BASIC are:
ACCESS, AND, ANGLE, A, ARITID1IC, 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, D, ELAPSE, ELSE, ELSEIF, END,
ERASE, ERASABLE, EIT, EINE, ETENAL, ETYPE, FILETYPE, FIX, FOR, FUNCTION, GO,
GO SUB, GOTO, HANDLER, IF, IMAGE, IN, INPUT, INTERNAL, IS, KEY, KEYED, LENGTH, LET,
LINE, LINES, LOOP, MARGIN, MAT, MISSING, NAM, NATIVE, N, NOT, NUMRIC, OF, OFF,
ON, OPEN, OPTION, OR, ORGANIZATION, OUTIN, OUTPUT, POINT, POINTER, POINTS, PRINT,
PROGRAM, PROMPT, RADIANS, RANDOMIZE, R, RECORD, RECSIZE, RECTYPE, RELATIVE, R,
REST, RESTORE, RETRY, RETURN, REWRITE, SA, SELECT, SEQUENTIAL, SET, SETTER, SIZE,
SKIP, STANDARD, STATUS, STEP, STOP, STRING, STYLE, SUB, TAB, TEPLATE, TET, THN,
T, TIM, TIMOUT, TO, TRACE, UNTIL, USE, USING, VARIABLE, VIEWPORT, WHN, 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 Infinitesiml
The smallest positive value (other than zero) which can be represented and manipu
lated by a BASIC implementation.
3.2.14 !:
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 strcture 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 M (see
5. 4. 4), or which exceeds the maximum value that can be represented by the declared
- 12 -
formt of a fixed point variable or array. With respect to string operations, 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.18 Program Unit
A self-contained part of a BASIC program consisting either of te main-program, which
is the sequence of lines up to and including tl1e line containing an E statement, or
of an external-sub-de or external-function-de.
3.2.19 Reserved Hord
BASIC-1
A character string whose usage as a routine-identifier, string-identifier or
numeric-identifier is forbidden in an EQ1A BASIC-1 program.Tese words are:
- the no-argument supplied function naes: DATE, EINE, ETYPE, M, PI,
R, TIM, TRANSFORM, DATE$, and TIME$,
- the identifier used in array-values: CON, ION, ZER, and N$,
- the following keywords: ACCESS, AND, ANGLE, AREA, ARITIC, ASK, AT, BASE,
BEGIN, BREAK, CALL, CASE, CHAIN, CLEAR, CLIP, CLOSE, COLLATE, COLOR, DATA,
DATUM, DEBUG, DECIMAL, DECLARE, DEF, DEGREES, DEVICE, DEVICE, DIM, DISPLAY,
DO, ELAPSED, ELSE, ELSEIF, END, ERASE, EASABLE, EIT, EAL, FILETYPE,
FOR, FUNCTION, GO, GOSUB, GTO, GRAPH, IF, IMAGE, INPUT, INTNAL, IS,
LENGTH, LET, LINE, LINES, LOOP, 1ARGIN, MAT, MISSING, NA, NATIVE, N,
NOT, Nil1ERIC, OFF, ON, OPEN, OPTION, OR, ORGANIZATION, OUTIN, OUTPUT, POINT,
POINTER, POINTS, PRINT, PROGRAM, PROMPT, RADIANS, RANDOMIZE, R, RECSIZE,
RECTYPE, R, RST, RESTORE, RETURN, SAt1, SELECT, SEQUETIAL, SET, SET,
SIZE, SKIP, STAARD, STATUS, STEP, STOP, STREAM, STRING, STYLE, SUB, TAB,
TET, T, THRE, TIMOUT, TO, TRACE, UNTIL, USING, VARIABLE, VIEWPORT,
WHILE, HINDOH, WITH, WRITE, ZONEWIDTH.
The function names EINE and ETYPE are not used in ECMA BASIC-1, but are
reserved for compatibility \vith ECHA BASIC-2.
BASIC-2
A character string \vhose usage as a routine-identifier, string-identifier or
numeric-identifier is forbidden in an ECMA BASIC-2 program.These words are:
- the no-argument supplied function names: DATE, EINE, ETYPE, M, PI,
R, TIM, TRANSFORM, DATE$ and TIMES$,
- the identifiers used in array-values: CON, IDN, ZE, ad N$,
- the keywords NOT, ESE, PRINT and R.
3.2.20 Rounding
The process by which a representation of a value with lower precision is generated
from a representation of higher precision taking into account the value of that por
tion of the original number which is to be omitted. For example, rounding X to the
nearest integer may be accomplished by INT(X+O.S) (see 5. 4).
- 13 -
3.2. 21 Shall
The word "shall" is used in an imperative sense to indicate tt a progra is re
quired to be constructed , or tt an implementation is required to act, as specified
in order to meet the constraints of standard conformance.
3. 2. 22 Significant Digits
The contiguous sequence of digits between the high-order nonzero digit and the low
order digit, without regard for the location of the radix point . Comonly, in a nor
mlized floating point interl representation, only the significant digits of a rep
resentation are maintained in the significand . In fixed-point representation, the low
order digit is the rightmost one explicitly specified, and non-significant high order
digits 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 precision 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
less in magitude t machine infinitesimal.
- 14 -
4. PROGR ELEMENTS
- 15 -
4 . PRORAM ES
A BASIC program is a sequence of l ines containing statements . Each line is itself a se
quence of characters .
4 . 1 Characters
4. 1.1 General Description
The character set for ECMA BASIC is contained in the Standard ECA-6 .
4 . 1. 2 Sytax
1 . character
2. quoted- string-character
3 . non-quote-character
4. double-quote
5. unquoted- string-character
6. plain-string-character
7 . digit
8. letter
9. upper-case- letter
10 . lower-case-letter
11 . other character
quotation-mark I non-quote-character
double-quote I non-quote-character
ampersand I apostrophe I asterisk I circuflex-accent
I colon I coma I dol lar-sign I equals-sign I
exclamation-mark I greater-than-sign I
left-parenthesis I less-than-sign I
number-sign I percent-sign I question-mark
right-parenthesis I semicolon I s lant I
underline I unquoted-string-character
quotation-mark quotation-mark
space I plain-string-character
digit I letter I period I plus-sign minus- sign
0111213141516171819
upper-case- letter I lower-case- letter
AIBICIDIEIFIGIHIIIJIKILIMINIOIPIQIRISITIUIVIWIXIYIZ
alblcldlelflglhliljlklllmlnlolplqlrlsltlulvlwlxlylz
[ implementation-defined]
The syntax as described generates programs which contain no spaces other than those
occurring in remark-strings , in certain quoted-strings , unquoted-strings , and
literal-strings , or where the presence of a space is explicitly indicated by the
metaname space.
Special conventions shall be observed regarding spaces . With the following 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 readability of the pro
gram. Spaces shall not appear:
- imediately preceding the l ine-number of a l ine
- within l ine-numbers
- within keywords
- witin identifiers
- within numeric-constants
- within multicharacter relation symbols .
In addition, spaces which appear in quoted-strings, unquoted-strings, and format
strings shall be significant ( though spaces which precede or fol low an unquoted
string are not part of tt string) .
All keywords in a program, when used as such, shal l be preceded and fol lowed by some
character other than a letter, digit, underline or dol lar-sign. A keyword may also be
followed by an end-of- l ine .
4 . 1 . 3 Exales
None .
- 16 -
4. 1. 4 Semntics
The letters shall be the set of capital ( upper-case) and small ( lower-case) latin
letters contained in the character set in positions 411 to 5110 and 611 to 7110, re
spectively.
The digits shall be the set of Arabic digits contained in the character set in posi
tion 310 to 319 .
The remining characters shall correspond to the rema1n1ng graphic characters in po
sition 210 to 2115 , 3110 to 3115, 5114, and 5115 of the EC character set .
The names of the characters are specified in Table 1 . Table 1 shall apply when the
standard collating
s
equence is in effect, either by default or by explicit use of a
COLLATE option ( see 6. 4, 6. 6 , and 8. 1) . The coding for the native collating sequence
shall be implementation-defined .
Al l characters other t letters denote themselves . Letters denote themselves
within quoted-strings , unquoted-strings and line- input-replies . Corresponding upper
case-letters and lower-case- letters shal l be equivalent when used in identifiers and
keywords . Quoted-string-characters also denote themselves , 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 Remrks
Other-characters may be defined by an implementation to be part of the character set
for BASIC . These characters may be used in strings and my be accepted as characters
in data supplied in response to a request for input or generated as the value of the
C$ function ( see 6. 4) . The effects of these other-characters are implementation
defined .
Programs written using other-characters ( except for end-of- l ine characters) are not
themselves standard-conforming programs .
4. 2 Programs , Lines , and Blocks
4. 2. 1 General Description
A BASIC program is a sequence of lines . Each line contains a unique line-number which
facilitates program editing and serves as a label for the statement contained in that
l ine.
A BASIC program is divided logically into a number of progra-units The first of
these is the main-program, which is terminated by an end- l ine . Following the main
program may be zero or more external-sub-def or exterl-function-def . Certain
logical groupings of lines within a BASIC program are cal led blocks .
4. 2. 2 Sytax
T synta elet avlale oy i E BIC-2 M prit i bld.
1. program
2. program-name- line
3. progra-nae
4. main-program
5. unit-block
6. interl-proc-def
> program-name- line? main-program procedure-par
line-number PROGRAM program-name function-parm- l ist?
tail
routine-identifier
unit-block)'< end-line
internal-proc-def I block
> interl-function-def I internal-sub-def
det-hler
7 . block
8. statement-line
9 . line-number
10 . statement
11 . declarative-statement
12 . imperative-statement
13. stop-statement
14. conditional-statement
15. tail
16. end-of-line
17 . end-line
18. end-statement
19 . procedure-part
20 . procedure
2 1 . remark-line
22. line
23 . progra-unit
24 . line-continuation
- 17 -
> statement-line I loop I if-block I select-block I
imge-line I protetion-blo
line-number statement tail
digit digit
)
'
C
> declarative-statement I imperative-statement
conditional-statement
> data-statement I declare-statement I
dimension-statement I null-statement
option-statement I remark-statement
> array-assignment I array-input-statement
array-line-input-statement I
array-print-statement I array-read-statement
array-write-statement I ask-statement I
break-statement I call-statement I
cause-statement I chain-statement I
close-statement I debug-statement I
erase-statement I exit-do-statement
exit-for-statement I exit-function-statement I
exit-hndler-statent I exit-sub-statement I
gosub- statement I gate-statement I
hndler-ret-statet I input-statement
let-statement I line-input-statement I
numeric-function-let-statement I
open-statement I print-statement I
rruldomize-statement I read-statement I
restore-statent I return-statement I
set-statement I stop-statement I
string-function-let-statement I
trace-statement I write-statement
STOP
if-statement I on-gosub-statement I on-gate-statement
tail-coment? end-of-line
[implementation-defined)
line-number end-statement tail
EN
remark-line)'< procedure
> external-function-def I external-sub-def
line-number ( null-statement I remark-statement)
end-of-line
> case-line I case-else-line I do-line I else-line
elseif-then-line I end-function-line I
end-hndler-line I end-if-line I end-line I
end-select-line I end-sub-line I ed-wen-line
I external-function-line I exteral-sub-line I
for-line I hndler-lie I internal-def-line I
internal-function-line I internal-sub-line I
if-tl1en-line I image-line I loop-line I
next-line I program-name-line I remark-line
select-line I statement-line I use-line I
wen-line I wen-use-n -line
> main-program I procedure
aersm1d space
)
'' tai 1 aersm1d
A program shall be composed of a sequence of lines . Exactly one of these lines shall
be c end-line ; the lines up to and including this end-line constitutes the main
program.
4 . 2 . 3
- 18 -
Line-number zero is not al lowed; leading zeroes shal l have no effect . Lines shal l
occur in ascending line-number order . Al l references to line-numbers within a
program-unit shal l be to line-numbers of lines within that program-unit. The number
of digits in a line-number shall not exceed 5. The value of a line-number shal l not
exceed 50000 .
The manner in which the end of a line is detected is determined by the
implementation; e . g . , the end-of-line may be a carriage-retur character, a carriage
return character followed by a line- feed character, or the end of a physical record .
A physical line in a program shall contain at most 132 characters before each end-of
line indicator.
At any place where a space may be used, except in quoted- strings, unquoted- strings,
literal- strings, and remark-strings ( see 4 . 1 and 4 . 3), a line-continuation may be
substituted for a space with no effect other t that of the space it replaces.
Parameters in the program-name- line shall not be explicitly dimensioned or declared
in the main-program.
Exales
2 . 100 PROGRAM Graphic & This program draws a graph
& ( x, & x is x-coordinate
& y) y is y-coordinate
18 . 999 END
4 . 2 . 4 Semantics
The program-name- line 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 implementation-defined . Parameters in the program
name-l ine are evaluated as described in 9 . 1 . Their scope is the main-program. For a
progra executed in isolation, tJ1e program-name has no effect . The effect of a
paraeter-list in a program-name-line for a program executed in isolation is
implementation-defined .
Lines in a program shall be executed in sequential order, starting with the first
line, until
- some other action is dictated by execution of a line, or
an exception occurs ( unless, in BASIC-2, it is a nonfatal exception which is not
handled by a user defined exception-hru1dler), or
- a chain-statement is executed, or
- a stop- statement or end-statement is executed .
The end-statement shall serve both to mark the physical end of ie main-program and
to terminate execution of the progran1 when encountered .
Execution of a stop-statement shal l also cause termination of execution of the
program.
4. 2 . 5 Exceptions
None .
4 . 2 . 6 Remrks
References to non-existent line-numbers in a program-unit are sY1 tax errors.
Implementations may therefore treat them as exceptions, if they are documented as
such.
- 19 -
4 . 3 . Program Annotation
4 . 3 . 1 General Description
BASIC programs may be annotated by coments at the end of program lines or by
separate remark-statements .
4 . 3 . 2 Syta
1 . remrk-statement
2 . remark-string
3 . null-statement
4 . tail -coment
R remrk-string
character'
tai l-coment
exclamation-mark remrk-string
Line-continuation shall not occur in remark- strings.
4 . 3 . 3 Exales
1. R FINAL CHCK
4 . ! COMPUE AVERAGE
4 . 3 . 4 Semantics
If the execution of a program reaches a line containing a remark-statement or nul l
statement, then it shal l proceed to the next l ine with no other effect .
A tail-coment has no effect upon the execution of the l ine in which it occurs. The
remrk-string in the tail -coment serves solely as a coment about the l ine.
4 . 3 . 5 Exceptions
None.
4 . 3 . 6 Remarks
None.
4 . 4 Identifiers
4 . 4 . 1 General Description
Identifiers are used to name variables , arrays, array-values, functions, programs,
subprograms and exception-handlers.
1. identifier
2. numeric- identifier
3. identifier-character
4. string- identifier
5. routine- identifier
> numeric- identifier I string- identifier
routine- identifier
letter identifier-characters>'<
letter I digit I underline
letter identifier-character>'<dolla-sign
letter identifier-character>'<
A identifier shal l contain at most 31 characters, including the dol lar- sign in the
case of a string identifier.
A given numeric- identifier may name a simple-numeric-variable, a one-dimensional ,
two-dimensional or three-dimensional numeric-array, a numeric-function, or a numeric
array-value, but not more t one of these in a program-unit. Likewise, a given
string- identifier may name a simple-string-variable, a one-dimensional, two
dimensional or three- dimensional 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 interl-subprogram, an internal-function-de or a
detached-handler but not more t one of these in a program-unit.
4 . 4 . 3
4 . 4 . 4
- 2 0 -
A given routine- identifier shal l not name more than one of an external-function-def,
an exterl-sub-def or a min-program in a program.
A numeric-identifier which names an external-function-def may not be used as a
routine- identifier .
The names of the no-argument supplied functions or array-values CON, DATE, EINE,
EPE, IDN, M, PI, R, TIM, TRANSFORM and ZE shal l not be used as numeric
identifiers to name any other entity. The names of the no-argument supplied
functions or array-values DAT$, NU$, and TIM$ shal l not be used as string
identifiers to name any oter entity. The keywords listed in 3. 2 . 19 shall not be used
as identifiers . Note that the list in 3. 2 . 19 is different for BASIC- 1 and BASIC-2 .
Exles
2 . X
sum
4 . A$
last_names$
5 . INVERT
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 program-units shall be local to each invocation of the program-unit in
which they occur; i. e . , they shall name different objects in different program-units
and in different invocations of the same program-unit . Identifiers used to name
supplied-functions or program-units, however, shal l be global to the entire program;
i. e . , they shall name the same object wherever they occur .
If the name of implementation-supplied function or the keyword TAB is impl icitly or
explicitly defined or declared as the identifier of a user-defined function, array,
or variable, then the defined declared interpretation of the identifier shall
override the interpretation specified by the Standard within the scope of the
definition or declaration. Therefore, within that scope, the implementation-supplied
function or the tab-cal l shall be unavailable .
Within any program-unit, 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
xl ) . Identifiers which differ in any other respect shall denote different obj ects .
4 . 4 . 5 Exceptions
None .
4 . 4 . 6 Remarks
No implementation-defined enhancement to this Standard may extend the list of words
unavailable for use as simple-variables. Since all arrays mst be declared ( see
7 . 1 . ) , and since all defined-functions must be declared or defined in the program
unit in which they are referenced, implementations may supply built-in functions
other than those specified in this Standard provided that any declaration for such
identifiers within a program overrides the implementation-supplied interpretation.
Note, however, that in some cases the use of a parameterless function supplied by an
implementation as an enhancement would be syntactical ly indistinguishable from a
- 21 -
variable having the sae 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 expl icitly in any
program-unit where they are used or requiring the use of empty parentheses ( e . g.
"NCTION( ) ") with reference to such functions .
A operating system my impose additional restrictions on the length and form or
identifiers for procedures which are compiled independently of the main-program.
A supplied-function may be overridden by defining a user-defined function or simple
variable with the same name.
In ECMA BASIC-2, an identifier may have the same spelling as a keyword ( other than
PRINT, ESE, RE or NOT) .
- 22 -
5. NUMBERS
- 23 -
5 . NUES
Numbers constitute one of two primitive data types in BASIC ( the other is strings ) . With
numbers are associated constants, variables, and implementation-supplied functions, from
which express ions can be formed .
5 . 1 Numeric Constants
5 . 1 . 1 General Description
5 . 1. 2
5 . 1 . 3
Numeric-constants denote scalar numeric values . A numeric-constant is a decimal
representation, in positional-notation, of a number . There are four general syntactic
fors of numeric-constants:
- implicit point unsealed representation d . . . d
- explicit point unsealed representation ds . . drd . . . d
- explicit point scaled representation sd . . . drd . . . dEsd . . . d
- implicit point scaled representation sd . . . dEsd . . . d
where d is a digit, r is a period, s is an optional sign, and E is the explicit
character E or e .
positive .
Syta
1 . constant
2 . numeric-constant
3 . sign
4 . numeric-rep
5 . significand
6 . integer
7 . fraction
8 . exrad
Exles
2 . -21
4 . 1E10
5e- 1
. 4E+1
5 . 500 .
1 . 2
7 . . 255
A numeric-constant not preceded by a sign is assumed to be
> nueric-constant
sign? numeric-rep
plus-sign I minus-sign
significand exrad?
integer period? I integer? fraction
digit digit,'<
period integer
E sign? integer
5 . 1 . 4 Semantics
The value of a numeric-constant is the number represented by that constant . "E" and
"e" stand for "times ten to the power" ; if no sign fol lows the symbols E and e, then
a plus-sign is understood .
A program can contain numeric-constants which have an arbitrary number of digits . A
implmentation must retain either the exact value of a numeric-constant, or that value
rounded to an implementation-defined precision. The implementation-defined precision
for numeric constants shall not be less than ten or six significant decimal digits,
depending on upon whether the arithmetic option in force is DECIM or NATIVE
respectively. Numeric-constants can also have an arbitrary number of digits in the
exrad, though nonzero constants whose magnitude is outside an implementation-defined
range may be treated as exceptions ( see 5 . 6) . Nonzero constants whose mgnitudes are
less t machine infinitesimal shall be replaced by zero, while constants whose
magnitudes are larger than M shall be reported as causing an overflow.
- 24 -
5.1.5 Exceptions
- The evaluation of a numeric-constant causes an overflow (1001, fatal).
5.1.6 Remrks
It is recornended 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
5.2.2
Numeric-variables may be either simple-numeric-variables or references to elements of
nueric-arrays.
Sytax
1. variable > numeric-variable
2. numeric-variable simple-numeric-variable I numeric-array-element
3. simple-numeric-variable numeric-identifier
4. numeric-array-element numeric-array subscript-part
5. numeric-array numeric-identifier
6. subscript-part left-parenthesis subscript (coma subscript)'''
right-parenthesis
7 . subscript index
8 . index numeric-expression
9. simple-variable > simple-numeric-variable
10. array-name > numeric-array
The number of subscripts in a subscript-part shall be one, two, or three.
5. 2. 3 Exales
3. X
sum
4. V(4)
table(i, j+l)
5.2.4 Semntics
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).
A 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 my 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 co1Ionly used alteratives for associating implementation-defined
initial values with variables; it is reco1Iended that all variables be recognizably
undefined 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
5.3.2
Numeric-expressions may be constructed from numeric- variables, numeric-reps, and
numeric- function- refs using the operations of addition, subtraction, multiplication,
division, and exponentiation (i.e., raising to a power) .
Sytax
1. expression
2. numeric-expression
3. term
4. factor
5. primary
6. numeric- function-ref
7 . numeric- function
8. function-arg- list
9 . function- argument
10. actual-array
11. multiplier
> numeric-expression
sign? term (sign term) l''
factor (multiplier factor) 1''
primary (circumflex- accent primary) 1''
numeric-rep numeric- variable I numeric-function- ref I
left- parenthesis numeric-expression
right- parenthesis
> numeric- function function- arg-list?
numeric-defined- function I numeric- supplied- function
left- parenthesis function- argument (com
function-argument)l''right-parenthesis
expression I actual- array
array-name
asterisk I slant
The number and types of arguments in a numeric- function- ref shall agree with the
number and types of corresponding parameters in the definition of the numeric
function. A actual-array shall have the sae number of dimensions as the
corresponding parameter.
Whenever numeric arguments are passed to an exterl- function-definition, the
AITIC options in effect for the external- function-definition and the invoking
progra-unit must agree.
Each numeric- function referenced in an expression within a program-unit shall either
be implementation- supplied , or shall be defined in an internal-function-def or
declared in a declare- statement occuring in a lower-numbered line, within the same
program-unit, tha the first reference to that numeric-function.
5.3.3 Exales
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 Setics
The formtion and evaluation of numeric-expressions fol lows the norml algebraic
rules. The symbols circumflex-accent ( - ) , asterisk ( *) , s lant ( / ) , plus-sign ( +) , and
minus-sign ( - ) represent the operations of exponentiation, multiplication, division,
addition, and subtraction or negation, respectively. Unless parenthesis dictate
otherwise, exponen-tiations shall be performed first, then multiplications and
divisions , and final ly additions , subtractions , and negations. In the absence of
parenthesis , operations of the same precedence shall be evaluated from left to right.
Thus A-B-C shal l be interpreted as (A-B) -C; A
-
B
-
C, as (A
-
B)
-
C; A/B/C, as (A/B) / C;
-A+B as ( -A)+B; and -A
-
B as - ( A
-
B) .
If an underflow occurs in the evaluation of a numeric-expression, then the value
generated by the operation which resulted in the underflow shall be replaced by zero.
For those mathematical operators which are associative, comutative, or both, full
use of these properties my 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, shall be substituted for the parameters ( see
5. 4, 6. 4 and 9. 1 ) used in the function-definition. The result of evaluating a
numeric-fuction, achieved by the execution of the defining algorithm, shall be a
scalar numeric value which replaces the numeric-function-ref in the numeric
expression.
5. 3. 5 Exceptions
Evaluation of a numeric-expression results in division by zero ( 3001 , fatal) .
Evaluation of a numeric-expression results in an overflow ( 1002 , fatal) .
- Evaluation of the operation of exponentiation results in a negative number being
raised to a non-integral power ( 3002 , fatal) .
Evaluation of the operation of exponentiation results in zero being raised to a
negative power ( 3003 , fatal) .
5. 3. 6 Remrks
The accuracy with which the evaluation of a numeric expression takes place may vary
from implementation to implementation, subject to the constraints of 5. 6.
It is recomended that implementations report underflow as an exception ( 1502 ,
nonfatal : replace by zero and continue) . In BASIC-2 implementation, this permits
interception by exception handlers.
Implementations may evaluate primaries and operations within a numeric-expression in
any order which is consistent with the semantics of 5. 3. 4. Of course, an operation
must be evaluated after its operands. For example, 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 impl ied by the third plus-sign, since the
product "D>'<E" is one of the operands of that addition.
5. 4 Imlementation-Supl ied Numeric Functions
5. 4. 1 General Description
Predefined algorithms are supplied by the implementation for the evaluation of
comonly 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 Sytax
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 EP I FP I
M I INT I IP I LOG I LOGlO I LOG2 I M I
MIN I MOD I PI I R I REAINDE I R I
ROUN I SEC I SGN I SIN I SINH I SQR I TAN I
TANH I TIM I TRUNCATE
2. randomize-statement RAMIZE
5.4.3 Exales
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 beloi. 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 DEGRES is in effect (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)
ATN(X)
The arcsine of X in radians or degrees (see 5.6), where -pil 2 s ASIN(X) s
pil 2 ; X shall be in the range -1 s X s 1.
The arctangent of X in radians or degrees (see 5. 6 ) , i.e., the angle whose
tangent is X, where -(pil 2) < ATN(X) < (pil2).
CEIL(X)
The smallest integer not less t X.
COS(X)
The cosine of X, where X is in radians or degrees (see 5. 6 ) .
COSH(X)
The hyperbolic cosine of X.
COT(X)
CSC(X)
DATE
DEG(X)
EPS(X)
EP(X)
FP(X)
INT(X)
IP(X)
LO(X)
- 28 -
The cotangent of X, where X is in radians or degrees (see 5 . 6) .
The cosecant of X, where X is in radians or degrees (see 5 . 6) .
The current date in decimal form YYDDD, where YY are the last two digits of
the year ad 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 .
The number of degrees in X radians .
The maximum of (X- X ' , X"-X, siga) where X ' and X" are the predecessor 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 smallest positive number representable by the implementation,
and is therefore implementation- defined. Note also that PS may produce
different results for different arithmetic options (see 5 . 6) .
The exponential of X , i. e. , the value of the base of natural logarithms
( e = 2 . 7 1828 . . . ) raised to the power X ; if EP(X) is less than machine
infinitesimal, then its value shall be replaced by zero.
The fractional part of X, i. e. , X - IP(X).
The largest integer not greater than X; e. g. , INT(1 . 3)= 1 and INT(- 1 . 3)= - 2 .
The integer part of X, i. e. , SGN(X)>'ciNT(ABS(X)).
The natural logarithm of X ; X shall be greater than zero.
LOG10(X)
The comon logarithm of X ; X shall be greater than zero.
LOG2(X)
The base 2 logarithm of X ; X shall be greater than zero.
M(X, Y)
The larger (algebraically) of X and Y .
The largest finite positive number representable and manipulable by the
implementation; implementation- defined. M 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)
PI
RAD(X)
X modulo Y, i. e . , X-Yi<INT(X/Y). Y shall not equal zero.
The constant 3 . 14159 . . . which is the ratio of the circumference of a circle
to its diameter.
The number of radians in X degrees.
REAINDE(X, Y)
R
The remainder function, i. e . , X-Yi<IP(X/Y). Y shall not equal zero.
The next pseudo-random number in an implementation-defined sequence of
pseudo-random numbers uniformly distributed in the range 0 R < 1.
ROUND(X, N)
SEC(X)
SGN(X)
SIN(X)
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.
The secant of X, where X is in radians or degrees (see 5 . 6).
The sign of X: -1 if X < 0, 0 if X 0, and +1 if X > 0.
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 tangent of X, where X is in radians or degrees (see 5 . 6).
TANH(X)
TIM
The hyperbolic tangent of X.
The time elapsed since the previous midnight, expressed in seconds; e . g. , the
value of TIM at 11: 15 A is 40500. If there is no clock available, then the
value of TIM shall be -1. The value of TIM at midnight shall be zero (not
86400).
TRUNCATE(X, N)
The value of X truncated to N decimal digits to the right of te decimal
point (or -N digits to the left if N < 0); i. e . , IP(Xl'<lO-N)/ 10-N.
- 30 -
I f OPTION ANGLE DEGRES is in effect, the term "in radians or degrees" in the above
list of function values shall mean degrees . If OPTION ANGLE RADIANS is in effect, the
term "in radians or degrees" shall mean radians . The accuracy requirements ( see
5 . 6 . 4) for the periodic trigonometric functions SIN, COS, TAN, SEC, CSC, COT are
l imited to providing ful l accuracy of m+1 decimal digits only for arguments n the
range of -2)'<pi to 2<pi . Loss of accuracy outside this range is limited to the result
of loss of precision in performing those range reductions on arguments necessary to
compute values of these functions, i . e . , "SIN ( x) " may be evaluated as if it were
written "SIN ( MOD ( x, 2)'<pi ) ) " and s imilarly for the other functions .
If no randomize-statement is executed, then the RND function shall generate the same
sequence of pseudo-random numbers each time a program is 1. Execution of a
randomize-statement shall override this implementation-supplied sequence of pseudo
random numbers, generating a new ( and unpredictable) starting point for the list of
pseudo-random numbers used subsequently by the RND function. The sequence of pseudo
random numbers shall be global 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, fatal) .
- The magnitude of the value of a numeric-supplied-function is larger than M or
is mthemtical infinity ( 1003, fatal ) .
The value of the second argument of the MOD or REAINDE 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 ) .
- A attempt is made to evaluate ANGLE( O,O) ( 3008, fatal ) .
5 . 4 . 6 RLks
In the case of implementations which do not have access to a randomizing device such
as a real-time clock, the randomize-statement may be implemented by means of an
interaction with the user .
This Standard requires that overflows be reported only for the final values of
numeric-supplied-functions; exceptions which occur in the evaluation of these
functions need not be reported, though implementations shall take appropriate actions
in the event of such exceptions to insure the accuracy of the final values . When
overflows are reported for the final values of numeric-supplied-functions, it is
recomended that the name of the function generating the overf low be reported also .
It is recomended that, if the magnitude of the value of a numeric-supplied-function
is nonzero, but less than machine inf ini tes imal, imp lamentations report this as an
underflow, set the value to zero ( 1503, nonfatal : retur zero and continue) . In
BASIC-2 implementations, this permits interception by exception handlers .
The time-zone used for DATE and TIM is implementation-defined .
It may not be possible, for reasons of overflow, to express the year in ful l format
in DATE. When this ful l formt is needed, the function DATE$ should be used .
- 3 1 -
5. 5 Numeric Assigent Statement
5. 5. 1 General Description
A let- statement provides for te simultaneous assignment of the computed value of a
numeric-expression to a list of numeric-variables.
5. 5 . 2 Sytax
1 . let- statement
2 . numeric- let- statement
3 . numeric- variable- list
5. 5 . 3 Exales
2 . LET P = 3 . 14159
LET A(X , 3) = SIN(X))'cy + 1
LET A, Y(l), Z I+l
LE T(I,J), I, J = I + J
5. 5 . 4 Semantics
> numeric- let- statement
LET numeric-variable- list equals-sign
numeric-expression
numeric- variable ( conn numeric- variable))'<
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 nueric-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 Numeric Arithmetic and Angle
5 . 6 . 1 General Description
LET A = 1
LET A, B(A)
LET A = l
LE A = 2
LET B(A) = 2
2
Unless specified otherwise, the values of all numeric- variables shall behave
logically as floating-point decimal numbers with an implementation-defined precision
of at least ten decimal digits. By use of an option- statement, a program may choose
to take advantage of a more efficient, but possibly less accurate, representation for
nueric values.
Unless specified otherwise the trigonometric functions (see 5. 4) require arguments or
generate values in radian measure. By use of 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
OPTION option- list
option (coma option),'<
> ARITHTIC (DECIMAL I NATIVE I FIX) I ANGLE
(DEGRES I RADIANS)
- 32 -
4. declare- statement DECLARE type- declaration
5. type- declaration > numeric- type
6. numeric- type > NUIC numeric- declaration (coma
nueric- declaration))''
7 . numeric- declaration > simple-numeric- variable
A option-statement with an ARITHTIC option, if present at all, shall occur in a
lower-numbered line than any numeric-expression, or a dimension- statement or a
declare- statement referencing a numeric-array or fixed- declaration in the sae
program-unit.
The option AITHTIC FIX is relevant only to BASIC-2.
A program-unit shall contain at most one ARITHIC option.
A ANGLE option, if present at all, shall occur in a lower-numbered line than any
reference to any numeric- supplied-function in the same program- unit.
A program-unit shall contain at most one ANGLE option.
A declare- statement, if present at all, must occur in a lower- numbered line than any
reference to the variables declared therein.
5.6.3 Exales
1. OPTION ARITHTIC DECIM, ANGLE DEGREES
5.6.4 Semntics
The ARITHTIC option controls the logical behavior of numeric entities within the
progra- unit containing the option.
If OPTION ARITHTIC DECIM is specified, or if no ARITHTIC 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 my 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 ml 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 shll the error for evaluation
of an individual constant, operation, or function be greater than 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 ARITHTIC NATIVE is specified, then the values of numeric variables and
constants shall be represented and mnipulated 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.
- 3 3 -
The ANGLE option controls the evaluation of the trigonometric functions within the
program-unit containing the option. If OPTION ANGLE RADIANS is specified, or if no
ANGLE option is specified, then the numeric-suppl ied-functions COS, COT, CSC, SEC,
SIN, and TAN use arguments in radian measure, and the numeric-suppl ied-functions
ACOS, ANGLE, ASIN and ATN generate results in radian measure .
If OPTION ANGLE DEGREES is specified, then the numeric-supplied-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
shall proceed to the next line with no further effect.
A simple-numeric-variable that appears in a numeric-type shall establish that
variable as a sile-numeric-variable.
If execution reaches a line containing a declare-statement, it shall proceed to the
next line with no further effect .
5.6.5 Exceptions
None.
5.6 . 6 Remarks
The representations chosen for numeric values when OPTION ARITHTIC NATIVE is
specified may be the same as that for OPTION ARITHTIC DECIMAL.
No minimum accuracy is specified for the evaluation of numeric expressions and
functions when OPTION ARITHIC NATIVE has been chosen. However, it is recomended
that implementations maintain at least six decimal digits of precision.
The value 2E- 38 is specified for the maximum value of the lower bound of positive
numbers to al low an implementation employing the IEC 559 floating point binary
arithmetic to be standard conforming .
- 34 -
6 . S TRI NGS
- 35 -
6 . STRINGS
Character strings constitute one of two primitive data types in BASIC (the other is num
bers). Strings consist of arbitrary sequences of characters. Their lengths are variable,
not fixed, although a maimum 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-mrks.
6 . 1. 2 Sytax
1. constant
2 . string-constant
3 . quoted-string
> string-constant
quoted-string
quotation-mark quoted-string-character)'(
quotation-mrk
The length of a string-constat, i. e. , the number of quoted-string-characters con
tained between the quotation-marks, shall be limited only by the implementation
defined maximum number of characters preceding each of end-of-line indicator (i. e. ,
at least 132 ) .
6 . 1. 3 Exales
2 . "XZ"
"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 finl quotation-mrks. The double-quote, when appearing in
side a quoted-string, shall denote 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 distinct within string-constats.
6 . 1 . 5 Exceptions
None.
6 . 1 . 6 Remarks
The mximum 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 t that
for the line, allowing for a continuation character ("&"), and the leading and trail
ing quotation-mark, e. g. :
100 L A$ = &
&"abc . . . unseen characters here . . . xyz"
As the mximum physical line length must be at least 132, the mximum string-constant
length must be at least 129.
6 . 2 String Variables
6 . 2 . 1 General Description
String-variables my be either simple-string-variables or references to elements of
one-dimensional, two-dimensional, or three-dimensional string-arrays.
6 . 2 . 2
6 . 2 . 3
6 . 2 . 4
- 36 -
Explicit declarations of simple-string-variables are not required . A dol lar-sign
serves to distinguish a string-variable from a numeric-variable .
Sytax
1. variable
2. string-variable
3 . simple-string-variable
4. string-array-element
5 . string-array
6 . substring-qualifier
7 . simple-variable
8 . array-name
Exales
2. K$
name$( X: Y)
IT$ ( 1 ,n) ( z : z+5)
4 . A$( 4)
table$ ( I , J)
Semntics
> string-variable
( simple-string-variable I string-array-element)
substring-qualifier?
string-identifier
string-array subscript-part
string- identifier
left-parenthesis index colon index right-parenthesis
> simple-string-variable
> string-array
At any instant in the execution of a program, a string-variable is associated with a
single 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 associated with a string-variable can vary during
the execution of a program from a length of zero characters ( signifying the null or
empty string) to the mi allowed for that string-variable ( see 6 . 6 . 4).
Simple-string-variables may be declared explicitly ( see 6 . 6) or may be declared im
plicitly through their appearance in a program-unit . The scope of a string-variable
shall 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-dimensional , two-dimensional or three-dimensional 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
ciated with a string-variable . A$ ( M: N) shall 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 shall be numbered from the left starting with one . There are
no exceptions associated with substring-qualifiers ; if either M or N is not in the
range from 1 to LE( A$ ) , the M shall be considered to be MAX( M, l ) and N shall be con
sidered to be MIN( N, LEN( A$ ) ) . If M > N, even after this adjustment, then A$( M: N)
shall be the nul l string occuring before the Mth character of A$ if M < LEN(A$ ) or
- 3 7 -
the null string iiilediately following A$ if M > L( A$). For example, if A$ =
1 1 1. 234" , then A$(1: 1) = 1 1 11 1 , A$(1: 3) = 1 1 123" , A$(0 : 3) = 1 1 1231 1 , A$(2 : 5) = "234" ,
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 my 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 coilonly used altertives for associating implementation-defined ini
tial values with variables; it is recoilended that all variables be recognizably un
defined 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 (3102 , non
fatal: supply an implementation-defined value and continue).
6 . 3 String Expressions
6 . 3 . 1 General Description
String-expressions are composed of string- variables, string- constants, string
function-references, or a concatenation of these.
6 . 3 . 2 Sytax
1. expression
2 . string-expression
3 . string-primary
4 . string-function-ref
5 . string-function
6 . concatenation
> string-expression
string-primary (concatenation string-primary) '
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. A 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, t the first reference to tt string-function.
6 . 3 . 3 Exales
2 . A2$ & B$(4 : 22) & 1 1 2231 1
3 . X$(1, 3 )(I: J)
6 . 3 . 4 Setics
The value of a string-expression shall be the concatenation of the values of the
string-primries in the expression (e. g. , if A$ = "COM " and B$ = "IN" , then A$ & B$
= " COM IN" and B$ & A$ = "INCOM ").
- 38 -
Within a string-expression, string-primries shall be evaluated from left to right.
For each string-primary, first the subscripts, if any, shall be evaluated, then the
substring-qualifiers, and then the value of the primary itself.
A string-function-ref is a notation for the invocation of a predefined algorithm,
into which the argument values, if any, shall be substituted for the parameters (see
6 . 4 and 9. 1) used in the function-de . The result of evaluating a string-function,
achieved by the execution of the defining algorithm, shall be a scalar string value
which replaces the string-function-ref in the string-expression.
6 . 3 . 5 Exception
- Evaluation of a string-expression causes a string overflow (1051, fatal).
6 . 3 . 6 Remrks
The ampersand is used both for concatenation and line-continuation. Thus:
100 PRINT "AC" &
& "XZ"
will print the sequence of characters ACXZ .
6 . 4 Imlementation-Supplied String Functions
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 Sytax
1. string-supplied-function > (CH I DATE I LCASE I LTRIM I REPEAT I RTRIM I STR I
TIM I UCASE I USING) dollar-sign
2 . nueric-supplied-function > LEN I ORD I POS I VAL
3 . numeric-function-ref > M left-parenthesis (simple-string-variable
string-array) right-parenthesis
6 . 4. 3 Exales
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
CH$(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 retured 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, CH$(53) = 1 1 51 1 , and
CH$(65) "A" . The values of CH$ for the native character set are
implementation-defined.
DATE$
- 39 -
The date in the string representation "YYY D" according to ISO 2014. For
example, the value of DATE$ on May 9 , 197 7 was 1 1 197 7 05091 1 If there is no
calendar available, then the value of DATE$ shall be 1 1 000000001 1
LCASE$(A$)
The string of characters resulting from the value associated with A$ by re
placing each upper-case-letter in the string by its lower-case version.
LEN(A$)
The number of characters in the value associated with A$ . Note that L( """")
= 1, since the value of the string constant consists of precisely one
quotation-mark.
LTRIM$(A$)
The string of characters resulting from the value associated with A$ by
deleting all leading space characters.
MAXE(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 M.
ORD(A$)
The ordinal position of the character named by the string associated with A$
in the collating sequence of the declared character set, where the first mem
ber of the character set is in ordinal position zero. The acceptable values
of A$ are single characters in the character set and two-character or three
character mnemonics for characters in the character set. Values of A$ with
two or more characters 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-defined. For example, for the standard character set,
ORD("BS") = 8, ORD("A") = 65 ORD("a") = 97 , ORD("S") = 53 , ORD("SOH1 1 ) = 1,
ORD("Soh") = 1, and ORD("ABC") causes an exception.
POS(A$,B$)
The character position, within the value associated with A$, of the first
character 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 character position, within the value associated with A, of the first
character of the first ocurence of the value associated with B$, starting at
the Mth character 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 t LEN(A$), the value retured is zero. Otherwise, the value re
turned is equivalent to
- 40 -
L tempi MAX( I , MIN( M, LE( A$ ) + I ) )
L temp2$ A$( tempi : LE(A$ ) )
L temp3 POS( tem2$ , B$)
IF tem3 0 T
L POS 0
ESE
L POS temp3 + tempi - I
E IF
For exampl e, if A$ has the value 1 1GRANSTANDING" , then POS( A$ , "AN" , I) = 3 ,
POS( A$ , "AN" , 4) = 8, and POS( A$ , "AN" , 9) = 0 . POS( A$ , ' "' ,M) shall be MAX( M, l ) ,
as long as M <= LE( A$ ) .
REPEAT$( A$ , M)
The string consisting of M copies of A$ ; M > 0 .
RTRIM$ ( A$ )
The string o f characters resulting from the value associated with A$ by
deleting al l trailing space characters .
STR$( X)
TIM$
The string generated by the print-statement as the numeric-representation of
the value associated with X. No leading or triling spaces shall be included
in this numeric-representation. For example, STR$ ( I23 . 5 ) 1 1 123 . 51 1 and
STR$ ( - 3 . I4) = 1 1 -3 . I41 1
The time of day in 24-hour notation according to ISO 3 307 . For example, the
value of TIM$ at l l : I5 A is 1 1 1 l : I5 : 001 1 If there is no clock available,
then the value of TIM$ shal l be 1 199 : 99 : 991 1
The value of TIM$ at midnight
is 1 1
00 : 00 : 001 1
UCASE$( A$ )
The string of characters resulting from the value associated wit A$ by re
placing each lower-case- letter in the string by its upper-case version.
USING$ ( A$ , X)
The string consisting of the foratted representation of X, using A$ as a
format- item, according to the semantics of I0 . 4 . The exceptions defined in
I0 . 4 . 5 for formatted output also apply to the USING$ function.
VAL( A$)
The value of the numeric-constant associated with A$ , if the string associ
ated with A$ is a numeric-constant . Leading and trailing spaces in the string
are ignored . If the evaluation of the numeric-constant would result in a
value which causes an underflow, then the value returned shall be zero . For
example, VAL( " 123 . 5 1 1 ) 123 . 5 , VAL( 1 1 2 . E-991 1 ) could be zero , and
VAL( "MCVII" ) causes an exception.
6 . 4 . 5 Exceptions
- The value of the argument of VAL is not a val id numeric-constant (4001, fatal ) .
- The value of the argument of VAL is a val id numeric-constant, but evaluating this
constant results in an overflow ( 1004 , fatal ) .
- 41 -
- The value of the argument of CH$ is not in the appropriate range ( 4002 , fatal ) .
- The value of the argument of OR is neither a valid single character nor a val id
mnemonic ( 4003 , fatal ) .
- The value of the second argument of REPEAT$ is not > 0 ( 4010, fatal ) .
6 . 4 . 6 Remrks
It is recomended that if the magnitude of the value of the VA function is less than
machine infinitesiml , implementations report this as an exception ( 1504 , nonfatal :
replace with zero and continue) . In BASIC-2 implementations , this permits intercep
tion by exception handlers .
The time zone used for DATE$ and TIM$ is implementation-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 implementation-defined , and may be specified in other national version
of this Standard to accomodate the needs of local alphabets .
6 . 5 String Assignment Statements
6 . 5 . 1 General Description
A let-statement provides for the simultaneous assignment of the computed value of a
string-expression to a l ist of string-variables .
6 . 5 . 2 Sytax
1 . let-statement
2 . string- let-statement
3 . string-variable- l ist
6 . 5 . 3 Exales
2 . LET A$ = "ABC"
LE A$( I ) = B$( 3 : 4)
> string- let-statement
LE string-variable- l ist equals-sign
string-expression
string-variable ( coma string-variable)
'
LET A$ , B$ = "NEGATIVE DISCRIMINANT"
LET C$ ( 7 : 10) = "wxyz"
LET A$ = "ABCD" &
& "XZ"
6 . 5 . 4 Semntics
The subscripts and substring-qualifiers , if any, of variables in the string-variable
l ist shal l be evaluated in sequence from left to right . Next the string-expression on
the right of the equals-sign shal l be evaluated ( see 6 . 3 ) . Finally, the value of that
string-'expression shal l be assigned to the string-variables in the string-variable
list in order from left to right .
When a value is assigned to a string-variable with a substring-qualifier , it shall
replace the substring of the value of the string-variable specified by the substring
qualifier . The length of the value of the string-variable my change as a result of
this replacement . For example, if A$ = 1 1 1234" , then assigning
1
1 321 1 to A$( 2 : 3 ) results
in
1
1 1324" , assigning 1 1 1
1
to A$( 2 : 3 ) results in 1 1 14" , assigning A$( 1 : 2 ) to A$ ( 2 : 3 ) re
sults in 1 1 1124" , and assigning 1 1 51 1 to A$( 2 : 1 ) results in 1
1
15234
1 1
6 . 5 . 5 Exceptions
- The assignment of a value to a string-variable causes a string overflow ( 1106,
fatal ) .
- 42 -
6 . 5 . 6 Remarks
The order of assignment of values to string-variables in the string-variable- l ist is
importat in statements such as
LET A$( 1 : 2 ) , A$( 2 : 3 ) = "X"
where different order of assignment my produce different results .
6 . 6 String Declarations
6 . 6 . 1 General Description
6 . 6 . 2
A option-statement may be used to define an ordering on the set of al l string char
acters .
A declare-statement may be used to set a maximum length for specified string
variables in a program-unit .
Sytax
l . option
2 . type-declaration
3 . string-type
4 . length-max
5 . string-declaration
6 . s imple-string-dec laration
>
>
>
COLLATE ( NATIVE / STANDARD)
string-type
STRING length-max? string-declaration ( coma
string-declaration) l'<
asterisk integer
simple-string-declaration
simple-string-variable length-max?
A option-statement with a COLLATE option, if present at al l , shal l occur in a lower
numbered line t any string-expression, or a dimension-statement or declare
statement referencing a string-array or string-variable within the same program-unit.
A program-unit shall contain at most one COLLATE option.
No simple-string-variable shal l be declared more than once in a program-unit . A
simp le-string-variable which is a formal-parameter or a parameter shal l not occur in
a declare-statement.
6 . 6 . 3 Exales
1. COLLATE NATIVE
3 . STRING\'<8 last_name$l'<20 , first_name$ , middle_name$
6 . 6 . 4 Semantics
The COLLATE option identifies the col lating sequence to be used within a program-unit
for comparing strings ( see 8 . 1) and for computing values of the CH$ and ORD func
tions ( see 6 . 4 ) . OPTION COLLATE NATIVE specifies that the native col lating sequence
of the host system shall be used . OPTION COLLATE STANDAR specifies that the col lat
ing sequence shal l correspond to the order of the characters in Table l . If no
COLLATE option appears in a program-unit then the STANDARD col lating sequence shall
be used within that program-unit .
Simple-string-variables whose string-identifiers appear in string-types may have a
mximum length less than or equal to the implementation-defined default value . The
maximum is determined , in descending order of precedence, from:
- the length-ma in the string-declaration for that variable;
the length-max in the string-type of the declare-statement containing that
variable, or
- the implementation-defined default .
The length-max guarantees that string values up to that length may be stored in the
variable and that an attemt to store a longer value wil l cause a string overflow ex-
- 43 -
ception. The implementation-defined mximum string length default shal l be at least
13 characters .
A length-max of 0 in a string-type shal l establish the associated string-variable as
having a maximum length of zero ; i . e . , the nul l string .
6 . 6 . 5 Exceptions
None .
6 . 6 . 6 Remarks
The native collating sequence my be the standard col lating sequence.
The COLT option my be extended , on national versions of this Standard , to
accomodate specif ic needs of l ocal alphabets .
- 44 -
7 . ARRAYS
- 45 -
7 . ARYS
Arrays are indexed col lections of numbers or strings . Array elements can be mnipulated by
scalar numeric and string operations ( see 5 and 6) . In addition, entire arrays may be m
nipulated by matrix statements .
7 . 1 Array Declarations
7 . 1 . 1 General Description
An option in the option-statement may be used to define the lower bound for al l array
subscripts within a program-unit which are not expl icitly stated . By use of an
option-statement the subscripts of al l such arrays may be declared to have a lower
bound of zero or one; if no such declaration occurs , the lower bound shal l be one .
Arrays may have one, two , or three dimensions . The number of dimensions and subscript
bounds for each dimension are declared in the declare-statement or dimension
statement . Al l array-names , except those appearing in a function-parm- l ist or a
procedure-parm- l ist, must be declared in one and only one such statement . If not ex
pl icitly declared, the lower subscript bound for a given dimension is one or zero ,
depending on te BASE option. Upper bounds must always be expl icitly declared .
A one-dimensional 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 dimension
contains 100 elements . Similarly, a three-dimensional array with subscript-bounds 1
to 10 for each d imension contains 1000 elements .
A declare-statement can be used to dimension numeric-arrays as wel l as to declare
maximum lengths for string-variables ad string-arrays , and to dimension string
arrays . A dimension-statement can be used to dimension arrays , but not to declare the
maximum length of strings in string-arrays .
7 . 1 . 2 Sytax
1 . dimension-statement
2 . dimension- l ist
3. array-declaration
4 . numeric-array-declaration
5 . bounds
6 . bounds-range
7 . signed- integer
8 . string-array-declaration
9 . option
10 . string-declaration
11 . numeric-declaration
12 . numeric-function-ref
13 . maxsize-argument
14 . bound-argument
DIM dimension- l ist
array-declaration ( coma array-declaration)>''
numeric-array-declaration I string-array-declaration
numeric-array bounds
left-parenthesis bounds-range ( coma bounds-range) *
right-parenthesis
s igned-integer TO signed-integer I signed- integer
sign? integer
string-array bounds
> BASE ( 0 I 1 )
> string-array-declaration length-mx?
> numeric-array-declaration
> MAXSIZE mxsize-argument I SIZE bound-argument I
LOU bound-argument I UOU bound-argument
left-parenthesis actual-array right-parenthesis
left-parenthesis actual -array ( com index) ?
right-parenthesis
The number of bounds-ranges in "bounds" shal l be one, two or three .
An array which is named as a formal-array of a defined-function, a subprogram or a
program shal l not be declared in a declare-statement or dimension-statement ( since
the formal-array in the function-parm- l ist or procedure-parm- list serves as its dec
laration) . Any other array shal l be declared in a lower numbered l ine than any
reference to that array or one of its e lements . Ay reference to an array and its el
ements must agree in dimensionality with the declaration of that array in a declare
statement, a dimension-statement, or as a function-parameter or procedure-parameter .
- 46 -
No numeric-array or string-array shal l be dimensioned or declared more t once in a
program-unit.
If the optional lower bound ( the first signed-integer) is included in the bounds
range, i t shal l be less t or equal to the upper bound ( the second s igned-integer) .
If the lower bound is not specified , then the upper bound must not be less t the
default lower bound, which may be zero or one, depending on the BASE option.
A option-statement with a BASE option, if present at al l , shall occur in a lower
numbered l ine t any declare-statement or dimension-statement or any MAT statement
that uses a numeric-array-value in the sae program-unit . A program-unit shal l con
tain at most one BASE option.
If a bound-argument does not specify an index, the actual-array must be declared as
one-dimensional .
7 . 1 . 3 Exales
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 Setics
Each array-declaration declares the named array to be either one-dimensional , two
dimensional , or three-dimensional , according to whether one, two , or three bounds
ranges are specified in the bounds for the array. In addition, the bounds specify the
mximum and optionally minimum values that subscripts for the array shall have . If a
minimum subscript is not expl icitly declared and no BASE option occurs within the
program-unit, then it shal l be implicitly declared 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 expl icitly declared .
I f the execution of a program reaches a l ine containing a dimension-statement, then
it shal l proceed to the next l ine with no further effect .
String-array-decl arations appearing in a string-declaration may include a length-max ,
which sets the mximm length of each element of the string-array. As with simple
string-variables , if there is no length-max in the string-declaration, then the
length-max , if any, of the string-type takes effect . If there is no length-max in ei
ther, then the implementation-defined length-mx, if any, shal l take effect .
The value of SIZE( A, N) where A is a actual-array ad N is a 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) shal l be the current
number of elements in the entire array A.
The value of MAXSIZE( A) shall be the total number of elements of the entire array
named by A permitted by the array-declaration.
The value of LBOUND( A, N) , where A is an actual -array and N is an index, shall be the
current minimum value allowed for the Nth subscript of the array named by A. The
value of UBOUND( A, N) shal l be the current maximum value allowed 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 left 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 ad maximum values al lowed for the subscript of the vector. (Here, and in the
fol lowing sections, the word "vector" shal l mean a "one-dimensional 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 less than one or greater than the
number of dimensions 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 dimensions in the array ( 4008 , fatal).
- The value of the index in a UBOUD reference is less than one or greater than the
number of dimensions in the array (4009 , fatal).
7 . 1 . 6 Remarks
The dimension statement is retained for compatibil ity with Minimal BASIC. Al l its ca
pabilities are incl uded within the declare-statement.
I f an implementation supports more t three dimensions, SIZE, LBOUND, and UBOUND
should work for those extra dimensions, and an exception should be generated only
when an attempt is mde to inquire about a dimension beyond those declared.
7 . 2 Numeric Arrays
7 . 2 . 1 General Description
Numeric-arrays in BASIC my be manipulated el ement by element. However, it is often
more convenient to regard numeric-arrays as entities rather than as indexed col lec
tions of entities, and to manipulate the entire entity at once. BASIC provides a num
ber of standard operations to facilitate such manipulations.
7 . 2 . 2 Sytax
1 . array-assignment > numeric-array-assignment
2 . numeric-array-assignment MAT numeric-array equals-sign
numeric-array-expression
3 . numeric-array-expression
4. numeric-array-operator
5 . scalar-multiplier
6 numeric-array-value
7 . redim
8. redim- bounds
(numeric-array numeric-array-operator)? numeric-array
I scalar-mul tiplier numeric-array I
numeric-array-value I
numeric-array-function-ref
sign I asterisk
primary asterisk
> scalar-multipl ier? (CON I IDN I ZER) redim?
left-parenthesis redim-bounds (com redim-bounds )*'
right-parenthesis
(index TO)? index
9 numeric-array-function-ref= ( T I INV) left-parenthesis numeric-array
10 . numeric-function-ref
right-parenthesis
> DET (left-parenthesis numeric-array
right-parenthesis) I DT left-parenthesis
numeric-array com numeric-array
right-parenthesis
The number of redim-bounds in a redim shal l be one, two, or three.
A numeric-array being assigned a value by a numeric-array-assignment shal l have the
same number of dimensions as the value of the numeric-array-expression.
- 48 -
The numeric-arrays in a numeric-function-ref involving DT shall be one-dimensional .
There must be no more than two redim-bounds following IDN .
The numeric-arrays in a sum or difference shall have the same number of dimensions .
The numeric-array serving as the argument of DET, INV or TRN shall be two
dimensional .
The numeric-arrays serving as operands for the numeric-array-operator asterisk
( matrix multiply) shall be either one-diensional or two-dimensional , and at least
one of them shal l be two-dimensional .
7 . 2 . 3 Exales
In the following examples A, B and C are doubly-subscripted numeric-arrays , X, Y, and
Z are singly-subscripted numeric-arrays , and W is a numeric-expression.
2 . MAT A B MAT X y
MAT A B + c MT X y - z
MAT A B>'IC 1AT X N'<Y 1AT X y)'IA
MAT A w
,.,
B HAT X w
,.,
CON
MAT A ZER( 4 , 3 ) MAT X ZER
MAT A INV( B) MAT A TRN( B)
10. DET( B) DOT( X, Y)
7 . 2 . 4 Semantics
Array Assignments and Redimensioning
Execution of a numeric-array-assignment shal l cause the numeric-array-expression to
be evaluated and its value assigned to the array named to the left of the equals
sign. If necessary, this array shal l have its size changed dynamically; i . e . , its
number of dimensions shall be unchanged , but its size in each dimension shall be
changed to conform to the size of the array which is the value of the numeric-array
expression.
When the size of a numeric-array is changed dynmically, the current upper bounds for
its subscripts shall be chaged to conform to the new sizes . That is ,
new_lower_bound
new_upper_bound
old_lower_bound
old_lower_bound + new_size - 1
The new sizes need not individually be less than or equal to the sizes determined in
the array-declaration 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 elements determined
by the array-declaration for that array.
Array Expression
The evaluation of numeric-array-expressions shall fol low the normal rules of matrix
algebra. The symbols asterisk ( '
ID 2
N
<o
K
'
ID 2
l''<ID 2
l'n'<ID 2
BEGIN
l'<OK
<ID 2
l''<ID 2
'n'<ID 2
E
l'<OK 4
l'<
ID 2
l'm
iD 2
'r<ID 2
SA
lOK
l'<ID 2
r
''
ID 2
'r<ID 2
PRINT
absent
l'<OK
l'<ID 2
'<
ID 2
l'n'<
ID 2
N
l'<OK
l'<ID 2
ID 2
d<ID 2
BEGIN
l'<OK
l'<ID 2
l'<lt
iD 2
l'<<
ID 2
E
l'<OK
l'<
ID 2
l
ID 2
:''<
ID 2
SA
<o
K
:'<
ID 2
l'ri<ID 2
l'd<ID 2
R
absent
l'<OK
l'<
OK
l'
'<OK
l'<<
OK
N
<o
K
>'<
OK
'r<OK
:'<l'<
OK
BEGIN
l'<OK
:'<OK
lh'<OK
l'ri<OK
E
'o
K 4
l'<OK 4
h'<OK
l'ri<OK
SA
<o
K
l'<OK
>bOK
:oK
RECORD )
'd<E 1
,'d<E 1
r<OK
,'cl< E 1
K
lh'<E 1
,'o'<E 1
lh'<E 1
r
:l''OK
WRITE
absent
l''OK
:o
K
l't><OK
:'tl'
E 3
N
l''
OK
l''
OK
l'd'OK
'
'cl<E 3
BEGIN
l''
OK
:''OK
l'<'
OK
lh''E 3
E
l''OK
:''
OK
:
:
'<OK )
'
(
:'<E 3
SA
l''OK
'''
OK
:''<OK
''d<E 3
RECORD
,'d<E 1
,'d<E 1
l'<'
OK )
'd<E 1 , 3
K ( exact)
,'d<E 1
,'d<E 1
''d<E 1
,'n
'<Q
K
REWRITE and DEETE
absent
l'(l
ID 5
l'
(
l
ID 5
>'rl'OK
>'<l'
OK
N
>'rl'
ID 5
>'rl' ID 5
>'d'OK
>'n'<OK
BEGIN
>'r'
ID 5
>'t>''
ID 5
>'<l'
OK
>'<l'OK
E
>'<l<
ID 5
d'
ID 5
>'
n
''OK 4
>'d'OK 4
SA
,.,,.,
ID 5
l't>'
ID 5
>'rl'
OK
:'d<OK
RECORD
l'(l'<
ID 5
>'d<ID 5
>'
n'<OK
,'d<E 1
K
>'<>'<ID 5
l'<l<
ID 5
,.,,,,
E 1
l'<l'<OK
SET wit pointer- items
absent
l'<OK
l'<OK
l'd<OK
l'd<OK
N
>''
OK
:''OK
:'d<OK
>'rl'OK
BEGIN
l'<OK
:''OK
l''<OK
>'r<OK
E
<o
K
l''OK
'<><
OK
'd<OK
SA
l''
OK
,o
K
n
'<OK
M<OK
RECORD
,c;'<
E 1
M<E 1
i
'<OK
M<E 1
K
>'<>E 1
,'d<E 1
''
()'<
E 1
>h'OK
OK - Semantics defined by Standard
E - Exception
ID - Implementation-defined
c
- BASIC-! and BASIC-2
de
- BASIC-2 only
Notes to the Table 1
- 97 -
1 . RECORD is val id only with REATIVE f iles and KEY wit K f iles . ( BASIC-2 only)
2 . INPUT and PRINT are defined for record-type DISPLAY , and DISPLAY is defined only for
SEQUTIAL.
3 . WRITE to a K fi le must specify an exact key search. ( BASIC-2 only)
4 . E impl ies that data-found wil l be false .
5 . REWRITE and DEETE are implementation-defined for f ile-organizations other then
RELATIVE and K. ( BASIC-2 only)
- TABLE 2 RECORD OPETIONS VS CONTROLS
This table i l lustrates which control features are allowed syntactical ly with the various
operations . SET is only al lowed with pointer-items . The permitted record setting are
N, BEGIN, E, SA.
record-setter
INPUT
PRINT
R
WRITE
REWRITE
DELETE
SET
A allowed
c
A
c
A
c
A
c
A
rc
A
>'
t''<A
l'C
A
l'c
BASIC-! and BASIC-2
)
'de
BASIC-2 only
CONTROLS
io-recovery
missing not
missing
'A
c
A
c
A
)
'C
A
cl'C
A
)
'
t)
'<A
l
'C
A
l'C
A
- TABLE 3 FILE-ORGANIZTION VS RECORD-TYPE
interpretation
image template
)
'C
A
)
'
n
'c
A
rc
A
-
'
cl
'<A
This table i l lustrates which combination of file-organization and record-type are defined
by this standard .
ORGANIZATION DISPLAY
SEQUTIAL
STREAM
RELATIVE
KY
A = allowed
)
'c
= BASIC-1 and BASIC-2
l
'
cic
= BASIC-2 only
l'C
A
Record-type
INNAL NATIVE
)
'C
A
ldt
A
l
'C
A
'
'dc
A
'
'o
<A
l
'
rc
A
lc,''A
- 98 -
11 . 1 File Oerations
11 . 1 . 1 General Description
1 1 . 1 . 2
There are four statements which affect a file as an entity. The open-statement makes
a file accessible to the program, establishing the connection between the file and
the program. Since the formt for identifying files may vary with the operating sys
tem, it is assumed only that with each file is associated a string of characters ,
cal led its nae, which identifies the f ile to the operating system. A file is identi
fied within a program by the number of a channel through which it is accessed . The
close-statement terminates the accessibil ity effected by they open-statement . The
erase-statement deletes al l or part of the data within a true file, but may have no
effect on a device . The ask-statement is used to inquire about the current status of
the fil e.
Sytax
BASIC-1 and BASIC-2
1 . open-statement
2 . channel-setter
3 . channel-expression
4. file-name
5 . f ile-attribute- l ist
6 . file-attribute
7 . core-file-attribute
8 . access-mode
9 . file-organization
10 . file-organization-value
1 1 . core- file-org-value
12 . record-type
13 . record-type-value
14 . core-record-type-value
15 . record-size
16 . close-statement
17 . erase-statement
18 . ask-statement
19 . ask- item- l ist
20 . ask- item
2 1 . ask-attribute-name
22 . core-attribute-name
BASIC-2 only
23 . file-organization-value
24. enhanced-file-org-value
N25 . record-tye-value
OPEN channel-setter NAM file-name
f ile-attribute- l ist
channel-expression colon
number-sign index
string-expression
( coma file-attribute) :'<
> core-file-attribute
access-mode I file-organization I record-type I
record-size
ACCESS ( INPUT / OUTPUT / OUTIN / string-expression)
ORGANIZATION ( fi le-organization-value
/ string-expression)
> core-file-org-value
SEQUENTIAL / STREM
RECTYPE ( record-type-value I string-expression)
> core-record-type-value
DISPLAY / INTERNAL
RECSIZE ( VARIABLE / string-expression) ( LENGTH
index) ?
CLOSE channel-expression
ERASE REST ? channel-expression
> ASK channel-setter ask-item- list
ask- item ( coma ask- item) :'<
ask-attribute-name variable variable:'<
> core-attribute-name
>
>
ACCESS / DATil1 / ERASABLE / FILETYPE / MARGIN / NAM
I ORGANIZATION I POINTER I RECSIZE I RECTYPE /
SETTER I ZONEWIDTH
enhanced-file-org-value
RELATIVE I KEYED
enhanced-record-type-value
N26 . enhanced-record-type-value= NATIVE
27 . file-attribute > enanced-file-attribute
28 . enhanced-file-attribute col late-sequence
29 . col late-sequence COLLATE ( STANDARD I NATIVE I string-expression)
30 . ask-attribute- name > enhanced-attribute-name
3 1 . enhanced-attribute-name RECORD I KEY I COLLATE
- 99 -
A given file-attribute must appear at most once in a file-attribute-list .
A given ask-attribute- name must appear at most once in a ask- item- l ist.
The number and types of variables in an ask- item must agree with the table below in
Semantics .
11 . 1 . 3 Exales
1. OPEN t3 : NAM "myfi le"
OPEN tN : NA A$ , ACCESS OUTIN, ORGANIZATION STREA, RECTYPE INTENAL, RECSIZE
VAIABLE LENGTH N
OPEN I!N+l : NAM "M" & F$ , ORGANIZATION ORG$
16 . CLOSE liN
17 . ERASE 113
ERASE REST 114
18 . ASK t3 : ACCESS AC$ , DATU DT$ , NA N$ , ORGANIZATION ORG$ , POINTER P$ , RECSIZE
RS$ NUCHARS , RECTYP RT$
ASK liN: KEY K$
11 . 1 . 4 Sttics
Files are accessed through channels to which they may be assigned during execution of
a program-unit. A channel is a logical path through which exterl data may be trans
ferred to or from a BASIC program. Within a program-unit, a channel is identified by
a channel number local to that program-unit . The channel number is an integer from 0
up to and including some implementation-defined maximum. This mi must be at
least 99 . A file, identified by its file-name, is open if it is currently assigned to
a chanel and closed otherwise. A channel is active if it currently has some file as
signed to it and inactive otherwise. At the initiation of execution of a program, all
channels except channel zero shall be inactive . Channel zero shal l always be active .
Execution of the open-statement, close-statement, or erase-statement ( see below) for
channel zero shal 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 channel-expressions .
Channel zero shal l behave as a device with the file-attributes sequential , display,
and outin, and without record-setter or erase capabil ity.
Oen-statement
The open-statement makes the file identified by the fi le-name accessible to the pro
gram through the channel number specified in the channel -express ion. It is
implementation-defined whether file names differing only in the case of the letters
( upper or lower) denote the same file or different fi les . Fol lowing a successful
open-statement, the associated channel shall be active and the file open. A attempt
to open a file on a chru1nel which is already active causes an exception. The effect
of attempting to open a file which is already open is implementation-defined . The
number of channels other than channel zero which may be active simultaneously is at
least one .
After a successful open, a true file shal l be accessible in accordance with the asso
ciated fi le-attributes , whether expl ic itly specified or in effect by default . This
accessibility consists of the abi l ity to perform certain operations and manipulate
the file pointer in certain ways . See the preceding section for an overview of which
statements are al lowed under which attributes . If an attempt is mde to OPE a file
which cm1not be made accessible with the requested attributes ( i . e . , if not al l the
associated operations can be successfully executed for this file) , then an exception
results .
- 100 -
For a device, a successful open guarantees that, with two exceptions , al l the file
processing statements will have the same effects as for a true file . In particular,
on output, the same data will be generated , and on input, values and characters wil l
be interpreted and assigned to variables in the same way. A device, however, might
not support the semantics associated with the recorder- setter ( see Section 11 . 2 ) or
the erase-statement (below) . The ask-statement may be used to determine whether a
particular device supports these capabilities .
BASIC- 1 only
If a file is opened successful ly with a given file-organization, record-type,
and record-size , then closed, and then opened at a later time with a different
value for one of these file-attributes , then it is implementation-defined
whether the file is thus accessible. Also , for files with record-type INTERNAL,
if a different ARITHIC option is in effect for the two executions , it is
impl ementation-defined whether the file is thus accessible . Conversely, if a
true file is reopened at a later time with the same values for the file
attributes mentioned and, for fi les with record-type INTERNAL, the same
ARITIC option is in effect, and the user has employed the implementation
defined means to preserve the file unchanged in the interim, then the file must
be accessible and the contents of the file faithful ly preserved . Devices are not
required to preserve data. In the foregoing, "same ARITHTIC option" refers to
DECIMAL or NATIVE.
If a file with record-type INERNAL opened in one program-unit is accessed by
another program-unit with a different ARITHTIC option, the results are
implementation-defined .
Implementations must provide true files for which all access-modes are avail
abl e. Implementations my also support true files for which some access-modes
are not available. A device need not support al l access-modes .
Implementations conforming to this standard need only to accept and process the
following combinations of file-organization-value and record-type-value:
- sequential display,
- sequential internal ,
- stream internal .
The effect of the other combination is implementation-defined .
Wen a string-expression is used as an attribute value, its value must be one of
the associated keywords for that attribute. Upper-case-characters and lower
case-characters shal l be treated as equivalent within such string values . Imple
mentations may define additional file attribute values .
BASIC-2 only
If a file is opened successful ly with a given file-organization, record-type,
and record-size , then closed , and then opened at a later time with a different
value for one of these file-attributes , then it is implementation-defined
whether the file is thus accessible. Also , for fi les with record-type INTERNAL
or NATIVE, if a different ARITHIC option is in effect for the two executions ,
it is implementation-defined whether the file is thus accessible . Conversely, if
a true file is re-opened at a later time with the same values for the file
attributes mentioned and , for files with record- type INAL or NATIVE, the
same ARITHTIC option is in effect, and the user has employed the
implementation-defined means to preserve the file unchanged in the interim, then
the file must be accessible and the contents of the file faithful ly preserved .
Devices are not required to preserve data. In the foregoing, "same ARITHTIC
- 101 -
option" refers to DECIMAL, NATIVE or FIXD ( see 15 . 1 ) , not to the default
specification in the FIXD option. If a KEYED file is re-opened with a different
col late-sequence, an exception results .
If a file with record-type INTERNAL or NATIVE opened in one program-unit is
accessed by another program-unit with a different ARITHTIC option, the results
are implementation-defined .
Implementations must provide true fi les for which all access-modes are avail
abl e. Implementations may also support true files for which some access-modes
are not available. A device need not support all access-modes .
Implementations conforming to this standard need only to accept and process the
fol lowing combinations of file-organization-value and record-type-value :
- sequential display
- sequential interal
- stream interl
- relative internal
- keyed internal
- sequential native
- relative native
- keyed relative
Te effect of the other combinations is implementation-defined .
When a string-expression is used as an attribute value, its value must be one of
the associated keywords for that attribute . Upper-case-characters and lower
case-characters shal l be treated as equivalent within such string values . Imple
mentations may define additional file attribute values .
Access-mode
A access-mode specifies the direction in which data may be transferred from and to a
file, either by one of the keywords INPUT, OUPUT, or OUTIN, or by a string
expression whose value is one of these keywords .
If access-mode is INPUT, then it shall be possible to read data from the file, but
not to change the file . In particular, R, SET with pointer- items , and INPUT
statements ( including variations with MAT and LINE) are allowed , but not PRINT,
\<RITE, RITE or DELETE . RITE and DELETE apply only to BASIC-2 .
I f the access-mode i s OUTPU, then it shall be possible to add new data to the file ,
but not to change existing data in it, nor to retrieve data from it . In particular,
PRINT, SE with pointer- items , and \<RITE are al lowed , but not R, INPU , RITE
or DELEE . REWRITE or DELEE apply only to BASIC-2 .
If the access-mode is OUTIN, then al l record-operations ( including RITE and DEETE
for BASIC-2 ) are allowed for the fil e.
The erase-statement shall be al lowed only for a file with an access-mode of OUTIN .
I f no access-mode is specified expl icitly in the file-attribute- l ist, then the
access-mode shal l be OUTIN if the file can be both read and written INPUT if it can
only be read , and OUTPUT if it can only be written . Channel zero shall behave as if
opened with OUTIN .
For a file opened with access-mode OUTPUT, the pointer shall be set to the end of the
fil e fol lowing the OPEN, otherwise, it shall be set to the beginning of file.
- 102 -
File-organization
The fi le-organization specifies the logical relationship between file elements , and
the means by which the file pointer can be manipulated to identify the elements . The
organization is specified with one of the keywords SEQUENTIAL, STREAM, RELATIVE or
KEYED, or with a string-expression whose value is one of these keywords . Devices are
accessed as either SEQUENTIAL or STRKM1 , RLATIVE and KEYED are al lowed only for true
files . RELATIVE and KEYED apply only to BASIC-2 .
If no file-organization is expl icitly specified in the open-statement , then the orga
nization shall be determined from available system information about the file. If
such information is insufficient, the system shall attempt to open the file as
SEQUENTIAL. Channel zero shall behave as if opened with SEQUENTIAL.
A sequential file is a sequence of records . The order of the records is establ ished
by the order in which they were written. Records can be added only to the end of
the file . The only meru1s for identifying records with the file pointer is relative
to the current position of the pointer , and the two special locations BEGIN ( which
identifies the first record in te sequence, if any) , and END , imediately follow
ing the last record ( the only location where it is possible to add records ) . A
single record operation may affect several DISPLAY records , but only one INTERNAL
or, for BASIC-2 , NATIVE record .
- A strea file is much l ike a sequential file, except that it is a sequence of indi
vidual values , rather than of records . The order of values is established by the
order in which they were written. Values cru1 be added only to the end of the file .
The only means for identifying values is relative to the current pointer position,
or BEGIN and END ( specifying respectively, the first value, if any, in the se
quence, and the location imediately fol lowing te last value) . One record opera
tion may typical ly read or write a contiguous series of values within a stream
file .
BASIC-2 only
- A relative file 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
lished by the identifying integer associated with each. The file pointer may
be manipulated with the use of this record number as wel l as by those means
provided for sequential files . For relative files , the beginning of file is
the first record-area, regardless of whether it contains a record . The end of
file imediately fol lows the last existing record . Thus if the highest exist
ing record number is 44, end of file refers to record-area 45 . If there are
no records in the file, end of file refers to record-area number 1 . Records
within a relative file 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 file , but also at any empty record-area, including those
past the end of file. A record operation processes at most one record .
A keyed file is a sequence of records , each of which is identified by a string
cal l ed a key. The logical sequence of records is establ ished by the collating
order of their keys . ( See col late-sequence , below. ) The file pointer may be
manipulated with respect to the keys , as wel l as by the means provided for
sequential files . As with sequential files , beginning of file refers to the
first existing record in te sequence ( if any) , and end of file refers to the
location imediately fol lowing the last record . Records may be added anywhere
within the sequence . A exact key, however, must always be specified for
record creation, and no dupl icate keys are allowed . Records may also be read ,
changed or deleted . A record operation processes at most one record .
- 103 -
Record-tyes
A record-type specifies the logical representation of data within a record or as an
individual file element . The record-type affects how data is interpreted and trans
formed when being transferred between a program and a file. A record-type is speci
fied with one of the keywords DISPLAY , INENAL or NATIVE or with a string-expression
whose value is one of these keywords . NATIVE apply only for BASIC-2 .
If no record- type is expl icitly specified on the OPE, the record-type is determined
from avai lable system information about the file. If such information is insuffi
cient, then the file shall be opened as DISPLAY . Channel zero behaves as if opened
with DISPLAY .
- The display type specifies 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) . R and WRITE
are also allowed for display records ; they fol low the semantic rules for INPUT and
PRINT, respectively.
- The internal type specifies that a record is a sequence of typed values ( or that
each file element is a value) , in the same sense that a program variable contains
a value . The essential aspect of internal format is that ( for a true file) values
are preserved and retrievable . Thus , if a numeric or string value is written from
a program variable, and later read into another variable, the two variables must
be strictly equal ( assuming the original variable to be unchanged) . Since INPUT
and PRINT statements are essentially character-oriented , they cause an exception
when used on a file opened as internal .
BASIC-2 only
- Te native type specifies that a record is a sequence of f ields , as described
by a program-specified TEPLATE. This TPLATE, in conjunction with the l ist
of operands of the associated record operation, specifies the size, type,
number, and order of f ields within the record . This al lows data in a file to
be put in a form suitable for exchange with other language processors which
have similar record specification capabil ities . Values are preserved subject
to certain restrictions regarding the size of the fields in the record . As
with the internal type , INPUT and PRINT cause an exception when used on a
file opened as native .
Record-si ze
A record- size specifies the maximum length of records in a file. It is specified ex
pl icitly with the keyword LENGTH.
Unless an enhancement to this Standard provides for f ixed- length records , all f iles
shall be composed of variable- length records , i . e . , of records whose lengths are in
dependent of each other . The length of a record of type DISPLAY shall be the number
of characters in that record . The length of records of other types ( INTENAL or, for
BASIC-2 only, NATIVE) shall be implementation-defined . A attempt to perform a record
operation for a record whose length exceeds the maximum set ( either expl ic itly or by
default) in the OPEN operation shall use an exception. A specified LENGTH index must
be greater than zero .
If no record-size is expl icitly specified in the open-statement, then the record-size
is determined from available system information about the file. If such information
is insufficient, then the file shall be opened as VARIABLE. If the index is omitted,
then the maxium length of records shall be implementation-defined . Channel zero
shal l behave as if opened with VARIALE and the length index omitted .
Impl ementations must support record-sizes of at least 132 for true files .
- 104 -
Col late-sequence ( BASIC-2 only)
The collate-sequence specifies , for a KEYE file, the col lating sequence of the
record keys . A collate-sequence is specified with one of the keywords STANDARD or
NATIVE, or with a string-expression whose value is one of these keywords . Col late
sequence has meaning only for a KYE fil e. For other file-organizations , it has no
effect .
The col late-sequence of a file govers al l record operations for that file and the
file-operation ERASE. Thus , the logical appearance of the file, when operated on by
R, WRITE, RERITE, DELETE, SE with pointer-control , ERASE and ASK must be in ac
cordance with the specified collate-sequence ( see file-organization, above and 1 1 . 2 ) .
The collate- sequences STANDARD and NATIVE imply exactly the same ordering as in the
option-statement ( see 6 . 6) . Thus , if the col late-sequence associated with a file and
a program-unit agree, it fol lows that an earl ier key in the file wi l l always compare
as less than a later key. When the sequences disagree, this relationship may not
hold . Nonetheless , it must be possible for a program-unit with a different col late
sequence to access a KEYED file; the col late-sequence affects only the logical order
of the records , not their contents . Implementations with KEYED files must support
both collate-sequences .
If no col late-sequence is specified in the open-statement, then the col late-sequence
shal l be determined from available system information about the file . If such infor
mtion is insufficient , the system shal l attempt to open the file with the same
collate-sequence as that in effect for the program-unit containing the open
statement . Since channel zero has file-organization SEQUENTIAL ( not KEYE) , it has no
associated col late- sequence .
Close-statement
Execution of a close-statement shall close the file assigned to the specified chan
nel , causing the channel to become inactive . If no file is assigned to the channel ,
no action occurs . Upon exit from an external-sub-def or external-function-def , any
files opened by such a procedure whose channels are not formal parameters shal l be
closed . Upon program termination, any files sti l l open shal l be closed .
Erase-statement
For a true file, execution of an erase-statement shal l delete al l or part of the data
within the file assigned to the specified channel . The file-attributes associated
with the file are not changed . If the REST option is omitted , then al l file elements
are deleted , the file becomes empty, and the file pointer points to the end of file
(which is the same as the beginning file) .
If the REST option is specified , then al l file elements at or beyond the current lo
cation of the file pointer are deleted . All file elements preceding it are left un
changed . The file pointer is then set to end of file .
The erase-statement may not be effective for a device . The ask-statement can be used
to determine if a device supports this capabi l ity.
A erase-statement executed for channel zero shall cause an exception, but no other
effect shal l occur .
A erase-statement is al lowed only for a file opened with access-mode OUTIN. For
other access-modes , there is no effect on the file and an exception results .
Ask-statement
Execution of an ask-statement shal l cause the variables in the ask- item- l ist to be
assigned values corresponding to the attributes of the file currently assigned to the
specified channel , as indicated in the fol lowing table . If the channel is inactive,
- 105 -
then all such string-variables shall be assigned the nul l string, and al l such
numeric variables shall be assigned 0 . In al l cases below, A$ represents a string
variable and N represents a numeric-variabl e.
In BASIC-2 the fol lowing responses can be expected :
Ask-item
Values
ACCESS A$
The access-mode of the file, i . e . , "INPUT" , "OUTPUT" , or "OUTIN" .
COLLATE A$
The col late-sequence associated with a KEYED file, i . e . "STANDARD" or
"NATIVE" . For file-organizations other than KEYED, the nul l string is as
signed .
DATUM A$
The type of the next datum in the file fol lowing the current pointer posi
tion, i . e . , "NUMRIC" , "STRING" , "NONE" ( if no data fol low) , or "UNKNOWN" ( if
it is impossible to determine the type or whether more data follow) . DATUM is
wel l-defined only for STREAM INTERNAL files . For other file organizations , it
is implementation-defined .
ERASABLE A$
"YES" or "NO" depending on whether or not this file is erasable, i . e . , if the
ERASE statement can delete file elements .
FILETYPE A$
KEY A$
"FILE" or "DEVICE" depending on whether this is a true file capable of pre
serving data, or is a device .
The key associated with the record identified by the file pointer in a keyed
file . If the pointer is at the end of file or if this is not a keyed file ,
the nul l string is assigned .
MARGIN N
The current margin for a display file ( M if the record may be of arbi
trary length) . If the file is not DISPLAY, zero is assigned .
NA A$
The name of the file assigned to the channel .
ORGANIZATION A$
The f He-organization of the file, i . e . , "SEQUETIAL" , "STREAM" , "RELATIVE"
or "KEYED" .
POINTER A$
The current pointer position for the file, i . e . , "BEGIN" , "MIDDLE" , or "END" ,
where MIDDLE shall mean neither BEGIN nor E, and END shal l be the pointer
position for an file, or a position beyond the end , in the case of a RELATIVE
file . UNKNOWN may be returned in the case of devices for which an implemen
tation cannot determine which of the above values is correct .
- 106 -
RECORD N
The number of the record-area identified by the file-pointer . For non
relative files , zero is assigned .
RECSIZE A$ N
The record-size of the file , i . e . "VARIABLE" and the maximum length for its
records ( M if there is no effective l imit on record- length, e . g . , a com
munication line) .
RECTYPE A$
The record-type for the file, i . e . "DISPLAY" , "INTERNAL" or "NATIVE" .
SETTER A$
"YES" or "NO" depending on whether or not this file has record-setter capa
bil ity.
ZONEWIDTH N
For DISPLAY files , the current zonewidth. For non-DISPLAY files , zero is re
turned .
In BASIC- 1 , the fol lowing responses can be expected :
ask-attribute
ACCESS
COLLATE
DATUM
ERASABLE
FILE TYPE
KEY
MARGIN
NAM
ORGANIZATION
POINTER
RECORD
RECSIZE
RECTYPE
SETTER
ZONEIDTH
value
as BASIC-2
nul l string
as BASIC-2
as BASIC-2
as BASIC-2
nul l string
as BASIC-2
as BASIC-2
SEQUIAL or STR
as BASIC- 2, except that END means an empty file
zero
as BASIC-2
DISPLAY or INTERNAL
as BASIC-2
as BASIC-2
The effect of executing an ask-statement for chnel zero is as fol lows :
ask-attribute value
ACCESS OUT IN
COLLATE nul l string
DATUM UOWN
ERASABLE NO
FILETYPE DEVICE
KEY nul l string
MARGIN current margin
NAM implementation-defined
ORGANIZATION SEQUIAL
POINTER UOWN
RECORD zero
RECSIZE VARIABLE M
RECTYPE DISPLAY
SET NO
ZONEIDTH current zonewidth
- 107 -
1 1 . 1 . 5 Exceptions
- The value of a channel -expression is not between 0 and the implementation-defined
maximum ( 7001 , fatal ) .
- Channel zero is specified in an open-statement, a close-statement, or an erase
statement ( 7002 , nonfatal do nothing and continue) .
- A nonzero channel specified in an open-statement is already active ( 7003 , fatal ) .
- A string-expression used to specify a file-attribute does not have a recognizable
value ( 7 100 , fatal ) .
Access to a file in an open-statement is not possible in accordance with the speci
fied or default file-attributes ( 7 1xx fatal : the values and meanings for xx are
implementation-defined) .
- A KEYED file is re-opened with a different col late-sequence from that of an earlier
open ( 7050, fatal ) . ( BASIC-2 only)
- A LENGTH index is not greater than zero ( 7051 , fatal ) .
- A device is opened as RELATIVE or KEYE ( 7052 , fatal ) . ( BASIC-2 only)
- A nonzero channel specified in an erase-statement is inactive ( 7004 , fatal ) .
- A erase-statement is used on a file which has not been opened as OUTIN ( 7 301 ,
fatal ) .
- A erase-statement is used on a device without erase capability which has been
opened with OUTIN ( 7 31 1 , nonfatal : do nothing and continue) .
1 1 . 1 . 6 Remarks
It is recomended that implementations recognize as file-names at least those strings
of characters consisting of an upper-case- letter followed by at most three more
upper-case-letters or digits . It is also recomended that information required by the
operating system, for the purpose of protecting the security of fi les be considered
part of the file-name .
It is recomended that implementations use the file-name to distinguish between the
opening of a true fil e, and opening of non-file devices , such as a comunications
l ine or a l ine printer .
It is recomended that the number of channels which may be active simultaneously be
at least four in addition to channel zero .
It is recomended that the default mximum length of records in a file be infinite,
i . e . , that records be al lowed to be of any length.
It is also recomended that record-size for INTERAL and, for BASIC-2 only, NATIVE
files has a meaning comparabl e to that for DISPLAY, i . e . , that it specifies the mxi
mum number of characters or bytes within the record .
Additional values may be returned by an ASK statement if an implementation supports
access-modes , file-organizations , record- types , record- sizes and col late-sequences in
addition to those specified in this Standard .
If implementations return a status code fol lowing various file operations , it is rec
omended that this be made accessible through an additional ASK attribute to be
cal led IOSTAT which returs a single string value, e . g . , "ASK IOSTAT S$1 1 returs a
value in S$ refl ecting the status of the file fol lowing the last attempted operation.
The maximum length of a KEY is implementation-defined . ( BASIC-2 only)
- 108 -
11 . 2 File Pointer Manipulation
11 . 2 . 1 General Description
The pointer for an open file can be altered in certain ways , without also performing
any data transfer. The rules for pointer mnipulation with the set-statement with
pointer-items also apply when used in conjunction with other record operations .
11 . 2 . 2 Sytax
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
> channel-setter pointer- items
( pointer-control I io-recovery I pointer-control
com io-recovery)
> POINTE core-record-setter
> core-record-setter
BEGIN I E I SAM
missing-recovery I not-missing-recovery
IF T THN io-recovery-action
BASIC-2 only ( Enhanced Files productions ) :
8 . pointer-control
9 . record-setter
10 . enhanced-record-setter
11. exact-search
12 . inexact-search
11 . 2 . 3 Exales
> enhanced-record-setter
> enhanced-record-setter
RECORD index I KY ( exact-search I inexact-search)
string-expression
equals-sign?
greater-than-sign I not- less
1 . SE #N: POINTER BEGIN, IF MISSING THN EIT D
SET #3 : RECORD N+l , IF MISSING T 1200
SET #4: KY "Jones" , IF T T EIT D
11 . 2 . 4 Semntics
Execution of a set- statement with pointer- items shal l set the pointer for the file
assigned to the specified channel . After the pointer has been set, an optional io
recovery my take effect . The semantics associated 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
control . A device may not be able to achieve the effect of a record-setter . The ask
statement my be used to determine whether a device has record-setter capability.
Record-setters
BASIC- 1
A absent record-setter leaves the file pointer unchanged from its previous
state . The io-recovery ( see below) , if present, stil l has its usual effect.
A record-setter of N indicates that the pointer is to be set to the next
record ( for SEQUTIAL files ) or value ( for STREAM files) at or beyond the cur
rent location. For a SEQUENTIAL fil e, the only case in which N would have
some effect is if there were a partial record pending ( see 11 . 3 ) . In this case,
an end-of-record shall be generated and the pointer left at end of file.
- 109 -
BASIC-2
A absent record- setter leaves the file pointer uchanged from its previous
state . The io-recovery ( see below) , if present, still has its usual effect .
A record-setter of N indicates that the pointer is to be set to the next ex
isting record ( for non-STREAM files) or value ( for STREAM files) at or beyond
the current location. In the case of a RELATIVE file, N shall therefore cause
the pointer to skip over any empty record areas to the next existing record . If
the pointer is already at or beyond the end of file, or is pointing to an exist
ing record, N shall leave the pointer unchanged . This capability allows
RELATIVE fi les to be processed as if they were SEQUENTIAL. In the case of STREAM
and KEYED f iles , the pointer is always pointing to an existing file element or
end of file and so is left unchanged . For a SEQUENTIA file, the only case in
which N would have some effect is if there were a partial record pending ( see
Section 11. 3 ) . In this case, an end-of-record shall be generated and the pointer
left at end of file.
A record-setter of BEGIN causes the pointer to be set to the beginning of file , i . e . ,
to the first file element . If the file is empty, the location is also the end of
file .
A record-setter of END causes the pointer to be set to end of file, defined as ime
diately beyond the last file element ( if any) in the case of SEQUENTIAL, STREAM, and
KEYED fi les , and as imediately beyond the last existing record in the case of a
RELATIVE file ( or at record-area number 1, if no records exist) .
A record- setter of SAM al lows the user to access the same fi le-element( s ) that have
most recently been processed since the OPEN for that channel . Its use is val id only
if the most recently executed record operation which accessed the channel meets these
conditions : it was not a delete-statement, and no exception occurred during its
execution at least until after the file pointer had been set .
If these conditions are not met, no pointer manipulation takes place and an exception
results . If they are met and the most recent operation was a R, INPUT, SET with
pointer- items , or REWRITE, then the file pointer is reset to the same file element it
was just set to by the record-setter of that operation. If this operation had no
record-setter, then SAM resets the pointer to the same location it had at the
beginning of that operation. If the most recent operation was a WRITE or PRINT, then
SAM sets the pointer to the first f ile element created by that operation.
A record- setter with RECORD is val id only for use with RELATIVE fi les . If an attempt
is made to use this record-setter on a file not opened as RELATIVE, the pointer is
left uchanged and an exception results . The index is evaluated by rounding to an
integer, and the pointer set to the corresponding 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 valid only for use with a KYE file . If an attempt is
made to use this record-setter on a file 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-expression; if none such exists , the
pointer is set to the f irst record whose key is greater t the ring-expression. If
there is no such record , the pointer is set to end of file . 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 condition ( see below) . For an inexact-search with greater
than-sign, the pointer is set to the first record whose key is strictly greater than
the string-expression; if none exists , it is set to end of file.
- l lO -
Io-recovery
At the completion of pointer manipulation there shal l be set a condition cal led data
found, which is either true or false . If data-found is true, and if a not-missing
recovery has been specified , then the io-recovery-action takes effect . If the data
found condition is false and a missing-recovery has been specified , then the io
recovery-action also takes effect. 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 specified , but no record was found whose
key was equal to the string-expression, or
- after the pointer is set, it points to end of file, or
- in BASIC-2 only, after the pointer is set, it points to an empty record-area, or
- for a device , there is an implementation-defined condition signifying that no data
is avai lable for input; otherwise, the data-found condition is true .
If the io-recovery-action is an exit-do-statement or exit-for-statement, the
statement shal l have its normal effect ( see 8 . 3 ) . If the io-recovery-action is a
line-number then execution shall continue at the specified l ine .
11 . 2 . 5 Exceptions
- A set-statement with pointer- items is executed for an inactive channel ( 7 004,
fatal ) .
- A record-setter is used with channel zero ( 7002 , nonfatal : do nothing and
continue) .
A record-setter is used on a device without record-setter capabi lity ( 7 205, nonfa
tal : do nothing and continue) .
- The record-setter SA is used , and the most recently executed operation for the
chanel was a delete-statement ( 7 204 , fatal ) . ( BASIC-2 only)
- The record- setter SAM is used , and the most recently executed operation for the
channel caused an exception before pointer manipulation took place ( 7 204, fatal ) .
- The record-setter SAM is used , and no record operation has been executed on that
channel since the OPEN ( 7 204, fatal ) .
- The record- setter RECORD is used on a file opened with a file-organization other
than REATIVE ( 7 202 , fatal ) . ( BASIC-2 only)
- The record-setter KEY is used on a file opened with a file-organization other than
KEYED ( 7203 , fatal ) . ( BASIC-2 only)
- The index of a RECORD record-setter evaluates to an integer less than one ( 7 206 ,
fatal ) . ( BASIC-2 only)
- A record-setter specifies an exact-search for the nul l string ( 7207 , fatal ) .
( BASIC-2 only)
l l . 2 . 6 Remarks
For devices , data-found could be set false by such conditions as no more cards in a
card reader, control-Z sent from a terminal ( which signifies end-of-file for some
systems ) , or that the device is for output only, e . g . , a line printer.
- 111 -
BASIC-2
Given a RELATIVE file, with three existing records , numbers 2 , 5 , and 6 :
1 2 3 4 5 6 7
RECORD RECORD RECORD
t
pointer
If READ RECORD 2 has just taken place, then the fol lowing record-setters will
have the described effect :
record- setter resulting pointer position in front of
BEGIN 1
E 7
s 2
N 5
absent 3
RECORD n n
11 . 3 File Data Creation
11 . 3 . 1 General Description
Statements are provided to al low the user to send data developed within the program
to an external destination. In the case of true files , such data can be retrieved ad
modified by later programs . The facil ities generalize te output capabil ities pre
sented in Section 10 to files . New facil ities are also defined to al low output to the
various record-types . The set-objects MARGIN or ZONEWIDTH are not part of a data cre
ation statement, but are included in this section because of their interaction with
display records .
11 . 3 . 2 Sytax
BASIC-1 and BASIC-2
1 . print-statement
2 . array-print-statement
3 . print-control
4. print-control-item
5 . set-object
6 . write-statement
7 . array-write-statement
8 . write-control
9 . write-control- item
10 . expression- l ist
l l . array- l ist
> PRINT channel - expression print-control ( colon
( print- l ist I output- l ist) ) ?
> MAT PRINT channel-expression print-control colon
( array-print- l ist I array-output- l ist)
= ( coma print-control -item) "'
core-record-setter I not-missing-recovery I USING
image
> channel -setter ( MARGIN I ZONEIDTH) index
WRITE channel -expression write-control colon
expression- l ist
MAT WRITE channel - expression write-control col on
array- l ist
( coma write-control-item)
)
'c
> record-setter I not-missing-recovery
expression ( coma expression) >'
array-nae ( coma array-name) *
- 112 -
BASIC-2 only ( Enhanced Files productions) :
Nl2 . write-control-item
N13 . template- identifier
Nl4. declarative-statement
Nl5 . template-statement
Nl6 . template-element- l ist
Nl7 . temlate-element
Nl8 . f ixed-field-count
N19 . variable-field-count
N20 . field-specifier
N21 . numeric-specifier
N22 . numeric-field-size
N23 . fixed-point-size
N24 . integer-size
N25 . fraction-size
N26 . string-specifier
N27 . string-field-size
> template- identifier
WITH ( line-number I string-express ion)
> template-statement
TEPLATE colon temlate-element- l ist
template-element ( coma template-element) l
'<
fixed-field-count ( field-specifier I left-parenthesis
template-element- l ist right-parenthesis) I
variable-field-count field-specifier
SKIP? ( integer OF) ?
question-mark OF
numeric-specifier I string-specifier
NRIC asterisk numeric-field-size
fixed-point-size I E
integer-size period? I integer-size? period
fraction-size
integer
integer
STRING asterisk string-field-size
integer
Within a print-statement or array-print-statement, an image must not be used with a
print- l ist, i . e . , only an output- list may be used when an image is present as a
print-control .
The l ine-number of a template- identifier must refer to a template-statement in the
same program-unit . ( BASIC-2 only)
The integer in a fixed-field-count must be greater than zero . ( BASIC-2 only)
In a f ixed-point-size, the integer-size or fraction-size must be greater t
zero . ( BASIC-2 only)
String-field-size must be greater t zero . ( BASIC-2 only)
The record-setter in a write-control must not specify an inexact-search. ( BASIC-2
only)
A given print-control - item must appear at most once in print-control .
A given write-control - item must appear at most once in write-control .
1 1 . 3 . 3 Exales
1 . PRINT #3 : A, B, C
PRINT #3 , END, USING 123 : A$ , B+C;
2 . MAT PRINT #N, SAM, IF T T EIT FOR: A$ , B$ , C
5 . #3 : MARGIN N+1
6 . WRITE 113 , RECORD 4 7 , IF T T 666 : A+B, C$ & D$
WRITE #X+Y WITH TEPLATES3$ : X, Y, Z + W
7 . MAT WRITE 113 , K "Whoever" , IF T T 666 ,
WITH 1 1 1 : A, B$
N15 . TEPLATE: STRINGl'< 5 , 2 OF NICi<3 . 4
TEPLATE : ? OF NUMICi<5 . 2 , ? OF STRINGl'<5
N16 . 5 OF STRING>'<22 , 3 OF NICl
'<E, ? OF NIC>'< . 6
1 1 . 3 . 4 Semtics
All data creation statements fol low a general pattern which wil l be described here.
In all cases , the function of a data creation statement is to add one or more new
fil e el ements to a fil e. Previously existing file elements are not affected . Details
- 113 -
on aspects peculiar 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
expression. The f ile-attributes are checked against the intended operations . All data
creation statements require an access-mode of OUTPUT or OUTIN. If the channel is ac
tive and the file-attributes are compatible with the data creation statement, then
the next phase begins . Otherwise , an exception results and the file, the file
pointer , and all program variables remain unchanged .
The second phase of processing involves setting the file pointer , based on the
record-setter ( or 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-missing-recovery is present , then the io- recovery-action is taken. If data-found
is true, and a not-missing-recovery is absent, then an exception results . In either
case, no furt1er change is made to the pointer position or the file.
If data-found is false, then the third phase begins , the actual output of data at the
location indicated by ti1e pointer . The operands are evaluated in succession from left
to right until enough data to fil l a file-element has been generated . Only then is
the f ile-element actually added to the file and the pointer advanced imediately be
yond the f ile-element just created . In particular, this means that an exception dur
ing data transfer will never result in a partial file-element being added to the
file . However, if a statement can create several fi le-elements , those which have al
ready been created before the exception occurs continue to exist in the file . Fol low
ing ti1e completion of data transfer, the file pointer is always left pointing at the
next fi le-element ( or end of file if none such exists ) beyond the last one created .
If an exception prevented the creation of any file 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
DISPLY file, rather ti1an current line, and end-of-record is generated in place of
end-of - l ine . Note that it is possible to create records containing zero characters .
End-of-record is the implementation-defined means whereby it is indicated that the
storage of a file-element in a file is completed , i . e . , no chage or addition to this
record is possible with a data creation statement . Except for the special case dis
cussed below, no data is actually added to the file until a valid end-of-record has
been generated , i . e . , partial records are not added to the fil e. The effective margin
for t1e file, which is used to control when end-of-record is generated , is taken from
the value of RCSIZE established when the file was opened , or from a set-statement
with MGIN for this channel executed since the open ( see below) .
In one special case , a partial record is added to a file. If the print- list or
output- list contains a trailing print- separator, then upon successful completion of
the statement , a partial record has been created at the end of file , with the pointer
left at end of file, i . e . just beyond the partial record . Note that if there is an
exception before completion of the statement, then the partial record is not added to
the file, as would also be true of a complete 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 place, an end-of-record is added to complete the partial record , and the
pointer left at end of file .
- 114 -
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
file, rather than the current l ine, and end-of-record is generated in place of end
of - line . Note that by the rules of 10 . 5 , a partial record is never created by the
array-print-statement with an array-print- l ist, but my be created with an array
output- list containing a trai ling semicolon. Since a array-print-statement always
starts a new line, it may not be used to complete a partial record . The effective
margin is controlled as described under print-statement and "Setting the margin"
( below) .
Setting the mrgin
Associated with each open DISPLAY file . 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 implementation-defined length,
which must be not less than the default zone width, if LENGTH is not specified ex
pl icitly. The set-statement with a MARGIN changes the mrgin for the active channel
to the specified index . If a partial record exists in the file affected by the mar
gin, te new margin is used when subsequently attempting to complete the partial
record . A mrgin of M indicates that a record may be arbitrarily large . The mar
gin index must evaluate to greater than zero . The effect of a set-statement with
MARGIN ends when the file is closed .
The mximum margin supported is implementation-defined .
Setting the zone width
Associated with each open DISPLAY file is a zone width, which controls the effect of
PRIN as described in 10 . 3 . Upon open, the zone widt for a file is set to te
implementation-defined default value, which shall be at least d+e+6 . The set
statement with ZONIDTH changes the zone width for the active channel to the
specified index .
Al l zones are the same width, except possibly the last, which my be shorter . If a
partial record exists in the file affected by the set-statement with ZONEIDTH, the
new zone width is used when subsequently attempting to complete the partial record .
In a set-statement with ZONEWIDTH the index must evaluate to greater t zero . The
effect of the set-statement with ZONIDTH ends when the file is closed .
The maximum zone width is implementation-defined .
Display record-tye
DISPLAY records are sequences of chracters ; the characters generated by the PRINT
operations are as described in Section 10 . The accuracy of numeric values is l imited
only by the implementation-defined significance-width or lengt of the formt- item,
and by the
A
RITHIC option in effect .
Channel zero
PRINT to channel zero works in accordance with the semntics for a device without
record-setter or erase capability. The destination of the output data is the same as
if the channel-expression had been omitted . Also, if there is an exception for which
a different recovery procedure is specified in Section 10 than in 1 1 , the procedure
of Section 10 shall be used . A set-statement with MARGIN or ZONEWIDTH specifying
channel zero has the same effect as if the channel-setter were omitted .
- 115 -
Write operation
The write-statement and array-write-statement are used to create records of any type.
Successive expression values are arranged in corresponding sequences of values or
fields or characters , and written out to the fil e. Partial records are never created .
File organization
For STREAM fi les , one statement may create several file-elements , specifical ly one
file-element is created for each expression or array-element evaluated . If an excep
tion occurs during internal evaluation, previously created values remin in the file,
the pointer is left at end of file, and any remaining values are ignored .
For INTERNAL SEQUTIAL or NATIVE files , the values or fields generated by te ex
pressions or arrays form one record . Thus , if an exception occurs before the state
ment is completed , no record is added to the file , and the file pointer is left un
changed from phase two . NATIVE files apply only to BASIC- 2 .
BASIC-2 only
Since records in a KEYE file are identified by their keys , it is necessary when
creating a new record that an expl icit key be associated with it; thus when at
tempting to write to a KEYED file, an exact-search must always be specified in
the record- setter . If data-found is false, then a new record is inserted into
the file, with a key equal to the string-expression of the exact-search.
Display record-tye
A WRITE operation type on a display record generates exactly the same sequence of
records and characters as would a PRINT operation with the same expression- l ist or
array- l ist . Note, however, tht not al l PRINT facilities are available for WRITE,
which is record-oriented , rather t l ine-oriented .
For DISPLAY files , one statement may create several file-elements in the case of mr
gin overflow. If a fatal exception occurs during generation of an element, any
elements previously created by that statement remain in the file, the pointer is left
at the end of the file, and any remining expressions are ignored .
Internal record-tye
A internal record ( of a STREAM file) is a sequence of values . There are two types of
values , numeric and string. The sequence of values and their types are determined by
the sequence and types of the expressions and array-elements from which the values
are generated . When a value stored in a file is later retrieved , the effect is as if
the expression or array-element with which it was created were assigned 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 limitations on precision
associated with the prevai l ing ARITHTIC option.
Native record-tye ( BASIC-2 only)
The TEPLATE describes the location, size, and type of fields within a record . When
writing to a native file, a TEPLATE must always be used . It must not be used with
any other record-type . A TEPLATE is associated with a particular data creation
statement by means of the template- identifier in the statement which specifies the
template-statement to be used or a string-expression whose value must be a syntacti
cally correct template-element- l ist . The string-expression, is evaluated before the
expression- l ist or array- l ist of the write-statement or array-write-statement.
Several statements may use the same template-statement.
When generating data for a native record , each expression within the expression- l ist
is associated with a numeric-specifier or string-specifier within a TEPLATE; the
specifier is then used to transfor the value of the expression into a field within a
- 1 16 -
record . The association takes place from left to right within the expression-list and
te templates-element- l ist, each expression using the next available field-specifier .
If the type of the expression ( numeric or string ) disagrees with the type of the
specifier, an exception results . The number of expressions must not be greater t
the number of specifiers . Extra specifiers beyond the last expression are ignored .
The contents of the field are determined by the value of the expression and the size
characteristics of the specifier.
For string values , the string-field-size is 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 field is padded on the right
with spaces .
Numeric f ields are used to retain numeric values ( both magnitude and sign) . The sign
is always stored in the field , but the nueric-field-size expl icitly describes only
the storage of the number ' s magnitude . For a numeric-field-size of E, the value is
retained with the implementation-defined number of significant digits for the pre
vai l ing ARITTIC option. For a fixed-point-size, the integer-size describes the
number of available digit places to the left of the decimal point, and the fraction
size, to the right of the deciml point . A omitted integer- size or fraction-size is
treated as equivalent to zero . The numeric value is stored in accordance with these
sizes . If the value contains significant digits to the right of the available field
positions , the value is rounded when stored . This my result in a field with a value
of zero . If the value contains significm1t digits to the left of the avai lable field
pos itions , an exception results .
The fixed-field-count in a template-statement indicates skipping and/or repetition
for individual specifiers or a series of specifiers . The integer of the fixed-field
count indicates the number of repetitions and the keyword SKIP indicates that the af
fected specifiers shall generate skipped fields . A field-count appl ies to the entity
( either a f ield-specifier or a parenthesized template-element- l ist) in the same
template-element . For an integer field-count ( indicating repetition) the effect is
just as if the entity governed by the field-count had been written out expl icitly the
equivalent number of times . When SKIP is used within a field-count, it indicates that
the specifiers governed by it are not associated with values from the expression- list
or array- list . Ratl1er, as the record is being generated, fields within the record are
assigned the value zero if numeric and spaces if string, corresponding to the usual
size and type of the field-specifier in question. If a field-specifier is governed by
several SKIPs ( from various levels above it) the effect is just as if it were gov
erned by only one, as described above . For example, given the fol lowing expression
l ists and templates-element- l ists ,
A, B, C and NRIC>'<4, NURIC>'< S, NURIC>'
<6
D, E and NURIC>'<4, SKIP NIC>'c s, NUIC>
'
<6
A and D will occupy equivalent field locations, as wi ll C and E. The second field in
the second record wil l be the same size as occupied by B in the first record, with a
value of zero .
As an i l lustration of the preceding description, equivalent pairs of template
element- l ists are shown below:
1 - STRING>'<4, STRING>'
<4 , STRING>'<4
2 - 3 OF STRING'<4
1 - STRING>'<S , STRING>'<4, NUERIC'2 , NURIC>
'<2 , NURIC>'<2 , STRING>'<4, NURIC>'<2 ,
NUIC>'<2 , NURIC>
'
<2
2 - STRING>S , 2 OF ( STRIN<4, 3 OF NURIC>'<2 )
- 117 -
1 - SKIP NI0''3 , SKIP NURIC>': 3, NURIC>': 4, SKIP STRING>'c s , SKIP STRING>6
2 - SKIP 2 OF NURIC>': 3 , NUIC>'c4, SKIP ( STRING>'cs , SKIP STRING''' 6)
Note that in 2 of the last examl e, the SKIP imediately in front of STRING>':6 is su
perfluous . A variable-field-count is used only in conjunction with arrays ( see
below) .
If execution reaches a template-statement , it proceeds to the next l ine with no fur
ther effect .
Array-write-statement
A array-write-statement behaves just like the write-statement would if the arrays
were written out expl icitly as array-elements in row major order ( the last subscript
varying most rapidly) . Thus , for exampl e, if "DIMA ( 3 ) , B( 2 , 2 ) " and OPTION BASE 1 are
in effect, the fol lowing two statements are equivalent:
MAT WRITE tt3 : A , B
WRITE #3 : A( l ) , A( 2 ) , A( 3 ) , B( l , l ) , B( 1 , 2 ) , B( 2 , 1 ) , B( 2 , 2 )
X. 7
BASIC-2 only
When writing to a NATIVE record , arrays in an array- list can use the variable
field-count . If a fixed-field-count is used , then the number and type of the
specifiers must match the array-elements as with WRITE . When the first element
of an array is to be associated with a field-specifier, and if a template
element has just been completed ( or if this is the first array in the l ist) , and
if the next template-element has a variable-field-count, then the field
specifier is used for all the elements of the array. When evaluation of the
array is complete, the next array, if any, uses the next template-element which
may or may not also have a variable-field-count . A array must use either a
template-element with a variable-field-count or template-elements with fixed
field-counts , but not both.
1 1 . 3 . 5 Exceptions
- The value of the index in a set-statement with MARGIN is less t the current
zonewidth for tat file ( 4006 , fatal ) .
- The value of the index in a set-statement with a ZONEWIDT is less than one , or
reater than the current margin for that fi le ( 4007 , fatal ) .
- A set-statement with MARGIN or ZONEWIDTH specifies an inactive channel ( 7004,
fatal ) .
- A set-statement with MARGIN or ZONEWIDTH specifies a file not opened as DISPLAY
( 7 312, fatal ) .
- A set-statement with a MARGIN or ZONEWIDTH specifies a file opened as INPUT ( 7 313 ,
fatal ) .
The following exceptions for data creation statements are grouped according to the
phase of processing during which they are detected . Phase 1 exceptions imply no
change to the fil e or file pointer . Phase 2 exceptions imply no change to the file .
Phase 3 exceptions imply tt some file-elements may have been created .
Phase 1 Exceptions :
- A data creation statement attempts to access an inactive channel ( 7004, fatal ) .
- A print-statement or array-print-statement attempts to access a file opened as
INTNAL or, for BASIC-2 only, NATIVE ( 73 1 7 , fatal ) .
- 118 -
The record-setter cannot be processed correctly, as described in 11 . 2 . 5 , exceptions
7002 and 7 202- 7 207 ( use the procedure of 11 . 2 . 5 ) .
- A data creation statement attempts to access a file opened as INPUT ( 7 302 , fatal ) .
- A write-statement or array-write-statement attemts to access a KEYED file, but
does not specify an exact-search in its record-setter ( 7 3 14, fatal ) . ( BASIC-2
only)
- The string-expression of a template-identifier is not a syntactical ly correct
template-element- l ist ( 825 1 , fatal ) . ( BASIC-2 only)
- A template- identifier is used on a file opened as DISPLAY or INTENA ( 7 3 1 5 ,
fatal ) . ( BASIC- 2 only)
- A write-statement or array-write-statement does not have a template- identif ier when
attempting to access a file opened as NATIVE ( 7 316, fatal ) . ( BASIC-2 only)
Phase 2 Exceptions :
- For a data creation statement, the condition data-found is true, and a not-missing
recovery has not been specified ( 7 308, fatal ) .
Phase 3 Exceptions :
- A attempt is made to create a record larger than the value of RECSIZE ( 8301 ,
fatal ) .
- A expression or array-element does not agree in type ( numeric or string) with its
associated TEPLATE field-specifier ( 8252 , fatal) . ( BASIC-2 only)
- A template-element with a variable-field-count does not coincide with te first el
ement of an array ( 8253 , fatal ) . ( BASIC-2 only)
- There are not enough field-specifiers in a template-statement for all the
expressions or array-elements (8254, fatal ) . ( BASIC-2 only)
- A numeric value has significant digits to the left of the available digit places in
the f ield of a template ( 825 5 , fatal ) . ( BASIC-2 only)
- A string value is longer than the length of its f ield in the temp late ( 8256 ,
fatal ) . ( BASIC-2 only)
11 . 3 . 6 RLks ( BASIC-2 only)
Implementations may provide syntactic enhancements to template-element- list, e . g . , to
al low for additional data types . The exception for incorrect syntax then appl ies to
the enhanced definition of template-element-list.
The variable-field-count is especial ly useful when writing an array whose size may
change in the program, since the use of the fixed-field-count impl ies knowing the ex
act size in advance .
1 1 . 4 File Data Retrieval
11 . 4 . 1 General Description
Statements are provided to al low the program to retrieve data from a file to which it
has previously been written or from a device . The facilities general ize the input ca
pabilities presented in Section 10 to files . New facilities are also defined to allow
input from the various record-types .
11 . 4 . 2 Sytax
BASIC-1 and BASIC-2
1. input-statement
2 . array- input-statement
3 . l ine- input-statement
- 119 -
> INPUT channel - expression input-control colon
variable- l ist ( coma SKIP REST) ?
> MAT INPUT channel -expression input-control colon
( redim-array- l ist I variable- length-vector)
> LINE INPUT channel-expression input-control colon
string-variable- l ist
4. array- line- input-statement> MAT LINE INPUT channel-expression input-control colon
5 . input- control
6 . input-control -item
7 . read- statement
8 . array-read-statement
9 . read-control
10 . read- control - item
redim-string-array- l ist
( coma input-control -item) )'(
core-record-setter I missing-recovery I
prompt-specifier I timeout-expression I
time- inquiry
> R channel - express ion read-control colon
variable- l ist ( coma SKIP REST) ?
> MAT R channel -expression read-control colon
redim-array- list
( coma read-control -item)
)
> record- setter I missing- recovery
BASIC-2 only ( Enhanced Files productions ) :
Nl l. read-control - item > template- identifier
A given input-control - item must appear at most once in input-control . ( BASIC-2 only)
A given read-control- item must appear at most once in read-control . ( BASIC-2 only)
A variable- length-vector must be declared as one-dimensional . ( BASIC-2 only)
11 . 4 . 3 Exales
1 . INPUT #3 : A, B, C, A$
2 . MAT INPUT #W, BEGIN, IF MISSING T EIT D: A, B$
3 . LINE INPUT #G, N: A$ , B$ , C$
MAT LINE INPUT #4, IF MISSING T 123 4: A$ , B$( N) , C$( 8)
4. MAT LINE INPUT #4, I F MISSING T 123 4: A$ , B$( N) , C$( 8)
7 . R #3 , SAM, WITH 3 3 3 : W$ , SKIP REST
8 . MAT R #N, RECOR W+2 , IF MISSING T 111, WITH 222 : N, W( Q)
11 . 4 . 4 . Setics
All data retrieval statements fol low a general pattern, which will be described here .
Details on the aspects peculiar to each of the various forms are presented below, un
der the headings for each statement type.
First, the channel from which data will be retrieved is determined from the channel
expression. Then, the file-attributes are checked against the intended operation . Al l
data retrieval statements require an access-mode of INPUT or OUTIN . If the channel is
active and the fi le-attributes are compatible with the data retrieval statement, then
the next phase begins . Otherise, an exception results and the pointer and al l pro
gram variables remain unchanged .
The second phase of processing involves setting the file pointer, based on the
record-setter if present . In the absence of a record-setter the file pointer does not
change . 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 false and a missing-recovery is
present, then the io-recovery-action is taken, otherwise an exception results . In ei
ther case, no further change is mde to the pointer position.
- 120 -
If data-foud is true, then the third phase begins , te actual input of data from the
element 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 te file being assiged to successive variables or arrays .
Note in paticular that evaluation of subscripts , substring-qualifiers , and redims is
delayed until after assigment of data to previous operands , but occurs before as
sigment 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 tes place i accor
dance with the usual s<tics of string ass igment described in 6 . 5 . If an exception
occurs during data transfer, variables and array-elements for which a legal assig
ment has been mde retain their new values , but all subsequent variables and array
elements retain their original values . Following a successful 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 usually affects only one file element. Te three cases
in which several file elements my be processed ae:
- LINE or M LINE INPUT,
- R from a STREA file, and
- INPUT or R from a DISPLAY file with records wit trailing co ( indicating
continution of data) .
Te SKIP RST 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 igored . It is
sti l l mdatory that the record contain enough data to satisfy the variables or
arrays i the list.
During this third phse of processing, a nuber of exception conditions my arise .
Each such exception is associated with a particular file element. In all cases , the
pointer is advaced to the file element imediately following te one with which the
exception is associated . Te following table sizes tese exceptions ad which
file-element they apply to .
Exception
File-element lager t RECSIZ
Invalid redim, subscript,
substring-qulifier, redim too
large.
Bad TL: wrong type ,
field-count of "? " on other
t first element of an array,
too few specifiers (BASIC-2 only)
Bad data: wrong type, syntax,
overflow
Insufficient data in file-element
Insuficient data in file
Excess data in file-element
Associated file-element
Te oversize file-element
Te file-element from which
data would have been taken
Te file-element from which
data would have been taken
File-element containing the
bad data
Te file-element with
insufficient data
End of file ( i . e . no associated
file-element)
The file-element with excess
data
- 121 -
Input-statement
The effect of a prompt-specifier, timeout-expression, and time-enquiry is as de
scribed in 10 . 2 . These input-control- items apply only to interactive terminal
devices . For other devices and true files , their effect is implementation-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- replies , and end-of-record i s treated like
end-of- l ine . Each datum ( as defined in 10 . 1) is assigned in order to a variable in
the variable- list . All the INPUT operations ( as opposed to the R operations) are
val id only for a file opened as DISPLAY . For any other record-type, an exception re
sults . The input-statement may process several records if the last non-blank charac
ter in a record is a coma. I f, following a record with a trail ing coma, end of file
is encountered before al l variables have been assigned values , then the remaining
variables shall retain their old values , the file pointer shall be positioned to end
of file, and an exception shall result.
When any of te INPUT statements is executed for a device and a phase 3 exception oc
curs , implementations may use the recovery procedures specified for true files in
this section, or, if an equivalent exception is specified 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-statement
The array- input- statement behaves just like the input-statement would if the arrays
were written out expl ic itly as array-elements in row maj or order ( the last subscript
varying most rapidly) . The only additional capabi lity is that of allowing a redim to
change the d imensions of the array in accordance with the redim rules for the array
input- statement without a chanel-express ion ( see 10 . 5 ) . Thus , for exaple, if "DIM
A( 3 ) 1 1 and OPTION BASE 1 are in effect, the following two statements are equivalent :
MT INPUT liN : A
INPUT #N: A( l ) , A( 2 ) , A( 3 )
The following two statements are also equivalent :
MT INPUT #N: A$( 2 , 2 ) , C( 2 )
INPUT #N: A$( 1 , 1 ) , A$( 1 , 2 ) , A$( 2 , 1) , A$ ( 2 , 2 ) , C( l ) , C( 2 )
However, the effect of
MT INPUT #N : A( 1) , B( A( l ) )
depends on the first datum encountered , s ince i t controls the effective size o f array
B. Nonetheless, 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 size less than 1 in any dimension, then it, and all subsequent
arrays , shal l retain their old values , and an exception shall result.
Variable- length-vectors
The transfer of data and consequent redimensioning 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 like input- repl ies , and end-of-record like end-of- l ine . The content of
each successive record is assigned as the value of successive string-variables , in
cluding any leading or trai ling spaces . A record may contain a nul l string, and it
- 122 -
shal l be assigned in the normal way. If end of file is encountered before all vari
ables have been assigned values , then the remaining variables shal l retain their old
values , the file pointer shall be positioned to end of file, and an exception shall
result .
Array- line-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 expl icitly, 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 assigned to an earl ier array, e . g . :
MAT LINE INPUT #N : A$( 1 ) , B$ ( VAL( A$ ( 1) ) )
If the first 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 yields a size less
than 1 in either dimension, then it, and all subsequent arrays , shall retain their
old values, and an exception results .
Input-statements for chanel zero
Input from channel zero works in accordance with the semantics for non-file devices .
For those exceptions for which a different recovery procedure is specified in Section
10 than in 11, the procedure of Section 10 shall be used .
Read-operation
The read-statement and array-read-statement are used to retrieve data from files with
records of any type . Successive data or values or fields are assigned to successive
variables or arrays in the operand list . READ may access several file elements for
SEQUENTIAL or STREAM files , but only one for RELATIVE and KEYED files . RELATIVE or
KEYED fi les are provided only in BASIC- 2.
File organizations
For non-STREAM fi les ( SEQUETIAL files in BASIC- 1 and RELATIVE and KEYED files 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 t
h
e
case of DISPLAY records with trailing comas ) to satisfy the variable- l ist ( except
for SKIP REST, see above) . For STREAM files , the variables receive their values di
rectly from the sequence that constitutes the file, beginning with the f ile-element
indicated by the pointer, and so file-element boundaries are insignificant . If end of
file is encountered before al l variables have been assigned values , then the remain
ing variables shall retain their old values , the file pointer shal l be positioned to
end of file, and an exception shall result .
Display record-tye
Records in DISPLAY fi les are sequences of characters . The retrieval of string data
shall take place as described in 10 . 2 . Note that retrieving data from a record cre
ated with PRINT does not necessarily preserve the same value , since , for instance ,
leading and trail ing spaces are not saved in unquoted strings n input. For nueric
data, the accuracy shall be consistent with the usual semtics for assignent of a
numeric-constant to a numeric-variable, i . e . at least six significant digits for
OPTION ARITHTIC NATIVE and at least ten digits for OPTION ARITHTIC DECIMAL . For a
numeric-constant with no more significant digits than the imlementation-defined pre
cision, the exact value is assigned with OPTION ARITHTIC DECIMAL.
A READ operation on a DISPLAY record assigns values exactly as would an INPUT opera
tion with the same variable- l ist or redim-array- l ist. Note, however, that not all the
INPUT facil ities are available for RE wl1ich is record-oriented .
- 123 -
Interl record-tye
A interal record ( and a stream file) is a sequence of values . There are two types
of value, numeric and string . For INTENAL fi le elements , the values must be re
trieved with a variable of the same type as that of the value , otherwise an exception
results . Thus , the contents of an INTERNAL fi le element are self-typed . The sequence
of values and their types are determined by the record operation which created or
modified the file-element( s ) . When a value is retrieved, the effect is as if the ex
pression with which it was created were assigned 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 precision and type associ
ated with the prevailing ARITHTIC option.
Native record-tye (BASIC-2 only)
The TEPLATE describes the location and type of fields within the record . When read
ing from a native record, a TEPLATE must always be used . It must not be used with
any other record-type. A TEPLATE is associated with a particular data retrieval
statement by means of the template-identifier in the statement, which specifies the
template-statement to be used , or a string-expression whose value must be a syntacti
cally correct template-element- l ist. The string-expression is evaluated before any
input takes place and before any redims , substring qualifiers , or subscripts are
evaluated . Several statements may use the same template-statement.
When retrieving data from a native record , each variable within the variable- list is
associated with a field-specifier within a template; the specifier is then used to
return data from a f ield within a record . This association taes place from left to
right, within the variable- list and template-element- l ist, each variable using the
next available field-specifier . A variable is associated with a specifier after a
value has been assigned to the previous variable, and any subscripts , substring
qualifiers , or redims for this variable have been evaluated . If te type of the vari
able ( numeric or string) disagrees with the type of the specifier, an exception re
sults . The number of specifiers must not be less t the number of variables . Extra
specifiers beyond the variables are ignored . The contents of the next field in the
record is interpreted according to the specifier , and the resulting value placed in
the variabl e.
When retrieving data, the specifiers of al l fields within a record must be compatible
with the specifiers with which they were created , otherwise the results are
implementation-defined . In order to be compatible, the creating and retrieving speci
fiers for a field must both be of type STRING, with equl string-field-sizes , or both
NURIC with a numeric-field-size of E, or both NUIC wit equal integer-sizes and
fraction-sizes . A omitted integer-size or fraction- size is treated as equivalent to
zero .
\fuen the TEMPLATE specifiers are compatible with the record , then the values are re
trieved in accordance with the field sizes . For strings , a value is assigned with
length equal to the string-field-size, and contents as originally stored in the
record , including any spaces used for padding . For numbers , a value is assigned whose
accuracy is l imited only by the numeric-field-size and ARITHIC option. For numbers
stored with a field size of E, or with a fixed-point-size and with no more signifi
cant digits thn the implementation-defined precision, the exact value is retained
under OPTION ARITHTIC DECIMAL. Otherwise, the numbers are rounded according to the
OPTION in effect and stored in the variable . Section 11 . 3 . 4 describes how values are
stored in the fields of native records an the effect of field-counts . The only dif
ference upon retrieval is that SKIP specifiers do not generate fields of zero or
spaces , but cause the affected f ields simply to be skipped over . As before, such
specifiers are not associated with variables .
- 124 -
Array-read- statement
In general , an array-read-statement behaves just l ike the read-statement would if the
arrays were written out expl icitly as array-elements . As with INPU, there is delayed
evaluation of redims .
BASIC-2 only
For this reason, when reading from a native record , a variable-field-count is
provided . If a fixed-field-count is used , then the number and types of the
specifiers must mtch the array-elements , as with R. When the first element
of an array is to be associated with the next specifier, however, and if a
template-el ement has just been completed ( or if this is the first array in the
l ist) , and the next template-element is a variable-field-count, then the associ
ated specifier is used for al l the elements of the array. When the array has
been filled , the next array, if any, uses the next template-element, which may
or may not also have a variable-field-count. A array must either use a
template-element with a variable-field-count or template-elements with fixed
field-counts , but not both.
11 . 4 . 5 Exceptions
The exceptions are grouped according to the phase of processing during which they are
detected . Phase 1 exceptions imply no change to the file pointer or variables . Phase
2 exceptions imply no change to the variables . Phase 3 exceptions imply that some
variables may have received values from the file .
Phase 1 Exceptions :
- A data retrieval attempts to access an inactive channel ( 7004, fatal ) .
- A input-statement, array- input- statement, l ine- input-statement, or array- l ine
input-statement attempts to access a file opened as INTENA or, in BASIC-2 only,
NATIVE ( 7 3 18 , fatal ) .
The record-setter cannot be processed correctly, as described in 11 . 2 . 5 , exceptions
7002 and 7202- 7207 ( use the procedure of 11 . 2 . 5 ) .
- A data retrieval statement attempts to access a file opened as OUTPUT ( 7 303 ,
fatal ) .
The string-expression of a temp late- identifier is not a syntactical ly correct
template-element- l ist ( 8251, fatal ) . ( BASIC- 2 only)
- A template- identifier is used on a file opened as DISPLAY or INTENAL ( 7 315,
fatal ) . ( BASIC-2 only)
- A read- statement or array-read-statement does not have a template-identifier when
attempting to access a file opened as NATIVE ( 7 316, fatal) . ( BASIC-2 only)
- The SKIP REST option is used on a file opened as STR ( 7321, fatal ) .
Phase 2 Exceptions :
For a data retrieval statement, the condition data-found is false and a missing
recovery has not been specified ( 7 305 , fatal ) .
Phase 3 Exceptions :
- A attempt is made to access a record l arger than the value of RECSIZE ( 8302 ,
fatal ) .
- The first index in a redim-bounds is greater t the second ( 6005 , fatal ) .
- A singl e index used in redim bounds is less t the default lower bound in effect
for the program unit ( 6005 , fatal ) .
- 125 -
- The total number of elements required for a redimensioned array exceeds the number
of elements reserved by the array' s original dimensions ( 5001 , fatal ) .
- A variable or array-element does not agree in type ( numeric or string) with its as
sociated TLATE specifier ( 8252 , fatal ) . ( BASIC-2 only)
- A variable-field-count in a template-element does not coincide with the first ele
ment of an array ( 8253 , fatal ) . ( BASIC-2 only)
- There are not enough TLATE specifiers for al l the variables or array-elements
( 8254, fatal ) . ( BASIC-2 only)
- A data retrieval statement, other t 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-reply ( 8105 , fatal ) .
The datum of a DISPLAY record to be assigned to a numeric variable is not a
numeric-constant ( 8101, fatal ) .
A value in an INAL record does not agree in type ( numeric or string) with the
variable to which it is to be assigned ( 8120, fatal ) .
A value, datum, or field ( for BASIC-2 only) in a file causes numeric overflow upon
assignment to the variabl e ( 1008, fatal ) .
A value, datum, or field ( for BASIC-2 only) in a file causes string overflow upon
assignment to a variable ( 1105 , fatal ) .
- There are not enough data, values , or fields ( for BASIC-2 only) within a record of
a non-ST file for the operands of a data retrieval statement and the record is
not DISPLAY with a trailing com ( 8012 , fatal ) .
- End of file is encountered while seeking further data for the operands of a data of
a data retrieval statement ( 8011 , fatal ) .
- There are too mny 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 trailing com to satisfy a
request for input, and SKIP REST is not specified ( 8013 , fatal ) .
11 . 4 . 6 Remrks
Implementations may choose to treat underflows as exceptions ( 1508, nonfatal : supply
zero and continue) . In BASIC-2, this permits interception by exception handlers .
1 1 . 5 File Data Modification (BASIC-2 only)
1 1 . 5 . 1 Gneral Description
Statements are provided to al low the user to modify data previously stored in a file .
Such data can either be changed or deleted . The modifications are always done at the
record level .
l l . 5 . 2 Sytax
Core productions
None.
- 126 -
BASIC- 2 only ( Enhanced Files productions) :
1 . imperative-statement > rewrite-statement I array-rewrite-statement I
delete-statement
2 . rewrite-statement RERITE channel - expression rewrite-control colon
expression- list
3 . array-rewrite-statement MAT RERITE channel -expression rewrite-control colon
array- list
4 . rewrite-control ( com rewrite-control - item) '
5 . rewrite-control - item > missing-recovery I record-setter
6 . delete-statement DEETE channel -expression delete-control
7 . delete-control ( com del ete-control - item) )'<
8 . delete-control - item missing-recovery I record-setter
N9 . rewrite-control - item > template-identifier
The l ine-number of a template-identifier must refer to a template-statement in the
same program-unit.
A given rewrite-control -item must appear at most once in rewrite-control .
A given delete-control - item must appear at most once in delete-control .
11 . 5 . 3 Exales
2 . RERITE #N, KEY = B$ , IF MISSING T 666 : A, B, C$
3 . MAT REWRITE 113 , RECORD N- 1 , WITH 111 : X, Y, Z
6 . DELETE 113 , KY "JONES"
11 . 5 . 4 Semntics
The data modification statements are modeled closely 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 file . The data modification statements are specified only for file
organizations RELATIVE and KEYED . For other file-organizations , their effect is
implementation-defined . The data modification statements may be used only with
access-mode OUTIN. Except for access-mode, te first and second phase of processing
( i . e . checking of file attributes and setting the file pointer) for these statements
is exactly like that for the data retrieval statements ( see 11 . 4 . 4) , because they op
erate on existing records . The third phase of processing, undertaken only if the op
eration is legal , the file 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 template- identifier, if any ( see 11 . 3 . 4 ) , with one exception : for a
NATIVE record , fields govered by SKIP are not fil led with zero or spaces , but rather
the previous contents of the fields are left unchanged . This effect of SKIP occurs
only if the TEPLATE used by the REWRITE is compatible with TELATE last used to al
ter the record ( see 11 . 4 . 4 for the definition of "comatible" ) . The result of using
an incompatible TEPLATE containing SKIP is implementation-defined . The use of a in
compatible TEPLATE without SKIP is defined above since the entire record is re
placed .
If no exceptions occur during the generation of data to be used for modification of
existing data, then the record pointed to by the file pointer is replaced by the
record just generated , and the file pointer advanced to the next file-element . This
- 127 -
impl ies that the identifying record-number in a REATIVE file, or identifying key in
a KEYE file is not changed . If there is an exception, the pointer is left as it was
set in the second phase ( see 11 . 3 . 4 and 11 . 4 . 4 ) and the data in the file is un
changed .
Array-rewrite-statement
A array-rewrite-statement behaves just like rewrite-statement would if the array
elements were written out expl icitly. The rules for mtching arrays and specifiers in
a TELATE are exactly the same as for the array-write-statement ( see 11 . 3 . 4) .
Delete-statement
The delete-statement causes the record indicated by the file pointer to be deleted,
and the file pointer advanced to the next file-element . This implies that for a
RELATIVE file, the affected record-area no longer contains a record, and for a K
file, the affected record is eliminated from the sequence of records constituting the
file .
11 . 5 . 5 Exceptions
The following exceptions are grouped according to the phase of processing during
which they are detected . Phase 1 exceptions imply no change to the file or file
pointer . Phase 2 exceptions imply no change to the fil e. Phase 3 exceptions also im
ply no change to the file .
Phase 1 Exceptions :
- A data modification statement attempts to access an inactive channel ( 7004, fatal ) .
- A data modification statement attempts to access channel zero ( 7 320, fatal ) .
- The record-setter cannot be processed correctly, as described in 11. 2 . 5 , exceptions
7002 and 7202- 7 207 ( use the procedure of 11 . 2 . 5 ) .
- A data modification statement attempts to access a file opened as INPUT or as
OUTPUT ( 7 322 , fatal ) .
The string-expression of a template- identifier is not a syntactically correct
template-element- list ( 8251, fatal ) .
- A template- identifier is used on a file opened as INTENA or DISPLAY ( 7315 ,
fatal ) .
- A rewrite-statement or array-rewrite-statement does not have a template- identifier
when attempting to access a file opened as NATIVE ( 7 316 , fatal ) .
Phase 2 Exceptions :
- For a data modification statement, the condition data-found is false, and a
missing-recovery has not been specified ( 7305 , fatal ) .
Phase 3 Exceptions :
- A attempt is made to rewrite a record larger than the value of RECSIZE ( 8301,
fatal ) .
A expression or array-element does not agree in type ( numeric or string) with its
associated TEPLATE specifier ( 8252 , fatal ) .
- A temlate-element with a variable-field-count does not coincide with the first el
ement of an array ( 8253 , fatal ) .
- 128 -
Tere are not enough TLT specifiers for al l the expressions or array-elements
( 8254, fatal ) .
A numeric value has significant digits to the left of the available digit p laces in
the field of a template ( 8255, fatal ) .
- A string value is longer t the l ength of its field in the template (8256, fatal )
1 1 . 5 . 6 Remrks
Note that the DE and RIT wil l affect the record indicated by the file
pointer, even if the pointer is set with NE or left as is from previous operation
( i . e . if the record-setter is absent) .
- 129 -
1 2. EXCEPT I ON HANDL I NG AND DEBUGG I NG
- 130 -
12 . ECEPTION HANLING A DEUGGING
12 . 1 Exception Handl ing ( BASIC-2 only)
12 . 1 . 1 General Description
Exception handl ing facilities provide a means of regaining control of a program af
ter an exception has occurred .
12 . 1 . 2 Sytax
BASIC-2 only
1 . protection-block
2 . when-use-block
3 . when- l ine
4 . when-block
5 . use- l ine
6 . exception-handler
7 . end-when- l ine
8 . when-use-name-block
9 . when-use-name- l ine
10 . handler-nae
11. handler-return-statement
12 . exit-handler-statement
13 . cause-statement
14 . exception-type
15 . detached-handler
16 . handler- l ine
17 . end-handler- l ine
18 . numeric-suppl ied-function
19 . string-suppl ied-function
when-use-block I when-use-name-block
when- line when- block use- l ine exception-handler
end-when- l ine
line-number W ECEPTION IN tail
blockl't
l ine-number USE tai l
blockl't
l ine-number E W tai l
when-use-name- l ine when-block end-when- l ine
l ine-number W ECEPTION USE handler-name tail
routine- identifier
RY I CONTINUE
EIT HANDLE
CAUSE ECEPTION exception-type
index
handler- l ine exception-handler end-handler- line
l ine-number HANDLE handler-name tai l
l ine-number EN HANDLE tail
> EINE I EPE
> E dol lar-sign
Handler-return-statements and exit-handler-statements shall only occur within
exception-handlers . The no-argument numeric-suppl ied-functions EINE and EPE
shall be invoked only within exception-handlers . E$ takes a single numeric argu
ment, which is an index .
No line-number in a control -transfer outside a protection-block shal l refer to a l ine
in that protection-block other than its when- l ine or when-use-name- line . No l ine
number in a control -transfer inside an exception-handler shall refer to a l ine out
side that exception-handler other than its own end-handler- l ine or end-when- l ine, nor
shall a line-number in a control -transfer outside an exception-handler refer to a
line inside that exception-handler or to its end-handl er- l ine or end-when- l ine .
A detached-handler referred to in a when-use-name- l ine within an interl-proc-def
mst be defined in the same internal-proc-def . A detached-handler referred to in a
when-use-name- line that is not within an internal-proc-def must be defined in the
same program-unit but not within an internal-proc-def . No two handler- lines in the
same program unit shal l have the same handler-name . A detached-handler may not appear
within a protection-block.
A protection-block may not appear within an exception-handler .
12 . 1 . 3 Exales
Example 1 handl ing errors in input-repl ies by allowing the input-reply to be
resuppl ied after issuing a suitabl e message
100 W ECEPTION IN
110 PRINT "Enter your age and weight"
120 INPUT a, w
130 IF a > 10 T
- 131 -
140 PRINT "What is your height"
150 INPUT h
160 E IF
170 USE
180 PRINT "Please enter numbers only"
190 RY
200 E W
Exampl e 2 : dynamic file opening
100 HL file_trouble
1 10 L file_ok$ = "false"
120 IF EPE = 7 107 T
130 L message$ = "doesn' t exist"
140 ESEIF EPE = 7 102 T
150
160 ESE
L message$ "is the wrong type"
170 L message$ "couldn' t be used"
180 E IF
190 PRINT "file" ; filename$ ; message$ ; "try again"
200 E HL
500 D
510 INPUT filename$
520 L file_ok$ = "true"
530 W ECEPTION USE file-troubl e
540 OPEN #n: NA filenae$ ! other parameters omitted
550 E W
560 LOP UNTIL file_ok$ = 1 1 true"
Examl e 3 : Nested handlers
100 W ECEPTION IN
110 D
120 R #1 , IF MISSING T EIT D: A
130 L I = I+l ! I initial ized outside loop
140 W ECEPTION IN
150 L B( I ) = lOOOiW''A
160 USE
170 ! Assume it is numeric overflow
180 L B( I ) = M
190 CONTINUE
200 E W
2 10 LOOP
220 USE
230
240
250
IF EPE 8101 T
RY
ESE
non-numeric data
get next data item
give up
260 PRINT "Unabl e to process file"
270 STOP
280 E IF
290 E W
13 . CAUSE ECEPTION I
- 132 -
12 . 1 . 4 Setics
When an exception occurs during the execution of a program-unit, the action taken
shall 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 handl ing procedures
specified in this Standard shal l be appl ied ( see 2 . 4) . If the exception occurs within
a when-block, then the default exception handl ing procedures , which require that an
exception be reported , shal l not be appl ied ; instead , control shall be transferred to
the exception-handler associated with the inner-most protection-block within which
the exception occurred .
When the protection-block is a when-use-block, the associated exception-handler is
that which fol lows the use- line of the protection-block. When the protection-block is
a when-use-name-block, the associated exception-handler is the detached-handler named
in the when-use-name- l ine of the protection-block. In all respects , a detached
handler behaves semantical ly as though it were an exception-handler in the when-use
block of the when-block with the exception.
Within an exception-handler, the type of the exception which caused that handler to
be executed shal l be obtainable as the value of the parameterless function ETYPE.
The values of EPE for al l exceptions defined in this Standard are specified in
Table 2 , along with the description of each exception in this Standard . The line-num
ber of the l ine whose execution caused the exception shall be obtainable as the value
of the parameterless function EINE.
There are four means of exiting from an exception-handler .
- Execution of the handler-retu-statement CONTINUE shal l cause control to be trans
ferred to the statement lexical ly fol lowing that which caused the exception. If
the exception occurred in a line which begins or is part of a structure ( such as a
do- l ine, loop- l ine, for- l ine, if-then- l ine, elseif-then- line, select- line, or
case- l ine ) , then control shall be transferred to the statement lexical ly fol lowing
the entire structure of which the line is a part .
- Execution of the handler-return-statement RETRY shal l cause control to be trans
ferred to the statement or line which caused the exception, causing the statement
or l ine to be re-executed ; if that statement was performing data retrieval , then
the previous input-reply or line-input-reply shal l be discarded and a new one re
quested .
- If control reaches an end-when- l ine which terminates an exception-handler or
reaches an end-handler-line , then control shal l be transferred to the l ine fol low
ing the end-when- l ine of the protection-block within which the exception occurred
with no further effect.
- Execution of an exit-handler- statement shall 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 handling the exception is as if the exception-handler
did not exist ( except for the effect of any statements already executed in the
handler) , and the rules for handling 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-block, or an end-when- l ine in a when
use-name-block, then control shall be transferred to the line fol lowing the
protection-block of which the use-line or end-when- line is a part . If execution
reaches an end-handler- l ine of a detached-handler , control shall continue at the l ine
fol lowing the end-when-line of the when-use-name-block causing the exception. If exe
cution reaches a handler- l ine of a detached-handler other than by the occurrence of
an exception, control shall then continue at the line imediately fol lowing the end
handler- l ine .
- 133 -
A separate GSUB stack is associated with each exception-handler ( see 8 . 2) so R
never attempts to transfer control into or out of an exception handler .
Execution of a cause-statement shal l result in the occurrence of a fatal exception
and the setting of EYPE to the rounded value of the exception-type.
If an exception is caused by a statement lexical ly within an exception-handler, then
this new exception shal l be handled by the default exception-handl 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-handler is entered , or
an exception-handler is entered , an exit-handler-statement is executed with the
handler, and there is no lexically surrounding when-block to intercept the
exception,
then the fatal exception shall be propagated back to the line that invoked the
procedure-part or internal-proc-def . This propagation shall continue to occur until
either :
- a user-defined exception-handler resolves the exception by execution of a handler
retur- statement o by causing control to pass to an end-handler- l ine or to an end
when- l ine which terminates the exception-handler, or
the main program or a parallel-section is reached , in which case the default
exception-handl ing procedures are appl ied .
If an exception-handler is invoked as a result of this process , then the value re
turned by the EYPE function shal l be 100000 plus the value that would have been re
turned by EYPE in the procedure-part or integral -proc-def in which the exception
original ly occurred . The value of EINE shall be the line-number of the most recent
l ine to which the exception was propagated , i . e . , the l ine lexical ly within the when
block associated with the exception-handler, not the l ine of the original exception .
The default exception-handl ing procedures shal l always report the EYPE and EINE
of the original exception .
The value of EYPE for exceptions defined by local enhancements to this Standard
shall be negative. Wen negative values of EYPE are propagated, the value shal l be
- 100000 p lus the value that would have been returned by EYPE for the original
exception.
Values of EYPE from 1 to 999 wi l l not be used by future enhancements to this
Standard , nor shal l they be used by local enhancements to this Standard .
The value of EE$ shall 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 exception, the value of
EE$ shal l be the nul l string .
If the main-program is reached and no exception-handler is invoked there as a result
of the original exception, then the exception shall be handled by the default excep
tion handl ing procedures specified in this Standard .
12 . 1 . 5 Exceptions
A cause-statement is executed ( exception-type, fatal ) .
12 . 1 . 6 Remrks
Users should note that there are two kinds of exception propagation specified in this
section. First, there is "lexical" propagation, outward to surrounding protection
blocks within a program-unit or internal -proc-def. If this process propagates the ex
ception outside of any such protection-block, "invocation" propagation takes effect,
passing the exception back to invoking statements .
- 134 -
The function EINE should be used with caution, as the use of editing facil ities
which renumber lines in a program ( see 16 . 2) may inval idate computations invo 1 ving
EINE. For exampl e, the progra fragent
1000 SELECT CASE INT( EINE/ 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-handling procedure is appl ied as a resul t, only the original exception 1 s
ETYPE and EINE must be reported . Implementations may, however, also report the
l ine-numbers of the lines through which the exception was propagated , or any other
inforation deemed useful .
It is not possible to pass a nonfatal exception back to a cal ling routine since it
wil l be handl ed either by an exception-handler in the cal led routine or by the system
handler . A exception handler my, however , cause a fatal exception with a cause
statement .
The cause-statement is not intended actual ly to simulate any given exception, but
rather to raise a fatal exception with a specified value of ETYPE . In particular, if
the specified ETYPE is the same as for some nonfatal exception, iplementations need
not apply the recovery procedure as though that nonfatal exception had actually oc
curred . It is presumed that a program wil l noral ly contain an exception-handler to
receive and process the exception.
Al l positive values of ETYPE are reserved for future versions of this Standard . Ex
ceptions defined by local enhancements to this Standard should be identified by nega
tive values for ETYPE, fol lowing the categories establ ished in Table 2 . The value
returned by ETYPE for an exception defined in a local enhancement and occurring in a
procedure-part or internal-proc-def should be -100000 p lus the negative value identi
fying that exception . For example, if an implementation chose an ETYPE 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 handled there, then the value of ETYPE in an
exception-handler in a cal l ing program should be - 104029 .
It is recomended that implementations use the "zero-th" value in a c lass of EYPE
values to represent "other exceptions of this type" . For example, an ETYPE value of
1000 might represent all overflows not defined in this Standard .
Values of ETYPE from 1 to 999 may only occur from cause-statements in appl ication
programs . These values should be encouraged for use , since they wil l not be assigned
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-statement, on-goto-statement, or if-statement, CONTINUE will
transfer control to the lexical ly fol lowing l ine . Such action my not be equivalent
to resumption of normal f low of control .
- 135 -
The following exampl e i llustrates the effect of CONTINUE with control structures :
100 W ECEPTION IN
120 INPUT PROMPT "enter your age and weight" : a, w
130 D WHILE a > 1
140 IF a < 9999999999 T
150 INPUT PROMPT "What is your height
1 1
: h
160 PRINT "Check the following:
1 1
170 PRINT "Age : " ; a, "Weight : " ; w, "Height : " ; h
200 INPUT PROMPT "Enter your age" : a
210 E IF
220 PRINT "Lexical ly fol lowing IF"
230 LOOP
240 PRINT "Lexical ly fol lowing D WHILE"
For exception in l ine :
120
130
140
150
CONTINUE transfers control to l ine :
130
240
220
160
The precise format of the values of the EE$ function is implementation-defined .
In particular, implementations may choose to omit, or to mark in a special way, those
fields in an error message that are specific to a particular instance of an excep
tion, such as the line number at which the exception occurred or the value of an out
of-range subscript.
12 . 2 Debuging ( BASIC- 1 and BASIC- 2)
12 . 2 . 1 General Description
Debugging facilities are provided by language statements in order to al low test
points to be built into a program. These statements allow the user to set break
points , to trace the action of the program, and to turn the debugging system on and
off within each program-unit .
12 . 2 . 2 Sytax
1 . debug-statement
2 . break-statement
3 . trace-statement
12 . 2 . 3 Exales
3. TRACE ON
TRACE ON TO 113
12 . 2 . 4 Semntics
DEBUG ( ON I OFF )
BREAK
TRACE ON ( TO channel-expression) ? I TRACE OFF
Each program-unit shal l have a debugging status , which is either active or inactive
at any given time . The debugging status of a progra-unit shal l persist between invo
cations of that program-unit ( with the exception of the main program) . Changes in the
debugging status of one program-unit shal l not affect the debugging status of any
other program-unit. At the beginning of execution of the program, debugging shall be
inactive for al l program-units .
Execution of the debug-statement DEBUG ON shal l cause debugging to become active for
the program-unit in which that debug- statement occurs . Debugging shal l remin 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 shal l cause debugging
to become inactive for the reminder of that invocation of that program-unit, and for
- 136 -
each subsequent invocation of that program unit, unti l the debug-statement DEUG ON
is executed in that program-unit .
The execution of a break-statement when debugging is active shall cause an exception.
The standard recovery procedure from this exception shal l be to report the line
number of the break-statement and to signify to the user that interaction with the
debugging system is possibl e. The actions allowed by the debugging system, including
the method for continuing execution or terminating execution of the program, are
implementation-defined . If the execution of a program reaches a line containing a
break-statement, and debugging is inactive, then it shall proceed to the next line
with no other effect .
The execution of a trace-statement when debugging is active shall turn tracing on ( if
ON is specified) or off ( if OFF is specified ) in the program-unit containing the
trace-statement . Prior to the execution of any trace-statement upon each separate en
try to a program-unit, tracing shall be off . If the execution of a program reaches a
line containing a trace-statement , and debugging is inactive , then it shall proceed
to the next l ine with no other effect .
The execution of a trace-statement shall not affect the debugging status , nor shall
the execution of a debug-statement affect the tracing status ( ON or OFF) .
Whenever tracing is on and debugging is active in a program-unit, the following
actions shall occur each time a line of the specified type is executed
for any line which interrupts the sequential order of execution of l ines in a pro
gram, both the line-number of that line and the line-number of the next l ine to be
executed shall be reported ; and
- for any line which assigns a value to a variable or to an element of an array, both
the line-number of that line and any values assigned by execution of that line
shall be reported . Whenever tracing has been turned on via a trace-statement with
a channel-expression, trace reports shall be directed to the ( display format) file
assigned to the specified channel . If no channel-expression has been specified ,
the trace report shall be directed to the device associated with channel zero .
The contents of the trace report are implementation-defined , but shall include at
least the name of the variable traced , as that name lexical ly appears in the state
ment causing the TRCE report, and its value ; if the variable is an array element ,
the value( s ) of its subscripts shall also be included .
12 . 2 . 5 Exceptions
A break-statement 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) .
- A attempt is made to direct a trace report to an inactive channel . ( 7401, fatal ) .
- A attempt is made to direct a trace report to a file which is not display format
opened with access OUTPUT or OUIN ( 7402 , fatal ) .
12 . 2 . 6 Remarks
Since an array-assigrent assigns a value to each element of an array, tracing an
array-ass igrent causes reporting of all new array element values .
The form of all trace reports is implementation-defined .
Implementations may provide debugging facil ities through comands in addition to
statements . It is recomended that such comands use the same keywords as the
statements .
- 137 -
1 3 . GRPHI C S
- 138 -
13 . GRPHICS
The facilities provided in section 13 . 1 through 13 . 3 are a subset of those provided by
level Ob of the Graphical Kernel System (GKS) as defined in ISO 7942 . The values of the
EPE function for exceptions defined in GKS are 11000 plus 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 calls to the functions OPE GKS , OPEN WORKSTATION ( tO, 1 1 Maindev1 1 , 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 my be chosen to suit the appl ication.
The range of this system of "probl em coordinates" ( world coordinates) is established
by a SE WINDOW statement . 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 specify what part of this abstract viewing surface will be presented to the
user on the display surface by a SET DEVICE WINDOW statement . This rectangle , in
turn, may be located on the display surface by a SET DEVICE VIEWPORT statement .
No output wil l be produced outside the device viewport . It is possible to guarantee
that all graphic output which lies outside the viewport will be el iminated by en
abl ing cl ipping .
Ask statements are provided to determine the current values for the parameters estab
lished by execution of one of the set statements or by default .
13 . 1 . 2 Sytax
1 . set-object
2 . boundaries
3 . boundary
4. ask-statement
5 . status-clause
6 . ask-object
7 . boundary-variables
13 . 1 . 3 Exales
1. WINDOW O, PP''2 , - 1 , 1
> WINDOW boundaries I VIEWPORT boundaries I DEVICE
\<iNDOW boundaries I DEVICE VIEWPORT boundaries
I CLIP string-expression
boundary coma boundary coma boundary coma boundary
numeric-expression
> ASK ask-obj ect status-clause?
STATUS numeric-variable
> WINDOW boundary-variables I VIEWPORT
boundary-variables I DEVICE WINDOW
boundary-variables I DEVICE VIEWPORT
boundary-variables I DEVICE SIZE
numeric-variable coma numeric-variable coma
string-variable I CLIP string-variable
numeric-variable coma numeric-variable coma
numeric-variable com numeric-variable
VIEWPORT . 5''width, width, . 5)''height, height
DEVICE WINDW O, . 8 , O, 1
DEVICE VIEWPORT . 3 , . 5 , . 1, 1
CLIP "Off"
4 . ASK WINDW X1 , X2 , Y1, Y2
ASK VIEPORT L, R, B, T
- 139 -
ASK DEVICE WINDOW XIN, X, YMIN, YMAX
ASK DEVICE VIEPORT L, RIGHT, BOTOM, TOP
ASK DEVICE SIZE Width, Height, Unit$
ASK CLIP CLIP_STATE$
13 . 1 . 4 Semantics
Graphic output is specified in problem coordinates . A norml ization transformation
defines the mapping from the problem coordinate system onto the normal ized device co
ordinate ( NDC) space which can be regarded as an abstract viewing surface .
The normalization transformation is specified by defining the l imits of a rectangular
area, cal led a window, in problem coordinates . The window is mapped linearly onto a
specified rectangular area, cal led a viewport, in NDC space .
Execution of a set-statement with the keyword WINDOW shal l establ ish the boundaries
of the window. The parameters represent the probl em coordinates of the left, right,
bottom, and top edges, 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 VIEPORT shal l establ ish the viewport
boundaries . The parameters represent the normal ized device coordinates of the left,
right, bottom, and top edges , in that order, of the viewport rectangle . Viewport co
ordinates must not be less t zero not more t one . The value of the left coordi
nate shal l be less than the ri1t, and the bottom less t the top . At the start of
program execution the viewport values are ( 0, 1, o, 1 ) .
The viewport may also be used to define a cl ipping rectangle. Execution of a set
statement with the keyword CLIP shall enable or disable cl 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, clipping
shal l be enabled .
A device transformation is used to map a rectangle in NDC space cal led a device win
dow uniformly onto a rectangle on a physical surface called a device viewport . This
transformation shal l perform equal scaling with a positive scale for both axes . To
ensure equal scal ing, the device transformation maps the device window onto the
largest rectangle that can fit 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 corer of the device viewport .
Execution of a set-statement with the keyword DEVICE WINDOW shal l establish the
boundaries of the device window. The parameters represent the normlized device coor
dinates of the left, right, bottom, and top edges , in that order, of the device widow
rectangle . These coordinates shal l not be less than zero not greater than one . The
value of the left coordinate shall 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 displayed , cl ipping takes
place at the device window boundaries . This cl ipping may not be disabled . Execution
of a set-statement with the keywords DEVICE WINDOW shal l cause the displ ay surface to
be cleared if it is not already clear .
- 140 -
The figure below i l lustrates the relationship between the window, the viewport, the
device window, and the device viewport; c lipping is assumed "ON" .
\Hndow Viewport
Device viewport
Device window
Problem coordinates NDC Space
DC Space
Execution of a set-statement with the keywords DEVICE VIEWPORT shall establ ish the
boundaries of the device viewport . The parameters represent the coordinates of the
left , right, 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 coordinates otherwise . The left
and bottom edges of a display 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 shall cause the display
surface to be c leared if it is not already cl ear .
If a status-clause is included in an ask-statement, a status associated with the exe
cution of the ask-statement shall be returned in the numeric-variable . If the
statement returned meaningful values for the ask-object, a value of zero shal l be re
turned in the status- clause . If the ask-statement could not retur meaningful values
for the ask-object a nonzero value shal l be returned in the status-clause that is de
fined with the semantics of the particular ask-object. If an ask-statement with a
particular ask-object is always expected to return meaningful values , te semantics
for that ask-object do not specify alternate status values and zero shall always be
returned .
Execution of an ask- statement with one of the keywords WINDOW, VIEWPORT, DEVICE
WINDOW, or DEVICE VIEWPORT shal l provide the current values for the specified rectan
gle . Values for the left, right, bottom and top sides , respectively, shal l be as
signed to the boundary-variables equal to the values last establ ished by a set
statement, or , if no appropriate set-statement has been executed , equal to the
default value .
Execution of an ask-statement with the keywords DEVICE SIZE shall ass ign to the first
numeric variable the size in the horizontal direction and shal l assign to the second
numeric variable the size in the vertical direction of the available display surface.
The string-variable shall be assigned the value "MTERS" if the sizes are i n meters
or the value "OTHR" if the units of measure are device coordinates of other units .
The values "MTERS" and "OTH" shal l consist of upper-case- letters .
Execution of an ask-statement with the keyword CLIP shall assign the value 1 1 0N1 1 to
the string-variable if cl ipping is enabled and the value 110F11 if it is disabled . The
values retured shall 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
( 11051 , nonfatal : 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 ( 1105 1, nonfatal :
continue with current values ) .
A boundary of te viewport is not in the range [ 0 , 1] ( 11052 nonfatal : continue
with current values ) .
A boundary of the device window is not in the range [ 0, 1] ( 11053 , nonfatal : con
tinue with current values) .
A boundary of the device viewport is not in the display space ( 11054, nonfatal :
continue with current values ) .
The value of the string-expression in a set-statement with the keyword CLIP is nei
ther "ON" nor "OFF" after conversion to upper-case ( 4101 , nonfatal : continue with
current value) .
13 . 1 . 6 Remrks
The manner in which a particular graphic display device is selected by a program is
implementation-defined .
The meaning of a window with the left edge greater than the right or the bottom edge
greater than the top is implementation-defined . If possible, implementations should
provide appropriately inverted images . The effect of all 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 states that reversal window coordinates causes an error .
SET WINDOW, SET VIEPORT, SET DEVICE WINDOW, and SET DEVICE VIEWPORT correspond to
the GKS functions SET WINDOW, SET VIEWPORT, SET WORKSTATION WINDOW, and SET
WORKSTATION VIEWPORT, respectively. 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 SE CLIPPING INDICATOR.
ASK WINDW and ASK VIEWPORT correspond to the GKS function INQUIRE NORMALIZATION
TRANSFORMATION for normalization transformation one .
ASK CLIP corresponds to the GKS function INQUIRE CLIPPING INDICATOR.
ASK DEVICE WINDW 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 identifier of one .
ASK DEVICE VIEPORT before any SET DEVICE VIEWPORT may be used to find the device co
ordinates of the ful l available device surface .
ASK DEVICE SIZE corresponds to the device coordinate units and mi display sur
face size in device coordinate units parameters of the GKS function INQUIRE MIM
DISPLAY SURFACE SIZE.
13 . 2 Attributes and Screen Control
13 . 2 . 1 General Description
A graphical display 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 my be able to draw lines and/ or fil l areas in a variety of col
ors . Particular colors my be selected for l ine drawing and screen background .
The current style and color of the geometric object may be determined by ask
statements . The number of colors and the number of l ine or point styles available may
also be determined by ask-statements .
The c lear- statement clears the entire screen, returning it to its background color .
For hard- copy devices , the clear-statement causes the paper to advance , the pen to
move aside , or s imilar action.
This Standard provides text of one style and size that shall be output horizontal ly
with the initial-point at the left .
13 . 2 . 2 Sytax
1 . imperative- statement
2 . clear- statement
3 . set-object
4 . primitive-2
5 . primitive- 1
6 . rgb- l ist
7 . ask-object
8 . mix- l ist
9. text-facet
13 . 2 . 3 Exales
3 . LINE STYLE 2
TET COLOR 5
7 . Max color color_max
Max point style PtStyles
13 . 2 . 4 Semantics
> clear-statement
CLEAR
> primitive- 1 STYLE index I primitive-2 COLOR index
primitive-1 / TET I A
POINT / LINE
> [ deleted ]
> primitive-1 STYLE numeric-variable I primitive-2
COLOR numeric-variable I M primitive-1 STYLE
numeric-variable I M COLOR numeric-variable
[ deleted ]
[ deleted ]
Execution of a c lear-statement shall clear the graphic display if not already clear .
For soft-copy devices , it shal l erase the screen. For hard-copy devices , it shal l ad
vance the medium or al low the device operator to change it .
Execution of a set-statement with the keywords LINE STYLE or POINT STYLE shal l cause
the index to be evaluated by rounding to obtain an integer N and shall establ ish the
style for subsequent l ines or points to be the Nth one of the set of available line
or point styles . The number of line styles available is implementation-defined, but
shall be at least three . A line style of one must correspond to drawing of solid
lines . A l ine style of two shall correspond to drawing of dashed lines . A line style
of three shal l correspond to dotted lines . All other values for line style are
impl ementation-defined . At the initiation of program execution, the line style shall
be one .
Point styles produce centered symbols . The number of point styles is implementation
defined , but shal l be at least three . A point style of one must correspond to a
dot ( . ) , a point style of two to a p lus sign ( +) , a point style of three to an
asterisk ( }'< ) . Al l other values for point-style are implementation-defined . At the
start of program execution, the point style shal l be three .
Execution of an ask-statement with the keywords LINE STYLE or POINT STYLE shall as
sign the number of the actual current line style or point style to the numeric
variabl e.
- 143 -
Execution of an ask-statement with the keywords M LINE STYLE or M POINT STYLE
shal l assign to the numeric-variable the largest value of LINE STYLE or POINT STYLE,
respectively, available .
Al l values for style shall be val id from one to the number returned by ASK M POINT
STYLE or ASK M LINE STYLE.
Execution of a set-statement with the one of the keyword pairs POINT COLOR, LINE
COLOR, TET COLOR, or AREA COLOR shall cause the index to be evaluated by rounding to
obtain an integer N and shall establish the color index of subsequent points , lines ,
text, or fi l led areas to be the Nth one of the set of colors , 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 implementation-defined , and the
foreground co lor indices shall all have te value one. The number of colors available
is implementation-defined .
Execution of an ask-statement with one of the keyword pairs POINT COLOR, LINE COLOR,
TET COLOR, or AREA COLOR shall assign to the numeric-variable the current value of
the color index for points , lines , text or fi l led areas , as appropriate .
Execution of an ask-statement with the keywords M COLOR shall assign to the
numeric-variable the largest distinct value available as an index for SET POINT
COLOR, SET LINE COLOR, SET TET COLOR, or SET AREA COLOR. All values for color index
from zero to this value should be val id .
13 . 2 . 5 Exceptions
- A color index in a set-statement with the keywords POINT COLOR, LINE COLOR, TET
COLOR, or A COLOR is less than zero or greater than te maximum color index for
the implementation ( 11085 , nonfatal : use the implementation default) .
- 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 available ( 11062 ,
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 available
( 11056 , nonfatal : use the value three) .
13 . 2 . 6 Remarks
It is recomended that implementations make the value returned by ASK MX COLOR the
sae as the number of colors ( not counting background color) avai lable for simltane
ous display, not the total number of different colors available 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 LINEYPE and SE MER TYPE, respectively. SET LINE COLOR, SET POINT COLOR, SET
TET COLOR, and SET AREA COLOR correspond to the GKS functions SET POLYLINE COLOUR
INDE, SET POLYR COLOUR INDE, SET TET COLOUR INDE, and SET FILL AREA COLOUR
INDE, respectively.
The fol lowing ask-objects correspond to various parameters of the GKS function
INQUIRE CUR INDIVIDUAL ATTRIBUTE VALUES : LINESTYLE is l inetype, POINSTYLE is
marker type, LINE COLOR is polyline colour index, POINT COLOR is polymarker colour
index, TET COLOR is text colour index and AREA COLOR is fill 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 segents , or fi lled- in areas to be
- 144 -
drawn on the screen. There is a facility 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 .
13 . 3 . 2 Sytax
1 . imperative-statement
2 . graphic-output-statement
3 . geometric-statement
4 . graphic-verb
5 . geometric-object
6 . point- l ist
7 . coordinate-pair
8 . array-geometric-statement
9 . size-select
10 . array-point- l ist
11. graphic-text-statement
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
> GRPH
POINTS I LINES I A
coordinate-pair ( semicolon coordinate-pair) )''
numeric-expression coma numeric-expression
[ deleted]
[ deleted ]
[ deleted]
graphic-verb TET initial -point ( com USING imge
colon expression- list I colon
string-expression)
coma AT coordinate-pair
[ deleted ]
[ deleted ]
A graphic-output-statement with LINES as the geometric-object must contain at least
two coordinate-pairs in its point- l ist. A graphic-output-statement with A as the
geometric-object must contain at least three coordinate-pairs in its point- list .
13 . 3 . 3 Exales
3 . GRAPH LINES : 3 , 4; 5 , 6 ; 66 . 66 , 7 7 . 7 7
11 . GRAPH TET, AT XP, YP: "here is the label : 11 & TET$
GRAPH T, AT O, Y_VALUE, USING "INt . 1/----, : Y_VALUE
13 . 3 . 4 Semantics
The graphic-output-statement
Graphic-output-statements are the means by which the user generates al l graphic out
put . The geometric- statement is used to draw a series of marked points , a contiguous
set of line segments , or a fil led polygon area. The graphic-text-statement produces
alphanumeric labels .
The geometric-statement
The geometric-statement makes use of a sequence of points specified in problem
coordinates . That sequence is determined by the coordinate-pairs in the point- list,
the first coordinate-pair designting the first point and so on through the end of
the point- list .
If the geometric-object is POINTS , then a point marker of the style and color indi
cated by the current value of POINT STYLE and POINT COLOR shal l be drawn at each
point in the sequence . If the geometric-object is LINES , then a l ine segent shal l be
drawn connecting each successive pair of points in the sequence , the first to the
second , the second to the third , and so on . Thus , the number of line segents shall
be one fewer t the number of points in the sequence . The style and color of the
segents are determined by the current value of LINE STYLE and LINE COLOR. If the
geometric-obj ect is A, then a fil led polygon is drawn whose edges consist of the
sequence of l ine segents as described above for LINES . If the first and last points
in the sequence are not coincident, then the l ine segent joining them completes the
outline . The color of the interior and edge is determined by the current value of
A COLOR. The interior of the polygon is defined as the set of al l points ( pixel s)
- 145 -
such that any l ine segent beginning at that point and extended indefinitely in any
direction wil l cross the polygon boundary an odd number of times . The fil l patter
shal l be solid on devices where this is possible.
The graphic-text-statement
The graphic-text-statement draws a label consisting of the string of characters gen
erated by its string-expression, or by its image and expression- l ist. The characters
used for label s shal l have an implementation-defined size and style. The effect of
c lipping on characters which lie partly in and partly out of the viewport on the
screen is implementation-defined .
13 . 3 . 5 Exceptions
- A graphic-output-statement with LINES as the geometric-object specifies fewer than
two points ( 11100, fatal )
- A graphic-output-statement with A as the geometric-object specifies fewer t
three points ( 11100 , fatal )
13 . 3 . 6 Remrks
The graphic-text-statement is designed 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 unable to fil l a polygon, it is recomended that the outl ine of the
polygon be drawn and the interior be hashed or shaded in a manner corresponding to
the current color number.
It is recomended that the result of fil ling an area consisting solely of col inear
points be a l ine segent through those points , tt filling or drawing a l ine through
a set of coincident points result in a dot being drawn.
GRAPH POINTS correspond to the GKS function POLY. GRAPH LINES correspond to the
GKS function POLYLINE. GRPH A correspond to the GKS function FILL A. GRAPH
TET is an extension of the GKS function T in that it al lows formatting of text
with USING.
- 146 -
1 5 . F I XED DEC I MAL NUMBERS
- 147 -
15 . FIX DECIM NES ( BASIC-2 only)
This Section specifies an option in which the values of all numeric variables behave logi
cal ly as fixed-point decimal numbers with program-defined precisions . Use of this option
also impl ies that nueric-constants and numeric-expressions general ly, are represented as
fixed-point decimal numbers . Implementation of this Section is mandatory in BASIC-2 .
The main intent of this data tye is to provide an interface with non-BASIC processors , and
as a result, the precision and accuracy requirements for numeric-expressions are not speci
fied .
15 . 1 Fixed Decimal Precision
15 . 1 . 1 General Description
A option is provided which al lows definition of al l numeric variables in a progra
unit as having fixed-point decimal nubers as values . The specification of this op
tion defines a default precision for the values of variables . In addition, other pre
cision attributes can be specified for individual variables .
15 . 1 . 2 Sytax
1 . option
2 . fixed-point- type
3 . numeric- type
4 . fixed-declaration
> ARITHIC FIX fixed-point- type
asterisk fixed-point-size
> NRIC fixed-point-type? fixed-declaration ( coma
fixed-declaration)i<
simp le-numeric-variable fixed-point-type? I
numeric-array-declaration fixed-point-type?
A option-statement with an ARITHTIC FIXD option, if present at al l , shal l occur
in a lower-numbered line than any numeric-expression, numeric-variable, or any
declare-statement with NRIC in the same program-unit .
A fixed-declaration, if present at al l , shal l occur in a lower-numbered l ine t any
reference to the variable or array declared therein.
A fixed-point-size may appear in a declare-statement only if the ARITHIC FIX op
tion has been specified for the program-unit.
Variables and arrays shal l not be described more than once, in either a declare
statement, a dimension-statement, or as a function-parameter or procedure-paraeter.
15 . 1 . 3 Exales
1 . ARITHTIC FIX1'<8 . 2
3 . NRIC1'<5 . 2 A, B, Cl'<5 . 5 , D ( 1 TO 8) 1'<6 . 6
NRIC E ( 1 TO 10, 1961 TO 1981)
15 . 1 . 4 Semantics
When the ARITHTIC FIXD option is specified , then the values of nueric constants ,
variables , and expressions shall behave logical ly as fixed-point decimal numbers . In
the case of variables , this means that the set of values they are capable of assuming
are exactly those values which can be expressed with integer-size decimal digits to
the left of the decimal point and fraction-size digits to the right, together with
the sign. The sign is not counted in the size of the representation. Each implementa
tion shal l define a mi precision, P , which control s the number of deciml digits
available for the representation of numeric values . This precision shal l not be less
than 18 .
The semantics for numeric-constants are as specified in Section 5 . 1 , except as fol
lows . Each numeric constant has a precision attribute defined by the number of sig
nificant decimal digits . The first significant digit is either the first nonzero
digit, or the digit imediately to the right of the decimal point, whichever is far-
- 148 -
ther left. The last significant digit is the last expl icitly written or the digit im
mediatel y to the left of the decimal point, whichever is farter right . In the spe
cial case of zero , there is at least one significant digit, namely imediately to the
left of the deciml point . A numeric-constant written in scaled notation is inter
preted as if expressed in the equivalent unsealed notation.
For example :
constant as written significant digits
12 . 34 12 . 34
12 . 300 12 . 300
12 . 300E-4 . 0012300
12 . 300E7 123000000 .
OO . OOE-3 . 00000
O . OE3 0 .
I f the number o f significant digits exceeds P, the implementation shal l round the
value to no fewer than P digits . If the number of significant digits to the left of
the decimal point exceeds P , an overflow exception results .
Each simple-numeric-variable 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-size . The representation of variables and arrays is
governed by ( in descending order of precedence) :
- the fixed-point-size specified in the fixed-declaration of the variable or array,
or,
- the f ixed-point-size fol lowing DECLARE NURIC in a declare-statement containing a
fixed- declaration for the variable or array, or
- the default fixed-point-size specified in the ARITIC FIXD option.
The precision attribute of a numeric-array appl ies to each of its elements . The sig
nificant digits for a numeric-variable are the same as if the variable were written
out with its ful l precision as a numeric-constant .
The semantics of numeric-expressions and numeric-suppl ied- functions are as specified
in 5 . 3 and 5 . 4, except a fol lows . The precision attribute of the result obtained by
evaluating a numeric-suppl ied-function or numeric-expression is implementation
defined . The accuracy of such evaluation is also implementation-defined .
Assignment of a numeric value to a numeric-variabl e, whether done by internal assign
ment ( such as with LE) , or from an external source ( such as with INPUT) , proceeds as
follows . The integer part and fraction part of the value are moved to the integer
part and fraction part of the variable, aligned on the decimal point . If any nonzero
digits are truncated on the left of the integer part, an overflow exception results .
If any digits are truncated on the right of the fraction part, the resulting value in
the variable is rounded to the precision of the variable . 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 fil l al l the digit places of the receiving variabl e.
The semantics for input and output are as specified in Section 10 , except as fol lows .
When a numeric-expression is used as a print- item in a print-statement, its value is
always printed in unsealed representation, either impl icit point or expl icit point .
The digits printed are exactly the significant digits , as defined above. Note that
for numeric-expressions oter than variables and constants , significant digits are
imlementation-defined . Impl icit point representation shal l be used when there are no
significant digits to the right of the decimal point ; otherwise explicit point repre
sentation shal l be used .
The semantics for file areas are
additions . For DISPLAY records ,
as specified in Section 11, with the fol lowing
the rules given above for input, output, and
- 149 -
assignment are used . For INTENAL records , the values are self-typed, and so input
and output takes place as defined above . Thus , the result of WITE A and R B,
where they access the same value in the file, is the same as L B = A. Note that it
is implementation-defined whether an INTERNAL file accessed with one ARITHTIC
option is accessible with another . The ARITHTIC FIX option with different default
prec1s1ons is not considered to be a different option for the purposes of
accessibil ity. For NATIVE records , assignment of values to and from fields of fixed
point-size takes place in accordance with the usual rules for fixed-point assignment .
When a value is moved to a field with a size of E ( indicating floating-point) , at
least the first P significant digits must be retained exactly. When a value obtained
from such a field is assigned to a variable, the field is treated as a scaled
numeric-constant, as described above . Again, note that it is implementation-defined
whether a NATIVE file accessed with one ARITil 1TIC option is accessible with another .
The ask-attribute DATUM returns the type of the next datum in a file . For numeric
data in STREAM INTERNAL files written with the FIXD option, the type returned by the
ask-attribute DATUM shall be :
where ii is the two digit number for integer-size and ff the two digit number for
fraction-size .
15 . 1 . 5 Exceptions
The number of significant digits in the integer part of a numeric-constant
exceeds P ( 1001 , fatal ) .
- In an option-statement or a declare-statement, the sum of integer-size and
fraction-size in a fixed-point-size exceeds P ( 1010 , fatal ) .
- Upon assignment of a numeric value to a variable, the number of significant digits
in the integer part exceeds the variable ' s integer- size ( 1011, fatal ) .
15 . 1 . 6 Remarks
It is recomended that the accuracy of transcendental functions such as LO, COSH,
ATN, SIN, and EP be no less than that specified for OPTION ARITHTIC DECIMAL. It is
recomended that for non-transcendental functions , such as ABS INT, and f1, and for
the operations +, - , ,., , I , and - , an intermediate result be maintained as floating
point decimal with P+2 significant digits . This would imply that whenever al l the
intermediate results of a numeric-expression are exact within P+2 decimal digits and
the final result is exact within P decimal digits , then the final result is exactly
correct .
15 . 2 Fixed Decial Program Segentation
15 . 2 . 1 General Description
When the fixed decimal option is specified for a program-unit, it applies to al l nu
meric entities in the scope of that unit, including paraeters , formal parameters ,
and ( in the case of an external -function-def ) the result of function evaluation.
15 . 2 . 2 Sytax
1 . function-parameter
2 . procedure-parameter
3 . numeric-fixed-parameter
4 . fixed- forml-array
5 . internal-function- l ine
> numeric- fixed-parameter
> numeric- fixed-parameter
simple-numeric-variable fixed-point-type I
fixed-foral-array
formal-array fixed-point-type
> line-number FUNCTION fixed-defined-function
function-pam- l ist? tail
- 150 -
6 . external-function- l ine > line-number EEA FUNCTION fixed-defined-function
function-parm- list? tail
7 . numeric-def-statement > DEF fixed-defined-function function-parm- l ist?
equals-sign numeric-expression
8 . defined-function > fixed-defined-function
9 . fixed-defined-function numeric-defined-function fixed-point-type
A numeric-variable or actual -array appearing in a cal l -statement shall have the same
integer-size and fraction-size as the corresponding procedure-parameter . For all
other numeric function-argument or procedure-arguments and their corresponding
function-parameters or procedure-parameters , it is necessary only that the ARITHTIC
options of their respective program-units agree, i . e . , that both be DECIM or NATIVE
or FIXD.
A option-statement with an ARITHTIC FIXD option shall occur in a lower-numbered
l ine within the program-unit than any internal -function-def that declares a numeric
defined-function or specifies numeric parameters .
A fixed-point-type may appear in an internal-function- line or numeric-def-statement
only if the ARITHTIC FIX option has been specified for the program-unit .
A numeric-fixed-paraeter may be used only if the ARITHIC FIXD option has been
specified for the program-unit .
When a fixed-defined-function is declared in a function-type, the fixed-point-sizes
specified either expl icitly or by default in the declaration and the corresponding
definition must agree .
15 . 2 . 3 Exales
3 . A( ) l'
C
8 . 2
B( '
) l'
C
4 . 4
5 . 123 FUNCTION SUMVECTQRl'c 5 . 2 ( V( ) >'<5 . 2)
6 . 234 EEA FUNCTION ANSWERll ( A$ )
7 . DEF AVERAGEl'c 10 . 3 ( X>'c 10 . 3 , Y>'c 1Q . 3 ) = ( X+Y) / 2
15 . 2 . 4 Semntics
When the ARITHTIC FIXD option is specified for a program-unit, the values of nu
meric procedure-parameters , numeric function-parameters , and numeric-defined
functions shall be represented and manipulated as fixed-point decimal numbers . If the
fixed-point-size of one of these is not expl icitly specified in the appropriate
procedure-parameter or function-parameter, internl-def - line or internal-function
l ine or external -function- l ine, then it is assumed to be the default specified in the
ARITHTIC FIXD option. The fixed-point-size of a normal -array appl ies to each of
its elements .
The evaluation and assignment 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 . In
the case where the fixed-point-size of an argument differs from that of the corre
sponding parameter, the assignment rules given in 15 . 1 . 4 apply.
The association of the procedure-arguments in a cal l -statement with the procedure
parameters in the corresponding sub-statement proceeds as described in Section 9 . 2 ,
with the fol lowing addition. In the case where the fixed-point-size of a procedure
argument which is a numeric-expression, but not a numeric-variable, differs from that
of the corresponding procedure-parameter, the assignment rules given in 15 . 1 . 4 apply.
- 151 -
15 . 2 . 5 Exceptions
- In a numeric-fixed-parameter or fixed-defined- function, the sum of the integer- size
and fraction-size in a fixed-point-size exceeds P ( 1010 , fatal ) .
- Upon assignment of a numeric value to a numeric-fixed-parameter or fixed- defined
function, the number of significant digits in the integer part exceeds the
integer- size of the numeric- fixed-parameter of fixed-defined-function ( 1011,
fatal) .
15 . 2 . 6 Remarks
None.
- 152 -
TABLE 1
Standard BASIC Character Set
The nae of the characters indicated in the table correspond to the name of the characters in
Standard ECMA-6 . \fuere different names are used in this Standard for the syntax of BASIC, these
names are indicated between parentheses .
ORDINAL
POSITION CODE GRAPHIC ACRONYM NA
0 . 0/ 0 NUL NULL
1. 0/ 1 SOH START OF HADING
2 . 0/ 2 ST START OF TET
3 . 0/ 3 E END OF TET
4 . 0/ 4 EOT END OF TRANSMISSION
5 . 0/ 5 ENQ ENQUIRY
6 . 0/ 6 ACK ACKNOWLEDGE
7 . 0/ 7 BEL BELL
8. 0/ 8 BS BACKSPACE
9 . 0/ 9 HT HORIZONTAL TABULATION
10 . 0/ 10 LF LINE FE
11 . 0/ 11 V VERTICAL TABUATION
12 . 0/ 12 FF FORM FEED
13 . 0/ 13 CR CARRIAGE RETURN
14. 0/ 14 so SHIFT OUT
15 . 0/ 15 SI SHIFT IN
16 . 1/ 0 DLE DATA LINK ESCAPE
17 . 1 / 1 DC1 DEVICE CONTROL ONE
18 . 1/ 2 DC2 DEVICE CONTROL TWO
19 . 1 / 3 DC3 DEVICE CONTROL THEE
20 . 1/ 4 DC4 DEVICE CONTROL FOUR
2 1 . 1 / 5 NAK NEGATIVE ACKNOWLEDGE
22 . 1/ 6 SYN SYNCHONOUS IDLE
23 . 1/ 7 ETB E OF TRANSMISSION BLOCK
24 . 1/ 8 CAN CANCE
25 . 1/ 9 E E OF MDIUM
26 . 1 / 10 SUH SUBSTITUTE
27 . 1 / 11 ESC ESCAPE
28 . 1/ 12 FS FILE SEPARATOR
29 . 1 / 13 GS GROUP SEPARATOR
30 . 1 / 14 RS RECORD SEPARATOR
3 1 . 1/ 15 us UNIT SEPARATOR
32 . 2/ 0 SP SPACE
33 . 2 / 1 ECLAMATION M
34 . 2 / 2
l
QUOTATION M
35 . 2 / 3 I NUMER SIGN
36 . 2 / 4 $ DOLLAR SIGN
37 . 2 / 5 % PERCENT SIGN
38 . 2/ 6 & AMPERSAND
39 . 2 / 7 APOSTROPH
40 . 2/ 8 LEF PARENTHSIS
41 . 2 / 9 RIGHT PARENTHSIS
42 . 2 / 10
7`l
ASTERISK
- 153 -
43 . 2 / 11 + PLUS SIGN
44 . 2 / 12 COMA
45 . 2 / 13 MINUS SIGN
46 . 2 / 14 FULL STOP ( Period)
47 . 2 / 15 SOLIDUS ( Slant)
48 . 3/ 0 0 DIGIT ZERO
49 . 3 / 1 1 DIGIT ONE
50 . 3 / 2 2 DIGIT TWO
5 1 . 3 / 3 3 DIGIT TE
52 . 3/ 4 4 DIGIT FOUR
53 . 3 / 5 5 DIGIT FIVE
54 . 3/ 6 6 DIGIT SIX
5 5 . 3 / 7 7 DIGIT SEVEN
5 6 . 3/ 8 8 DIGIT EIGHT
57 . 3/ 9 9 DIGIT NINE
58 . 3 / 10 COLON
59 . 3 / 11 SEICOLON
60 . 3 / 12 < LESS-THAN SIGN
61 . 3 / 13 EQUALS SIGN
62 . 3 / 14 > GREATER-THAN SIGN
63 . 3 / 15 ? QUESTION M
64 . 4/0 @ COMRCIAL AT
65 . 4/ 1 A CAPITAL LETER ( Upper-case) A
66 . 4/ 2 B CAPITAL LETER ( Upper-case) B
67 . 4/ 3 c CAPITAL LETTER ( Upper-case) c
68 . 4/4 D CAPITAL LETE ( Upper-case) D
69 . 4/ 5 E CAPITAL LETER ( Upper-case) E
7 0 . 4/ 6 F CAPITAL LETTER ( Upper-case) F
7 1 . 4/ 7 G CAPITA LETER ( Upper-case) G
7 2 . 4/8 H CAPITAL LETTE ( Upper-case) H
7 3 . 4/ 9 I CAPITAL LET ( Upper-case) I
7 4. 4/ 10 J CAPITAL LETER ( Upper-case) J
7 5 . 4/ 11 K CAPITAL LETTER ( Upper-case) K
76 . 4/12 L CAPITAL LETTER ( Upper-case) L
7 7 . 4/ 13 M CAPITAL LETTER ( Upper-case) M
7 8. 4/ 14 N CAPITAL LETE ( Upper-case) N
79 . 4/ 15 0 CAPITAL LETER ( Upper-case) 0
80 . 5/ 0 p CAPITAL LETTER ( Upper-case) p
81 . 5 / 1 Q CAPITAL LETTE ( Upper-case) Q
82 . 5 / 2 R CAPITAL LETER ( Upper-case) R
83 . 5 / 3 s CAPITAL LETTER ( Upper-case) s
84 . 5/ 4 T CAPITA LETTER ( Upper-case) T
85 . 5 / 5 u CAPITA LETER ( Upper-case) u
86 . 5 / 6 v CAPITAL LETTER ( Upper-case) v
87 . 5 / 7 w CAPITAL LETER ( Upper-case) w
88 . 5 / 8 X CAPITAL LETTE ( Upper-case) X
89 . 5 / 9 y CAPITAL LETTE ( Upper-case) y
90 . 5 / 10 z CAPITAL LETTER ( Upper-case) z
9 1 . 5 / 11
[
L SQUARE BRACKT
92 . 5 / 12 \ REVESE SLANT ( Reverse sol idus)
9 3 . 5 / 13
l
RIGHT SQUARE BRACKET
94 . 5 / 14 CIRCUMLE ACCET
9 5 . 5 / 15 UNDERLINE
96 . 6/ 0 GRAVE ACCENT
97 . 6/ 1 A SMALL LETTER ( Lower-case) a
98. 6/ 2 b SMALL LT ( Lower-case) b
99 .
100 .
101 .
102 .
103 .
104 .
105 .
106 .
107 .
108 .
109 .
no .
l l l .
ll2 .
113 .
ll4 .
ll5 .
l l 6.
ll7 .
ll8 .
ll9 .
120 .
121 .
122 .
123 .
124 .
125 .
126 .
127 .
6/ 3
6/ 4
6 / 5
6/ 6
6/ 7
6/ 8
6/ 9
6 / 10
6/ 1 1
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
L
p
q
r
s
t
u
v
w
7
y
z
{
}
DEL
- 154 -
SMALL LETTER ( Lower-case) c
SMALL LETE ( Lower-case) d
SMALL LT ( Lower-case) e
SMALL LT ( Lower-case) f
SMALL LETTE ( Lower-case) g
SMALL LT ( Lower-case) h
SMALL LETER ( Lower-case) i
SMALL LT ( Lower-case) j
SMALL LETER ( Lower-case) k
SMALL LETTE ( Lower-case) 1
SMALL LT ( Lower-case) m
SMALL LET ER ( Lower-case) n
SMALL LETTE ( Lower-case) o
SMALL LETTE ( Lower-case) p
SHALL LET ER ( Lower-case) q
SMALL LET ( Lower-case) r
SMALL LETTER ( Lower-case) s
SMALL LETER ( Lower-case) t
SMALL LETTER ( Lower-case) u
SMALL LETER ( Lower-case) v
SMALL LETTE ( Lower-case) w
SMALL LETER ( Lower-case) /
SMALL LETER ( Lower-case) y
SMALL LETTER ( Lower-case) z
LEF CURLY BRACKET ( Left brace)
VERTICAL LIN
RIGHT CURLY BRACKET ( Right brace)
TILDE
DELETE
Characters in position 0/ 0 to 1 / 1 5 , 4/ 0, 5 / 1 1 , 5 / 1 2 , 5 / 13 , 6/ 0 and 7 / 11 to 7 / 15 are "other
characters" according to the definition in 4 . 1 . Additional other-characters my occur in C1
and/ or G1 set ( see ECHA-3 5 ) . The number of other-characters is implementation-dependent .
- 155 -
TABLE 2
Exception Codes
The fol lowing table specifies the values of the ETYPE function corresponding to the exceptions
specified in this Standard . Nonfatal exceptions are designated by an exclamation-mark ( ! ) . The
numbers in parentheses following each exception refer to the sections in which that exception is
specified .
Overflow ( 1000)
1001 Overflow in evaluating numeric-constant ( 5 . 1 , 15 . 1 )
1002 Overflow in evaluating numeric-expression ( 5 . 3 )
1003 Overflow in evaluating numeric-suppl ied-function ( 5 . 4)
1004 Overflow in evaluating VA ( 6 . 4)
1005 Overflow in evaluating numeric-array-expression ( 7 . 2 )
1006 Overflow in numeric datum for ( MAT) RAD ( 10 . 1 , 10 . 5 )
1007 Overflow in numeric datum for ( MAT) INPUT from terminal ( 10 . 2 , 10 . 5 )
1008 Overflow in numeric data for file input ( 11 . 4 )
1009 Overflow during evaluation o f DET or DOT ( 7 . 2 )
1010 Too ny digits declared for fixed decimal ( 15 . 1 , 15 . 2 ) ( BASIC-2 only)
1011 Overflow in fixed decimal assignment ( 15 . 1 , 15 . 2 ) ( BASIC-2 only)
1051 Overflow in evaluating string-expression ( 6 . 3 )
1052 Overflow in evaluating string-array-expression ( 7 . 3 )
1053 Overflow in string datum for ( MAT) READ ( 10 . 1 , 10 . 5 )
1054 Overflow in string datum for ( MAT) ( LINE) INPUT ( 10 . 2 , 10 . 5 )
1105 Overflow in string datum for file input ( 11 . 4)
1106 Overflow in string assignment ( 6 . 5 , 9 . 1 , 7 . 3 )
Underf low errors ( 1500)
The fol lowing exceptions are recomended in the RLks Sections , and are not mandatory.
1501 Numeric constant underflow ( 5 . 1)
1502 Numeric expression underflow ( 5 . 3 )
1503 Function value underflow ( 5 . 4)
1504 VA underflow ( 6 . 4)
1505 Array expression underf low ( 7 . 2 )
1506 Numeric DATA underflow ( 10 . 1)
1507 Numeric input underflow ( 10 . 2 , 10 . 5 )
1508 File numeric input underflow ( 11 . 4)
Subscript errors (2000)
2001 Subscript out of bounds ( 5 . 2 , 6 . 2)
Mthemtical error ( 3000)
3001 Division by zero ( 5 . 3 )
3002 Negative number raised to nonintegral power ( 5 . 3 )
3003 Zero raised to negative power ( 5 . 3 )
3004 Logarithm of zero o r negative number ( 5 . 4)
3005 Square root of negative number ( 5 . 4)
3006 Zero divisor specified for MOD or RAINDE ( 5 . 4)
3007 Argument o f ACOS or ASIN not in range - 1 < = x <= 1 ( 5 . 4)
008 Attempt to evaluate ANGLE( O , O) ( 5 . 4)
3009 Attempt to invert a singular matrix, or loss of all significance in such attempt ( 7 . 2 )
- 156 -
Uninitialized errors ( 3 100)
The following exceptions are recomended in the Remarks Sections , and are not mandated .
3 101 Uninitialized numeric-variable ( 5 . 2)
3 102 Uninitialized string-variable ( 6 . 2 )
Parameter error (4000)
4001 Argument of VAL not a numeric-constant ( 6 . 4 )
4002 Argument of CH$ out o f range ( 6 . 4 )
4003 Argument of ORO not a valid character o r mnemonic ( 6 . 4)
4004 Index of SIZE out of range ( 7 . 1)
4005 Index in TAB less than one ( 10 . 3 )
4006 Margin setting less than current zonewidth ( 10 . 3 , 11. 3 )
4007 Index o f ZONEWIDTH out o f range ( 10 . 3 , 11 . 3 )
4008 Index o f LBOUND out of range ( 7 . 1)
4009 Index of UBOUND out of range ( 7 . 1)
4010 Second argument of REPEAT$ < 0 ( 6 . 4)
4101 Value of the string-expression i n a set-statement ( 13 . 1)
4301 Parameter type or count mismatch between chain-statement and corresponding program-name
line ( 9 . 3 )
4302 Mismatched dimensions between chain array parameter and corresponding formal-array ( 9 . 3 )
4303 Numeric parameters passed in chain having different ARITTIC options ( 9 . 3 )
Storage exhausted ( 5000)
5001 Size of redimensioned array too large ( 7 . 2 , 7 . 3 , 10 . 5 , 11 . 4)
Matrix errors ( 6000)
6001 Mismatched sizes in numeric-array-expression ( 7 . 2)
6002 Argument of DET not a square matrix ( 7 . 2 )
6003 Argument of INV not a square matrix ( 7 . 2 )
6004 Arguments to IDN do not specify square matrix ( 7 . 2 )
6005 First index greater than second in redim, or index less trul1 lower bound ( 7 . 2 , 7 . 3 , 10 . 5 ,
11 . 4)
6101 Mismatched sizes in string-array-expression ( 7 . 3 )
File use errors ( 7000)
7001 Channel number not in range 0 <= c <= m ( 11 . 1)
7002 Channel zero in OPEN, CLOSE, ERASE, or with record-setter ( 11 . 1 , 11 . 2 )
7003 Nonzero channel in OPEN already active ( 11 . 1 )
7004 Inactive channel in file statement other than OPEN or ASK ( 11 . 1, 11 . 2 , 11 . 3 , 11 . 4, 11 . 5 )
7050 Keyed file OPEN with wrong col late sequence ( 11 . 1) ( BASIC-2 only)
7051 LENG1! not greater than zero on OPEN ( 11 . 1)
7052 A device is opened as RELATIVE or KY ( 11 . 1) ( BASIC-2 only)
7 100 Unrecognizable file attribute in OPEN ( 11 . 1)
71xx Implementation-defined failures to provide access toe inaccordance with file attribute
( 11 . 1)
- 157 -
7202 The record- setter RECORD is used on a file opened with a file-organization other t
RELATIVE ( 11 . 2) ( BASIC-2 only)
7203 The record- setter KEY is used on a file opened with a file-organization other t K
( 11 . 2 ) ( BASIC-2 only)
7204 Record-setter SA fol lowing DELETE, OPE, or exception ( 11 . 2 )
7205 Record- setter used on device without that capabi lity ( 11 . 2 )
7206 The index o f a record-setter evaluates to an integer less than one ( 1 1 . 2 ) BASIC-2 only)
7207 A record-setter specifies an exact-search for the nul l string ( 11 . 2 ) ( BASIC-2 only)
7 301 Attempt to ERASE file not opened as OUTIN ( 11 . 1)
7 302 Output not possible to INPUT file ( 11 . 3 )
7 303 Input not possible from OUTPUT file ( 11 . 4)
7 305 Attempt to input nonexistent record ( 11 . 4)
7 308 Attempt to write existing record ( 11 . 3 )
7 311 Attempt to erase a device without erase capability ( 11 . 1)
7312 Zonewidth or margin set for non-display file ( 11 . 3 )
7 3 13 Zonewidth or margin set for INPUT file ( 11 . 3 )
7 314 A write-statement or array-write-statement attempts to access a KEYED file, but does not
specify an exact-search in its record-setter ( 11 . 3 ) ( BASIC-2 only)
7 315 A template- identifier is used on a file opened as DISPLAY or INTERNAL ( 11 . 3 ) ( BASIC-2
only)
7 316 A write-statement or array-write-statement does not have a template- identifier when
attempting to access a file opened as NATIVE ( 11 . 3 ) ( BASIC-2 only)
7 317 ( MAT) PRINT to INTERNAL file ( 11 . 3 )
7 318 ( MAT) ( LINE) INPUT from INTENAL file ( 11 . 4 )
7321 SKIP REST on stream file ( 11 . 4)
7 322 A data modification statement attempts to access a file opened as INPUT or as OUTPUT
( 11 . 5 ) ( BASIC-2 only)
7401 Attemt to trace to inactive channel ( 12 . 2 )
7402 Attempt to trace to non-display-formt or INPUT file ( 12 . 2 )
Input-output errors ( 8000)
8001 (MAT) R beyond end of data ( 10 . 1, 10 . 5 )
8002 Too few data in input-reply ( 10 . 2 , 10 . 5 )
8003 Too many data in input-reply ( 10 . 2 , 10 . 5 )
8011 End-of-file encountered on input ( 11 . 4)
8012 Too few data in record ( 11 . 4 )
8013 Too many data in record ( 11 . 4)
8101 Nonnumeric datum for ( MAT) R or INPUT o f number from DISPLAY record ( 10 . 1 , 10 . 5 , 11 . 4)
8102 Syntactical ly incorrect input-reply from terminal ( 10 . 2 , 10 . 5 )
8103 Nonnumeric datum for ( MAT) INPUT o f number ( 10 . 2 , 10 . 5 )
8105 Syntactically incorrect input reply from file ( 11 . 4)
8120 Type mismatch on INTERNAL input ( 11 . 4)
8201 Invalid format-string ( 10 . 4, 10 . 5 )
8202 No format- item in format-string for output list ( 10 . 4 , 10 . 5 )
8203 Format- item too short for output string ( 10 . 4)
8204 Exrad overflow ( 10 . 4)
8251 The string-expression of a template-identifier is not a syntactical ly correct template
element- list ( 11 . 3 , 11 . 4, 11 . 5 ) ( BASIC-2 only)
8252 A expression or array-element does not agree in tye ( numeric or string) with its
associated TEPLATE field-specifier ( 11 . 3 , 11 . 4 , 11 . 5 ) ( BASIC-2 only)
8253 A template-element with a variable-field-count does not coincide with the first element
of an array ( 11 . 3 , 11 . 4, 11 . 5 ) ( BASIC-2 only)
8254 There are not enough field-specifiers in a template-statement for all the expressions or
array-elements ( 11 . 3 , 1 1 . 4, 11. 5 ) ( BASIC-2 only)
8255 A numeric value has significant digits to the left of the available digit places in the
field of a template ( 11 . 3 , 11 . 5 ) ( BASIC-2 only)
- 158 -
8256 A string value is longer t the lengt of its field in the template ( 11 . 3 , 1 1 . 5 )
( BASIC-2 only)
8301 Record length exceeded on output to file ( 11 . 3 , 1 1 . 5 )
8302 Input from a record longer t RECSIZE ( 11 . 4 )
8401 Timeout on (MAT) ( LINE) INPUT ( 10 . 2 , 10 . 5 )
8402 I l legal numeric value specified for time-expression ( 10 . 2 , 10 . 5 )
Device errors ( 9000)
9xxx Implementation-defined device failures
Control errors ( 10000)
10001 Index out of range, no ELSE in on-goto- or on-gosub ( 8 . 2 )
10002 Retur without corresponding gosub o r on-gosub ( 8 . 2 )
10004 No case-block selected and no CASE ELSE ( 8 . 4)
10005 Attempt to chain to unavailable program ( 9 . 3 )
10007 Break statement executed when debugging active ( 12 . 2 )
Graphical errors ( 11000)
11051 Set-statement boundaries with zero width or height ( 13 . 1)
11052 Viewport boundary not in range ( 13 . 1)
11053 A boundary of the device window is not in the range [ 0 , 1 ] ( 13 . 1)
11054 A boundary of the device viewport is not in the display space ( 13 . 1)
11056 Set-statement point style out of range ( 13 . 2 )
11062 Set-statement line style out of range ( 13 . 2 )
11085 Set statement color index out of range ( 13 . 2 , 13 . 3 )
11100 Graphic-output with LINES and fewer t two points , or with A and fewer t three
points ( 13 . 3 )
When an exception occurs in a program-unit and is not handled by an exception-handler in that
program-unit, the exception which results at the line which invoked the program-unit shall be
identified by te value 100000 plus the value specified above for the exception.
- 159 -
APPEND I CES
- 160 -
APPENDIX 1
ORGANIZATION OF T STANDARD
This Standard is organized into a number of sections , each of which covers a group of related
features of BASIC. Each section is divided further to treat particular features of BASIC . The
final subdivisions of each section are used as fol lows .
Sbetion 1
General Description
This subsection briefly describes the features of BASIC to be treated .
Sbetion 2
The exact syntax of features of the language is describes in a modified context-free
gram ar or Backus-Naur Form. The details of this method of synta specification are
described in 3 . 1 .
In order to keep the syntax reasonably s imple the syntax specification will 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 ruling such
constructions out by a more complicated formal syntax, this Standard instead rules them out
by placing restrictions on that syntax .
The primary goal of the syntax is to define the notion of a program and its constituent
parts . In addition the syntax defines several other items which are not needed for the
definition of a program. These include the input-prompt , which is output to request input,
the input-reply and l ine-input-reply, which are strings supplied in response to a request
for input .
Sbsetion 3
Exales
A short l ist of valid examples that can be generated by the productions in Subsection 2 is
given. The numbering of the examples corresponds to the numbering of the productions , and
wil l not be consecutive if examples are not given for al l rules .
Sbetion 4
Semantics
The semantic rules in this Standard assign a meaning to the constructions generated
according to the syntax .
- 161 -
Sbeto 5
Exceptions
This subsection contains a list of those exception conditions which a standard-conforming
imlementation must recognize. Exception numbers ( values of the EYPE function) are also
given.
Sbetion 6
Remrks
This subsection contains remarks which point out certain features of this Standard as wel l
as remarks which make recollendations concerning the implementation of a BASIC language
processor in an operating environment .
- 162 -
APPEDIX 2
SCOPE RULES
The scope of an entity is that part of the program where its nae is recognized as referring to
that object ( 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 nae, 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 passing by reference, the same object is known by two different names , and so the object it
self may be accessed outside the scope of its name.
In all cases , the indicated scope is the scope of the name of the object in question.
Object
1 . non-parameter variable
2 . non-parameter array
3 . program-unit parameter
4 . inter-proc-def-parameter
5 . inter-proc-def
6 . program-unit
7 . DATA
8 . channel-number ( non-zero)
9 . chanel zero
10 . IMAGE, TEPLATE
11 . GOSUB stack
12 . OPTIONs
13 . filenaes
14 . R sequence
15 . [ deleted ]
16 . [ deleted ]
17 . Graphic and PRINT
set-object
18 . line-number
19 . DEBUG and TRACE state
Scope
program-unit
program-unit
program-unit ( ** )
internal-proc-def U' )
program-unit
program
program-unit
program-unit
program
program-unit ( BASIC-2 only for TEPLATE)
smaller of progra-unit, internal-proc-def , when- lock
( BASIC-2 only) , or exception-handler ( BASIC-2
only)
program-unit
program
progra
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 reference, the object denoted is comon to both the invoked and invoking unit .
- 163 -
APPEDIX 3
IMPLATION-DEINE FTS
A number of the features defined in this Standard have been left for definition by the imple
menter . However, this wil l not affect portability, provided that the limits recomended in the
various sections are respected .
The way these features are implemented shal l be defined in the user or system manual of the spe
cific imlementation.
The following is a l ist of implementation-defined features .
Subsection 2 . 3
- interpretation of syntactical ly il legal constructs
- formt of error messages
Subsection 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- line
- maximum physical l ine length
- effect of parameter list in program-name-line 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 compiled independently from the min program
Subsection 5 . 1
- precision and range of numeric-constants
Subsection 5 . 2
- initial value of numeric variables
Subsection 5 . 3
- order of evaluation of numeric-expressions
- 164 -
Subsection 5 . 4
- accuracy of evaluation of nueric functions
- value of M and EPS
- pseudo-radom number sequence
- availability of calendar and clock
- time zone for DATE and TIM
Subsection 5 . 6
- precision and range of numeric values
- precision and range of floating decimal arithmetic
- precision and range of native arithmetic
accuracy of evaluation of numeric expressions
Subsection 6 . 2
- mximum length of undeclared string-variables
- initial value of string-variables
Subsection 6 . 4
- values of CH$ for the native character set
- values of OR for the native character set
- availability of calendar and clock
- time-zone for DATE$ and TIM$
- effect of UCSE$ and LCSE$ for other-characters
Subsection 6 . 6
- collating sequence under OPTION COLATE NATIVE
- maximum length of declared string-variables without length-max
Subsection 7 . 1
- maximum lengths of strings in string-arrays with length-max
Subsection 7 . 2
- value of the inverse of a singular matrix
Subsection 9 . 1
- maximum length of string parameters without length-max
- value of a defined function when no value has been specified
- initial values of local variables in external functions
Subsection 9 . 2
- maximum length of string parameters without length-max
- effect of redimensioning an array parameter when an element of that array is also a parameter
- initial values of variables which are not forl parameters to a procedure
Subsection 9 . 3
- interpretation of the program-designator in a chain-statement
- interretation of upper-case- letters and lower-case-letters in a program-designator
- initial values of variables in a chained-to program
Subsection 10. 2
- input-prompt
- means of requesting input in batch mode
- values ( minimum and mximum) and resolution of timeout-expression and time- inquiry
- 165 -
Subsection 10 . 3
- effect of invoking a function which causes printing whi le printing
- s ignificance width for printing numeric representations
- exrad width for printing numeric representations
- effect of nonprinting characters on columnar position
- default margin
- default zonewidth
- treatment of trailing space at end of print line
- use of upper-case or lower-case "E" in exrad
Subsection 10 . 5
- treatment o f re-supply of input to a re-dimensioned array
Section 11
- effect of some fi le operations on devices
- effect of certain combinations of file organization and type
Subsection 11 . 1
- maximum channel number
- wheter a file name with different case letters ( lower or upper) denotes the same file or dif-
ferent files
- effect of attempting to open an already oper file
- number of channels which can be active simultaneous ly
- attempting to open a file with attributes different from those under which it was created
- attempting to reopen a file under a different ARITHTIC option
- two program-units attempting to open a file under different attributes or options
- means of insuring preservation of file contents between runs
- effect of certain combinations of file organization and type
- length of records in INTENAL and NATIVE ( for BASIC-2 only) files
- maximum length of records when not specified or available
- value of DATUM for a SEQUTIAL ( BASIC- 1) or non-STREAM ( BASIC-2 only) file
- value of ask-attribute NAM for channel zero
- meaning of exception codes 7 101-7 199
- maximum length of keys for KEYED file ( BASIC-2 only)
Subsection 11 . 2
- method o f signifying that data i s not available for input on a non-file device channel
Subsection 11 . 3
- means of indicating end-of-record
- default margin and zonewidth
- maximum margin and zonewidth supported
- accuracy of printed numeric values produced by PRINT for DISPLAY files
Subsection 11 . 4
number of significant digits for values received from a numeric field in a NATIVE ( for BASIC-2
only) file
- effect of input-control-items on files and nonterminal devices
- precision of numeric contents received from display fi les
precision of numeric-values that can be retrieved without loss of precision from a NATIVE file
( BASIC-2 only)
- retrieving a record from a NATIVE file having contents which are incompatible with the TEPLATE
( BASIC-2 only)
- use of fatal or nonfatal exception procedure on illegal input-reply
- 166 -
Subsection 11 . 5 ( BASIC-2 only)
- effect of data modification statements on files that are not RELATIVE or KEYED
- use of SKIP in incompatible template for REWRITE
Subsection 12 . 1 ( BASIC-2 only)
- value of EPE for locally defined exceptions
- format of EE$ values
Subsection 12 . 2
- actions al lowed by debugging system
- form of trace reports
Subsection 13 . 1
- mner of selecting a particular graphic display device
- effect of " inverted" windows
Subsection 13 . 2
- number o f line styles available for graphics
- effect of line styles other than 1
- number of point styles available for graphics
- effect of point styles other than 3
- the number of color values available
- the color associated with each color value
Subsection 13 . 3
- character size , style, and orientation for graphic labels
Subsection 15 . 1 ( BASIC-2 only)
- the maximum precision avai lable for fixed decimal arithmetic
- the precision of fixed decimal expression and function evaluation
- the accuracy of fixed decimal expression and function evaluation
- definition of "significant digits"
- the accessibi lity of an INTERNAL format file to programs having different ARITHETIC options
- the accessibil ity of a NATIVE format file to programs having different ARITHIC options
Table 1
- The number of additional other-characters .
It should be noted that implementation-defined features my cause the same program to produce
different results on different implementations , for these and possibly other reasons :
- The logical flow of a program may be affected by the algorithm used for the pseudo-random num
ber sequence .
- The logical flow of a program may be affected by the value of machine infinitesimal and/or the
value of M and/ or the precision for numeric values .
- The initial value of variables my affect the logical flow of a program which contains logical
errors .
The order of evaluation of numeric-expressions may affect the logical flow of a program.
- 167 -
APPEIX 4
INDE OF SYNTACTIC OBJECTS
This Appendix indexes all occurences of terminal symbols 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. A asterisk following a reference
indicates that the metaname is defined in that production. Sbls a tI ue oly i
BIC-2 M so i bld.
Example: 4 . 1-07 refers to Section 4 . 1 , Subsection 4 . 1 . 2 ( the Syntax subsection) , production
rule 7 .
0 4 . 1-07 7 . 1-09
1 4 . 1-07 7 . 1-09
2 4 . 1-07
3 4 . 1-07
4 4 . 1-07
5 4. 1-07
6 4 . 1-07
7 4 . 1-07
8 4 . 1-07
9 4 . 1-07
A 4 . 1-09
ABS 5 . 4-01
ACCESS 11 . 1-08 11 . 1-22
ACOS 5 . 4-01
A 8. 1-03
ANGLE 5 . 4-01 5 . 6-03
A 13 . 2-04 13 . 3 -05
ARITHTIC 5 . 6-03 15 . 1-01
ASIN 5 . 4-01
ASK 10 . 3 -08 11 . 1-18 13 . 1-04
AT 13 . 3-12
ATN 5 . 4 . 01
B 4 . 1-09
BASE 7 . 1-09
BEGIN 11 . 2-05
BREAK 12 . 2-02
c 4 . 1-09
CALL 9 . 2- 14
CASE 8 . 4-13 8 . 4-16 8 . 4-21
CAUSE 12 . 1-13
CEIL 5 . 4-01
CHAIN 9 . 3-01
CH 6 . 4-01
CLEAR 13 . 2-02
CLIP 13 . 1-01 13 . 1-06
CLOSE 11 . 1-16
COLLATE 6 . 6-01 11. 1-29 11. 1-31
COLOR 13 . 2-03 13 . 2-07
CON 7 . 2-06
- 168 -
CONTINUE 12. 1-11
cos 5 . 4-01
COSH 5 . 4-01
COT 5 . 4-01
esc 5 . 4. 01
D 4 . 1-09
DATA 10 . 1-06
DATE 5 . 4-01 6 . 4-01
DATUM 11 . 1-22
DEUG 12 . 2-01
DECIMAL 5 . 6-03
DECLAR 5 . 6-04
DEF 9 . 1-05 9 . 1-07 9 . 1-20 15 . 2-07
DEG 5 . 4-01
DEGRES 5 . 6-03
DEETE 11. 5-06
DET 7 . 2- 10
DEVICE 13 . 1-01 13 . 1-06
DIM 7 . 1-01
DISPLAY 11 . 4- 14
D 8 . 3-04 8 . 3-07
DT 7 . 2-10
E 4 . 1-09 5 . 1-08 11.3-N22
ELAPSE 10 . 2-07
ESE 8 . 2-03 8 . 2-06 8. 4-01 8. 4-09 8. 4-21
ESEIF 8. 4-07
E 4 . 2-18 8. 4-10 8 . 4-22 9 . 1-13 9 . 2- 10
11. 2-05 12 . 1-07 12. 1-17
EPS 5 . 4-01
EASABLE 11 . 1-22
ERASE 11. 1-17
ECEPTION 12 . 1-03 12. 1-09 12. 1-13
EIT 8 . 3-07 8. 3- 18 9 . 1-18 9 . 2-11 12. 1-12
EINE 12. 1-18
E 5 . 4-01
EEA 9 . 1-15 9 . 1-22 9 . 2-13 9 . 2-19 15. 2-06
E 12. 1-19
EPE 12. 1-18
F 4 . 1-09
FILETYPE 1 1 . 1-22
FIX 5 . 6-03 15. 1-01
FOR 8 . 3-12 8 . 3-18
FP 5 . 4-01
FUNCTION 9 . 1-12 9 . 1-13 9 . 1-15 9 . 1-18 9 . 1-21
9 . 1-22 15. 2-05 15. 2-0
G 4 . 1-09
GO 8 . 2-02 8 . 2-03 8 . 2-04 8. 2-06
GO SUB 8. 2-04 8 . 2 -06
GOTO 8 . 2-02 8 . 2-03
GRAPH 13 . 3-04
H 4 . 1-09
- 169 -
HL 12. 1-12 12. 1-16 12. 1-17
I 4 . 1-09
IDN 7 . 2-06
IF 8 . 4-01 8 . 4-04 8 . 4-10 10 . 1-03 11. 2-07
IMAGE 10 . 4-05
IN 12. 1-03
INPUT 10 . 2-01 10 . 2-08 10 . 5-04 10 . 5-06 11 . 1-08
11. 4-01 11 . 4-02 1 1 . 4-03 11. 4-04
INT 5 . 4-01
INTERNAL 11 . 1-14
INV 7 . 2-09
IP 5 . 4-01
IS 8 . 4-19
J 4 . 1-09
K 4 . 1-09
KEY 11 . 1-31 11.2-10
KEYED 11. 1-24
L 4 . 1-09
LBOUND 7 . 1- 12
LCASE 6 . 4-01
L 6 . 4-02
LENGT 11. 1-15
LET 5 . 5-02 6 . 5-02 9 . 1-16 9 . 1- 17
LINE 10 . 2-08 10 . 5-06 11 . 4-03 11 . 4-04 13 . 2-05
LINES 13 . 3 -05
LOG 5 . 4-01
LOG10 5 . 4-01
LOG2 5 . 4-01
LOOP 8 . 3 -09
LTRIM 6 . 4-01
M 4 . 1-09
MARGIN 10 . 3 . 07 10 . 3- 10 11 . 1-22 11. 3-05
MAT 7 . 2-02 7 . 3- 02 10 . 5-01 10 . 5-04 10 . 5-06
10 . 5-09 11 . 3-02 11 . 3 -07 11 . 4-02
11 . 4-04 11. 4-08 11. 5-03
MA 5 . 4-01 13 . 2-07
MAXEN 6 . 4-03
M 5 . 4-01
MAXSIZE 7 . 1- 12
MIN 5 . 4-01
MISSING 10 . 1-03
MOD 5 . 4-01
N 4 . 1-09
NAM 11. 1-01 11 . 1-22
NATIVE 5 . 6-03 6 . 6-01 11. 1-29 1Ll-N26
N 8 . 3 -20
- 170 -
NOT 8. 1-04
N 7 . 3 -05
NUMRIC 5 . 6-06 11. 3-N21 15. 1-03
0 4. 1-09
OF 11. 3-Nl8 11. 3-N19
OFF 12 . 2-01 12 . 2-03
ON 8. 2-03 8 . 2-06 12 . 2-01 12 . 2-03
OPEN 11 . 1-01
OPTION 5 . 6-01
OR 8 . 1-02
ORD 6 . 4-02
ORGANI ZATION 11. 1-09 11 . 1-22
OUT IN 11 . 1-08
OUTPUT 11 . 1-08
p 4. 1-09
PI 5 . 4-01
POINT 13 . 2 -05
POINTER 11 . 1-22 11 . 2-03
POINTS 13 . 3 -05
POS 6 . 4-02
PRINT 10 . 3-01 10 . 4-01 10 . 5-09 11 . 3 -01 1 1 . 3-02
PROGRAM 4. 2-02
PROMPT 10 . 2-04
Q 4 . 1-09
R 4. 1-09
RAD 5 . 4-01
RADIANS 5 . 6-03
RANDOMIZE 5 . 4-02
R 10 . 1-01 10 . 5 . 01 11 . 4-07 11 . 4-08
RECORD 11. 1-31 11. 2-10
RECSIZE 11 . 1-15 11 . 1-22
RECTYPE 11 . 1-12 11 . 1-22
RELATIVE 11. 1-24
R 4. 3 -01
REAINDE 5 . 4-01
REPEAT 6 . 4-01
REST 11. 1-17 11 . 4-01 11 . 4-07
RESTORE 10 . 1-05
RETRY 12. 1-11
RETURN 8 . 2-05
REWRITE 11. 5-02 11. 5-03
R 5 . 4-01
ROUND 5 . 4-01
RTRIM 6 . 4-01
s 4. 1-09
SAM 11 . 2-05
SEC 5 . 4-01
SELECT 8 . 4-13 8 . 4-22
SEQUENTIAL 11 . 1-11
SET 10 . 3-06
SETTE 11 . 1-22
- 17 1 -
SGN 5 . 4-01
SIN 5 . 4-01
SINH 5 . 4-01
SIZE 7 . 1-12 13 . 1-06
SKIP 11. 3-N18 11 . 4-01 11 . 4-07
SQR 5 . 4-01
STANDARD 6 . 6-01 11. 1-29
STATUS 13 . 1-05
STEP 8 . 3 -12
STOP 4 . 2-13
STR 6 . 4-01
STREA 1 1 . 1-11
STRING 6 . 6-03 11. 3-N26
STYLE 13 . 2-03 13 . 2-07
SUB 8 . 2-04 8 . 2-06 9 . 2-04 9 . 2- 10 9 . 2-11
9 . 2-18 9 . 2-19
T 4 . 1-09
TAB 10 . 3 -04
TAN 5 . 4-01
TANH 5 . 4-01
TEPLATE 11. 3-N15
T 13 . 2-04 13 . 3 - 11
T 8 . 4-01 8 . 4-04 8 . 4-07 10 . 1-03 11 . 2-07
T 11 . 2-07
TIM 5 . 4-01 6 . 4-01
TIMOUT 10 . 2 . 05
TO 7 . 1-06 7 . 2-08 8 . 2-02 8 . 2-03 8 . 3 - 12
8 . 4- 19 12 . 2-03
TRACE 12 . 2-03
TRN 7 . 2-09
TRUNCATE 5 . 4-01
u 4 . 1-09
UBOUND 7 . 1-12
UCASE 6 . 4-01
UNTIL 8 . 3 -05
USE 12 . 1-05 12 . 1-0
USING 6 . 4-01 10 . 4-02 10 . 5-09 11 . 3-04 13 . 3 - 11
v 4 . 1-09
VAL 6 . 4-02
VARIABLE 11 . 1-15
VIEWPORT 13 . 1-01 13 . 1-06
w 4 . 1-09
W 12. 1-03 12. 1-07 12. 1-09
WHILE 8 . 3 -05
WINDOW 13 . 1-01 1 3 . 1-06
WITH 9 . 3 -01 11. 3-N13
WRITE 11 . 3-06 11 . 3-07
X 4 . 1-09
y 4 . 1-09
- 172 -
z 4 . 1-09
ZE 7 . 2-06
ZONIDT 10 . 3 -07 10 . 3- 10 11 . 1-22 11 . 3-05
a 4 . 1-10
access-mode 1 1 . 1-07 11 . 1-08l'<
actual-array 5 . 3 -09 5 . 3- lOl'< 7 . 1- 13 7 . 1-14 9 . 2-16
ampersand 4 . 1-03 4 . 2-24 6 . 3-06
apostrophe 4 . 1-03 10 . 4-08
array-assignment 4 . 2- 12 7 . 2-0ll'< 7 . 3-0ll'<
array-declaration 7 . 1-02 7 . l-03l'<
array-input-statement 4 . 2- 12 10 . 5-04)'( 1 1 . 4-02)'(
array- line- input-statement 4 . 2-12 10 . 5-06)'1 11 . 4-04)'1
array- list 1 1 . 3 -07 11 . 3- 1P'< 11. 5-03
array-name 5 . 2- lOl'< 5 . 3 - 10 6 . 2-08)'( 9 . 1-11 10 . 5-03
10 . 5-05 10 . 5- 10 10 . 5-11 11 . 3 - 11
array-output- list 10 . 5-09 10 . 5- lP 11 . 3-02
array-print- list 10 . 5-09 10 . 5- lOl'< 11 . 3-02
array-print-statement 4 . 2- 12 10 . 5-09l'< 11 . 3 -02l'<
array-read-statement 4 . 2-12 10 . 5-0P'< 1 1 . 4-08l'<
array-rewrite-statement 11. 5-01 11. 5-03*
array-write-statement 4 . 2- 12 11 . 3-07l'<
ask-attribute-name 11 . 1-20 ll . l-2ll'< 11. 1-30
ask- io- item 10 . 3-09 10 . 3 - 10l'<
ask-io- list 10 . 3 -08 10 . 3 -09l'<
ask- item 11 . 1-19 11 . 1-20l'<
ask-item- list 1 1 . 1-18 ll . 1- l9l'l
ask-object 13 . 1-04 13 . 1-06' 13 . 2-07l'<
ask-statement 4 . 2- 12 10 . 3-08l'< ll . l- l8l'l 13 . l-04l'<
asterisk 4 . 1-03 5 . 3 - 11 6 . 6-04 7 . 2-04 7 . 2-05
10 . 4-13 11. 3-N21 11. 3-N26 15. 1-02
b 4 . 1-10
block 4 . 2-05 4. 2-07l': 8 . 3-06 8 . 3 - 17 8 . 4-05
8 . 4-06 8 . 4-08 8. 4- 14 8 . 4-20
9 . 1-02 9 . 2-02 12. 1-0 12. 1-06
bound-argument 7 . 1-12 7 . 1- 14)':
boundaries 13 . 1-01 13 . l-02l'<
boundary 13 . 1-02 13 . l-03l'<
boundary-variables 13 . 1-06 13 . 1-07l'<
bounds 7 . 1-04 7 . 1-05' 7 . 1-08
bounds-range 7 . 1-05 7 . 1-06'
break-statement 4 . 2-12 12 . 2-02
c 4 . 1-10
call-statement 4 . 2-12 9 . 2- l4l'<
case-block 8 . 4-11 8 . 4- 14'
case-else-block 8 . 4-J. l 8 . 4-20)'(
case-else- line 4 . 2-22 8 . 4-20 8 . 4-2P''
case- item 8 . 4- 17 8 . 4- l8l'<
case- line 4 . 2-22 8 . 4- 14 8. 4- 15:':
case- list 8 . 4-16 8 . 4-l7l'<
case-statement 8 . 4-15 8 . 4- l6l'<
cause-statement 4 . 2-12 12 . 1-13*
- 17 3 -
chain-statement 4 . 2-12 9 . 3-0P<
channel-expression 9 . 2-16 11. 1-02 11 . 1-03, 11. 1-16 11. 1-17
11. 3-01 11 . 3-02 11. 3-06 11. 3 -07
11. 4-01 11 . 4-02 11-4-03 11 . 4-04
11 . 4-07 11 . 4-08 11. 5-02 11. 5-03
11. 5-06 12 . 2-03
channel-number 9 . 2-07 9. 2-08)'(
channel-setter 11. 1-01 11 . 1-02)'( 11 . 1-18 11 . 2 -01 11. 3-05
character 4 . 1-01>'< 4 . 3 -02 10 . 2-11
circumflex-accent 4 . 1-03 5 . 3 -04 10 . 4-15
clear-statement 13 . 2-01 13 . 2-02)'(
close-statement 4 . 2-12 11. 1-16)'(
collate-sequence 11. 1-28 11. 1-29*
colon 4 . 1-03 6 . 2-06 10 . 1-01 10 . 2-02 10 . 4-02
10 . 4-05 10 . 4-08 10 . 5-01 10 . 5-09
11. 1-02 11 . 3-01 11 . 3-02 11. 3-06
11. 3-07 11. 3-N15 11. 4-01 11. 4-02
11. 4-03 11. 4-04 11. 4-07 11. 4-08
11. 5-02 11. 5-03 13 . 3-03 13 . 3 -11
coma 4 . 1-03 5 . 2-06 5 . 3 -08 5 . 5-03 5 . 6-02
5 . 6-06 6 . 5-03 6 . 6-03 7 . 1-02
7 . 1-05 7 . 1-14 7 . 2-07 7 . 2- 10
8 . 2-03 8. 2-06 8. 4-17 9 . 1-09
9 . 1-11 9 . 1-23 9 . 2-06 9 . 2-15
9 . 2-20 10 . 1-02 10 . 1-07 10 . 2-02
10 . 2- 10 10 . 3-05 10 . 3 -09 10 . 4-04
10 . 4-12 10 . 5-02 10 . 5-07 10 . 5 -11
11. 1-05 11. 1-19 11 . 2-02 11 . 3 -03
11 . 3-08 11 . 3 - 10 11 . 3-11 11. 3-N16
11. 4-01 11. 4-05 11 . 4-07 11. 4-09
11. 5-04 11. 5-07 13 . 1-02 13 . 1-06
13 . 1-07 13 . 3 -07 13 . 3 - 11 13 . 3 -12
15. 1-03
comparison 8 . 1-05 8 . 1-06>'(
concatenation 6 . 3 -02 6 . 3-06l'< 7 . 3 -03 7 . 3-05
conditional-statement 4 . 2-10 4 . 2- 14)'(
conjunction 8 . 1-02 8. 1-03l'(
constant 5 . 1-0P'< 6 . 1-01)'( 8 . 4- 18 8. 4- 19 10 . 1-08
control-transfer 8 . 2-0P'<
control-variable 8. 3 - 12 8 . 3- 13l'< 8 . 3 -20
coordinate-pair 13 . 3 -06 13 . 3 -07l'( 13 . 3 - 12
core-attribute-name 11 . 1-21 11 . 1-22'
core-file-attribute 11. 1-06 11 . 1-07>'<
core-file-erg-value 11. 1-10 11 . 1- 1P'<
core-record-setter 11. 2-03 11 . 2-04 11 . 2-05>'< 11 . 3-04 11. 4-06
core-record-type-value 11. 1-13 11 . 1- 14)'(
d 4 . 1-10
data- list 10 . 1-06 10 . 1-07>'< 10 . 2- 10
data-statement 4. 2-11 10 . 1-06l'<
datum 10 . 1-07 10 . 1-08>'<
debug-statement 4 . 2- 12 12 . 2-0P'<
declarative- statement 4 . 2-10 4. 2-1P'< 11. 3-N14*
declare-statement 4 . 2- 11 5 . 6-04)'<
def- statement 9 . 1-03 9 . 1-04>'(
def-type 9 . 1-19 9 . 1-20)'(
- 174 -
defined-function 9 . 1-23 9. 1-24'( 15. 2-08
delete-control 11. 5-06 11. 5-07*
delete-control - item 11. 5-07 11. 5-0
delete-statement 11. 5-01 11. 5-0
detached-handler 4. 2-06 12 . 1-15*
digit 4 . 1-06 4. 1-07)'( 4. 2-09 4. 4-03 5 . 1-06
10 . 4-08
digit-place 10 . 4- 12 10 . 4- 13)'(
dimension- list 7 . 1-01 7 . 1-02l'(
dimension-statement 4. 2-11 7 . l-OP''
disjunction 8. 1-01 8 . 1-02)'(
do-body 8 . 3-02 8. 3-Q6l'C
do- l ine 4 . 2-22 8 . 3-02 8. 3-03)'(
do- loop 8. 3-01 8 . 3-02,
do-statement 8 . 3-03 8. 3-04,
dol lar-sign 4 . 1-03 4 . 4-04 6 . 4-01 7 . 3-05 10 . 4-11
12. 1-19
double-quote 4 . 1-02 4. 1-Q4l'C
e 4 . 1-10
e-format- item 10 . 4-09 10 . 4-15)'(
else-block 8. 4-03 8 . 4-08)'(
else- l ine 4 . 2-22 8 . 4-08 8 . 4-09)'(
elseif-block 8 . 4-03 8 . 4-06)'(
elseif-then- line 4 . 2-22 8 . 4-06 8. 4-07,
end-function- line 4 . 2-22 9 . 1-02 9 . l- 13l'C 9 . 1-14
end-hadler- line 4. 2-22 12. 1-15 12. 1-17*
end- if- line 4 . 2-22 8 . 4-03 8 . 4- 10)'(
end- l ine 4 . 2-04 4 . 2- 17)'( 4 . 2-22
end-of- l ine 4 . 2-15 4. 2- 16)'( 4 . 2-21 10. 2-10 10 . 2- 11
10 . 4-05
end-select- line 4 . 2-22 8 . 4-11 8 . 4-22)'(
end-statement 4 . 2- 17 4 . 2- l8l'C
end-sub- line 4 . 2-22 9 . 2-02 9 . 2-09) 9 . 2-12
end-sub-statement 9 . 2-09 9. 2- lQl'C
end-when- line 4. 2-22 12 . 1-02 12. 1-07* 12. 1-08
enhanced-attribute-name 11. 1-30 11. 1-31*
enhanced-file-attribute 11. 1-27 11. 1-28*
enhanced-file-org-value 11. 1-23 11. 1-24*
enhanced-record-setter 11. 2-08 11. 2-0 11. 2-10
enhanced-record-type-value 11. 1-N25 11. 1-N26*
equality-relation 8. 1-07 8 . 1-Q8l'C
equals-sign 4 . 1-03 5 . 5-02 6 . 5-02 7 . 2-02 7 . 3 -02
8. 1-08 8. 1-10 8. 1-11 8. 3-12
9 . 1-05 9 . 1-07 9 . 1-16 9 . 1-17
10 . 4-08 11. 2-11 15 . 2-07
erase-statement 4 . 2-12 11 . 1- 17'(
exact-search 11. 2-10 11.2-11*
exception-handler 12. 1-02 12 . 1-0 12. 1-15
exception-type 12 . 1-13 12. 1-14*
exclamation-mark 4 . 1-03 4 . 3-04 10 . 4-08
exit-condition 8 . 3-04 8 . 3-05)'( 8 . 3-09
exit-do-statement 4 . 2-12 8 . 3 -07it 10 . 1-04
exit-for-statement 4 . 2- 12 8 . 3- 18 10 . 1-04
exit-function-statement 4 . 2- 12 9 . 1- 18)'(
exit-handler-statement 4. 2-12 12 . 1-12*
- 175 -
exit-sub-statement 4 . 2-12 9 . 2-11'
expression 5 . 3-01l'( 5 . 3-09 6 . 3-0P't 8 . 4-13 9 . 2- 16
10 . 3-03 10 . 4-04 11 . 3- 10
expression-list 11 . 3-06 11 . 3- 10l'( 11. 5-02 13 . 3-11
exrad 5 . 1-04 5 . 1-08l'(
external-function-de 4 . 2-20 9 . 1-01 9 . 1- 14l'(
external-function- line 4 . 2-22 9 . 1-14 9 . 1- l5l't 15.2-0
external-function-type 9 . 1-19 9 . 1-22l't
external-sub-de 4. 2-20 9 . 2-01 9 . 2- l2l'(
exteral-sub- line 4 . 2-22 9 . 2- 12 9 . 2- 13l't
external-sub-type 9 . 2-17 9 . 2- l9l'(
f 4 . 1-10
-format- item 10 . 4-09 10 . 4- l4l'( 10 . 4-15
factor 5 . 3-03 5. 3 -04'
field-specifier 11. 3-NH 11. 3-N20
file-attribute 11 . 1-05 11 . 1-06l't 11. 1-27*
file-attribute-list 11 . 1-01 11 . 1-05l't
file-name 11 . 1-01 11 . 1-04l':
file-organization 11 . 1-07 11 . 1-09l':
file-organization-value 11 . 1-09 11 . 1-10l': 12. 1-23*
fixed-declaration 15 . 1-03 15. 1-04*
fixed-defined-function 15. 2-05 15. 2-06 15. 2-07 15. 2-08 15. 2-09*
fixed-field-count 11. 3-N17 11. 3-NlS*
fixed-foral-array 15. 2-03 15. 2-04*
fixed-point-size 11. 3-N22 11. 3-R23* 15. 1-02
fixed-point-type 15 . 1-01 15. 1-02* 15. 1-03 15. 1-0 15. 2-03
15 . 2-04 15. 2-09
floating-characters 10 . 4-09 10 . 4- l P't
for-body 8 . 3 - 10 8 . 3- 17l'(
for- line 4 . 2-22 8 . 3 - 10 8 . 3- 1P't
for- loop 8 . 3 -01 8 . 3 - 10l'(
for-statement 8 . 3 - 11 8 . 3- 12l'(
formal-array 9 . 1-10 9 . 1- 1P 9 . 2-07 15. 2-0
formt- item 10 . 4 . 06 10 . 4-09l't
formt-string 10 . 4 . 05 10 . 4 . 06l'(
formatted-print- list 10 . 4-01 10 . 4-02l'(
fraction 5 . 1-05 5 . 1-07l':
fraction-size 11. 3-N23 11. 3-N25l
function-arg- list 5 . 3 -06 5 . 3 -08' 6 . 3 -04 9 . 3-01
function-argument 5 . 3 -08 5 . 3 -09l't
function-de 9 . 1-0P't
function- list 9 . 1-20 9 . 1-21 9 . 1-22 9 . 1-23l't
function-parameter 9 . 1-09 9 . 1- 10l't 15. 2-01*
function-parm- list 4 . 2-02 9 . 1-05 9 . 1-07 9 . 1-09l't 9 . 1-12
9 . 1-15 15. 2-05 15. 2-0 15. 2-07
g 4 . 1-10
geometric-object 13 . 3-03 13 . 3-05l't
geometric-statement 13 . 3 -02 13 . 3-03'
gosub-statement 4 . 2-12 8 . 2-01 8. 2-04l'(
goto-statement 4 . 2-12 8 . 2-01 8 . 2-02l't
graphic-output-statement 13 . 3 -01 13. 3 -02l'(
graphic-text-statement 13 . 3 -02 13 . 3- 11'
graphic-verb 13 . 3-03 13 . 3-04l't 13 . 3 - 11
- 176 -
greater-than-sign 4. 1-03 8 . 1-07 8 . 1-09 8 . 1-10 10 . 4- 10
11.2-12
h 4. 1-10
handler- line 4. 2-22 12. 1-15 12. 1-16*
handler-name 12. 1-0 12. 1-10 12. 1-16
handler-retur-statement 4. 2-12 12. 1-11*
i 4 . 1-10
i-formt-item 10 . 4-09 10 . 4-12)'( 10 . 4-14 10 . 4-15
identifier 4. 4-0P'
<
identifier-character 4. 4-02 4. 4-03)'( 4. 4-04 4. 4-05
if-block 4. 2-07 8 . 4-03)'(
if-clause 8 . 4-01 8 . 4-02)'(
if-statement 4 . 2-14 8 . 2-01 8. 4-0P'<
if-then-line 4. 2-22 8 . 4-03 8. 4-04j(
iage 10 . 4-02 10. 4-03)'( 10 . 5-09 11. 3-04 13 . 3- 11
image- l ine 4 . 2-07 4 . 2-22 10 . 4-05)'(
imperative-statement 4. 2 - 10 4 . 2-12)'( 8 . 2-03 8 . 2-06 8 . 4-02
11. 5-01* 13 . 2-01)'( 13 . 3-01j(
implementation-defined 4. 1-11 4. 2-16 10 . 2-09
increment 8 . 3-12 8. 3-16)'(
index 5 . 2-07 5 . 2-08)'( 6 . 2-06 7 . 1-14 7 . 2-08
8 . 2-03 8 . 2-06 10 . 3-04 10 . 3-07
11 . 1-03 11 . 1-15 11. 2-10 11. 3-05
12. 1-14 13 . 2-03
inexact-search 11. 2-10 11. 2-12*
initial -point 13 . 3- 11 13 . 3-12)'(
initial-value 8 . 3 -12 8. 3-14)'(
input-control 11 . 4-01 11. 4-02 11 . 4-03 11 . 4-04 11 . 4-05)'(
input-control-item 11 . 4-05 11 . 4-06)'(
input-modifier 10 . 2-02 10 . 2-03)'(
input-modifier- list 10 . 2-01 10 . 2-02)'( 10 . 2-08 10 . 5-04 10 . 5-06
input-prompt 10. 2-09)'(
input-reply 10 . 2- 10)'(
input-statement 4 . 2-12 10 . 2-02)'( 11 . 4-0P'<
integer 5 . 1-05 5 . 1-06)'( 5 . 1-07 5 . 1-08 6 . 6-04
7 . 1-07 9 . 2-08 11. 3-N18 11. 3-N24
11. 3-N25 11. 3-N27
integer-size 11. 3-N23 11. 3-N24*
interl-def-line 4. 2-22 9 . 1-02 9 . 1-03)'(
internal-function-def 4. 2-06 9 . 1-01 9 . 1-02)'(
internal-function-line 4. 2-22 9 . 1-02 9 . 1-12)'( 15. 2-05*
interal-function-type 9 . 1-19 9 . 1-2P'<
internal-proc-def 4. 2-05 4. 2-06)'(
interl-sub-def 4. 2-06 9 . 2-01 9 . 2-02)'(
internal-sub- line 4. 2-22 9 . 2-02 9 . 2-03)'(
interl-sub-type 9 . 2-17 9 . 2- 18)'(
io-recovery 8 . 2-01 11. 2-02 11. 2-06)'(
io-recovery-action 10 . 1-03 10 . 1-04)'( 11. 2-07
j 4. 1-10
justifier 10 . 4-09 10 . 4-10)'(
- 177 -
k 4 . 1-10
1 4 . 1-10
left-parenthesis 4 . 1-03 5 . 2-06 5 . 3 -05 5 . 3 -08 6 . 2-06
6 . 3 -03 6 . 4-03 7 . 1-05 7 . 1-13
7 . 1-14 7 . 2-07 7 . 2-09 7 . 2-10
8 . 1-05 9 . 1-09 9 . 1-11 9 . 2-06
9 . 2-15 10 . 3 -04 10 . 4-08 10 . 5-05
11. 3-N7
length-mx 6 . 6-03 6. 6-04>'( 6 . 6-06 7 . 1-10 9 . 1-07
9 . 1-12 9 . 1-15
less-than-sign 4 . 1-03 8 . 1-07 8 . 1-09 8 . 1-11 10 . 4-10
let-statement 4 . 2-12 5 . 5 -0P'' 6 . 5-0P'c
letter 4 . 1-06 4 . 1-08>'( 4 . 4-02 4 . 4-03 4 . 4-04
4 . 4-05 10 . 4-08
l imit 8 . 3 - 12 8 . 3 - 15>'(
line 4 . 2- 22>'(
line-continuation 4 . 2 . 24>'(
line-continuation 4 . 2-24>'(
line- input- reply 10 . 2- l l\'(
l ine- input- statement 4 . 2-12 10 . 2-08>'c 11 . 4-03>'(
line-number 4 . 2-02 4 . 2-08 4 . 2-09>'( 4. 2-17 4 . 2-21
8 . 2-02 8 . 2-03 8 . 2-04 8 . 2-06
8 . 3 -03 8 . 3-08 8 . 3 - 11 8 . 3-19
8 . 4-02 8 . 4-04 8 . 4-07 8. 4-09
8 . 4- 10 8 . 4- 12 8 . 4- 15 8 . 4-21
8 . 4-22 9 . 1-03 9 . 1-12 9 . 1-13
9 . 1-15 9 . 2-03 9 . 2-09 9. 2-13
10 . 1-04 10 . 1-05 10 . 4-03 10 . 4-05
11. 3-N3 12. 1-03 12 . 1-05 12. 1-07
12 . 1-09 12 . 1-16 12 . 1-17 15. 2-05
15. 2-06
l iteral- item 10 . 4-07 10 . 4-08>'
l iteral-string 10. 4-06 10 . 4-07>'(
loop 4 . 2-07 8 . 3-0l>'c
loop- l ine 4 . 2-22 8 . 3 -06 8 . 3-08>'(
loop-statement 8 . 3 -08 8 . 3-09>'(
lower-case- letter 4 . 1-08 4 . 1- 10>'c
m 4 . 1-10
main-program 4 . 2-01 4 . 2-04>'( 4 . 2-23
maxsize-argument 7 . 1- 12 7 . 1- 13>'c
minus-sign 4 . 1-06 5 . 1-03 10 . 4-11
missing-recovery 10 . 1-01 10 . 1-03>'( 10 . 5-01 11. 2-06 11 . 4-06
11 . 4- 10 11. 5-05 11. 5-08
multiplier 5 . 3 -03 5 . 3-11>'c
n 4 . 1-10
next- l ine 4 . 2-22 8 . 3 - 17 8 . 3- 19>'(
next-statement 8 . 3 - 19 8 . 3-20>'(
non-quote-character 4 . 1-01 4 . 1-02 4 . 1-03>'(
not-equals 8 . 1-08 8 . 1-09>'c
not-greater 8 . 1-07 8 . 1- 111''
not- less 8 . 1-07 8 . 1- 10>'( 11. 2-12
not-missing-recovery 11 . 2-06 11 . 2-07>'( 11 . 3 -04 11 . 3-09
- 178 -
nul l-statement 4 . 2-11 4 . 2-21 4. 3-0V<
number-sign 4 . 1-03 9 . 2-08 10 . 4-13 10 . 4-14 11. 1-03
numeric-array 5 . 2-04 5 . 2-05l'< 5 . 2- 10 7 . 1-04 7 . 2-02
7 . 2-03 7 . 2-09 7 . 2- 10
numeric-array-assignment 7 . 2-01 7 . 2-02l'l
numeric-array-declaration 7 . 1-03 7 . l-04l'( 7 . 1-11 15. 1-04
numeric-array-element 5 . 2-02 5. 2-04l'l
numeric-array-expression 7 . 2-02 7 . 2-03)'(
numeric-array-function-ref 7 . 2-03 7 . 2-09l'l
numeric-array-operator 7 . 2-03 7 . 2-04l'(
numeric-array-value 7 . 2-03 7 . 2-06)'(
numeric-constant 5 . 1-01 5 . 1-02)'(
numeric-declaration 5 . 6-06 5. 6-07)'( 7 . 1- lP'<
numeric-def-statement 9 . 1-04 9 . 1-05)'( 15 . 2-07*
numeric-defined-function 5 . 3 -07 9 . 1-05 9 . 1-06)'( 9 . 1-12 9 . 1-15
9 . 1-16 9 . 1-24 15 . 2-09
numeric-expression 5 . 2-08 5 . 3 -01 5. 3-02)'( 5 . 3 -05 5 . 5-02
8 . 1-06 8 . 3-14 8 . 3-15 8. 3 - 16
9 . 1-05 9 . 1-16 10 . 2-06 13 . 1-03
13 . 3-07 15 . 2-07
numeric-field-size 11. 3-N21 11. 3-N22*
numeric-fixed-parameter 15. 2-01 15 . 2-02 15. 2-03*
numeric-function 5 . 3-06 5 . 3-07)'(
numeric-function- let-statement 4 . 2- 12 9 . 1- 16)'(
numeric-function-ref 5 . 3-05 5. 3-06)'( 6 . 4-03l'( 7 . 1-12)'( 7 . 2-10)'(
numeric- identifier 4 . 4 . 01 4 . 4-02)'( 5 . 2-03 5 . 2-05 9 . 1-06
numeric- let-statement 5 . 5-01 5. 5-02)'(
numeric-rep 5 . 1-02 5 . 1-04l'< 5 . 3-05
numeric-specifier 11. 3-N20 11. 3-N21*
numeric-supplied- function 5 . 3 -07 5 . 4-0ll'l 6 . 4-02l'( 12. 1-18*
numeric-time-expression 10 . 2-05 10 . 2-06)'(
numeric-type 5 . 6-05 5 . 6-06l'l 15 . 1-03
numeric-variable 5 . 2-01 5 . 2-02)'( 5 . 3-05 5 . 5-03 10 . 2-07
10 . 3- 10 13 . 1-05 13 . 1-06 13 . 1-07
13 . 2-07
numeric-variable- l ist 5 . 5-02 5 . 5-03)'(
L 4 . 1-10
on-gosub- statement 4 . 2- 14 8 . 2-01 8. 2-06)'(
on-goto- statement 4. 2-14 8 . 2-01 8 . 2-03l'l
open-statement 4 . 2- 12 1 1 . 1-0P'<
option 5 . 6-02 5 . 6-03l'l 6 . 6-0P'' 7 . 1-09)'( 15. 1. -01*
option- list 5 . 6-01 5 , 6-02l'C
option-statement 4 . 2-11 5 . 6-0P'<
other-character 4 . 1-lP''
output- list 10 . 4-02 10 . 4-04l'l 11 . 3-01
p 4 . 1-10
percent-sign 4. 1-03 10 . 4- 13
period 4 . 1-06 5 . 1-05 5 . 1-07 10 . 4-14 11. 3-N23
plain-string-character 4 . 1-05 4 . 1-06l'( 10 . 1-09
plus-sign 4 . 1-06 5 . 1-03 10 . 4-11
point- list 13 . 3 -03 13 , 3-06l'C
pointer-control 11. 2-02 11 . 2-03)'( 11. 2-0B*
pointer-items 11 . 2-01 1 1 . 2-02)'(
primry 5 . 3-04 5 . 3 -05l'l 7 . 2-05
- 179 -
primitive-! 13 . 2-03 13 . 2-04 13 . 2-05l 13 . 2-07
primitive-2 13 . 2-03 13 . 2-04l'( 13 . 2-07
print-control 1 1 . 3 -01 11 . 3-02 11 . 3-03l'(
print-control - item 1 1 . 3 -03 11 . 3 -04l'(
print-item 10 . 3 . 02 10. 3-03>
print- list 10 . 3-01 10 . 3-02>'( 11 . 3 -01
print-separator 10 . 3-02 10 . 3 -05>'( 10 . 5- 10
print-statement 4 . 2-12 10 . 3-0P'' 10. 4-0P'' 11 . 3-0P''
procedure 4 . 2-19 4. 2-20>'( 4 . 2-23
procedure-argument 9 . 2- 15 9 . 2- 16>'(
procedure-argument- l ist 9 . 2- 14 9 . 2- 15>':
procedure-parameter 9 . 2-06 9 . 2-07>'( 15. 2-02*
procedure-par-list 9 . 2-04 9 . 2-06>':
procedure-part 4 . 2-01 4 . 2- 19>'(
program 4 . 2-0P''
program-designator 9 . 3 -01 9. 3 -02>:
program-name 4 . 2-02 4 . 2-03'
program-name- l ine 4 . 2-01 4 . 2-02>': 4 . 2-22
program-unit 4 . 2-23l'(
prompt-specifier 10 . 2 -03 10 . 2-04>'( 11 . 4-06
protection-block 4. 2-07 12. 1-01*
q 4 . 1-10
question-mark 4. 1-03 10 . 4-08 10 . 5 -05 11. 3-Nl9
quotation-mark 4 . 1-01 4 . 1-04 6 . 1-03
quoted- string 6 . 1-02 6 . 1-03>'(
quoted-string-character 4 . 1-02>': 6 . 1-03
r 4 . 1-10
randomize-statement 4 . 2- 12 5 . 4-02>':
range 8 . 4- 18 8 . 4- 19>':
read-control 11 . 4-07 11 . 4-08 11 . 4-09>'(
read-control - item 11 . 4-09 11 . 4- 10>'( 11. 4-Nl1*
read-statement 4 . 2-12 10 . 1-01' 11 . 4-07
record-setter 11 . 2-04>': 11. 2-09* 1 1 . 3 -09 11 . 4- 10 11. 5-05
11. 5-08
record- size 11 . 1-07 11 . 1- 15>'(
record-type 11 . 1-07 1 1 . 1-12>'(
record-type-value 11 . 1-12 1 1 . 1- 13>'( 11. 1-N25*
redim 7 . 2-06 7 . 2-07>'( 7 . 3 -05 10 . 5-03 10 . 5-08
redim-array 10 . 5-02 10 . 5-03>'(
redim-array- l ist 10 . 5 . 01 10 . 5-02>': 10 . 5-04 11 . 4-02 11 . 4-08
redim-bounds 7 . 2-07 7 . 2-08>':
redim-string-array 10 . 5 -07 10 . 5-08>'
redim-string-array- list 10 . 5-06 10 . 5-07>'( 11 . 4-04
relation 8 . 1-06 8 . 1-07>'( 8 . 4- 19
relational-expression 8 . 1-0P'' 8 . 1-05 8 . 3 -05 8 . 4-01 8 . 4-04
8 . 4-07
relational-primry 8 . 1-04 8 . 1-05>'
relational-term 8 . 1-03 8 . 1-04>'(
remark- line 4. 2 - 19 4 . 2-21' 4 . 2-22 8 . 4-11
remark- statement 4 . 2- 11 4 . 2-21 4 . 3 -01>'(
remark-string 4 . 3-01 4 . 3-02>' 4 . 3-04
restore-statement 4. 2-12 10 . 1-05>''
return-statement 4 . 2- 12 8 . 2-05>'
rewrite-control 11. 5-02 11. 5-03 11. 5-0*
- 180 -
rewrite-control- item 11. 5-04 11. 5-05* 11.5-N
rewrite-statement 11. 5-01 11. 5-02*
right-parenthesis 4 . 1-03 5 . 2-06 5 . 3-05 5 . 3 -08 6 . 2-06
6 . 3-03 6 . 4-03 7 . 1-05 7 . 1-13
7 . 1-14 7 . 2-07 7 . 2-09 7 . 2-10
8 . 1-05 9 . 1-09 9 . 1-11 9 . 2-06
9 . 2-15 10 . 3-04 10. 4-08 10 . 5-05
11. 3-Nl7
routine- identifier 4 . 2-03 4. 4-01 4. 4-05
>'
( 9 . 2-05 12 . 1-10
s 4. 1-10
scalar-multiplier 7 . 2-03 7 . 2-05
>'
( 7 . 2-06
select-block 4 . 2-07 8 . 4-lP
''
select- line 4 . 2-22 8 . 4-11 8 . 4-12:(
select-statement 8 . 4-12 8 . 4-13
>'
(
semicolon 4. 1-03 10 . 3-05 10 . 4-04 10 . 4-08 10 . 5-11
13 . 3-06
set-object 10 . 3-06 10 . 3-07
>'
( 11. 2-0P
''
11 . 3-05:( 13 . 1-01>'
(
13 . 2-03)(
set-statement 4 . 2-12 10 . 3-061:
sign 5 . 1-02 5 . 1-03
>'
( 5 . 1-08 5 . 3 -02 7 . 1-07
7 . 2-04
signed-integer 7 . 1-06 7 . 1-07
>'
(
significand 5 . 1-04 5 . 1-05
>':
simle-numeric-variable 5 . 2-02 5 . 2-03
>'
( 5 . 2-09 5 . 6-07 8 . 3-13
15. 1-0 15. 2-03
simple-string-declaration 6 . 6-05 6 . 6-06>'
(
simple-string-variable 6 . 2-02 6 . 2-03
>'
( 6 . 2-07 6 . 4-03 6 . 6-06
simple-variable 5. 2-09)
'
( 6 . 2-07)
'
( 9 . 1-10 9 . 2-07
slant 4 . 1-03 5 . 3-11 10 . 4-08
space 4. 1-05 4. 2-24 10 . 4-08
statement 4. 2-08 4. 2-10
>':
statement- line 4 . 2-07 4. 2-08
>'
( 4. 2-22
status-clause 13 . 1-04 13 . 1-05>
stop-statement 4 . 2-12 4 . 2-13
>':
string-array 6 . 2-04 6 . 2-05:( 6 . 2-08 6 . 4-03 7 . 1-08
7 . 3-02 7 . 3 -04 10 . 5-08
string-array-assignment 7 . 3-01 7 . 3-02
>'
(
string-array-declaration 7 . 1-03 7 . 1-08
>'
( 7 . 1-10
string-array-element 6 . 2-02 6. 2-04
>'
(
string-array-expression 7 . 3-02 7 . 3 -03
>'
(
string-array-primary 7 . 3-03 7 . 3-04
>'
(
string-array-value 7 . 3-03 7 . 3-05
>'
(
string-constant 6 . 1-01 6. 1-02
>'
( 6 . 3-03
string-declaration 6 . 6-03 6 . 6-05
>'
( 7 . 1-10
>'
(
string-cef-statement 9 . 1-04 9 . 1-0711
string-defined-function 6 . 3-05 9 . 1-07 9 . 1-08:/( 9 . 1-12 9 . 1-15
9 . 1-17 9 . 1-24
string-expression 6 . 3-01 6. 3-02:: 6. 3-03 6 . 5-02 8 . 1-06
9 . 1-07 9 . 1-17 9 . 3-02 10 . 2 -04
10 . 4-03 11 . 1-04 11 . 1-08 11. 1-09
11 . 1-12 11 . 1-15 11. 1-29 11. 2-10
11. 3-Nl3 13 . 1-01 13 . 3-11
string-field-size 11. 3-N26 11. 3-N27*
string-function 6 . 3-04 6 . 3-05
>'
(
string-function- let-statement 4. 2-12 9 . 1-17
>'
(
- 181 -
string-function-ref 6 . 3-03 6 . 3-041<
string-identifier 4 . 4-01 4 . 4-04)'( 6 . 2-03 6 . 2-05 9 . 1-08
string- let-statement 6 . 5-01 6 . 5-02)'(
string-primary 6 . 3- 02 6 . 3-03)'( 7 . 3 -03 7 . 3 -05
string-specifier 11. 3-N20 11. 3-N26*
string-suppl ied-function 6 . 3 -05 6 . 4-0P'< 12. 1-19*
string-type 6 . 6-02 6 : 6-03)'(
string-variable 6 . 2-01 6 . 2-02)'( 6 . 3 -03 6 . 5-03 13 . 1-06
string-variable- l ist 6 . 5-02 6 . 5-03)'( 10 . 2-08 11. 4-03
sub-list 9 . 2-18 9 . 2- 19 9 . 2-20)'(
sub-statement 9 . 2-03 9 . 2-04)'( 9 . 2-13
subprogram-def 9 . 2-0P'<
subprogram-name 9 . 2-04 9 . 2-05)'( 9 . 2-14 9 . 2-20
subscript 5 . 2-06 5 . 2-07)'<
subscript-part 5 . 2-04 5 . 2-06)'( 6 . 2-04
substring-qualifier 6 . 2-02 6 . 2-06)'( 7 . 3-02 7 . 3 -04
t 4 . 1-10
tab-cal l 10 . 3-03 10 . 3 -04)'(
tai l 4 . 2-02 4 . 2-08 4 . 2- 15)'( 4 . 2- 17 4 . 2-24
8 . 3 -03 8 . 3 -08 8 . 3-11 8. 3-19
8 . 4-04 8 . 4-07 8 . 4-09 8. 4-10
8 . 4- 12 8 . 4-15 8 . 4-21 8 . 4-22
9 . 1-03 9 . 1-12 9 . 1-13 9 . 1-15
9 . 2-03 9 . 2-09 9 . 2-13 12. 1-03
12. 1-05 12. 1-07 12. 1-09 12. 1-16
12 . 1-17 15. 2-05 15. 2-06
tai l-coment 4 . 2-15 4 . 3 -03 4 . 3-04)'(
template-element 11. 3-N16 11. 3-N17*
template-element-list 11. 3-N15 11. 3-N16* 11. 3-Nl7
template- identifier 11. 3-N12 11. 3-Nl3* 11. 4-N11 11. 5-N
template-statement 11. 3-N14 11. 3-Nl5*
term 5 . 3 -02 5 . 3 -03)'(
then-block 8 . 4-03 8 . 4-05)'(
time-enquiry 10 . 2-03 10 . 2-07)'( 11 . 4-06
timeout-expression 10 . 2-03 10 . 2-05)'( 11. 4-06
trace-statement 4 . 2-12 12 . 2-03)'(
type-declaration 5 . 6-04 5 . 6-05l'< 6 . 6-02)'( 9 . 1- 19)'( 9 . 2- 17)'(
u 4 . 1-10
underline 4 . 1-03 4 . 4-03 10 . 4-08
unit-block 4 . 2-04 4 . 2-05)'( 9 . 1-14 9 . 2-12
unquoted-string 10 . 1-08 10 . 1-09)'(
unquoted-string-character 4 . 1-03 4 . 1-05)'( 10 . 1-09
upper-case- letter 4 . 1-08 4 . 1-09)'(
use- line 4. 2-22 12 . 1-02 12. 1-05*
v 4 . 1-10
variable 5 . 2-01)'< 6 . 2-011< 10 . 1-02 11 . 1-20
variable-field-count 11. 3-N17 11. 3-N19*
variable- length-vector 10 . 5-04 10 . 5-05)'( 11 . 4-02
variable- list 10 . 1-01 10 . 1-02)'( 10 . 2-01 11 . 4-01 11 . 4-07
- 182 -
w 4 . 1-10
when-block 12. 1-02 12. 1-0* 12. 1-08
when- l ine 4. 2-22 12. 1-02 12. 1-03*
when-use-block 12. 1-01 12 . 1-02*
when-use-name-block 12. 1-01 12. 1-08*
when-use-name- l ine 4.2-22 12. 1-08 12. 1-09*
write-control 11 . 3 -06 11 . 3 -07 11 . 3-08(
write-control- item 11 . 3 -08 1 1 . 3 -09( 11. 3-N12*
write-statement 4 . 2- 12 11 . 3-06)'(
7 4 . 1-10
y 4 . 1-10
Z 4 . 1-10
- 183 -
APPEDIX 5
COMINE LIST OF PRODUCTION RULES
access-mode
actual-array
array-assignment
array-declaration
array- input-statement
array- line- input-statement
array- list
array-name
array-output- list
array-print- list
array-print-statement
array-read-statement
array-rewrite-statement
array-write-statement
ask-attribute-name
ask-io- item
ask- io- list
ask- item
ask- item- list
ask-object
ask-statement
block
bound-argument
boundaries
boundary
ACCESS ( INPUT I OUTPUT I OUTIN I string-express ion)
array-nae
numeric-array-assignment I string-array-assignment
numeric-array-declaration I string-array-declaration
MAT INPUT input-modifier- list? ( redim-array- l ist I
variable- length-vector) I MAT INPUT
channel-expression input-control colon
( redim-array- list I variable- length-vector)
MAT LINE INPUT input-modifier-list?
redim-string-array- list I MAT LIN INPUT
channel-expression input-control colon
redim-string-array- list
array-name ( coma array-name) '''
numeric-array I string-array
array-name ( coma array-name) >': semicolon?
array-name ( print-separator array-name) r:
print-separator?
MAT PRINT ( array-print- list I ( USING image colon
array-output- list) I MAT PRINT
channel -expression print-control colon
( array-print- l ist I array-output- list)
MAT READ ( missing-recovery colon) ? redim-array- l ist
I MAT READ channel-expression read-control
colon redim-array- l ist
MAT RERITE channel-expression rewrite-control colon
array- l ist
MAT WRITE channel-expression write-control colon
array- list
core-attribute-name I enhanced-attribute-name
( MARGIN I ZONEWIDTH) numeric-variabl e
ask- io- item ( coma ask-io-item)'''
ask-attribute-name variable variable>':
ask-item ( coma ask-item)'''
WINDOW boundary-variables I VIEPORT
boundary-variables I DEVICE WINDOW
boundary-variables I DEVICE VIEPORT
boundary-variables I CLIP string variable
DEVICE SIZE numeric-variable com
numeric-variable com string-variable I
primitive- ! STYLE numeric-variable I
primitive-2 COLOR numeric-variable I M COLOR
numeric-variable
ASK ask- io-list I ASK channel-setter ask- item- l ist
ASK ask-object status-clause?
statement- line I loop I if-block I select-block
image- line
left-parenthesis actual-array ( com index) ?
right-parenthesis
boundary com boundary com boundary com boundary
nueric-expression
boundary-variables
bounds
bounds-range
break-statement
cal l -statement
case-block
case-else-block
case-else- line
case- item
case-line
case-list
case-statement
cause-statement
chain-statement
channel-expression
channel -number
channel -setter
character
clear-statement
close-statement
col late-sequence
comparison
concatenation
conditional-statement
conjunction
constnt
control-transfer
control -variable
coordinate-pair
core-attribute-name
core-file-attribute
core-file-org-value
core-record-setter
core-record-type-value
data- list
data-statement
datum
debug-statement
declarative-statement
declare-statement
def- statement
def-type
defined-function
delete-control
- 184 -
numeric-variable coma numeric-variable coma
numeric-variable com numeric-variable
left-parenthesis bounds-range ( coma bounds-range)''
right-parenthesis
signed- integer TO signed-integer I signed- integer
BREA
CALL subprogram-name procedure-argument- list?
case- line block''
case-else- line block''
line-number CASE ESE tail
constant I range
line-number case-statement tail
case-item ( coma case-item) '
CASE case- list
CAUSE ECEPTION exception-type
CHAIN program-designator ( WITH function-arg-list) ?
number-sign index
number-sign integer
channel-expression colon
quotation-mark I non-quote-character
CLEAR
CLOSE channel-expression
COLLATE ( STANDARD I NATIVE I string-expression)
numeric-expression relation numeric-expression I
string-expression relation string-expression
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
lon-goto-statement
simple-numeric-variable
numeric-expression coma numeric-expression
ACCESS I DATUM I ERASABLE I FILETYPE I MARGIN NAM
I ORGANIZATION I POINTER I RECSIZE I RECTYPE I
SETTE I ZONEWIDTH
access-mode I file-organization I record-type I
record- size
SEQUETIAL I STREAM
BEGIN I E I N I SAM
DISPLAY I INENAL
datum ( com datum)
l
'
t
DATA data- list
constat I unquoted-string
DEBUG ( ON I OFF)
data-statement I declare-statement I
dimension-statement I null-statement I
option-statement I remark-statement I
template-statement
DECLARE type-declaration
numeric-def-statement I string-def-statement
DEF function- list
numeric-defined-function I string-defined-function
fixed-defined-function
( com delete-control- item)''
delete-control- item
delete-statement
detached-handler
digit
digit-place
dimension- l ist
dimension-statement
disjunction
do-body
do- line
do- loop
do-statement
double-quote
e-format- item
else-block
else- l ine
elseif-block
elseif -then- line
end-function- line
end-handler- l ine
end-if- line
end- l ine
end-of- l ine
end-select- line
end-statement
end-sub- l ine
end-sub-statement
end-when- l ine
enhanced-attribute-name
enhanced-file-attribute
enhanced-file-org-value
enhanced-record-setter
enhanced-record-type-value
equality-relation
erase-statement
exception-handler
exception-type
exit-condition
exit-do-statement
exit-for-statement
exit-function-statement
exit-handler-statement
exit-sub-statement
expression
express ion- list
exrad
external-function-de
external -function- line
- 185 -
missing-recovery I record-setter
DELETE channel-expression delete-control
handler- l ine exception-handler end-handler- line
Ol ll 21 3 1
4
15l 6/ 7 181
9
asterisk I number-sign I percent-sign
array-declaration ( coma array-declaration) >'<
DIM dimension- l ist
conjunction ( OR conjunction) >'<
block>'< loop- l ine
l ine-number do-statement tail
do- line do-body
D exit-condition?
quotation-mark quotation-mark
( i-format- item I -format- item) circumflex-accent
circumflex-accent circumflex-accent
circumflex-accent>'<
else-line block>'<
line-number ELSE tail
else if -then- line block>'<
line-number ESEIF relational-express ion THN tail
line-number E FUNCTION tail
line-number E HL tail
line-number END IF tail
line-number end- statement tail
( implementation-defined)
line-number E SELECT tail
END
line-number end-sub-statement tail
END SUB
line-number E W tail
RECORD I K I COLLATE
collate- sequence
RELATIVE I KE
RECORD index I K ( exact-search I inexact-search)
string-expression
NATIVE
equals-sign I not-equals
ERASE REST? channel-expression
block<
index
( WILE I UIL) relational-expression
EIT DO
EIT FOR
EIT FUNCTION
EIT HL
EIT SUB
numeric-expression I string-expression
expression ( coma expression) >'<
E sign? integer
external-function- l ine unit-block>'< end-function- line
line-number EAL FUNCTION
( numeric-defined-function I
( string-defined-function length-max? ) )
function-parm- list? tail I line-number
ETERNAL FUNCTION fixed-defined-function
function-parm- l ist? tail
external -function- type
external-sub-def
exterl-sub- line
exteral-sub-type
f-fonat- item
factor
field-specifier
f He-attribute
file-attribute- l ist
file-name
fi le-organization
file-organization-value
fixed-declaration
fixed-defined-function
fixed-field-count
fixed- formal-array
fixed-point-size
fixed-point-type
floating-characters
for-body
for- l ine
for- loop
for- statement
formal-array
format- item
format-string
formatted-print- l ist
fraction
fraction-size
function-arg- l ist
function-argument
function-def
function- l ist
function-parameter
function-parm- list
geometric-obj ect
geometric-statement
gosub-statement
goto-statement
graphic-output-statement
graphic- text-statement
graphic-verb
handler- l ine
handler-name
- 186 -
ETERNAL FUNCTION function- l ist
external-sub- l ine unit-blockl'< end- sub- l ine
l ine-number EAL sub-statement tail
EAL SUB sub- l ist
period number-sign number-signl'< I i -format- item
period number- signl'<
primary ( circumflex-accent primary ) l'<
numeric-specifier I string-specifier
core-file-attribute
( coma f ile-attribute) )'<
string-expression
ORGANIZATION ( fi le-organization-value
string-expression)
core-file-org-value I enhanced-file-erg-value
simple-numeric-variable fixed-point-type? I
numeric-array-declaration fixed-point-type?
numeric-defined-function
SKIP? ( integer OF) ?
formal-array fixed-point-type
integer-size period? I integer-size? period
fraction-size
asterisk fixed-point-size
( plus-signl'< I minus-signl'< ) dol lar-sign?
dol lar-signl'< ( plus- sign I minus-sign) ?
blockl
'
< next- l ine
l ine-number for-statement tai l
for- l ine for-body
FOR control -variable equals- sign initial-value TO
limit ( STEP increment) ?
array-name left-parenthesis coma:< right-parenthesis
( justifier? f loating-characters ( i -fonnat- item I
f-format- item I e- format- item) ) I justifier
l iteral-string ( format-item l iteral-string) :<
USING image ( colon output- list ) ?
period integer
integer
left-parenthesis function-argument ( coma
function-argument) l'< right-parenthesis
expression I actual-array
internal-function-def I external-function-def
defined-function ( coma defined-function)l'<
s imple-variable I forml-array I
numeric-fixed-paraeter
left-parenthesis function-parameter ( coma
function-parameter) :< right-parenthesis
= POINTS I LINES I A
graphics-verb geometric-obj ect colon point- l ist
( GOSUB I GO SUB) l ine-number
( GOTO I GO TO) l ine-number
geometric-statement I graphic-text-statement
graphic-verb T initial-point ( coma USING image
colon expression- l ist I colon
string-expression)
GRAPH
l ine-number HL handler-name tail
routine- identifier
handler-retur-statement
i-format-item
identifier
identifier-character
if-block
if-clause
if-statement
if-then-l ine
image
image- line
imperative- statement
increment
index
initial-number
initial-point
initial-value
input-control
input-control- item
input-modifier
input-modifier- l ist
input-prompt
input-reply
input- statement
integer
integer-size
interl-def- l ine
- 187 -
RY I CONIN
digit-place digit-place* ( com digit-place
digit -p lacel'< ) l'<
numeric- identifier I string- identifier
routine- identifier
letter I digit I underline
if-then- line then-block elseif-blockl'< else-block?
end- if - l ine
imperative-statement I line-number
IF relational-expression TH if-clause ( ESE
if-clause) ?
line-number IF relational-expression TH tail
line-number I string-expression
line-number IMGE colon format-string end-of- line
array-assignment I array- input-statement I
array- line- input-statement I
array-print-statement I array-read- statement I
array-write-statement I ask-statement I
break-statement I cal l-statement I
cause-statement I chain-statement I
close-statement I debug-statement I
erase-statement I exit-do-statement I
exit-for-statement I exit-function-statement I
exit-sub-statement I gosub-statement I
goto-statement I input-statement I
let-statement I line- input-statement I
numeric-function- let-statement I
open-statement I print-statement I
randomize-statement I read-statement I
restore- statement I return-statement I
set-statement I stop- statement I
string-function- let-statement I
trace-statement I write-statement I
rewrite-statement I array-rewrite-statement I
delete-statement I clear-statement I
graphic-output-statement
numeric-expression
numeric-expression
line-number
coma AT coordinate-pair
numeric-expression
( coma input-control - item) :'<
core-record-setter I missing-recovery I
prompt-specifier timeout-expression I
time- inquiry
prompt-specifier timeout-expression I time- inquiry
input-modifier ( coma input-modifier) l'< colon
( implementation-defined )
data-list coma? end-of- l ine
INU input-modifier- list? variable- list I INU
channel-expression input-control colon
variable- l ist ( coma SKIP REST) ?
digit digit)
integer
l ine-number cef-statement tail
interl -function-def
interl-function- line
interl-function-type
interl-proc-def
interl-sub-def
interl-sub-l ine
internal - sub-type
io-qual ifier
io-recovery
io-recovery-action
justifier
length-mx
let-statement
letter
l imit
line
line-continuation
line- input-reply
line-input-statement
l ine-number
l iteral- item
literal-string
loop
loop- l ine
loop-statement
lower-case- letter
main-program
maxsize-argument
missing-recovery
multipl ier
next- l ine
next-statement
- 188 -
interl-def-l ine I internal-function- line block)'<
end-function- line
line-number FUNCTION ( numeric-defined-function I
( string-defined-function length-mx? ) )
function-parm- l ist? tail I line-number
FUNCTION fixed-defined-function
function-parm- l ist? tail
FUNCTION function- l ist
internal-function-def I internal-sub-def I
detached-handler
internal-sub- l ine block)'< end-sub- line
line-number sub-statement tail
SUB sub- list
INPUT / OUTPUT / OUTIN
missing-recovery I not-missing-recovery
exit-do-statement I exit-for-statement I line-number
greater-than-sign I less-than-sign
asterisk integer
numeric- let-statement I string- let-statement
upper-case- letter I lower-case- letter
numeric-expression
case- line I case-else- line I do- line I else- line I
elseif-then- line I end-function- line I
end-handler- line I end-if- line I end-line I
end-select- line I end-sub- line I end-when- l ine
I external-function- line I external-sub- line I
for- line I handler- line I internal-def- line I
interl-function- line I interl-sub- line I
if-then- line I image- l ine I loop-line I
next- l ine I program-name- line I remrk-line I
select- line I statement- line I use- line I
when-use-name- l ine
amersand space)'< tail ampersand
characteri< end-of-l ine
LINE INPUT input-modifier- list? string-variable- list
I LINE INPUT channel -expression input-control
colon string-variable-list
digit digit)'<
letter /digit I apostrophe I colon I equals-sign I
exclamation-mark I left-parenthesis I
question-mark I right-parenthesis I semicolon
/ slant I space I underline
literal-item)'<
do-loop I for- loop
line-number loop-statement tail
LOOP exit-condition?
a I b I c I d I e I f I g I h I i I j I k I 1 I m I
n I o I p I q I r I s I t I u I v I w I x I
y I z
unit-block)'< end- l ine
left-parenthesis actual-array right-parenthesis
IF MISSING T io-recovery-action
= asterisk I slant
line-number next-statement tail
= N control -variable
non-quote-character
not-equals
not-greater
not- less
not-missing-recovery
numeric-array
numeric-array-assignment
numeric-array-declaration
numeric-array-element
numeric-array-expression
numeric-array-function-ref
numeric-array-operator
numeric-array-value
numeric-constant
numeric-declaration
numeric-def-statement
numeric-defined-function
numeric-expression
numeric- field-size
numeric-fixed parameter
- 189 -
ampersand I apostrophe I asterisk I circumflex-accent
I colon I coma I dol lar-sign I equals-sign I
exclamation-mark I greater-than-sign I
left-parenthesis I less-than-sign I
number-sign I percent-sign I question-mark
right-parenthesis I semicolon I s lant I
underline I unquoted-string-character
less-than-sign greater-than-sign I greater-than-sign
less-than-sign
less-than-sign equals-sign I equals-sign
less-than-sign
greater-than-sign equals-sign I equals-sign
greater-than-sign
IF TR T io-recovery-action
numeric- identifier
MT numeric-array equals-sign
numeric-array-expression
numeric-array bounds
numeric-array subscript-part
( numeric-array numeric-array-operator) ? numeric-array
I scalar-multipl ier numeric-array I
numeric-array-value I
numeric-array-function-ref
( TRN I INV) left-parenthesis numeric-array
right-parenthesis
sign I asterisk
scalar-multipl ier? ( CON I IDN I ZE) redim?
sign? numeric-rep
simple-numeric-variable I numeric-array-declaration
DEF nueric-defined-function function-parm- l ist?
equals-sign numeric-expression I DE
fixed-defined-function function-parm- l ist?
equals-sign numeric-expression
numeric- identifier
sign? term ( s ign term) l'
c
fixed-point-size I E
simple-numeric-variable fixed-point-type I
fixed-formal-array
numeric-function numeric-defined-function I numeric-suppl ied-function
numeric- function- let-statement= LET numeric-defined-function equals-sign
numeric-function-ref
numeric- identifier
numeric- let-statement
numeric-rep
numeric-specifier
numeric-expression
numeric-function function-arg- list? I M
left-parenthesis ( simple-string-variable I
string-array) right-parenthesis I MSIZE
maxsize-argument I SIZE bound-argument I
LBOUND bound-argument I UBOUND bound-argument
I DET ( left-parenthesis numeric-array
right-parenthesis ) I DOT left-parenthesis
numeric-array coma numeric-array
right-parenthesis
letter identifier-characterl'c
LET numeric-variable- l ist equals-sign
numeric-expression
significand exrad?
NUMRIC asterisk numeric-field-size
numeric-suppl ied-function
numeric-time-expression
numeric-type
numeric-variable
numeric-variable- list
on-gosub-statement
on-goto- statement
open-statement
option
option- list
option-statement
other-character
output- l ist
plain-string-character
point- list
pointer-items
primary
primitive-1
primitive-2
print-control
print-control - item
print- item
print- l ist
print-separator
print-statement
procedure
procedure-argument
procedure-argument- list
procedure-parameter
procedure-parm- list
procedure-part
program
program-designator
- 190 -
ABS I ACOS I ANGLE I ASIN I ATN I CEIL I COS I COSH I
COT I esc I DATE I DEG I EPS I EP I FP I
M I !NT I IP I LOG I LOGlO I LOG2 I M I
MIN I MOD I PI I RAD I RAINDE I R I ROUND
I SEC I SGN I SIN I SINH I SQR I TAN I TANH I
TIM I TRUNCATE I LE I ORD I POS I VAL I
EINE I ETYPE
numeric-expression
NUMRIC numeric-declaration ( coma
numeric-declaration) >'( I NUMRIC
fixed-point-type? fixed-declaration ( com
fixed-declaration) >'(
s imple-numeric-variable I numeric-array-element
numeric-variable ( coma numeric-variable) '''
ON index ( GOSUB I GO SUB) line-number ( coma
line-number) >'l ELSE imperative-statement) ?
ON index ( GOTO I GO TO) line-number ( coma
line-number) >'l ( ELSE imperative-statement ) ?
OPEN channel-setter NA}f file-name
file-attribute-list
ARITHTIC ( DECIMAL I NATIVE) I ANGLE ( DEGREES I
RADIANS) I COLLATE ( NATIVE I STANDARD) I BASE
( 0 I 1 ) I ARITHTIC FIX fixed-point-type
option ( coma option) >'l
OPTION option- list
[ implementation-defined ]
expression ( coma expression) >'( semicolon?
digit I letter I period I plus-sign I minus- sign
coordinate-pair ( semicolon coordinate-pair ) ''1
( pointer-control I io-recovery I pointer-control
coma io-recovery)
numeric-rep I numeric-variable I numeric-function-ref
I left-parenthesis numeric-expression
right-parenthesis
POINT I LINE
primitive-1 I TET I A
( coma print-control - item)>'l
core-record- setter I enhanced-record-setter I
not-missing-recovery I USING image
expression I tab-cal l
( print-item? print-separator) >'( print-item?
coma I semicolon
PRINT print- list I PRINT formatted-print- l ist I PRINT
channel-expression print-control ( colon
( print- list I output- list) ) ?
external-function-de I external-sub-de
expression I actual-array I channel-express ion
left-parenthesis procedure-argument ( coma
procedure-argument) ''' right-parenthesis
s imple-variable I forl-array I channel-number
numeric-fixed-parameter
left-parenthesis procedure-parameter ( coma
procedure-parameter) '''
remark- l ine''1 procedure
program-name- l ine? min-program procedure-part>'l
string-expression
program- line
program-nae
program-name- l ine
program-unit
prompt-specifier
protection-block
quoted-string
quoted-string-character
randomize-statement
range
read-control
read-control- item
read-statement
record-setter
record-size
record-type
record-type-value
redim
redim-array
redir-array- list
redim-bounds
redim-numeric-array
redim-string-array
redim-string-array- list
relation
relational-expression
relational-primary
relational-term
remark- line
remrk-statement
remark- string
restore-statement
retur-statement
rewrite-control
rewrite-control - item
rewrite-statement
routine-identifier
scalar-multiplier
select-block
select-line
select-statement
- 191 -
line-number ( character I line- continuation) i
t
end-of- l ine
routine- identifier
line-number PROGRAM program-name function-parm- list?
tail
main-program I procedure
PROMT string-expression
when-use-block I when-use-name-block
quotation-mark quoted- string-characterl't
quotation-mark
double-quote I non-quote-character
RAOMIZE
( constant TO I IS relation) constant
( coma read-control - item) l't
record-setter I missing-recovery
template- identifier
R ( missing-recovery colon) ? variable- list I R
channel-expression read- control colon
variable-list ( coma SKIP REST) ?
core-record-setter I enhanced-record-setter
RECSIZE ( VARIABLE I string-expression) ( LEGT
index) ?
RECTYPE ( record-type-value I string-expression)
core-record-type-value I enhanced-record-value
left-parenthesis redim-bounds ( coma redi-bounds) l't
right-parenthesis
array-name redim?
redim-array ( coma redir-array ) l't
( index TO) ? index
numeric-array redim?
string-array redim?
redim-string-array ( com redim-string-array) l
't
equality-relation I greater-than-sign I
less-than-sign I not-greater I not- less
disjunction
comparison I left-parenthesis relational-expression
right-parenthesis
NOT? relational-primary
line-number ( null-statement I remark-statement)
end-of- line
RE remark-string
characterl't
RESTORE line-number
R
( coma rewrite-control - item) l
't
missing-recovery I record-setter
template-identifier
RERITE channel-expression rewrite-control colon
expression list
letter identifier-characterl
't
primary asterisk
select- l ine remark- l inel't
case-block case-blockl
case-else-block? end-select-line
l ine-number select-statement tail
SEECT CASE expression
set-object
set-statement
sign
signed- integer
significand
simle-numeric-variable
simple-string-declaration
simple-string-variable
simple-variable
statement
statement- line
status-clause
stop-statement
string-array
string-array-assignment
string-array-declaration
string-array-element
string-array-expression
string-array-primary
string-array-value
string-constant
string-declaration
string-def-statement
string-defined-function
string-expression
string-field-size
string-function
string-function- let-statement
string-function-ref
string- identifier
string- let-statement
string-primary
string-specifier
string-supplied-function
- 192 -
(MARGIN I ZONEWIDTH) index I channel-setter
pointer-items I chanel -setter ( MARGIN I
ZONEWIDTH) index I WINDOW boundaries I
VIEWPORT boundaries I DEVICE WINDOW boundaries
I DEVICE VIEWPORT boundaries I CLIP
string-expression I primitive- 1 STYLE index I
primitive-2 COLOR index
SET set-object
plus-sign I minus- sign
sign? integer
integer period? I integer? fraction
numeric-identifier
simple-string-variable length-max?
string-identifier
simple-numeric-variable I simple-string-variable
declarative-statement I imperative-statement I
conditional-statement
line-number statement tail
STATS numeric-variable
STOP
string- identifier
MAT string-array substring-qual ifier? equals-sign
string-array-expression
string-array bounds
string-array subscript-part
string-array-primary ( concatenation
string-array-primary) ? I string-primary
concatenation string-array-primary I
string-array-priary concatenation
string-primary I string-array-value
string-array substring-qualifier?
( string-primary concatenation) ?
quoted- string
simple-string-declaration I string-array-declaration
length-max?
DEF string-defined-function length-max?
function-par- list? equals-sign
string-expression
string-identifier
string-primary ( concatenation string-primary ) *
'
integer
string-defined-function I string-supplied-function
LET string-defined-function equals-sign
string-expression
string-function function-arg-list?
letter identifier-character,'c dol lar-sign
LET string-variable- list equals-sign
string-expression
string-constant I string-variable
string-function-ref I left-parenthesis
string-expression right-parenthesis
STRING asterisk string-field-size
( CH I DATE I LCASE I LTRIM I REPEAT I RTRIM I STR I
TIM I UCASE I USING) dollar-sign I E
dol lar-sign
string-type
string-variable
string-variable- list
sub-list
sub-statement
subprogram-def
subprogram-name
subscript
subscript-part
substring-qualifier
tab-call
tail
template-element
template-element- list
template- identifier
template-statement
term
then-block
time-expression
time- inquiry
timeout-expression
trace-statement
type-declaration
unit-block
unquoted-string
unquoted-string-character
upper-case- letter
use- line
variable
variable-field-count
variable- length-vector
variable- list
when-block
when- line
when-use-block
when-use-name-block
when-use-name- line
write-control
write-control - item
write-statement
- 193 -
STRING length-max? string-declaration ( coma
string-declaration) ,''
( s imple-string-variable I string-array-element)
substring-qualifier?
string-variable ( coma string-variable),.,
subprogram-name ( com subprogram-name),.,
SU subprogram-name procedure-pam- list?
internal-sub-def I exterl-sub-de[
routine-identifier
index
left-parenthesis subscript ( coma subscript) ,''
right-parenthesis
left-parenthesis index colon index right-parenthesis
TA left-parenthesis index right-parenthesis
tail-coment? end-of- l ine
fixed-field-count ( field-specifier I left-parenthesis
template-element- list right-parenthesis ) I
variable-field-count field-specifier
template-element ( coma template-element) *
WITH ( line-number I string-expression)
TEPLTE colon template-element- list
factor ( multipl ier factor),'<
block'
numeric-time-expression I string-time-expression
ELPSED numeric-variable
TIMOUT numeric-time-expression
TRCE ON ( TO channel-expression) ?
numeric-type I string-type I def-type
internal-function-type I
exterl-function-type I internal-sub-type I
exterl - sub-type
interl-proc-def I block
plain-string-character I plain-string-character
unquoted-string-character,''
plain-string-character
space I plain-string-character
A I B I c I D I E I F I G I H I I I J I K I L I M I
N I o I P I Q I R I s I T I u I v I w I x I
Y I z
line-number USE tail
numeric-variable I string-variable
question-mark OF
array-name left-parenthesis question-mark
right-parenthesis
variable ( coma variable)'
block,''
line-number WHN ECEPTION IN tail
when- line when-block use-line exception-handler
end-when- line
when-use-nae-line when-block end-when- line
l ine-number W ECEPTION USE handler-name tail
= ( coma write-control - item),''
record- setter I not-missing-recovery
template- identifier
WRITE chnel-expression write-control colon
expression- list
- 194 -
APPEDIX 6
DIFCES BEE MINIMAL BASIC A ECA BASIC
The differences between Minimal BASIC and ECMA BASIC ( either BASIC-1 or BASIC-2) may be
classified as either syntactic incompatibilities or semantic ( run-time) differences .
Sytactic Differences
With the following exception, this Standard forms an upward compatible syntactic extension
of Standard ECMA-5 5 , Minimal BASIC .
* All arrays in a standard conforming program must be dimensioned before use .
Programs written in Minimal BASIC may therefore produce errors when run on an implemen
tation that conforms to this Standard . Such programs may be modified to run correctly as
fol lows :
- identify all arrays which are impl icitly dimensioned ;
- insert a dimension-statement covering each such array with upper bound equal to 10 .
Ech such dimension-statement must fol low an option-base-statement, if any, and pre
cede any reference to the arrays contained in the dimension-statement .
For example, if a vector A is used in a Minimal BASIC program but is not dimensioned there,
inserting
DIM A( lO)
will cause the program to run correctly with respect to the vector A. Since array-names in
Minimal BASIC are limited to single letters , there can be no more than 26 such changes
needed .
Semantic Differences
In addition, this Standard differs from Minimal BASIC in several other ways that may be
classified as "run-time" . As a result, a Minimal BASIC program run under a BASIC implemen
tation might produce s lightly different results .
: The default lower bound for arrays is 1 , not 0 as in Minimal Basic . Programs in Minimal
Basic can be made to run correctly if the fol lowing statement is introduced prior to any
DIM statement .
OPTION BASE 0
: This Standard specifies that arithmetic be carried out using a floating-point deciml rep
resentation, with at least ten decimal digits of precision, whereas Minimal BASIC is more
permissive in al lowing arithmetic to be carried out using other representations ( e . g . ,
floating-point binary) , with at least six decimal digits of precision ( see 5 . 6) . The only
effect should be that the program gives more precise results , which should not cause prob
lems for the user . A option is provided which permits NATIVE arithmetic , which might be
defined as in Minimal BASIC for a given implementation.
: The default maimum length for strings must be at least 132 , not 18 as in Minimal BASIC .
The only difference is that a program might not get a string-overflow exception which it
would have gotten in Minimal BASIC. The old behavior can be restored by declaring the maxi
m length of the strings to be the old mximum.
- 195 -
1( It is not necessary to prevalidate an entire input-reply before assignment of values to
variables takes place, whereas this was required in Minimal BASIC . Thus , an input-reply of
11 2 , 4, x1 1 in response to INUT I , A( I ) , J could change the value of A( 2 ) , whereas this is not
allowed in Minimal BASIC .
)'( Certain exceptions - overflow, division by zero , and ra1s1ng to a negative power - are fa
tal exceptions in EC BASIC and nonfatal in Minimal BASIC . However, since the Minimal
BASIC Standard specifies that nonfatal exceptions can be treated as fatal under certain
circumstances , a Minimal BASIC program should not rely on these exceptions being nonfatal .
- 196 -
APPEDIX 7
LANGUAGE ES UE CONSIDEATION FOR F REOVAL
The gosub-statement, on-gosub-statement, and the retur-statement are under consideration
for future removal . It is recomended that as users write new programs , or maintain exist
ing programs , they refrain from using these statements , in order to improve compatibility
with future versions of this Standard .
The GOSUB facility is being considered for removal because it encourages poor programing
practice by al lowing the construction of subroutines with several entry points . Further
more, these "subroutines" are not delineated by any distinctive syntax; any line of a pro
gram may be the beginning of such a subroutine . Users are encouraged to avail themselves of
the subprogram facilities ( see 9 . 2 ) described in this Standard when they need subroutines .
Furthermore, the GOSUB facility interacts in a complex way with other aspects of the lan
guage ( e. g. , interl -proc-defs , exception-handlers) , thus making it more difficult to un
derstand source code, to implement conforming language processors , and to describe the lan
guage correctly. Thus , programers , implementors , teachers , and writers are all impeded in
their work with BASIC .