You are on page 1of 203

EUROPE

CO

ER

ANU

CTU

ERS

June 1986

ASSOCI

ON

Free copies of this document are available from EC:\lA,


European Computer :\Iannfadnrers Association

I H Rue dn Hhi'me

1201 Geneva (Switzerland)

BRIEF HISTORY

The f irst version of the language BASIC, acronym for Beginner 1 s A l l -purpose
Instruction Code , was produced in June 1965 at the Dartmouth Co l lege in the USA .

Symbo l ic

In January 197 8 , ECMA publ ished a Standard for Minimal BASIC, ECMA- 5 5 , prepared in coopera
tion with ANSI X3J2 and ful ly compatible with the corresponding ANSI standard . This Stan
dard ECMA - 5 5 served as a bas is for the ISO Standard on Minimal BASIC.
With the continuation of the work , a draft Standard for ful l BASIC was agreed by ANSI X3J2 ,
EWICS TC2 and ECMA / TC2 1 in January 1985 . This draft is composed of a mandatory Core module
and f ive optional modules .
Starting from this draf t , ECMA / TC2 1 prepared a Standard for ful ly def ined subsets of the
language . These subsets , cal led ECMA BASIC-! and ECMA BASIC- 2 , are des igned for business
app l ications , requiring extended f i le fac i l ities . ECMA BASIC- 1 has no exception hand l ing
fac i l ities and a reduced set of f i le operations . In add ition, a l l the keywords in
ECMA BASIC-1 are reserved word s , reducing the comp lexity of the interpreter or comp i ler
needed . ECMA BASIC-2 provides ful l exception handl ing capab i l ities , ful l f i le operations
and f ixed decimal capab i l ities . The set of reserved words is minimal . Both subsets provide
the full f l ow control capab i l ities provided in the ANSI standard . An additional module
( ECMA GRAPHICS ) provides a minimum of graphic capab i lities and can be used with either
subset .
Compatibi l ity with the ANSI standard has been a primary design obj ective , and the ECMA
Standard i s ful ly upward compatible with corresponding imp lementations of the ANSI
Standard .

Approved as an ECMA Standard by the General Assembly of June 2 6 , 1986 .

- i -

TABLE OF CONTENTS

1.

2.

3.

INTRODUCTION

1.1
1.2

2
2

Scope
Related Standards

CONFORMANCE

2. 1
2.2
2.3
2.4
2.5

4
4
5
5
5

Program Conformance
Imp lementation Conformance
Errors
Exceptions
Relationship to the ANSI Standard

SYNTAX SPECIFICATION AND DEFINITIONS


3.1
3.2

Method of Syntax Speci fication


Definitions of Terms
3.2.1
3.2.2
3.2.3
3.2.4
3.2.5
3.2.6
3.2.7
3.2.8
3.2.9
3 . 2 . 10
3 . 2 . 11
3 . 2 . 12
3 . 2 . 13
3 . 2 . 14
3 . 2 . 15
3 . 2 . 16
3 . 2 . 17
3 . 2 . 18
3 . 2 . 19
3 . 2 . 20
3 . 2 . 21
3 . 2 . 22
3 . 2 . 23
3 . 2 . 24

4.

5.

BASIC
Batch-mode
Can
End - of - line
Error
Exception
External
Identi fier
Interactive mode
Internal
Keyword
Line
Machine Infinitesimal
May
Native
Overf l ow
Print Zone
Program Unit
Reserved Word
Rounding
Sha l l
S ignificant Digits
Truncation
Underf low

8
8
9
9
9
10
10
10
10
10
10
10
11
11
11
11
11
11
11
12
12
12
12
13
13
13
13

PROGRAM ELEMENTS

15

4.1
4.2
4.3
4.4

15
16
19
19

Characters
Programs, Lines and B locks
Program Annotation
Identif iers

NUMBERS

23

5.1
5.2
5.3
5.4
5.5

23
24
25
26
31

Numeric Constants
Numeric Variables
Numer ic Express ions
Imp lementation-Suppl ied Numeric Functions
Numeric Assignment Statement

- ii -

5.6
6.

7.

8.

9.

Numeric Arithmetic and Angle

31

STRINGS

35

6.1
6.2
6.3
6 .4
6.5
6.6

35
35
37
38
41
42

String Constants
String Variables
String Express ion
Implementation- Supp l ied String Functions
String Ass ignment Statements
String Declarations

ARRAYS

45

7.1
7 .2
7.3

45
47
50

Array Declarations
Numeric Arrays
String Arrays

CONTROL STRUCTURES

53

8.1
8.2
8.3
8.4

53
54
56
58

Relation Expre s s ion


Contro l Statements
Loop Structures
Deci s ion Structures

PROGRAM SEGMENTATION

63

9.1
9.2
9.3

63
68
73

User-Def ined Funct ions


Subprograms
Chaining

10 . INPUT AND OUTPUT


10 . 1
10 . 2
10 . 3
10 . 4
10 . 5

Internal Data
Input
Output
Formatted Output
Array Input and Output

F i le
F i le
F i le
File
F i le

76
77
80
84
88
93

1 1 . FILES
11 . 1
11 . 2
11. 3
11.4
11 . 5

76

Operations
Pointer Manipulation
Data Creation
Data Retrieval
Data Modi f ication ( BASIC-2 only )

1 2 . EXCEPTION HANDLING AND DEBUGGING


12 . 1 Exception Hand l ing ( BASIC-2 only )
12 . 2 Debugging ( BASIC - 1 and BASIC- 2 )
1 3 . GRAPHICS
1 3 . 1 Coordinate Systems
1 3 . 2 Attributes and Screen Contro l
1 3 . 3 Graphic Output

98
108
111
1 18
125
130
130
135
138
138
141
143

14 . REAL TIME ( not in ECMA BASI C )


1 5 . FIXED DECIMAL NUMBERS ( BASIC-2 only )
15 . 1 Fixed Decimal Preci s ion
15 . 2 Fixed Decimal Program Segmentation
TABLE 1 - Standard BASI C Character Set

146
147
149
152

- iii -

TABLE 2 - Exception Codes

155

APPENDICES

159

APPENDIX 1 - O rganization of the Standard

160

APPENDIX 2 - Scope Rules

162

APPENDIX 3 - Implementation-def ined Features

163

APPENDIX 4 - Index of Syntactic Objects

167

APPENDIX 5 -

Combined List of Production Rules

183

APPENDIX 6 - Differences between Minimal BASIC and ECMA BASIC

194

APPENDIX 7 - Language Elements under Consideration for future


Removal

196

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 N T RO D UCT I O N

- 2 -

1.

INTRODUCTION
This Standard is des igned to promote the interchangeab i l ity of BASIC programs among a var i
ety of automatic data process ing systems . Programs conforming t o this Standard wil l b e said
to be written in ECMA BASIC .
Two leve l s of the language are specified in this Standard: ECMA BASIC - 1 and ECMA BASIC-2 .
In addition this Standard def ines an optional Graphics module .

1.1

Scope
This Standard estab lishes:
The syntax of programs written in ECMA BASIC .
- The formats of data and the min imum precis ion and range of numeric representations
and the minimum length and set of characters in strings which are acceptable as input
to an automatic data process ing system being contro l led by a program written in
ECMA BASIC .
- The fo rmats of data and the min imum prec1s1on and range of numeric representations
and the min imum length and set of characters in strings which can be generated as
output by an automatic data process ing system being contro l led by a program written
in E CMA BASIC .
- The s emantic rules for interpreting the meaning of a program written in ECMA BASIC .
- The errors and exceptional c ircums tances which sha l l be detected .
A lthough the BASIC language was origina l ly designed pr imar i ly for interactive use , this
Standard describes a language that is not so restricted . This Standard is not meant to
preclude the use of any particular imp lementation technique , for examp le interpreters ,
incremental or one-pass compilers .

1.2

Related S tandards
ECMA-6
ECMA- 3 5
E CMA - 5 3
E CMA - 5 5
ISO 2014
ISO 2 7 1 1
ISO 3 307
ISO 7942
IEC 559
ANSI X3 . 113 - 198X

7 -Bit Coded Character Set


Code Extension Techniques
Representation of Source Program for Program Interchange: - APL ,
COBOL, FORTRAN , Minimal BASIC and PL / 1
Minimal BASIC
Writing of Calendar Dates in a l l - numeric form
Representation of Ordinal Dates
Representation of Time of the Day
GRAPHICAL KERNEL System ( GKS )
Binary Floating Point Ari thmetic for Microprocessor Systems .
American National Standard for BASIC

- 3 -

2.

CONF O RMANCE

- 4 -

2.

CONFORMANCE
This Standard speci f ies two levels of the language: ECMA BASIC - 1 and ECMA BASIC- 2 . In addi
tion this Standard defines a Graphics modu l e .
ECMA BASIC-1 includes a l l the parts defined i n Section 4 t o 12 , with the exception of those
portions of Section 11 that describes enhanced files and Section 12 . 1 , Exception Handling .
A l l the keywords , l isted i n 3.2 . 19 under the heading BASIC-1 are reserved words .
ECMA BASIC-2 includes a l l the parts defined in Section 4 to 12 and in Section 15 . The key
words , l isted in 3 . 2 . 19 under the heading BASIC-2 are reserved words .
The graphics module is specified in section 13. It is optional , and it can be used together
either with ECMA BASIC-1 or ECMA BASIC- 2 .
There are two aspects of the confo rmance to the language defined in this Standard: confor
mance by a program written in the ECMA BASIC language , and conformance by an imp lementation
which processes such programs .
Broad ly speaking , the confo rmance requirements are structured so that any program conform
ing to this standard wil l produce the same results when executed by any implementation con
forming to the standard ( though some implementation-defined features are noted in Appendix
3).

2.1

Program Conformanc e
A program conforms t o this Standard only when
- the program and each statement or other syntactic e l ement contained therein is syntac
tica l ly valid according to the syntactic rules specified by this Standard as belonging
to that leve l , and
- the program as a who le vio lates none of the g lobal constraints imposed by this level
of the Standard on the app l ication of the syntactic rules .

2.2

Implementation Confo rmance

An imp l ementation conforms to a level of this Standard only when


- it accepts and processes a l l programs conforming to that level of this Standard ,
- it reports reasons for rejecting any program which does not conform to this Standard ,
- it interprets errors and exceptional c ircumstances according to the specifications of
this Standard ,
- it interprets the semantics of each statement of a conforming program according to the
specif ications in this Standard ,
- it interprets the semantics of a conforming program as a who le according to the speci
fications i n this Standard ,
- it accepts as input , manipulates , and can generate as output numbers of at least the
preci s ion 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 Standar d ,
- it is accompanied b y documentation avai lab le t o 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
a l l enhancements to the language defined in this Standard .
This Standard makes no requirement concerning the interpretation of the s emantics of any
statement or program as a who le that does not conform to this Standard .

- 5 -

2.3

Errors
This Standard does not include spec ific 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

An exception is a c ircumstance 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 has been invoked
by the user to handle exceptions .
In the absence of programme r-spec if ied 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 imposs ible 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 the exception handling mechanism reports an exception is
implementation-defined , except that the contents of the report shall identify at least
the exception code and the line number of the line in which the original exception occurred .
Except in the case of f iles , when several exception are caused by the execution of a
s ingle 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 . 1 1 3 - 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 i s optional in the ECMA standard .
Programs written in ECMA BASIC- 1 will run on implementations conforming to the ANSI
standard if the implementation implements at least the Core module . Provided that the
implementation-def ined 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 run 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 def ined in a compatible way in the
two implementations , the program will act in the same way and give the same results .

- 6 -

The reverse wi l l not always be true . In view of the modular nature of the ANSI standard ,
programs conforming to the ANSI standards w i l l run on an ECMA BASIC imp lementations only
if they use the set of fac i l ities defined in the ECMA BASIC Standard . Rea l -time programs
w i l l not

run

on ECMA BASIC implementations .

A further d ifference exists in reserved words . A l l keywords defined in ECMA BASIC- 1 are
reserved and cannot be used as identifiers . Only a l imited number of keywords is re
served in the ANSI Standard . Thus programs written in ECMA BASIC- 1 w i l l run on an ANSI
implementation, with the l imitations defined above . A program written in ANSI BASIC , and
which uses only the fac i litites defined in ECMA BASIC- 1 , is not granted to run on an
ECMA BASIC- 1 imp lementation, unless the l imitations on identifiers have been observed .
The ECMA graphics module is a subset of the ANSI one . Thus programs conforming to the
ECMA module wi l l run on an ANSI implementation, but programs conforming to the ANSI mod
ule w i l l not run on an ECMA imp lementation unless they use only the fac i l ities defined
in ECMA BASIC .

- 7 -

3.

S YN TAX

S P E C I F I CAT I O N AN D

DEF I N I T I ONS

- 8 -

3.
3.1

SYNTAX SPECIFICATION AND DEFINITIONS


Method of Syntax Spec if ication
The syntax , through a series of rewriting rules known as "productions" , def ines syntac
tic objects of various types , such as a program or express ion , and describes which
strings of symbols are objects of these types .
In the syntax , upper-case-letters , d igits , and ( poss ibly hyphenate d ) lower-case words
are used as "metanames " , i . e . as names of syntactic objects . Most of these metanam es are
def ined by productions in terms of other metanames . In order that this process termi
nates , certain metanames are des ignated as "terminal" metanames , and productions for
them are not
included
in the syntax .
With the exception of the construct
11
[ implementation-def ined]" , all terminal metanames 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 d igits are terminal metanames which denote themselves . In ad
d ition , 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 ques tion . In some cases a recommendation as to the representation of the
object is given in the corresponding remarks section .
\-le illustrate further details of the syntax by cons idering 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 metaname ( i . e . , it does not occur on the left-hand s ide of any production) , the se
mantics in 4.1 identify the particular character denoted by a period .
What is integer? The production
integer = d igit d igit>'<
indicates that an integer is a digit followed by an arbitrary number of other d igits . An
asterisk is a syntactic operator indicating that the object it follows may be repeated
any number of time , including zero times .
\fuat is a d igit? In 4.1 the production
d igit

o I 1 I 2 I 3 I 4 I 5 I 6 I 7 I 8 I 9

indicates that a d igit 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 terminal metanames , our decipherment of the syntax for a fraction
comes to an end . The semant ics in 4.1 identify the d igits in terms of the characters
they represent .
A question-mark is a s yntactic operator like the asterisk , indicating that the obj ect it
follows may be omitted . For example , the production
exrad

E s ign? integer

indicates tl1at an exrad cons ists of the letter E or e followed by an optional s ign fol
lowed by an integer .
Parentheses may be used to group sequences of metanames together. For example ,
variable-list = variable ( comma variable ) l'<

- 9 -

defines a variable-list to consist of a variable followed by an arbitrary number of


other variables separated by commas . If we wish parentheses actually to appear in syn
tactic obj ect s , rather than j ust wish to use them to describe syntactic objects , then we
indicate their presence by the metanames 11left-parenthesis11 and " right-parenthes i s " .
When several s yntactic 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 immediately follow . The operator 11111 applies to the sequence of
words and express ions , separated by spaces , which occur s ince the beginning of the en
tire expression , the last 11 I" , or the last unmatched left parenthesis . Thus , for
example,
s ignif icand

integer period? I integer? fraction

is equivalent to
s ignif icand = ( integer (period ) ? ) I ( ( intege r ) ? fraction)
Spaces in the syntax are used to separate terms in a production from each other . Special
conventions are observed regarding spaces in BASI C programs ( see 4.1).
Some syntactic objects are defined by more than one production . For
example , in 5.2 we f ind
s imple-variable > s imple-numeric-variable
and in 6 . 2 we f ind
s imple-variable > s imple-string-variable .
Those two productions are equivalent to the s ingle production below (provided no other
definition of s imple-variable exists )
s imple-variable = s imple-numeric-variable I s imple- string-variable .
In all cases , a greater-than-s ign is used in place of an equals - s ign to indicate a mul
tiple definition , such definitions are equivalent to a s ingle definition containing the
various right-hand s ides separated by slants .
In order to maintain the same numbering of productions in the ECMA and ANSI standards
productions not used in the ECMA Standard are identified by the construct: [deleted] .
As an illustration of the method of syntax specification, following is a description of
the syntax of this method . The terminal metanames occurring below are defined in 4. 1 .
1 . production
2. metaname
3. metacharacter

4.
5.
6.
7.
8.

spaces
syntax-expression
s yntax- te rm
syntax- factor
syntax-primary

9 . repetition
3.2

metanames spaces ( equal s - s ign I greater- than-s ign)


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 - facto r ) )'<
syntax-primary repetition?
metaname I digit d igit)'< I upper-case-letter
upper-case-letteri< I left-parenthesis space)'<
syntax- expres s ion space)'< right-parenthes is
asterisk I question-mark

Def initions of Terms


For the purpose of this Standard , the following terms have the meanings indicated .

- 10 -

3. 2. 1

BASIC
A term applied as a name to members of a special class of languages which possess
similar syntaxes and seman tic meanings, acronym for Beginner's All-purpose Symbolic
Instruction Code.

3. 2. 2

Batch-mode
The processing of programs in an environment where no provision is made for user in
teraction.

3. 2. 3

Can

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 and may also vary depending upon
context. Thus, for example, the end-of-line in an input-reply may vary on a given
system depending on the source for input being used in interactive or batch mode.
Typical examples of end-of-line are carriage-return, carriage-return line-feed, and
end of record (such as end of card).

3. 2. 5

Error
A flaw in the syntax of a program which causes the program to be incorrect.

3. 2. 6

Exception
A circumstance arising in the course of executing a program when an implementation
recognizes that the semantic rules of this Standard cannot be followed or that some
resource constraint is about to be exceeded. Certain exceptions (nonfatal exceptions)
may be handled by automatic recovery procedures specified in this Standard. These and
other exceptions may also be handled by recovery procedures specified in the program
(see 12. 1, BASIC-2 only). If no recovery procedure is given in this Standard (fatal
exceptions) or if restrictions imposed by the hardware or operating environment make
it impossible to follow the given procedure, and if no recovery procedure is speci
fied in the program, then the way in which the exception is handled depends on the
context. If the exception occurred in an invocation of a function, picture, or sub
program, then the exception is 'propagated back' to the invoking statement of the in
voking program unit (see 12. 1, BASIC-2 only). If this propagation procedure reaches
the main program, or if the exception occurred in the main program, then the excep
tion shall be handled by terminating the program.

3. 2. 7

External
With respect to procedures, refers to a procedure lexically not contained within a
larger program-unit.

3. 2. 8

Identifier
A character string used to name a variable, an array, an array-value, an exception
handler, a function, subprogram, or a program.

3. 2. 9

Interactive mode
The processing of programs in an environment which permits the user to respond di
rectly to the actions of individual programs and to control the initiation and termi
nation of these programs.

- 11 -

3.2.10 Internal
With respect to record-type, refers to data representations such that both the type
and exact value of the written data are preserved and retrievable by subsequent read
operations.
With respect to procedures, refers to a procedure lexically
larger program: unit and sharing data with that unit.

contained within a

3.2.ll Keyword
A character string, usually with the spelling of a corrunonly used or mnemonic 1vord,
which provides a distinctive identification of a
statement or a component of a
statement of a prograrruning language.
The keywords in ECMA BASIC are:
ACCESS, AND, ANGLE, AREA, ARITID1ETIC, ARRAY, ASK, AT, BASE, BEGIN, BREAK, CALL, CASE,
CAUSE, CHAIN, CLEAR, CLIP, CLOSE, COLLATE, COLOR, DATA, DATUM, DEBUG, DECIMAL,
DECLARE, DEF, DEGREES, DELETE, DEVICE, DIM, DISPLAY, DO , ELAPSED, ELSE, ELSEIF, END,
ERASE, ERASABLE, EXIT, EXLINE, EXTERNAL, EXTYPE, FILETYPE, FIXED, FOR, FUNCTION, GO,
GOSUB, GOTO, HANDLER, IF, IMAGE, IN, INPUT, INTERNAL, IS, KEY, KEYED, LENGTH, LET,
LINE, LINES, LOOP, MARGIN, MAT, MISSING, NAME, NATIVE, NEXT , NOT, NUMERIC, OF, OFF,
ON, OPEN, OPTION, OR, ORGANIZATION, OUTIN, OUTPUT, POINT, POINTER, POINTS, PRINT,
PROGRAM, PROMPT, RADIANS, RANDOMIZE, READ, RECORD, RECSIZE, RECTYPE, RELATIVE, REM ,
REST, RESTORE, RETRY, RETURN, REWRITE, SAME, SELECT, SEQUENTIAL, SET, SETTER, SIZE,
SKIP, STANDARD, STATUS, STEP, STOP, STRING, STYLE, SUB, TAB, TEMPLATE, TEXT, THEN ,
THERE , TIME, TIMEOUT, TO, TRACE, UNTIL, USE, USING, VARIABLE, VIEWPORT, WHEN, WHILE,
WINDOW, WITH, WRITE, ZONEWIDTH.
Keywords may also be spelled using lower-case letters or mixed upper-case and lower
case letters.
3.2.12 Line
Two types of lines are described in the Standard, a physical line and a logical line.
A physical line is an ordered sequence of characters which terminates with an end-of
line. A physical line starts with a line-number or with an ampersand. A logical line
consists of a line-number followed by an ordered sequence of text where each line
continuation has logically been replaced by a space.
3.2.13 Machine Infinitesimal
The smallest positive value (other than zero) which can be represented and manipu
lated by a BASIC implementation.
3.2.14 !::!2Y
The word "may" is used in a permissive sense to indicate that a standard-conforming
implementation may or may not provide a particular feature.
3.2.15 Native
With respect to record-type, refers to a record with a specified structure for the
fields within the record, so as to be compatible with records generated by other lan
guages on the same system. With respect to numeric or string data, refers to data for
which certain
semantic rules are left implementation-defined (e.g. collating se
quence, precision) so as to be directly implementable on the host hardware.
3.2.16 OVerflow
With respect to numeric operations, the term applied to the condition which exists
when a prior operation has attempted to generate a result which exceeds MAXNUM (see
5.4.4), or which exceeds the maximum value that can be represented by the declared

- 12 -

format 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.1 8 Program Unit
A self-contained part of a BASIC program consisting either of the main-program, which
is the sequence of lines up to and including tl1e line containing an END statement, or
of an external-sub-de or external-function-de.
3.2.1 9 Reserved Hord
BASIC-1
A character string whose usage as a routine-identifier,

string-identifier or

numeric-identifier is forbidden in an EQ1A BASIC-1 program.These words are:


-

the no-argument supplied function names:

DATE,

EXLINE,

EXTYPE, MAXNUM ,

PI,

RND, TIME, TRANSFORM, DATE$, and TIME$,

- the identifier used in array-values: CON, ION, ZER, and NUL$,


- the following keywords:

ACCESS, AND,

BEGIN,

BREAK,

CALL, CASE,

DATUM,

DEBUG,

DECIMAL, DECLARE,

DO,

ELAPSED,

FOR,

ELSE,

FUNCTION,

LENGTH,

LET,

LINE,

NOT, Nill1ERIC,
RECTYPE, REM,
TEXT,

THEN ,

ELSEIF,
LINES,

DEF,

END,

GOSUB,

GOTO,
LOOP,

ANGLE, AREA, ARITHMETIC, ASK, AT, BASE,

CLEAR,

CLIP,

DEGREES,

ERASE,

CLOSE,
DEVICE,

ERASABLE,

GRAPH,
1ARGIN,

IF,
MAT,

COLLATE,

EXIT,

IMAGE,

COLOR,

DATA,

DEVICE, DIM, DISPLAY,


EXTERNAL,

INPUT,

MISSING,

NAME,

FILETYPE,

INTERNAL,
NATIVE,

IS,
NEXT,

OFF, ON, OPEN, OPTION, OR, ORGANIZATION, OUTIN, OUTPUT, POINT,

POINTER, POINTS,
SIZE, SKIP,

GO,

CHAIN,

PRINT, PROGRAM,

PROMPT,

REST, RESTORE,

RETURN,

STANDARD, STATUS,

STEP,

THERE,

TIMEOUT,

TO,

RADIANS,

SAt1E,
STOP,

TRACE,

RANDOMIZE, READ ,

SELECT,
STREAM,

UNTIL,

RECSIZE,

SEQUENTIAL, SET,
STRING,

USING,

STYLE,

VARIABLE,

SETTER,

SUB,

TAB,

VIEWPORT,

WHILE, HINDOH, WITH, WRITE, ZONEWIDTH.


The function names EXLINE and EXTYPE 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,

EXLINE,

EXTYPE,

MAXNUM ,

PI,

RND, TIME, TRANSFORM, DATE$ and TIMES$,

- the identifiers used in array-values: CON, IDN, ZER, and NUL$,


- the keywords NOT, ELSE, PRINT and REM .
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 that a program is re
quired to be constructed , or that an implementation is required to act , as specified
in order to meet the constraints of s tandard conformance .
3. 2. 22 Significant Digits
The contiguous sequence of digits between the high-order nonzero digit and the low
order d igit , without regard for the location of the radix point . Commonly , in a nor
malized floating point internal representation , only the significant d igits of a rep
resentation are maintained in the s ignificand . In fixed-point representation, the low
order d igit i s the rightmost one explicitly spec i f ied , and non-significant high order
d igits may be maintained .
3. 2. 23 Truncation
The process by which a representation of a value with lower precision is generated
from a representation of higher precis ion by merely deleting the unwanted low-order
digits of the original representation .
3. 2. 24 Underflow
With respect to numeric operations , the terms applied to the condition which exists
when a prior operation has attempted to generate a result , other than zero , which is
les s in magnitude than machine infinitesimal .

- 14 -

4.

P ROGRAM E L E ME N T S

- 15 -

4.

PROGRAM ELEMENTS
A BASIC program i s a sequence of l ines containing statements . Each l ine i s itself a se
quence of character s .

4.1

Characters

4 . 1.1

General Description
The character set for ECMA BASIC is contained in the Standard ECMA-6 .

4 . 1. 2

Syntax
1 . character
2. quoted- string-character
3 . non-quote-character

4. double-quote
5. unquoted - string-character
6. p lain- string-character
7 . digit

8.
9.
10 .
11 .

letter
upper- case- letter
lower-cas e - l etter
other character

quotation-mark I non-quote-character
double-quote I non-quote-character
ampersand I apostrophe I asterisk I c ircumflex-accent
I colon I comma I dol lar - sign I equal s - s ign I
exc lamation-mark I greater-than-s ign I
left-parenthesis I les s - than - s ign I
number- s ign I percent- s ign I question-mark
right-parenthes is I semicolon I s lant I
underl ine I unquoted- s tring-character
quotation-mark quotation-mark
space I p lain-str ing-character
minus- s ign
d igit I letter I period I p lus- s ign
4
3
01 1121 1 1 516171819
upper-case- letter I lower-case- letter
AIBICIDIEIFIGIHI I IJIKILIMINIOIPIQIRISIT IUIVIWIXIY IZ
alblcl dlelflglhliljlkl l lmlnlo lpl qlrlsltlulvlwlxlylz
[ imp lementation-defined]

The s yntax as described generates programs which contain no spaces other than those
occurring in remark-strings , in certain quoted- strings , unquoted- strings , and
l iteral-strings , or where the presence o f a space is exp l icitly indicated by the
metaname space.
Special conventions sha l l be observed regarding spaces . With the f o l l owing excep
tions , spaces may occur anywhere in a BASIC program without affecting the execution
of that program and may be used to improve the appearance and readab i lity of the pro
gram . Spaces sha l l not appear :
-

immed iately preceding the l ine-number of a l ine


within l ine-numbers
within keywords
within identif iers
within numeric -constants
within multicharacter relation symbols .

In addition, spaces which appear in quoted - s tring s , unquoted- strings , and format
str ings sha l l be s ignif icant ( though spaces which precede or fol low an unquoted
string are not part of that string ) .
A l l keywords in a program , when used as suc h , shal l be p receded and f o l lowed by some
character other than a letter, d igit , underl ine or dol lar - s ign. A keyword may also be
f o l l owed by an end - of - l ine .
4. 1.3

Examp les
None .

- 16 -

4. 1. 4

Semantics
The letters sha l l be the set of capital ( upper-case) and sma l l ( lower-case) latin
letters contained in the character set in pos itions 411 to 5110 and 611 to 7110 , re
spectivel y .
The digits sha l l be the set of Arabic d igits contained in the character set in posi
tion 310 to 319 .
The remaining characters sha l l correspond to the rema1n1ng graphic characters in po
s i t ion 210 to 211 5 , 3110 to 311 5 , 5114 , and 5115 of the ECMA character set .
The names of the characters are specified in Table 1 . Table 1 shall app ly when the
standard c o l lating sequence is in effect , either by default or by exp licit use of a
COLLATE option ( see 6. 4 , 6. 6 , and 8. 1 ) . The coding for the native col lating sequence
s ha l l be imp lementation-defined .
A l l characters other than letters denote themselves . Letters denote
themse lves
within quoted-strings , unquoted- strings and l ine- input-rep l ies . Corresponding upper
case-letters and lower-case- letters shal l be equivalent when used in identifiers and
keywords . Quoted- string-characters also denote themse lves , except for the double
quote, which denotes one occurrence of the quotation-mark in the value of the string .

4. 1 . 5

Exceptions
None .

4 . 1. 6

Remarks
Other-characters may be defined by an imp lementation to be part of the character set
for BASIC . These characters may be used in strings and may be accepted as characters
in data supp l ied in response to a reques t for input or generated as the value of the
CHR$ function ( see 6. 4 ) . The effects of these other-characters are imp l ementation
defined .
Programs written us ing other-characters ( except for end-of - l ine characters ) are not
themselves standard-conforming programs .

4. 2 Programs , Lines , and B locks


4. 2. 1

General Description
A BASIC program is a sequence of l ines . Each l ine contains a unique l ine-number which
fac i litates program editing and serves as a label for the s tatement contained in that
l ine .
A BASIC
program is d ivided logica l ly into a number of program-units The f irst of
these i s the main-program, which is terminated by an end - l ine . Fo l l owing the main
program may be zero or more external - sub-def or external -function-def . Certain
logical groupings of l ines within a BASIC program are cal led blocks .

4. 2. 2

Syntax
The syntax eleEDts available only in ECHA BASIC-2

1. program
2. program-name- l ine

3.
4.
5.
6.

program-name
main-program
unit-block
internal -proc- def

are

printed in bold.

> program-name- l ine? main-program procedure-par


l ine-number PROGRAM program-name function-parm- l ist?
tai l
routine - identifier
unit-block)'< end - l ine
interna l -proc-def I b lock
> internal- function-def I internal-sub-def
detached-handler

- 17 -

7 . block

8. statement-line
9 . line - number
10 . statement
11 . declarative-statement

12 . imperative-statement

13.
14.
15.
16.
17 .
18.
19 .
20 .
21.

stop-s tatement
conditional-statement
tail
end-of-line
end-line
end-statement
procedure-part
procedure
remark-line

22. line

23 . program-unit
24 . l ine- continuat ion

> statement-line I loop I if-block I select-block I


image- line I protection-block
line-number statement tail
d igit d igit)'C
> declarative-statement I imperative-statement
conditional-statement
> data-statement I declare-statement I
d imens ion-statement I null-statement
option-statement I remark-statement
> array-ass ignment 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-s tatement I
close-statement I debug-statement I
erase-statement I exit-do-statement
exit-for- s tatement I exit-function- statement I
exit-handler-statement I exit-sub-statement I
gosub- statement I gate-statement I
handler-return-statement I input-statement
let-statement I l ine- input-s tatement I
numeric-function-let-statement I
open-statement I print-statement I
rruldomize-statement I read-statement I
restore-statement I return-statement I
set-statement I stop - s tatement I
string-function-let-statement I
trace-statement I write-statement
STOP
if-statement I on-gosub-statement I on-gate-statement
tail-comment? end-of-line
[ implementation-def ined)
line-number end-statement tail
END
remark-line)'< procedure
> external-funct ion-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-funct ion-line I
end-handler-line I end-if-line I end-line I
end-select-line I end- sub-line I end-wen-line
I external-function-line I external-sub-line I
for-line I handler-line 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
when-line I when-use-na:e-line
> main-program I procedure
arnpersm1d space)'' tai 1 arnpersm1d

A program shall be composed of a sequence of lines . Exactly one of these lines shall
be an end-line ; the lines up to and including this end-line constitutes the main
program.

- 18 -

Line-number zero is not al lowed; leading zeroes sha l l have no effect .


occur

in

ascending

line-number

order .

All

references t o

Lines shal l

line-numbers within

program-unit shal l be to line-numbers of lines within that p rogram-unit . The number


o f digits in a l ine-number sha l l not exceed 5. The value of a line-number shal l not
exceed 50000 .
The manner in which the end of a l ine is detected is determined by the
imp lementation ; e . g . , the end - of - l ine may be a carriage- return character, a carriage
return character f o l l owed 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 indicato r .
A t any p lace where a space may b e used, except in quoted- strings, unquoted- strings,
litera l - strings, and remark-strings ( see 4 . 1 and 4 . 3 ), a line-continuation may be
substituted for a space with no effect other than that of the space it replaces.
Parameters in the program-name- line sha l l not be exp l icit ly d imensioned or dec lared
in the main-program .
4.2.3

Examples
2 . 100 PROGRAM Graphic
&
( x,
&
y)
18 . 999 END

4.2.4

&
&

This program draws a graph


x is x-coordinate
y is y-coordinate

Semantics
The program-name- l ine is the operand of the chain-statement ( see 9 . 3 ) . The
relationship between the progranJ-name and the program-designator in a program
executing a chain-statement is imp lementation-defined . Parameters in the program
name-l ine are evaluated as described in 9 . 1 . Their scope is the main-program . For a
program executed in iso lation, tJ1e program-name has no effect . The effect of a
parameter - l ist in a program-name-line for a program executed in iso lation is
implementation-defined .
Line s in a program sha l l be executed in sequential order,
line, until

starting with the first

- some other action is d ictated by execution of a line, or


an exception occurs ( unless, in BASIC-2, it is a nonfatal exception which is not
hand led by a user defined exception-hru1d ler), or
- a chain-statement is executed, or
- a stop- statement or end-statement is executed .
The end-statement shal l serve both to mark the physical end of ilie main-program and
to terminate execution of the progran1 when encountered .
Execution
program .
4. 2 . 5

of

stop-statement

shal l

a l so

cause

termination

of

execution

of

the

Exceptions
None .

4.2.6

Remarks
References to non-existent line-numbers in a program-unit are sY11tax errors.
Imp lementations may therefore treat them as exceptions, if they are documented as
such .

- 19 -

Program Annotation

4.3.
4.3.1

General Description
BASIC programs may be annotated by comments at the end of program
separate remark-statements .

4.3 .2

l ines

or by

Syntax
REM remark- st ring
character'
tai l -comment
exc lamation-mark remark-string

1 . remark- statement
2 . remark-string
3 . nul l - s tatement
4 . tai l -comment

Line-continuation sha l l not occur in remark- strings.


4.3.3

Examples
1. REH FINAL CHECK
4 . ! COMPUTE AVERAGE

4.3.4

Semantics
I f the execution of a program reaches a l ine containing a remark-statement or nul l
statement, then it sha l l proceed to the next l ine with no other effect .
A tail - comment has no effect upon the execution of the l ine in which it occurs. The
remark-string in the tai l -comment serves solely as a comment about the l ine.

4.3 . 5

Exceptions
None.

4.3.6

Remarks
None.

4.4

Identifiers

4.4.1

General Description
Identif iers are used to name variab les , arrays, array-values, functions, programs,
subprograms and exception-hand lers.

1. identif ier

2. numeric- identif ier


3. identif ier-character
4. string- ident i f ier
5 . routine- identi f ier

>

numeric- ident if ier I str ing- identif ier


routine- identif ier
letter identif ier-characters>'<
letter I d igit I under l ine
letter identi f ier- character>'<dollar- s ign
letter ident ifier-character>'<

An identifier s ha l l contain at most 31 characters , inc luding the do l lar- s ign in the
case of a string identifier.
A given numeri c - identi f ier may name a s imp le-numeric-variable, a one-dimens ional ,
two- d imensional or three-dimensional numeri c -array, a numeri c - function, or a numeric
array-value, but not more than one of these in a program-unit. Likewise, a given
string - identif ier may name a s imp le-str ing-variable, a one-d imensional, two
d imens ional or three- d imensional string-array, a string-function, or a string-array
value, but not more than one of these in a program-unit.
A given identifier may name an internal- subprogram, an internal - function-de or a
detached-handler but not more than one of these in a program-unit.

- 20 -

A given routine- identifier shal l not name more than one of an externa l -function-def,
an external - sub- def or a main-program in a program .
A numeric - identi fier
routine- identifier .

which names an externa l -function-def may not

be used

as

The names of the no -argument supplied functions or array-values CON, DATE, EXLINE,
EXTYPE, IDN, MAXNUM, PI, RND, TIME, TRANSFORM and ZER shal l not be used as numeric
identifiers to name any other entity .
The names of the no-argument supp l ied
functions or array-values
DATE$ ,
NUL$, and TIME$ shal l not be used as string
identifiers to name any other entity . The keywords l is ted in 3 . 2 . 19 sha l l not be used
as identifiers . Note that the list in
4 4.3
.

3 . 2 . 19 is d ifferent for BASIC- 1 and BASIC- 2 .

Exles
2. X
sum
4 . A$
last_names$
5 . INVERT

4.4.4

Semantics
Each program-unit is a distinct entity in that identifiers used to name variables,
arrays,
detached-handlers, internal-function-definitions,
or internal-procedures
defined within p rogram-units sha l l be local to each invocation of the program-unit in
which they occur; i . e . , they sha l l name different objects in different program-units
and in different invocations of the same program-unit . Identifiers used to name
supp l ied-functions or program-units, however, shal l be global to the entire program;
i . e . , they sha l l name the same object wherever they occur .
If the name of imp lementation- supp lied function or the keyword TAB is imp l icitly or
exp l ic itly defined or dec lared as the identifier of a user-defined function, array,
or variab le, then the defined dec lared interpretation of the identifier sha l l
override the interpretation specif ied b y the Standard within the scope of the
definition or declaration . Therefore, within that scope, the imp lementation- supp lied
function or the tab-cal l sha l l be unavai lable .
Within any program-un it, identifiers which differ only in the cases of the letters
they contain shal l denote the same objects ( e . g . , Xl identifies the same obj ect as
x l ) . Identifiers which differ in any other respect shall denote different obj ects .

4.4.5

Exceptions
None .

4.4.6

Remarks
No imp lementation-defined enhancement to this Standard may extend the l ist of words
unavailable for use as s imp le-variables. Since a l l arrays must be dec lared ( see
7 . 1 . ) , and s ince all defined-functions must be declared or def ined in the program
unit in which they are referenced, imp lementations may supp ly buil t - in functions
other than those specified in this Standard provided that any declaration for such
identifiers within a program overrides the imp l ementation-supp l ied interpretation .
Note, however, that in some cases the use of a parameter less function supp l ied by an
implementation as an enhancement would be syntactical ly indistinguishable from a

- 21 -

variabl e

having

the

same

name .

Therefore,

implementations

which

provide

such

functions must also provide a syntactic means for identifying them as functions .
Examples of such syntax are a requirement to declare such functions exp l icitly in any
program-unit where they are used or requiring the use of empty parentheses ( e . g .
"NEWFUNCTION ( ) ") with reference to such functions .

An operating system may impose additional restrictions on the length and form or
identifiers for procedures which are compi led independently of the main-program .
A supp lied-funct ion may be overridden by defining a user-defined function or s imp le
variable with the same name .
In ECMA BASIC- 2 , an identifier may have the same spe l l ing as a keyword ( o ther than
PRINT, ELSE, REM or NOT ) .

- 22 -

5.

N UMB E RS

- 23 -

5.

NUMBERS
Numbers const i tute one of two primitive data types in BASIC ( the other is strings ) . With
numbers are associated constants, variables, and imp lementation-suppl ied functions , from
which express ions can be formed .

5.1

Numeric Constants

5.1.1

General Description
Numeric-constants

denote

scalar numeric

values .

numeric-constant

is

a decimal

representation, in positional-notation, of a number . There are four general syntactic


forms of numeric-constants :
-

imp l ic i t
exp l ic i t
exp l ic i t
imp l icit

po int
po int
po int
point

unsealed representation
unsealed representation
scaled representation
scaled representation

d. .
ds .
sd .
sd .

.d
. drd . . . d
. . drd . . . dEsd . . . d
. . dEsd . . . d

where d is a digit, r is a period, s is an optional s ign, and E is the exp l icit


character E or e . A numeric-constant not preceded by a s ign is assumed to be
positive .
5 . 1. 2

Syntax
1 . constant
2 . numeric-constant
3 . s ign
4 . numeri c -rep
5 . s igni f icand
6 . integer
7 . fraction
8 . exrad

5.1.3

> numeric-constant
s ign? numeric-rep
p lus - s ign I minus- s ign
s ignificand exrad ?
integer period? I integer? fraction
d igit d igit,'<
period integer
E s ign? integer

Exles
2 . -21
4 . 1E10
5e- 1
. 4E +1
5 . 500 .
1.2
7 . . 2 55

5 . 1.4

Semantics
The value of a numeric-constant is the number represented by that constant . "E" and
"e" stand for " t imes ten to the power" ; if no s ign fol lows the s ymbo ls E and e, then
a p lus -s ign is understood .
A p rogram can contain numeric-constants which have an arbitrary number of digits . An
imp lmentation must retain either the exact value of a numeric-constant, or that value
rounded to an imp lementation-def ined precis ion . The impl ementation-def ined precis ion
for numeric constants sha l l not be less than ten or s ix s ignificant dec imal digits,
depending on upon whether the ari thmetic option in force is DECIMAL or NATIVE
respectively . Numeric-constants can also have an arbitrary number of digits in the
exrad, though nonzero constants whose magnitude is outs ide an imp lementation-defined
range may be treated as exceptions ( see 5 . 6 ) . Nonzero constants whose magnitudes are
less than machine infinites imal sha l l be replaced by zero, whi l e constants whose
magnitudes are larger than MAXNUM sha l l be reported as causing an overf low .

- 24 -

5.1.5

Exceptions
- The evaluation of a numeric-constant causes an overflow (1001, fatal).

5.1.6

Remarks
It is recorrnnended that implementations report constants whose magnitudes are less
than machine infinitesimal as underflows (1501, nonfatal replace by zero and
continue). In BASIC-2 implementation, this permits interception by exception
handlers.
Although this Standard contains no prov1s1on for named constants, their effect can be
achieved through no-argument defined-functions (see 9.1).

5.2

Numeric Variables

5.2.1

General Description
Numeric-variables may be either simple-numeric-variables or references to elements of
numeric-arrays.

5.2.2

Syntax
1.
2.
3.
4.
5.
6.

variable
numeric-variable
simple-numeric-variable
numeric-array-element
numeric-array
subscript-part

7 . subscript
8 . index
9. simple-variable
10. array-name

> numeric-variable
simple-numeric-variable I numeric-array-element
numeric-identifier
numeric-array subscript-part
numeric-identifier
left-parenthesis subscript (comma subscript)'''
right-parenthesis
index
numeric-expression
> simple-numeric-variable
> numeric-array

The number of subscripts in a subscript-part shall be one, two, or three.


5.2.3

Examples
3. X
sum
4. V(4)
table(i, j+l)

5.2.4

Semantics
At any instant in the execution of a program, a numeric-variable is associated with a
single numeric value. The value associated with a numeric-variable may be changed by
the execution of statements in tl1e program.
Simple-numeric-variables are declared implicitly through their appearance in a
program-unit. The scope of a numeric-variable shall be the program-unit in which it
appears, unless it is a parameter of an internal-function-definition (see 9. 1).
An index is a numeric-expression whose value shall be rounded to the nearest integer;
the rounded value of X is defined to be INT(X+.5).
A numeric-array-element is called a subscripted numeric-variable and refers to the
element in the array selected by the value(s) of the subscript(s). The acceptable
range of values must be explicitly declared in a dimension-statement or a declare
statement (see 7 .1). Subscripts shall have values within the appropriate range.
At the initiation of execution the values associated with all numeric-variables shall
be implementation-defined.

- 25 -

5.2.5

Exceptions
- A subscript is not in the range of the declared bounds (2001, fatal) .

5.2.6

Remarks
Since initialization of variables is not specified , and hence may vary from
implementation to implementation, programs that are intended to be transportable
should explicitly assign a value to each variable before any expression involving
that variable is evaluated.
There are many co1IIIl1 only used alternatives for associating implementation-defined
initial values with variables; it is reco1IIIl1 ended that all variables be recognizably
und efined in the sense that an exception will result from any attempt to access the
value of any variable before that variable is explicitly assigned a value (3101 ,
nonfatal: supply an implementation-defined value and continue) .

5 .3

Numeric Expressions

5.3.1

General Description
Numeric- expressions may be constructed from numeric- variables, numeric-reps, and
n umeric- function- refs using the operations of add ition , subtraction , multiplication ,
d ivision , and exponentiation (i.e., raising to a power) .

5.3.2

Syntax
1.
2.
3.
4.
5.

expression
numeric- expression
term
factor
primary

6. numeric- function-ref
7 . numeric- function
8 . function- arg- list
9 . function- argument
10. actual- array
11. multiplier

> 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 (comma
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 d efinition of the numeric
function. An actual-array shall have the same number of d imensions as the
corresponding parameter.
Whenever numeric arguments are passed to an external- function-definition , the
ARITHMETIC options in effect for the external- function-definition and the invoking
program - unit must agree.
Each numeric- function referenced in an expression within a program-unit shall either
be implementation- supplied , or shall be d efined in an internal- function-def or
declared in a declare- statement occuring in a lower-numbered line, within the same
program- unit, than the first reference to that numeric- function.
5 .3 .3

Examples
2. 31''X - Y - 2
costl''quantity + overhead
4. 2 - (- X )
5. SQR(X - 2+Y - 2 )
6 . value(X , Y , a$ )

- 26 -

5. 3. 4

S emantics
The formation and evaluation of numeric-express ions fol lows the normal algebraic
rules. The symbo l s circumf lex-accent ( - ) , asterisk ( *) , s lant ( / ) , p lus - s ign ( + ) , and
minus- s ign ( - ) represent the operations of exponentiation , multipl ication , d ivis ion ,
addition, and subtraction or negation , respectively. Unless parenthesis dictate
otherwise , exponen-tiations sha l l be performed f irst, then multip l ications and
divisions , and fina l ly additions , subtractions , and negations. In the absence of
parenthesis , operations of the same precedence sha l l be evaluated from left to right.
- - Thus A-B-C sha l l be interpreted as (A-B ) - C ; A B C , as (A B ) C ; A / B / C , as (A/B) / C ;
-A+B a s ( -A)+B; and -A B as - ( A B ) .
If a n underflow occurs i n the evaluation of a numeric-express ion, then the value
generated by the operation which resulted in the underf low sha l l be replaced by zero.
For those mathematical operators which are associative , commutative , or both , full
use of these properties may be made in order to revise the order of evaluation of the
numeric-expression except where constrained by the use of parenthesis.

o- o is defined to be 1.
A numeric-function-ref is a notation for the invocation of a predefined algorithm,
into which the argument values , if any , sha l l be substituted for the parameters ( see
5. 4 , 6. 4 and 9. 1 ) used in the function-definition. The result of evaluating a
numeric-function , achieved by the execution of the defining algorithm, sha l l be a
scalar numeric value which replaces the numeric-function-ref in the numeric
express ion.
5. 3. 5

Exceptions
Evaluation of a numeric-expression results in d ivis ion by zero ( 3001 , fata l ) .
Evaluation o f a numeric -expression results i n an overflow ( 1002 , fata l ) .
- Eva luation of the operation o f exponentiation results i n a negative number being
raised to a non-integral power ( 3002 , fata l ) .
Evaluation o f the operation o f exponentiation results i n zero being raised t o a
negative power ( 3003 , fata l ) .

5. 3. 6

Remarks
The accuracy with which the evaluation of a numeric expression takes p lace may vary
from implementation to imp lementation , subj ect to the constraints of 5. 6.
It is recommended that imp l ementations report underflow as an exception ( 1502 ,
nonfatal : replace by zero and continue ) . In BASIC-2 implementation , this permits
interception by exception handlers.
Imp lementations may evaluate primaries and operations within a numeric-express ion in
any order which is cons istent with the semantics of 5. 3. 4. Of course , an operation
must be evaluated after its operands. For examp le, in the expression "A+B+C+D>'<E11 , the
primaries and additions may be evaluated in any order. However , the multipl ication
must be performed before the addition imp l ied by the third p lus-sign , s ince the
product "D>'<E" is one of the operands of that addition.

5. 4

Implementation-Supp l ied Numeric Functions

5. 4. 1

General Description
Predefined algorithms are supp lied by the imp lementation for the evaluation of
commonly used numeric functions. Additional functions related to other features of
this Standard are defined in 6. 4 , 7. 1 and 7. 2.

- 27 -

5.4.2

Syntax
1. numeric-supplied-function > ABS I ACOS I ANGLE I ASIN I ATN I CEIL I COS I COSH
COT I esc I DATE I DEG I EPS I EXP I FP I
MAXNUM I INT I IP I LOG I LOGlO I LOG2 I MAX I
MIN I MOD I PI I RAD I REMAINDER I RND I
ROUND I SEC I SGN I SIN I SINH I SQR I TAN I
TANH I TIME I TRUNCATE
2 . randomize-statement
RANDOMIZE

5.4.3

Examples
2 . RANDOMIZE

5.4.4

Semantics
The values of the numeric-supplied functions, as Hell as the number of arguments
required for each function, shall be as described beloiV. In all cases, X and Y stand
for numeric-expressions, and N stands for an index, i.e., the rounded integer value
of a numeric-expression. Each function accepts numeric arguments Hithin the range of
the negative number with the largest magnitude to the largest positive number, except
where noted. For functions which return a value in angle measure (ACOS, ANGLE, ASIN
and ATN), the value shall be in radians unless OPTION ANGLE DEGREES is in e ffect (see
5 . 6 ) , when the value shall be in degrees. In the semantics below, " pi" (lower-case)
stands for the true value of that constant.
Function
Function value
ABS(X)
The absolute value of X.
ACOS(X)
The arccosine of X in radians or degrees (see 5.6), Hhere 0 s ACOS(X) s pi; X
shall be in the range - 1 s X s 1.
ANGLE(X, Y)
The angle in radians or degrees (see 5 . 6 ) between the positive x-axis and the
vector joining the origin to the point with coordinates (X , Y), where -pi <
ANGLE(X, Y) s pi. X and Y must not both be 0. Note that counterclockHise is
positive, e.g., ANGLE(l,l)
45 degrees.
=

ASIN(X)
The arcsine of X in radians or degrees (see 5.6),
pil 2 ; X shall be in the range -1 s X s 1.

where -pil 2 s ASIN(X) s

ATN(X)
The arctangent of X in radians or degrees (see 5. 6 ) , i.e., the angle whose
tangent is X , where -(pil 2 ) < ATN(X) < (pil 2 ).
CEIL(X)
The smallest integer not less than X.
COS(X)
The cosine of X, where X is in radians or degrees (see 5 . 6 ) .
COSH(X)
The hyperbolic cosine of X.

- 28 -

COT(X)
The cotangent of X, where X is in radians or degrees (see 5 . 6 ) .
CSC(X)
The cosecant of X, where X is in radians or degrees (see 5 . 6 ) .
DATE
The current date in decimal form YYDDD, where YY are the las t two digits of
the year and DDD is the ordinal number of the current day of the year; e . g . ,
the value of DATE on May 9, 1977 was 7 7 129. If there is no calendar
available, then the value of DATE shall be - 1 .
DEG(X)
The number of degrees in X radians .
EPS(X)
The maximum of (X- X ' , X " - X , s igma) where X ' and X" are the predecess or and
successor of X and sigma is the s mallest positive value representable . If X
has no predecessor then X ' = X and if X has no successor then X"=X" . Note
EPS(O) is the s malles t positive number representable by the implementation,
and is therefore implementation- defined. Note also t hat PS may produce
different results for different arith metic options (see 5 . 6 ) .
EXP(X)
The exponential of X , i. e . , the value of the base of natural logarithms
(e = 2 . 7 1828 . . . ) raised to the power X ; if EXP(X) is less than machine
infinitesimal, then its value shall be replaced by zero.
FP(X)
The fractional part of X, i . e . , X - IP(X ) .
INT(X)
The larges t integer not greater than X ; e . g . , INT(1 . 3)= 1 and INT(- 1 . 3 )= - 2 .
IP(X)
The integer part of X , i . e . , SGN(X)>'ciNT(ABS(X)).
LOG(X)
The natural logarithm of X ; X shall be greater than zero.
LOG10(X)
The common logarith m of X ; X shall be greater than zero .
LOG2 (X)
The bas e 2 logarithm of X ; X shall be greater than zero.
MAX(X, Y)
The larger (algebraically) of X and Y .

The largest finite pos itive number representable and manipulable by the
implementation;
implementation- defined .
MAXNUM
may represent different
numbers for different arithmetic options (see 5 . 6 ) .

- 29 -

MIN(X, Y)
The smaller (algebraically) of X and Y .
MOD(X, Y)
X modulo Y , i . e . , X-Yi<INT(X/Y). Y shall not equal zero.
PI
The c onstant 3 . 14159 . . . which is the ratio of the c ircumference of a c ircle
to its diameter.
RAD(X)
The number of radians in X degrees.
REMAINDER(X, Y)
The remainder f unction, i . e . , X-Yi<IP(X/Y). Y shall not equal zero.
RND

The next pseudo-random number in an implementation-def ined sequence


pseudo-random numbers uniformly distributed in the range 0 RND < 1 .

of

ROUND(X, N)
The value of X rounded to N decimal digits to the right of the decimal point
(or -N digits to the left if N < 0); i . e . , INT(Xl'<10-N+ . 5)/ 10-N .
SEC(X)
The secant of X , where X is i n radians o r degrees (see 5 . 6) .
SGN(X)
The sign of X : -1 if X < 0, 0 if X

0, and +1 if X > 0.

SIN(X)
The sine of X, where X is in radians or degrees (see 5 . 6).
SINH(X)
The hyperbolic sine of X .
SQR(X)
The non-negative square root of X ; X shall be non-negative .
TAN(X)
The t angent of X, where X is in radians or degrees (see 5 . 6) .
TANH(X)
The hyperbolic tangent of X .
TIME
The time elapsed since the previous midnight, expressed in seconds; e . g . , the
value of TIME at 11 : 15 AM is 405 00. If there is no clock available, then the
value of TIME shall be -1. The value of TIME at midnight shall be zero (not
86400) .
TRUNCATE(X, N)
The value of X truncated to N decimal digits to the right of the
point (or -N digits to the left if N < 0); i . e . , IP(Xl'<lO -N)/ 10- N .

dec imal

- 30 -

I f OPTION ANGLE DEGREES is in effect, the term "in radians or degrees " in the above
list of function values sha l l mean degrees . If OPTION ANGLE RADIANS is in effect, the
term "in radians or degrees " sha l l mean radians . The accuracy requirements ( see
5 . 6 . 4 ) for the periodic trigonometric funct ions SIN, COS, TAN, SEC, CSC, COT are
l imited to providing ful l accuracy of m+1 decimal d igits only for arguments n the
range of - 2)'<pi to 2<pi . Los s of accuracy outside this range is l imited to the resul t
of loss of prec is ion i n performing those range reductions o n arguments necessary to
compute values o f these functions, i . e . , "SIN ( x ) " may be evaluated as if it were
written "SIN ( MOD ( x, 2)'<pi ) ) " and s imi larly for the other functions .
If no randomize-statement is executed, then the RND function sha l l generate the same
sequence of pseudo- random numbers each t ime a program is run . Execution of a
randomize-statement sha l l override this imp l ementation- supp l ied sequence of pseudo
random numbers, generating a new ( and unpredictabl e ) starting point for the list of
pseudo-random numbers used subsequently by the RND function . The sequence of pseudo
random numbers sha l l be g lobal to the entire program, not local to individual
program-units .
5.4.5

Exceptions
The value of the argument of the LOG, LOG10, or LOG2 function is zero or negative
( 3004, fatal ) .
- The value of the argument of the SQR function is negative ( 3005, fata l ) .
- The magnitude of the value of a numeric- supp l ied-function is larger than MAXNUM or
is mathematical infinity ( 1003, fatal ) .
The value of the second argument of the MOD or REMAINDER function is zero ( 3006,
fatal ) .
The value of the argument of the ACOS or ASIN function is less than - 1 or greater
than 1 ( 3007 , fatal ) .

- An attempt is made to evaluate ANGLE ( O , O ) ( 3008, fatal ) .


5 .4.6

R emarks
In the case of imp lementations which do not have access to a randomizing device such
as a real-time c l ock, the randomize - s tatement may be implemented by means of an
interaction with the user .
This S tandard requires that overf l ows be reported only for the final values of
numeric- supp l ied-functions ; exceptions which occur in the evaluation of these
functions need not be reported, though imp lementations sha l l take appropriate actions
in the event of such exceptions to insure the accuracy of the final values . When
overf lows are reported for the f inal values of numeric- supp l ied- functions, it i s
recommended that the name of the function generating the overf low be reported also .
It is recommended that, if the magnitude of the value of a numeric-supp lied - funct ion
is nonzero, but less than machine inf ini tes imal, imp lamentations report this as an
underf low, set the value to zero ( 1503, nonfatal : return zero and continue ) .
BASIC- 2 imp lementations, this permits interception by exception hand lers .

In

The time-zone used for DATE and TIME is imp l ementation-defined .


It may not be poss ible, for reasons of overflow, to express the year in ful l format
in DATE . When this ful l format is needed, the function DATE$ should be used .

- 31 -

5. 5

Numeric Assignment Statement

5. 5. 1

General Description
A let- statement provides for the simultaneous assignment of the computed value of a
numeric-expression to a list of numeric- variables .

5. 5 . 2

Syntax
1 . let- statement
2 . numeric- let- statement
3 . numeric- variable- list

5. 5 . 3

Examples
2 . LET
LET
LET
LET

5. 5 . 4

> numeric- let- statement


LET numeric-variable- list equals- sign
numeric-expressio n
numeric- variable (connna numeric- variable))'<

P = 3 . 14159
A(X , 3) = SIN(X))'cy + 1
A, Y(l), Z
I+l
T(I,J), I, J = I + J

Semantics
The subscripts, if any, of variables in the numeric- variable- list shall be evaluated
in sequence from left to right . Next the numeric-expression on the right of the
equals- sign shall be evaluated (see 5 . 3 ) . Finally, the value of that numeric
expression, if necessary rounded to the nearest value which can be retained by the
variable , shall be assigned to the numeric- variables in the numeric- variable- list in
order from left to right .

5.5.5

Exceptions
None .

5. 5.6

Remarks
Note that :

is not equivalent to :

5.6

LET A = 1
LET A, B(A)

LET A = l
LET A = 2
LET B(A) = 2

Numeric Arithmetic and Angle

5.6.1

General Description
Unless specified otherwise , the values of all numeric- variables shall behave
logically as f loating-point decimal numbers with an implementation-def ined precision
of at least ten decimal digits . By use of an option- statement, a program may choose
to take advantage of a more eff icient, but possibly less accurate , representation for
numeric values.
Unless specified otherwise the trigonometric functions (see 5 . 4) require arguments or
generate values in radian measure . By use o f an option- statement, a program may
change the angle measure of all such functions to degrees.

5. 6 . 2

Syntax
1 . option- statement
2 . option- list
3 . option

OPTION o ption- list


option (comma option),'<
> ARITHMETIC (DECIMAL I NATIVE I FIXED) I ANGLE
(DEGREES I RADIANS)

- 32 -

4. declare- statement
5. type- declaration
6. numeric- type
7 . numeric- declaration

DECLARE type- declaration


> numeric- type
> NUMERIC numeric- declaration (comma
numeric- declaration))''
> simple-numeric- variable

An option- statement with an ARITHMETIC 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 same
program-unit.
The option ARITHMETIC FIXED is relevant only to BASIC- 2 .
A program-unit shall contain a t most one ARITHMETIC option.
An 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

Examples
1. OPTION ARITHMETIC DECIMAL, ANGLE DEGREES

5.6.4

Semantics
The ARITHMETIC option controls the logical behavior of numeric entities within the
program- unit containing the option.
If OPTION ARITHMETIC DECIMAL is specified, or if no ARITHMETIC option is specified,
then the values of the numeric- variables shall behave logically as decimal floating
point numbers, with an implementation-defined precision, say m, of at least ten
significant decimal digits and with an implementation- defined range of at least lE- 38
to 1E+38.
The results of decimal computations can be described in terms of floating- point
decimal intermediate results with at least m+l decimal digits of precision (but may
be implemented in some other equivalent fashion). The value of a numeric- variable
shall be assumed to be exact. Numeric- constants shall be evaluated accurately to at
least m decimal digits of precision. Numeric operations and functions shall also be
evaluated accurately to at least m+l decimal digits of precision with respect to the
computed value of their operands and arguments (which may themselves be intermediate
results). In all cases, the intermediate result of an evaluation shall be represented
as a floating- point decimal number with at least m+l decimal digits of precision,
thus, when the true result can be expressed as a decimal number with m+l significant
digits, the computed result shall be exact. In no case shall t he error for evaluation
of an individual constant, operation, or function be greater t han 5 in the (m+2)nd
significant digit. Implementations are free to use any method of numeric evaluation
which always yields results whose absolute error (with respect to the true result) is
no greater than the absolute error of the results generated by the preceding
specification.
If OPTION ARITHMETIC NATIVE is specified, then the values of numeric variables and
constants shall be represented and manipulated in an implementation- defined fashion,
with an implementation- defined precision of at least six decimal digits and with an
implementation- defined range of at least 2E- 38 to 1E+38 . Decimal values need not be
represented exactly, as long as the error is within the limits of this precision.

- 33 -

The ANGLE option contro ls the evaluation of the trigonometric functions within the
program-unit containing the option . I f OPTION ANGLE RADIANS is specif ied, or if no
ANGLE option is specified, then the numeric-supp l ied- functions COS, COT, CSC, SEC,
SIN, and TAN use arguments in radian measure, and the numeric-supp l ied-functions
ACOS, ANGLE, ASIN and ATN generate results in radian measure .
If OPTION ANGLE DEGREES is specified, then the numeric-supp l ied- functions COS, COT,
esc , SEC, SIN, and TAN use arguments in degree measure, and the numeric - suppl ied
functions ACOS, ANGLE, ASIN, and ATN generate results in degree measure .
If the execution of a program reaches a line containing an option-statement, then it
sha l l proceed to the next l ine with no further effec t .
A s imple-numeric-variable that appears
variable as a s imp le-numeric-variabl e .

in

numeric-type

sha l l

establ ish

that

I f execution reaches a l ine containing a dec lare- s tatement, i t sha l l proceed t o the
next l ine with no further effect .

5.6.5

Exceptions
None .

5.6 . 6

Remarks
The representations chosen for numeric values when OPTION ARITHMETIC
specified may be the same as that for OPTION ARITHMETIC DECIMAL .

NATIVE

is

No minimum accuracy is specified for the evaluation of numeric express ions and
functions when OPTION ARITHMETIC NATIVE has been chosen . However, it is recommended
that imp lementations maintain at least s ix decimal d igits of precis ion .
The value 2E- 38 is specified for the maximum value of the lower bound of positive
numbers to al low an imp lementation emp loying the IEC 559 f loating point binary
arithmetic to be standard conforming .

- 34 -

6.

S TR I NG S

- 35 -

6.

STRINGS
Character strings constitute one of two p rimitive data types in BASIC (the other is num
bers). Strings consist of arbitrary sequences of characters. Their lengths are variable,
not fixed, although a maximum length for a string may be specified . With strings are asso
ciated constants, variables, and implementation-supplied functions, from which expressions
can be formed .

6.1

String Constants

6.1.1

General Description
A string-constant is a character string of fixed length enclosed within quotation
marks. A quotation-mark itself may be included in a string-constant by representing
it by two adjacent quotation-marks.

6 . 1. 2

Syntax
1 . constant
2 . string-constant
3 . quoted-string

> string-constant
quoted-string
quotation-mark quoted-string-character)'(
quotation-mark

The length of a string-constant, 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 p receding each of end-of-line indicator (i . e . ,
at least 132 ) .
6 . 1. 3

Examples
2 . "XYZ"
"1E10"
"He said, ""Don ' t"" "

6 . 1. 4

Semantics
The value of a string-constant shall be the sequence of all quoted -string-characters
between the initial and final quotation-marks. The dou ble-quote, when appearing in
side a quoted -string, shall d enote a single quotation-mark. Spaces in string
constants, including trailing spaces, shall be significant . A string consisting only
of two quotation-marks shall represent the null string . Upper-case-letters and lower
case-letters shall be d istinct within string-constants.

6.1.5

Exceptions
None.

6.1.6

Remarks
The maximum length of a string-constant is constrained by the maximum length of a
physical line . The maximum length of the constant would therefore be 3 less than that
for the line, allowing for a continuation character ("&"), and the leading and trail
ing quotation-mark, e . g . :
100 LET A$ = &
&"abc . . . unseen characters here . . . xyz"
As the maximum p hysical line length must be at least 132 , the maximum string-constant
length must be at least 129 .

6.2

String Variables

6.2.1

General Description
String-variables may be either simple-string-variables or references to elements of
one-dimensional, two-dimensional, or three-dimensional string-arrays.

- 36 -

Exp l ic i t declarations of

simple-string-variab les are not required .

A do l lar-s ign

serves to d istinguish a string-variabl e from a numeric-variable .


6.2.2

Syntax
1 . variable
2 . string-variabl e
3.
4.
5.
6.
7.
8.

6.2. 3

s imp le- string-variable


string-array-element
string-array
substring-qualifier
s imple-variabl e
array-name

> string-variab l e
( s imple- string-variable I string-array-element)
substring-qualifier?
string-identifier
string-array subscript-part
string- identifier
left-parenthesis index colon index right-parenthesis
> s imp le- string-variable
> string-array

Examples
2 . K$
name$ ( X : Y )
ITEM$ ( 1 ,n ) ( z : z+ 5 )
4 . A$ ( 4 )
table$ ( I , J )

6.2.4

Semantics
At any instant in the execution of a program , a string-variable is associated with a
s ingle string-value . The value associated with a string-variable may be changed by
the execution of statements in the program.
The length of the character string assoc iated with a string-variable can vary during
the execution of a program from a length of zero characters ( s ignifying the nu l l or
empty string) to the maximum allowed for that string-variable ( see 6 . 6 . 4) .
Simple-string-variables may be dec lared exp l ic itly ( see 6 . 6) o r may b e dec lared im
p l icitly through their appearance in a program-unit . The scope of a string-variab le
sha l l be the program-unit in which it appears , unless it is a parameter of an
internal - proc-def , in which case its scope is that definition .
A string-array element is cal led a subscripted string-variable and refers to the ele
ment in the one-dimensiona l , two-dimensional or three-dimens ional array selected by
the value ( s ) of the subscript ( s ) . Subscripts shal l have values within the appropriate
range ( see 7 . 1 ) .
The substring-qualifier provides a means for specifying a portion of the value asso
c iated with a string-variab le . A$ ( M : N ) sha l l specify that substring of the value as
sociated with A$ from its Mth through Nth characters ( M and N are indices ) .
Characters in a string sha l l be numbered from the left starting with one . There are
no exceptions assoc iated with substring-qual ifiers ; if either M or N is not in the
range from 1 to LEN( A$ ) , the M sha l l be considered to be MAX ( M , l ) and N sha l l be con
s idered to be MIN( N , LEN( A$ ) ) . If M > N, even after this adjustment , then A$ ( M : N )
sha l l b e the nul l string occuring before the Mth character o f A $ i f M < LEN(A$ ) or

- 37 -

the null string iiiDll ediately following A$ if M > LEN( A$ ) . For example, if A$ =
1 11 . 2 34" , then A$ (1 : 1) = 1111 1 , A$ (1 : 3 ) = 1112 3 " , A$ (0 : 3 ) = 1112311 , A$ (2 : 5 ) = " 2 34" ,
A$ (3 : 2) is the null string preceding the third character of A$ , and A$ (5 : 7 ) is the
null string following A$ . At the initiation of execution the values associated with
all string-variables shall be implementation-defined.
6.2.5

Exceptions
- A subscript is not in the range of the declared bounds (2001, fatal) .

6.2.6

Remarks
Since initialization of variables is not specified, and hence may vary from implemen
tation to implementation, programs that are intended to be transportable should ex
plicitly assign a value to each variable before any expression involving that vari
able is evacuated.
There are many coiiUll only used alternatives for
tial values with variables; it is recoiiUll ended
defined in the sense that an exception will
value of any variable before that variable is
fatal: supply an implementation-defined value

6.3

associating implementation-defined ini


that all variables be recognizably un
result from any attempt to access the
explicitly assigned a value (3 102 , non
and continue).

String Expressions

6.3.1

General Description
String-expressions are composed of string- variables ,
function-references, or a concatenation of these .

6.3.2

string- constants,

string

Syntax
1 . expression
2 . string-expression
3 . string-primary

4 . string-function-ref
5 . string-function
6 . concatenation

> string-expression
string-primary (concatenation string-primary)l'<
string-constant I string- variable I
string-function-ref I left- parenthesis
string-expression right-parenthesis
string- function function- arg-list?
string-defined- function I string- supplied-function
ampersand

The number and types of arguments in a string-function- ref shall agree with the num
ber and types of the corresponding parameters specified in the definition of the
string-function. An actual- array shall have the same number of dimensions as the cor
responding parameter .
Each string- function referenced in an expression within a program- unit shall either
be implementation-supplied, or shall be defined in an internal- function-de or de
clared in a declare- statement occurring in a lower- numbered line, within the same
program-unit, than the first reference to that string-function .
6.3.3

Examples
2 . A2$ & B$(4 : 22) & 1 1 2 2 311
3 . X$(1, 3 )(I : J)

6 . 3 . 4 Seman tics
The value of a string-expression shall be the concatenation of the values of the
string-primaries in the expression (e . g . , if A$ = " COME " and B$ = "IN" , then A$ & B$
= " COME IN" and B$ & A$ = "INCOME " ) .

- 38 -

Within a string-expression, string-primaries 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

6.3.6

- Evaluation of a string-expression causes a string overflow (1051, fatal).


Remarks
The ampersand is used both for concatenation and line-continuation. Thus :
100 PRINT "ABC" &&
& "XYZ"
will print the sequence of characters ABCXYZ .

6.4

Implementation-Sup plied 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

Syntax
> (CHR I DATE I LCASE I LTRIM I REPEAT I RTRIM I STR I
TIME I UCASE I USING) dollar-sign
2 . numeric-supplied-function > LEN I ORD I POS I VAL
> MAXLEN left-parenthesis (simple-string-variable
3 . numeric-function-ref
string-array) right-parenthesis
1. string-supplied-function

6 . 4. 3

Examples
None .

6.4.4

Semantics
The values of the implementation-supplied functions, as well as the number and types
of arguments required for each function, are described below. In all cases, M repre
sents an index, i. e . , the rounded integer value of some numeric-expression; X stands
for a numeric-expression;
V$ represents a simple-string-variable or string-array;
and A$ and B$ stand for string-expressions .
Function
Function value
CHR$ (M)
The one-character string consisting of the character occupying ordinal posi
tion M+1 in the collating sequence for the declared character set, i . e . , the
first character is returned for an argument of zero. M shall be at least zero
and less than the number of characters in the declared character set (see
table 1) . For example, for the standard character set, CHR$ (53) = 1 1 51 1 , and
CHR$ (65)
"A" . The values of CHR$ for the native character set are
implementation-defined.

- 39 -

DATE$
The date in the string representation " YYYYMD
MD " according to ISO 2 014 . For
example, the value of DATE$ on May 9 , 197 7 was 1 1 19 7 7 05 09 1 1 If there is no
calendar available, then the value of DATE$ shall be 1 1 0000000011
LCASE$ (A$ )
The string of c haracters resulting from the value associated with A$ by re
placing each upper-case-letter in the string by its lower-case versi on.
LEN(A$)
The number of c haracters in the value associated with A$ . Note that LEN ( " " " " )
= 1, since the value o f the string c onstant c onsists of precisely one
quotation-mark.
LTRIM$(A$)
The string of c haracters resulting from the value
deleting all leading space c haracters.

associated with A$

by

MAXLEN(V$ )
The maximum length associated with the simple-string-variable or string-array
(see 6. 6 ) . If there is no effective limit on string length, the value re
turned shall be MAXNUM .
ORD(A$ )
The ordinal position of the c haracter named by the string assoc iated with A$
in the c ollating sequence of the declared c haracter set, where the first mem
ber of the c haracter set is in ordinal position zero . The acceptable values
of A$ are single c haracters in the c haracter set and two-character or three
c haracter mnemonics for c haracters in the c haracter set . Values of A$ with
two or more cha racters shall be treated with upper-case-letters and lower
case-letters equivalent. The acceptable values for the standard character set
are shown in Table 1. The acceptable values for the native character set are
implementation-define d . For example,
for the standard c haracter set,
ORD("BS")
8, ORD("A") = 65 , ORD(" a") = 9 7 , ORD(" S " )
53 , ORD("SOH11)
1,
ORD(" Soh") = 1 , and ORD("ABC" ) c auses an exception.
=

POS(A$ ,B$)
The c haracter position, within the value associated with A$, of the first
c haracter of the first occurrence of the value associated with B$ . If there
is no such ocurence , then POS(A$, B$ ) shall be zero . POS(A$ , "" ) shall be one,
for all values of A$ .
POS(A$, B $ ,M)
The c haracter position, within the value assoc iated with A, of the first
character of the first ocurence of the value associated with B$ , starting at
the Mth c haracter of A$ . If the value associated with B$ does not occur
within the designated portion of the value associated with A$ , or if M is
greater than LEN(A$), the value returned is zero. Otherwise, the value re
turned is equivalent to

- 40 -

LET tempi
LET temp 2 $
LET temp3
IF temp3
LET POS
ELSE
LET POS
END IF

MAX( I , MIN( M , LEN( A$ ) + I ) )


A $ ( temp i : LEN(A$ ) )
POS( temp2$ , B$ )
0 THEN
0
temp3 + tempi - I

For examp l e , i f A$ has the value 11 GRANSTANDING" , then POS ( A$ , "AN" , I ) = 3 ,


POS ( A$ , "AN" , 4 ) = 8 , and POS ( A$ , "AN" , 9 ) = 0 . POS ( A$ , '" ' ,M) sha l l be MAX( M , l ) ,
as long as M <= LEN( 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
de leting a l l tra i l ing space characters .
STR$ ( X )
The string generated by the print-statement as the numeric-representation of
the value assoc iated with X. No leading or tril ing spaces sha l l be inc luded
11 123 . 5 11 and
in this numeric-representation . For examp l e , STR$ ( I2 3 . 5 )
STR$ ( - 3 . I4 ) = 11 - 3 . I4 11
TIME$
The time of day in 24-hour notation according to ISO 3 307 . For examp l e , the
value of TIME$ at l l : I5 AM is 11 1 l : I5 : 00 11 If there is no c lock available ,
then the value of TIME$ shal l be 1 199 : 99 : 99 11 The value of TIME$ at midnight
is 11 00 : 00 : 00 11
UCASE$ ( A$ )
The string of characters resulting from the value associated with A$ by re
p lacing each lower-case- letter in the string by its upper-case vers ion .
USING$ ( A$ , X )
The string consisting of the formatted 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 app ly to the USING$ function .
VAL( A$ )
The value of the numeric-constant assoc iated with A$ , if the string associ
ated with A $ i s a numeric-constant . Lead ing and tra i l ing spaces i n the string
are ignored . If the evaluation of the numeric-constant would result in a
value which causes an underf low, then the value returned sha l l be zero . For
examp l e ,
VAL ( " 123 . 5 11 )
123 . 5 ,
VAL( 11 2 . E-99 11 )
could
be
zero ,
and
VAL ( "MCMXV I I " ) causes an exception .
6.4. 5

Exceptions
- The value of the argument of VAL is not a val id numeric-constant (400 1 , fata l ) .
- The value of the argument of VAL is a val id numeric-constant, but evaluating this
constant results in an overf low ( 1004 , fata l ) .

- 41 -

- The value of the argument of CHR$ is not in the appropriate range ( 4002 , fatal ) .
- The value of the argument of ORD i s neither a valid s ing le character nor a val id
mnemonic ( 4003 , fata l ) .
- The value of the second argument of REPEAT$ is not > 0 ( 4010, fatal ) .
6.4.6

Remarks
I t is recommended that if the magnitude of the value of the VAL function is less than
machine infinites imal , imp lementations report this as an exception ( 1504 , nonfatal :
replace with zero and continue ) . In BASIC-2 imp lementations , this permits intercep
tion by exception handlers .
The time zone used for DATE$ and TIME$ is imp lementation-defined .
The effect of the functions UCASE$ , and LCASE$ is fully defined only for the ECMA
character set as defined in 4 . 1 . 4 . For other-characters , such as accented letters ,
the effect is imp lementation-defined , and may be specified in other national version
of thi s Standard to accommodate the needs of local a lphabets .

6.5

String Ass ignment Statements

6.5.1

General Descr iption


A let-statement provides for the s imultaneous ass ignment of the computed value of a
string-express ion to a l ist of string-variables .

6.5.2

Syntax
1 . let-statement
2 . string- let-statement
3 . string-variable- l ist

6.5.3

> string- let - s tatement


LET string-variab le- l ist equals-sign
string-expression
string-variable ( comma string-variab l e ) l'<

Examples
2 . LET A$ = "ABC"
LET A$ ( I ) = B $ ( 3 : 4 )
LET A$ , B$ = "NEGATIVE DISCRIMINANT"
LET C$ ( 7 : 10 ) = "wxyz"
LET A$ = "ABCD" &&.
& "XYZ"

6.5.4

Semantics
The subscripts and substring-qua l ifiers , if any , of variables in the string-variable
l ist sha l l be evaluated in sequence from left to right . Next the string-express ion on
the right of the equals- s ign sha l l be evaluated ( see 6 . 3 ) . Fina l l y , the value of that
s tring-'express ion sha l l be ass igned to the string-variab les in the string-variab le
list in order from left to right .
When a value is ass igned to a string-variab le with a substring-qua l if ier , it sha l l
replace the substring of the value of the string-variable specif ied b y the substring
qualifier . The length of the value of the string-variable may change as a result of
this rep lacement . For examp l e , if A$ = 1 1 12 34" , then ass igning 1 13211 to A$ ( 2 : 3 ) results
in 1 11324" , ass igning 1 1 1 1 to A$ ( 2 : 3 ) results in 1 1 14" , ass igning A$ ( 1 : 2 ) to A$ ( 2 : 3 ) re
sults in 1 1 1 124" , and ass igning 11511 to A$ ( 2 : 1 ) results in 1 1 1523411

6.5.5

Exceptions
- The ass ignment of a value to a string-variable causes a string overflow ( 1 10 6 ,
fatal ) .

- 42 -

6.5.6

Remarks
The order of ass ignment of values to string-variables in the string-variable- l ist is
important in statements such as
LET A$ ( 1 : 2 ) , A$ ( 2 : 3 )

"X"

where different order of ass ignment may produce different results .


6.6

String Dec larations

6.6.1

General Description
An option-statement may be used to define an ordering on the set of a l l str ing char
acters .
A dec lare-statement may be
variables in a program-unit .

6 . 6 .2

used

to

set a maximum

length

for

specified

string

Syntax
l . option
2 . type-declaration
3 . string-type

> COLLATE ( NATIVE / STANDARD)


> string- type
STRING length-max? string-dec laration ( comma
string-dec laration ) l'<
4 . length-max
asterisk integer
5 . string-dec l aration
> s imp le-string-dec laration
6 . s imp le-string-dec laration
s imp le-string-variab le length-max?
An option-statement with a COLLATE option , if present at al l , shal l occur in a lower
numbered l ine than any string-express ion , or a dimens ion-statement or declare
statement referencing a string-array or string-variable within the same program-uni t .
A program-unit sha l l contain a t most one COLLATE option .
No s imp le-string-variable sha l l be declared more than once in a program-unit . A
simp le-string-variable which is a forma l -parameter or a parameter sha l l not occur in
a declare-statement .
6.6.3

Examples
1. COLLATE NATIVE
3 . STRING\'<8 last_name$l'<20 , f irst_name$ , midd le_name$

6. 6.4

Semantics
The COLLATE option identifies the c o l lating sequence to be used within a program-unit
for comparing strings ( see 8 . 1 ) and for computing values of the CHR$ and ORD func
tions ( see 6 . 4 ) . OPTION COLLATE NATIVE specifies that the native col lating sequence
of the host system sha l l be used . OPTION COLLATE STANDARD specifies that the col lat
ing sequence shal l correspond to the order of the characters in Tab le l . If no
COLLATE option appears in a program-unit then the STANDARD col lating sequence sha l l
be used within that program-unit .
S imp le-string-variab les whose string-identifiers appear in string-types may have a
maximum length less than or equal to the imp lementation-def ined default value . The
maximum is determined , in descending order of precedence, from :
- the length-max in the string-dec l aration for that variabl e ;
the length-max
variab l e , or

in

the

string-type

of

the

dec lare-statement

containing

that

- the imp lementation-def ined defau l t .


The length-max guarantees that string values up to that length may be stored in the
variable and that an attempt to store a longer value wil l cause a string overflow ex-

- 43 -

ception . The imp lementation-defined maximum string length default sha l l be at least
13 characters .
A l ength-max of 0 in a string-type sha l l estab l ish the associated string-variab le as
having a maximum length of zero ; i . e . , the nul l string .
6.6.5

Exceptions
None .

6.6.6

Remarks
The native c o l lating sequence may be the standard col lating sequenc e .
The COLLATE option may be extended , on national
accommodate spec if ic needs of l ocal alphabets .

versions of

this

Standard ,

to

- 44 -

7 .

ARRAYS

- 45 -

7.

ARRAYS
Arrays are indexed c o l lections of numbers or strings . Array elements can be manipulated by
scalar numeric and string operations ( see 5 and 6 ) . In add ition , entire arrays may be ma
nipulated by matrix statements .

7.1

Array Declarations

7 . 1. 1

General Description
An option in the option- s tatement may be used to def ine the lower bound for a l l array
subscripts within a program-unit which are not exp l ic itly stated . By use of an
option-statement the subscripts of al l such arrays may be dec lared to have a lower
bound of zero or one ; if no such dec laration occurs , the lower bound sha l l be one .
Arrays may have one , two , or three d imens ions . The number of d imens ions and subscript
bounds for each d imens ion are dec lared in the dec lare-statement or d imens ion
statement . Al l array-names , except those appearing in a function-parm- l ist or a
procedure-parm- l is t , must be dec lared in one and only one such statement . If not ex
p l icitly dec lared , the lower subscript bound for a given d imens ion is one or zero ,
depending on the BASE option. Upper bounds must a lways be exp l icitly declared .
A one-dimens ional array with subscripts 1 to 10 or 1980 to 1989 or -9 to 0 contains
10 elements . A two-dimensional array with subscript bounds 1 to 10 for each d imens ion
contains 100 e lements . S imilarly, a three-d imens ional array with subscript-bounds 1
to 10 for each d imension contains 1000 e lements .
A declare-statement can be used to d imens ion numeric-arrays as wel l as to dec lare
maximum lengths for string-variables and string-arrays , and to dimension string
arrays . A dimension-statement can be used to d imension arrays , but not to dec lare the
maximum length of strings in string-arrays .

7 .1.2

Syntax
1.
2.
3.
4.
5.
6.
7.
8.
9.
10 .
11 .
12 .

d imension-statement
d imens ion- l is t
array-dec laration
numeric-array-dec laration
bounds
bounds - range
s igned- integer
string-array-declaration
option
string-dec laration
numeric -dec laration
numeric-function-ref

13 . maxs i ze-argument
14 . bound-argument

>
>
>
>

DIM dimension- l ist


array-dec laration ( comma array-dec laration )>''
numeric- array-dec laration I string-array-dec laration
numeric-array bounds
left-parenthesis bounds - range ( comma bounds -range ) *
right-parenthesis
s igned- integer TO s igned- integer I signed- integer
s ign? integer
string-array bounds
BASE ( 0 I 1 )
string-array-dec laration length-max?
numeric-array-declaration
MAXSIZE maxs i ze-argument I S I ZE bound-argument I
LBOUND bound-argument I UBOUND bound-argument
left-parenthes i s actual - array r ight-parenthesis
left-parenthesis actual -array ( comma index) ?
right-parenthesis

The number of bounds -ranges in "bounds" sha l l be one , two or three .


An array which is named as a formal-array of a defined-function , a subprogram or a
program sha l l not be declared in a dec lare-statement or d imens ion-statement ( s ince
the formal-array in the function-parm- l ist o r procedure-parm- list serves as its dec
laration) . Any other array sha l l be declared in a lower numbered l ine than any
reference to that array or one of its e lements . Any reference to an array and its e l
ements must agree i n d imens iona l ity with the dec laration of that array i n a declare
statement , a d imens ion- s tatement , or as a function-parameter or procedure-parameter .

- 46 -

No numeric-array or string-array sha l l be dimensioned or declared more than once in a


p rogram-unit .
If the optional lower bound ( the f irst s igned- integer) is included in the bounds
range , i t sha l l b e less than o r equal to the upper bound ( the second s igned - integer) .
I f the lower bound is not specif ied , then the upper bound must not be less than the
defaul t lower bound , which may be zero or one , depending on the BASE option .
An option-statement with a BASE option , if present at a l l , sha l l occur in a lower
numbered l ine than any declare-statement or d imens ion-statement or any MAT statement
that uses a numeric-array-value in the same program-unit . A program-unit sha l l con
tain at most one BASE optio n .
I f a bound-argument does not specify a n index , the actual-array must b e dec lared as
one-dimensional .
7.1.3

Examples
1. DIM A ( 6 ) , B ( 10 , 10 ) , B$ ( 100 ) , D( 1 TO 5 , 1980 TO 1989 )
DIM A$ ( 4 ,4 ) , C ( - 5 TO 10)
10 . A$ ( 3 TO 21) * 8
12 . SIZE ( A , l )
SIZE( B$ , 2 )
SIZE( X )
LBOUND ( A )
UBOUND ( C$ , 2 )

7 . 1.4

S emantics
Each array-dec laration dec lares the named array to be either one-dimensiona l , two
d imensional , or three- dimens ional , according to whether one , two , or three bounds
ranges are speci f ied in the bounds f o r the array . In addition, the bounds specify the
maximum and optiona l l y minimum values that subscripts for the array sha l l have . If a
minimum subscript is not exp l icitly dec lared and no BASE option occurs within the
program-uni t , then it sha l l be imp l icitly dec lared to be one .
The BASE option in an option-statement is local to the program-unit in which it oc
curs and declares the minimum value for all array subscripts in that program-unit
which are not exp l icitly declared .
I f the execution of a program reaches a l ine containing a dimens ion-statement , then
it sha l l proceed to the next l ine with no further effect .
String-array-dec l arations appearing in a string-dec l aration may include a length-max ,
which sets the maximum length of each element of the string-array . As with s imp le
string-variab les , if there is no length-max in the string-dec laration, then the
length-max , if any , of the string-type takes effect . If there is no length-max in ei
ther , then the imp l ementation-def ined length-max, if any , sha l l take effect .
The value of SIZE( A , N ) where A is an actual -array and N is an index , shal l be the
current number or permissible values for the Nth subscript of the array named by A
( the value of N is rounded to the nearest integer , and the subscripts of A are in
dexed from left to right , starting at one ) . The value of SIZE ( A ) sha l l be the current
number of elements in the entire array A .
The value of MAXSIZE ( A ) sha l l b e the total number o f elements o f the entire array
named by A permitted by the array-dec laration .
The value of LBOUND ( A , N ) , where A is an actual -array and N is an index, sha l l be the
current minimum value a l l owed for the Nth subscript of the array named by A . The
value of UBOUND ( A , N) sha l l be the current maximum value a l l owed for the Nth subscript
of array A . As in the SIZE function, the value of N is rounded to the nearest inte-

- 47 -

ger, and the subscripts of array A are indexed from l eft to right, starting at one.
The LBOUND and UBOUND functions may be cal l ed with a single arguments provided that
arguments is a vector, in which case the value of LBOUND and UBOUND are the current
minimum and maximum values al l owed for the subscript of the vector. (Here, and in the
fol l owing sections, the word "vector" shal l mean a " one-d imensional array" and the
word " matrix" shal l mean a " two-dimensional array").
7 .1.5

Exceptions
- The value of the index in a SIZE reference is l ess than one or greater than the
number of d imensions in the array ( 4004 , fatal).
- The value of the index in an LBOUND reference is l ess than one or greater than the
number of d imensions in the array ( 4008 , fatal).
- The value of the index in a UBOUND reference is less than one or greater than the
number of d imensions in the array ( 4009 , fatal).

7 . 1.6

Remarks
The dimension statement is retained for c ompatibil ity with Minimal BASIC. Al l its ca
pabil ities are inc l uded within the decl are-statement.
I f an impl ementation supports more than three dimensions, SIZE, LBOUND , and UBOUND
should work for those extra dimensions, and an exception should be generated on ly
when an attempt is made to inquire about a dimension beyond those d ec l ared.

7.2

Numeric Arrays

7.2.1

General Description
Numeric-arrays in BASIC may be manipul ated el ement by element. However, it is often
more c onvenient to regard numeric-arrays as entities rather than as indexed col l ec
tions of entities, and t o manipulate the entire entity at once. BASI C provides a num
ber of standard operations to facil itate such manipul ations.

7 .2.2

Syntax
1 . array-assignment
2 . numeric-array-assignment
3.

4.
5.
6
7.
8.
9
10 .

> numeric -array-assignment


MAT numeric-array equal s-sign
numeric-array-expression
(numeric -array numeric-array-operator)? numeric-array
numeric-array-expression
I scal ar-mul tiplier numeric-array I
numeric-array-value I
numeric-array-function-ref
sign I asterisk
numeric -array-operator
scal ar-mul tiplier
primary asterisk
> sc al ar-mul tipl ier? (CON I IDN I ZER) redim?
numeric -array-val ue
red im
l eft-parenthesis redim-bounds (comma redim-bounds)'''
right-parenthesis
(index TO)? index
red im- bounds
numeric -array-function-ref= ( TRN I I NV) l eft-parenthesis numeric-array
right-parenthesis
> DET (left-parenthesis numeric-array
numeric-function-ref
right-parenthesis) I DOT left-parenthesis
numeric-array comma 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 d imensions as the value of the numeric-array-expression.

- 48 -

The numeric-arrays in a numeric- function-ref invo lving DOT s ha l l be one-dimens ional .


There must be no more than two redim-bounds following IDN .
The numer ic-arrays in a sum or difference sha l l have the same number of d imens ions .
The numeric-array serving as the argument of DET , INV or TRN sha l l be two
d imens ional .
The numeric-arrays serving as operands for the numeric -array-operator asterisk
( matrix multip ly) sha l l be either one-dimensional or two-d imensiona l , and at least
one of them shal l be two-d imensional .
7.2.3

Examples
In the f o l l owing examp les A, B and C are doub ly-subscripted numeric-arrays , X, Y, and
Z are s ingly- subscripted numeric -arrays , and W is a numeric-express ion .
2 . MAT A
MAT A
MAT A
MAT A
MAT A
MAT A
10. DET ( B )

7.2.4

B
B + c
B>'IC
w ,., B
ZER ( 4 , 3 )
INV ( B )

y
MAT X
y - z
MAT X
N'<Y
1AT X
w ,., CON
HAT X
MAT X
ZER
MAT A
TRN ( B )
DOT( X , Y )

1AT X

y ) IA
'

Semantics
Array Ass ignments and Redimensioning
Execution of a numeric -array-ass ignment shal l cause the numeric-array-express ion to
be evaluated and its value as s igned to the array named to the left of the equals
s ign . I f necessary , this array shal l have its s i ze changed dynamica l l y ; i . e . , its
number of d imens ions shall be unchanged , but its s i ze in each d imens ion sha l l be
changed to conform to the s ize of the array which is the value of the numeric -array
express ion .
When the s ize of a numeric-array is changed dynamically, the current upper bounds for
its subscripts sha l l be changed to conform to the new s i zes . That is ,
new_lower_bound
new_upper_bound

o l d_lower_bound
old_lower_bound + new_s ize - 1

The new s izes need not individua l ly be less than or equal to the s izes determined in
the array-dec laration for that numeric -array , as long as the new total number of ele
ments for the numeric-array does not exceed the total number of e lements determined
by the array-dec laration for that array .
Array Express ion
The evaluation of numeric-array-express ions sha l l fol low the normal rules of matrix
algebra . The symbo ls asterisk ( >'< ) , p lus ( +) , and minus ( - ) sha l l represent the opera
tions of multipl ication , add ition , and subtraction respectively .
The d imensions of numeric -arrays in numeric-array-express ions sha l l conform to the
rules of matrix algebra . The numeric-arrays in a sum or difference sha l l have the
same s izes in each dimens ion . The numeric-arrays in a product sha l l have s izes L x H
and H x N for some L , H and N ( in which case the product shal l have s ize L x N ) , or
an H e l ement vector and a s ize H x N matrix ( in which case the product sha l l be an N
element vector ) , or a s ize L x H matrix and an M element vector ( in which case the
product sha l l be an L element vector ) . A l l e l ements in a numeric-array sha l l be used
when evaluating a numeric-array-expre s s ion ; i . e . , each numeric-array sha l l be treated
as an entity .

- 49 -

When a scalar-mu ltip l ier is present in a numer ic-array-expre s s ion , the primary sha l l
b e evaluated , and then each e l ement o f the numeric-array sha l l b e multip l ied by this
value .
If an underf low occurs in the evaluation of a numeric-array-express ion, then the
value generated by the operation which resul ted in the underf low shal l be rep laced by
zero .
Array Values
Numeric-array-values s ha l l be assigned to the numeric-array on the left of the equal s
sign . If n o redim is present , the size of the numeric-array generated sha l l b e the
same as the size of the numeric-array to which it is to be assigned . If a redim is
present, a numeric-array of the d imens ions spec if ied sha l l be generated , and the
numeric-array to which it is ass igned sha l l be redimensioned as described above . In a
redim-bounds , the values of the indices are the lower and upper bounds of the corre
sponding d imens ion in the assoc iated array-value . If the redim-bounds consi sts of a
s ingl e index , its value sha l l be the upper bound , and the lower bound sha l l be the
current default lower bound in effect . I f a redim is used with the IDN constant , then
it sha l l produce a square matrix ; i . e . , the number of rows sha l l equal the number of
columns . If a redim is not used with the IDN constant , the numeric-array being as
s igned to sha l l be square .
The ZER constant sha l l generate a numeric-array, a l l of whose e lements are zero . The
CON constant sha l l generate a numeric -array , a l l of whose e lements are one . The IDN
constant sha l l generate an identity matrix , i . e . , a square matrix with ones on the
main diagonal and zeros e l sewhere . If only one redim-bounds is used with IDN, then
the effect is j ust as if that redim-bounds had been specified twice .
If a scalar-mu lt ip l ier is used with an IDN , ZER or CON constant , then the primary
( see 5 . 3 ) is evaluated and each non-zero e lement of the IDN , ZER or CON constant is
rep laced by the value of the primary .
Array Functions
The function TRN sha l l produce the transpose of its argument . An N x M matrix is re
turned for an M x N argument .
The function I NV sha l l produce the inverse of its argument . The argument must be a
square matrix .
The function DET shal l return the determinant of its argument . The argument must be a
s quare matr i x .
The value of DOT ( X , Y ) sha l l result i n a scalar value , which is the resul t of the in
ner product multip l ication of the one-d imens ional numer ic-vectors X and Y .
7 .2.5

Exceptions
The sizes of numeric-arrays in a numeric-array-expression do not conform to the
rules of matrix algebra ( 6001 , fatal ) .
- The total number of e lements required for a redimensioned array exceeds the number
of elements reserved by the array ' s original d imensions ( 5001 , fata l ) .
The f irst index in a redim-bounds is greater than the second ( 6005 , fata l ) .
- A red im-bounds cons ists of a s ingl e index which is less than the defau l t lower
bound in effect ( 6005 , fata l ) .
- The redim f o l lowing IDN does not spec ify a square matri x , or no redim is present
and the receiving matrix is not square ( 6004 , fatal ) .
- The argument o f the DET function is not a s quare numeric matrix ( 6002 , fata l ) .

- so -

The argument of the INV function is not a s quare numeric matrix ( 600 3 , fatal ) .
- Evaluation of a numeric-array-express ion results in an overflow ( 1005 , fata l ) .
- Evaluation of DET or DOT results in an overf low ( 1009 , fatal ) .
- App l ication of INV to a s ingular matri x , or loss of a l l s ignificant d igits ( 3009 ,
fatal ) .
7 .2.6

Remarks
It is recommended that imp l ementations report underf l ow as an exception ( 1505 , nonfa
tal : rep lace by zero and continue ) . In BASIC-2 imp lementation , this permits intercep
tion by exception hand lers .

7.3

String Arrays

7.3.1

General Description
As with numeric-arrays , string - arrays may be regarded as entities rather than as in
dexed c o l lections of entities . BASIC provides the abi l ity to concatenate and assign
entire arrays of strings .

7 .3.2

Syntax
1 . array-ass ignment
2 . string-array-ass ignment
3 . String-array-express ion

4 . string-array-primary
5 . string-array-value

> string-array-assignment
MAT string-array substring-qualifier? equa l s - s ign
string-array-express ion
string-array-primary ( concatenation
string-array-primary) ? I string-primary
concatenation string-array-primary I
string-array-primary concatena-tion
string-pr imary I string-array-value
string-array substring-qualifier?
( string-primary concatenation) ? NUL dol lar - s ign
redim?

A string-array being ass igned a value by a string-array-ass ignment sha l l have the
same number of d imensions as the value of the string-array-express ion .
Two string-arrays being concatenated sha l l have the same number of d imens ions .
7.3.3

Examples
2 . MAT
MAT
MAT
MAT

7 .3.4

A$ & B$
A$
A$
NUL$ ( 5 , 6 )
( "Number" ) & B$
A$
A$ ( 4 : 6 ) = ( " ") & B$

Semantics
Execution of a string-array-ass ignment sha l l cause the string-array-express ion to be
evaluated and its value ass igned to the array named to the left of the equals - s ign .
If appropriate , this array sha l l have its s ize changed dynamica l ly ; i . e . , its number
of dimensions sha l l be unchanged , but its s ize in each dimension sha l l be changed to
conform to the s i ze of the array which is the value of the string-array-express ion .
When the s ize of a string-array is changed dynamical ly , the current upper bounds for
its subscripts sha l l be changed to conform to the new s izes . That is ,
new_lower_bound
new_upper_bound

o ld_lower_bound
o ld_lower_bound + new_size - 1

The new s izes need not individua l ly be less than or equal to the s izes determined in
the string-array-dec laration for that string-array , as long as the new total number

- 51 -

of e l ements for the s tring-array does not exceed the total number of e l ements deter
mined by the array-dec laration for that array .
When a s tring-array on the left of a string-array-ass ignment has a substring
qualifier , the ass ignment to each element of the string-array sha l l replace the sub
string of the value of each element
specif ied
by
the substring-qualifier . The
substring-qua l i f ier on the left sha l l be evaluated before the string-array
express io n .
String-array-expressions involve the operations of concatenation and substring ex
traction . Two string-arrays being concatenated sha l l have the same s i ze in each d i
mens ion; the concatenation sha l l b e performed e l ement b y e l ement . When concatenation
is by scalar , this scalar sha l l be prefixed or suffixed , as appropriate , to every e l
ement o f the string- array . When a substring-qua l if ier i s app l ied t o a string-array,
then the spec i f ied substring sha l l be extracted from each e l ement in the array .
The order of evaluation and assignment sha l l be as f o l lows :
- evaluate the substring-qualif iers in the string-array on the left ;
- evaluate the string-array-expression from left to right , by evaluating
each
string-primary or string-array-primary as f o l lows : evaluate first the subscripts ,
if any , then the substring qualif iers , and then the value of the primary itself ;
- concatenate ;
- make the assignment .
The string-array-value NUL$ is an array a l l of whose e l ements are the nul l string . If
a red im is not present , the s i ze of the string-array generated sha l l be the same as
the s i ze of the string-array to which it is to be ass igned . If a redim is present , a
string-array of the d imensions specified sha l l be generated and the string-array to
which it is ass igned sha l l be redimensioned as described above . The rules in 7 .2 .4
for redims with numeric-array-values app ly to NUL$ as wel l .
7 . 3.5

Exceptions
- The arrays in a string-array-expres sion have different s i zes ( 6101 , fatal ) .
- The first index in a redim-bounds is greater than the second ( 6005 , fatal ) .
- A redim-bounds cons ists of a s ingle index which is less than the default lower
bound in effect ( 6005 , fatal ) .
- The total number of elements required for a redimensioned array exceeds the number
of elements reserved by the array ' s original dimensions ( 5001 , fatal ) .
- Evaluation of a string-array-express ion results in a string overf low ( 1052 , fata l ) .
- Assignment of a value to a string-array causes a string overflow ( 1106 , fata l ) .

7.3.6

Remarks
None .

- 52 -

8 .

CO N T RO L

S T RUCT UR E S

- 53 -

8.

CONTROL STRUCTURES
Contro l structures govern the order of execution of l ines in a program , both by statements
which make exp l ic i t reference to l ine-numbers and also by exp l ic it ly-constructed loops and
decis ion mechanisms which make no reference to l ine-numbers .

8.1

Relational Expressions

8.1.1

General Description
Relationa l - expressions enable the values of express ions to be compared in order to
inf luence the f low of control in a program .

8.1.2

Syntax
1.
2.
3.
4.
5.

relational-expression
disjunction
conjunction
relationa l - term
relationa l -primary

6. comparison
7 . relation
8 . equal ity-relation
9 . not-equals
10 . not - less
1 1 . not-greater

8.1.3

Examples
2 . NOT X < Y OR
3 . A < = X AND X
1 <= I AND I
I < N AND ( J

8.1.4

d isj unction
conjunction ( OR conjunction) >'c
relationa l -term ( AND relational-term)>'c
NOT? relational-primary
comparison I left-parenthesis relational-express ion
right-parenthesis
numeric-express ion relation numeric-expres s ion
string-express ion relation string-express ion
equa l ity-relation I greater-than-sign I
less-than - s ign I not-greater I not - less
equa l s - s ign I not-equals
less-than-s ign greater-than-s ign I greater- than-s ign
less-than-s ign
greater-than-s ign equa l s - s ign I equals- s ign
greater- than- s ign
less -than-s ign equa l s - s ign I equal s - s ign
less -than - s ign

A$ = B$ AND B$
C$
<= B
<= 10 AND A ( I ) = X
> M OR A ( I ) < B ( J ) )

Semantics
The relation " less than or equal to" i s denoted by not-greater . The relation "greater
than or equal to" is denoted by not- less . The relation "not equal to" is denoted by
not-equa l s . The relations "greater than" , " less than" , and "equals" are denoted by
the corresponding syntactic s ign .
The relation of equal ity sha l l ho ld between two numeric-expressions if and only if
the two numeric-express ions have the same value .
The relation of equality shal l ho ld between two string-expressions if and only if the
values of the two string-express ions have the same length and contain identical se
quences of characters .
In the evaluation of relational-express ions invo lving string-express ions , the rela
tion " less than" sha l l be interpreted to mean "earl ier in the co l lating sequence
than" , and the other relations sha l l be def ined in a corresponding manner . More pre
cisely, if two unequa l strings in a relationa l -express ion have the same length , then
one sha l l be " less than" the other i f , in the leftmost character pos ition in which
they differ , the character in that string precedes the character in the other accord
ing to the establ ished col lating sequence ( see 6.6). If the two strings in a
relationa l - expression have different lengths and one has zero length or is an initial

- 54 -

leftmost segment of the other , then the shorter string sha l l be " less than" the
other . Otherwise the relationship between two strings of unequal length sha l l be de
termined by the contents of the shorter string and the leftmost portion of the longer
string which is of the same length as the shorter string .
The precedence of the operators AND , OR , and NOT sha l l be as imp l ied by the formal
syntax . That is , NOT operates only on the relational-pr imary innne diately fol lowing
it , AND app l ies to the relationa l -terms innne diately preceding and fol lowing i t , and
OR app l ies to the conjunctions immediately preceding and fo l lowing i t .
The order of evaluation of relational-express ions sha l l b e a s fol l ows . The
relationa l -express ion sha l l take on the truth-value of the d i sjunction which consti
tutes it . The conjunctions immediately contained in the disjunction sha l l be evalu
ated from left to right until a true conjunction is found or none are lef t . As soon
as a true conjunction is found , the who le disjunction is evaluated as true , and any
remaining conjunctions are not evaluated . If no true conjunctions are found , the d is
j unction i s false . For each conj unction, the relational-terms innne diately contained
in it are evaluated from left to right unt i l a false relational- term is found or none
are left . As soon as a false relational- term is found , the who le conjunction is eval
uated a s false and any remaining relational-terms are not evaluated . I f a l l the
relationa l - terms are true , then the conjunction is true . For each relational-term,
the relationa l -primary immediately contained in it is evaluated , its truth value re
versed if and only if NOT is also immediately contained in the term, and the result
ing value assigned to the relational-term . A relational-primary sha l l be evaluated
according to the description above of the various relations , if it is a compar ison .
Otherwise , it sha l l take on the value of the relational-expression immediately con
tained within it . This relational-express ion sha l l be evaluated by re-applying the
rules of this paragraph to it .
8.1.5

Exceptions
None .

8.1.6

Remarks
The spec ification for evaluation of relational-expressions guarantees that certain
parts of the express ion will not be evaluated if not necessary . For instance, if an
array A has subscripts from 1 to 10 :
1 < X AND X < 10 AND A ( X )

KEY

w i l l never cause an exception for subscrip t out of range .


8.2

Control Statements

8.2.1

General Description
Control s tatements al low for the interruption of the normal sequence of execution of
statements by causing execution to continue at a specified line , rather than at the
one with the next higher l ine- number .
The goto- statement al lows for an unconditional transfer . The on-goto-statement al lows
control to be transferred to a selected l ine . The gosub-statement and return
statement allow for subroutine cal ls . The on-gosub - statement and return-statement al
low for s elected subroutine cal ls .

8.2 .2

Syntax
1 . contro l - transfer

2 . goto- s tatement

gosub- statement I goto-statement I if-statement I


io-recovery I on-gosub - s tatement I
on-goto- s tatement
( GOTO I GO TO ) l ine- number

- 55 -

3 . on-goto- s tatement
4 . gosub-statement
5 . return-statement
6 . on-gosub-statement

8.2.3

ON index ( GOTO I GO TO) l ine-number ( comma


l ine-number ) l'< ( ELSE imperative-statement ) ?
( GOSUB I GO SUB ) l ine-number
RETURN
ON index ( GOSUB I GO SUB ) l ine-number ( comma
l ine-number ) l'< ( ELSE imperative- statement ) ?

Examples
2 . GO TO 999
GOTO 999
3 . ON 1+1 GO TO 400 , 400 , 500
ON X GO TO 100 , 200 , 150 , 9999 ELSE LET A
1
4 . GO SUB 5000
GOSUB 5 160
6 . ON A+7 GOSUB 1000 , 2000, 7000 , 4000
ON Fl-2 GOSUB 4360 , 446 0 , 4660 ELSE PRINT F$

8.2.4

Semantics
Execution of a goto-statement sha l l cause execution of the program to be continued at
the l ine with the spec ified l ine-number .
The index in an on-goto-statement sha l l be evaluated and its value rounded to obtain
an integer , whos e value shal l be used to select a l ine-number from the l ist f o l lowing
the GOTO ( the l ine-numbers in the l ist are indexed from left to right , starting with
1 ) . Execution of the program sha l l continue at the l ine with the selected l ine
number . If the on-goto-statement contains an ELSE clause , and the value of the index
in the on-goto-statement is less than one or greater than the number of l ine-numbers
in the l i s t , then the imperative - statement fol lowing the ELSE sha l l be executed ; if
the imperative-statement in the ELSE part does not transfer contro l to another l ine ,
then execution sha l l be continued in sequence , i . e . , with the l ine f o l lowing that
containing the on-goto- s tatement .
The execution of the gosub-statement or on-gosub-statement and the return- statement
can be described in terms of stacks of l ine-numbers , one associated with each invoca
t ion of a program-unit or internal -proc- def ( but may be imp lemented in some other
fashion ) . ( The s tack is conceptual ; the S tandard does not require that this method be
used ) . Prior to execution of the f irst gosub - s tatement or on-gosub- s tatement in the
invocation of a program-unit or internal-proc-def , the stack in that entity s ha l l be
empty . Each time a gosub-statement i s executed , the l ine- number of the gosub
s tatement sha l l be p laced on top of this stack and execution of the program-unit o r
internal -proc-def sha l l b e continued a t the l ine specified in the gosub-statement .
The index in a on-gosub-statement sha l l be evaluated by rounding to obtain an inte
ger , whose value sha l l be used to s elect a l ine-number from the l i s t f o l lowing the
GOSUB ( the numbers in the l ist are indexed from left to right , starting w ith 1 ) . The
l ine-number of the on-gosub statement sha l l be p laced on top of the stack for the ap
propriate program-unit or internal-proc-def , and execution sha l l continue at the l ine
with the l ine-number selected by the index . If the on-gosub-statement contains an
ELSE c lause , and the value of the index in the on-gosub-statement is less than one o r
greater than the number of l ine-numbers in the l i s t , then the imperative- statement
fo l lowing the ELSE sha l l be executed and the stack of l ine- numbers sha l l not be
changed ; if the imperative-statement in the ELSE part does not transfer contro l to
another l ine , execution sha l l then continue in sequenc e , i . e . , with the l ine fol low
ing that containing the on-gosub-statement .
Each time a return- statement is executed , the l ine-number on top of the s tack sha l l
b e removed from the s tack and execution o f the program-uni t o r internal -proc-def
shal l continue at the l ine fol lowing the one with that l ine-number .

- 56 -

A return - s tatement , gosub-statement and on-gosub-statement within an internal -proc


def sha l l interact only with the stack for that internal-proc-def . A l l other such
statements interact only with the stack for the program-unit containing the state
ment .
It is not necessary that equal numbers of gosub-statements or on-gosub-statements and
return-statements be executed before termination of a program-unit or internal -proc
def ; the stack of l ine-numbers associated with the current invocation of a program
unit or internal -proc-def shal l be emptied upon termination of that program-unit or
internal -proc-def .
8.2.5

Exceptions
- The value of the index in an on-goto-statement or an on-gosub - statement without an
ELSE c lause is less than one or greater than the number of l ine-numbers in the
l ist ( 1000 1 , fata l ) .
- An attempt i s made to execute a return-statement without having executed a corre
sponding gosub-statement or on-gosub-statement within the same program-unit or
internal -proc-def ( 10002 , fata l ) .

8.2.6

Remarks
The syntactic element contro l -transfer is defined solely to permit describing l imita
tions on transfers to l ine numbers . It is not generated by o ther productions .
References to nonexistent l ine- numbers in a program-unit , inc luding those in contro l
transfers , are syntax errors ( see 4 . 2 ) . There is , therefore , n o exception defined in
this Standard for such references . Imp lementations may , however , choose to treat them
as exceptions , if they are so documented , s ince the effect of non- standard programs
is imp lementation-defined .

8.3

Loop Structures

8.3.1

General Description
Loops provide for the repeated execution of a sequence of s tatements . Do- loops pro
vide for the construction of loops with arbitrary exit cond itions . The for-statement
and next- s tatement provide for the construction of counter-contro l led loop s .

8.3.2

Syntax
l.
2.
3.
4.
5.
6.
7.
8.
9.
10 .
11.
12 .

loop
do- loop
do- l ine
do-statement
exit-condition
do-body
exit-do- s tatement
loop - l ine
loop - statement
for- loop
for- l ine
for- s tatement

13 .
14 .
15 .
16 .
17 .
18 .
19 .

control -variable
initial-value
l imit
increment
for-body
exit-for-statement
next- l ine

do- loop I for- loop


do- l ine do-body
l ine -number do-statement tai l
DO exit-condition ?
(WHILE I UNTIL) relationa l - express ion
b lock>'< loop - l ine
EXIT DO
l ine-number loop-statement tail
LOOP exit-condition?
for- l ine for-body
l ine-number for-statement tai l
FOR contro l -variable equa l s - s ign initial -value TO
l imit ( STEP increment) ?
s imp le-numeric -variable
numeric-express ion
numeric-express ion
numeric-express ion
b l ock>'< next- l ine
EXIT FOR
l ine-number next-statement tail

- 57 -

20 . next-statement

= NEXT control -variable

The contr o l - variabl e in the next- statement which terminates a for- loop sha l l be the
same as the control -variable in the for-statement which begins the for- loop .
A for- loop contained in the for-body of another for- loop sha l l not emp loy the same
control -variabl e as that other for- loop . No l ine-numbers in a contro l -transfer out
side a for - l oop or do- loop sha l l refer to a l ine in the for-body of that for - l oop or
in the do-body of that do- loop .
An exit-do- s tatement may only occur in a do- loop . An exit-for-statement may only oc
cur in a for - l oop .
8.3.3

Examples
10 DO WHILE I <= N AND A( I ) <> 0
LET I = I + 1
20
30 LOOP
2 . 100 DO
LET I = I + 1
l lO
120
PRINT "MORE ENTRIES ( ENTER ' NO ' I F NONE) "
130
I NPUT A$ ( I )
140 LOOP UNTIL A$ ( I ) = "NO"
2 . 10 DO
20
I NPUT X
3 0 I F 0 < X AND X < = 7 AND X = INT ( X ) THEN EXIT DO
40
PRINT " I NPUT AN INTEGER BETWEEN 1 AND 7 1 1
50 LOOP
10 . 100 FOR I = 1 TO 10
150
LET A( I ) = I
200 NEXT I
12 . FOR I = A TO B STEP - 1
20 . NEXT C 7
2.

8 . 3 .4

Semantics
An exit-condition sha l l be said to require exi t from a loop if the value of the
relationa l - expression f o l lowing the keyword WHILE is false or if the value of the re
lational expression f o l lowing the keyword UNTIL i s true .
If execution of a program reaches a do- l ine , then the exit-cond it ion, if any , in that
do- l ine sha l l be evaluated . If there is no exit- cond ition, or if it does not require
exit from the loop , then execution sha l l proceed to the next l ine . If the cond ition
requires exit from the loop , then execution sha l l continue at the l ine f o l l owing the
associated loop - l ine . If execution of a program reaches a loop- l ine , then the exit
condition in that loop - l ine , if any , sha l l be evaluated . If there is no exit cond i
tion, or if it does not require exit from the loop , then execution sha l l resume at
the associated do- l ine ; if the condition requires exit from the loop , then execution
sha l l continue at the l ine f o l l owing the loop - l ine .
The action of the for-statement and the next-statement is defined in terms of other
statements , as f o l l ows .

- 58 -

1 10 FOR v
150 NEXT v

initial -value TO l imit STEP increment ( l ines )

sha l l be equivalent to
l lO
120
130
140
150
160

LET own1
l imit
LET own2
increment
LET v
initial -value
DO UNTIL (v-own1 ) l'< SGN( wn2 ) > 0 ( l ines )
LET v
v + own2
LOOP
=

Here v is any s imple-numeric-variab l e , and own1 and own2 are variables associated
with the particular for- loop and not accessible to the programmer . The variables
ownl and own2 sha l l be distinct from s imi lar variab les associated with other for
loops . In the above equivalenc e , a contro l- transfer to the for - l ine sha l l be inter
preted as a contro l - transfer to the f irst let-statement , and a contro l-transfer to
the next- l ine sha l l be interpreted as a contro l - transfer to the last let-statement .
In the absence of a STEP c lause in a for-statement , the value of the increment sha l l
be +1 .
Execution of an exit-do-statement sha l l cause execution to continue the l ine f o l l ow
ing the loop - l ine of the smal lest do- loop in which the exit-do-statement occurs . Exe
cution of the exit-for-statement sha l l cause execution to continue at the l ine fo l
lowing the next- l ine o f the smal lest for- loop i n which the exit-for-statement occurs .
8.3.5

Exceptions
None .

8.3.6

Remarks
On exit from a for- loop through the next-statement , the value of the contro l -variable
is the first value not used ; on a l l other exits from a for - loop the contro l -variable
retains its current value .

8 . 4 Deci s ion Structures


8.4.1

General Description
An if-statement al lows for conditional transfers , for the conditional execution o f a
s ing le imperative-statement , or for the execution of one of two alternative
imperative-statements .
An if-block a l lows for the conditional execution of a sequence of l ines or for the
execution of one of several alternative sequences of l ines .
A se lect-b lock al lows for the conditional execution of any one of a number of alter
native sequences of l ines , based on the value of an expression .

8.4.2

Syntax
2 . if-c lause
3 . if-block
4.
5.
6.
7.
8.
9.
10 .

if-then- l ine
then-block
elseif-block
elseif-then- l ine
else-block
e lse- l ine
end- if- l ine

imperative-statement I l ine-number
if-then- l ine then-b lock elseif-blockl'< e lse-block?
end- if- l ine
l ine-number IF re lational-expression THEN tai l
blockl'<
else if - then- l ine b lockl'<
l ine-number ELSEIF relational-expression THEN tai l
e lse- l ine b lockl'<
l ine-number ELSE tai l
l ine- number EN D I F tai l

- 59 -

1 1 . select-block
12 .
13 .
14 .
15 .
16 .
17 .
18 .
19 .
20 .
21 .
22 .

se lect- l ine
se lect- statement
case-block
cas e - l ine
case-statement
case- list
case- item
range
case-else-b lock
case-else- l ine
end - select - l ine

se lect- l ine remark- l ine)'< case-block case-block)'<


case-else-block? end-select- l ine
l ine-number select- statement tai l
SELECT CASE express ion
case- l ine b lock)'<
l ine-number case-statement tail
CASE case- l ist
case-item ( comma case- item ) )'<
constant I range
( constant TO I IS relation) constant
case-else- l ine b l ock*
l ine-number CASE ELSE tai l
l ine- number END SELECT tai l

The constants appearing i n case-statements i n a select-block sha l l be the same type


( i . e . , either numeric or string ) as the express ion in the select- statement . The
ranges and constants specified in case- l ists in a select-block sha l l not overlap .
No l ine-number in a contro l -transfer outside an if-block, then-block , elseif-block,
e lse-block, select-block, case-block , or case-el se-block shal l refer to a l ine ins ide
that i f-block, then-block , e lseif-b lock, e l se-block, se lect- b lock, case-block, or
case-e l se-block, respectivel y , other than to the if-then- l ine of that if-block or the
s elect- l ine of that select-block.
A l ine-number in a contro l - transfer inside an elseif-block, e lse-block , case-block ,
or case-else-block may not refer to the associated e lseif-then- l ine , e lse- l ine , case
l ine or case-else - l ine .
8.4. 3

Examples
1 . IF X = > Y2 THEN GOSUB 900 ELSE GOSUB 2000
I F X$ = "NO" OR X$ = " STOP" THEN LET A = 1
IF A = B THEN 100
IF A$ = B$ THEN 200 ELSE 300
3 . 10 IF X = INT ( X ) THEN
20
PRINT X ; " I S AN INTEGER"
30 ELSE
40
PRINT X ; " I S NOT AN INTEGER"
50 END I F
1 0 0 IF A = 0 THEN
1 10
PRINT "ONE ROOT"
120 ELSEIF DISC < 0 THEN
130
PRINT "COMPLEX ROOTS"
140 ELSE
150
PRINT "REAL ROOTS"
160 END IF
1 1 . 10 SELECT CASE A$ ( 1 : 1 )
20 CASE "A" TO "Z" , "a" TO " z"
30
PRINT A$ ; " starts with a letter"
40 CASE 11 0 11 TO 11 911
50
PRINT A$ ; "starts with a d igit"
60 CASE ELSE
70
PRINT A$ ; "doesn ' t start with a letter or a d igit"
80 END SELECT

- 60 -

8.4.4

10

SELECT CASE X

20
30
40
50
60
70
80

CASE IS < 0
PRINT X ; " is negative"
CASE IS > 0
PRINT X ; " is pos itive"
CASE ELSE
PRINT X ; " is zero"
END SELECT

Semantics
I f the value o f the relational-express ion in an if-statement is true and an
imperative-statement f o l l ows the keyword THEN , then this imperative-statement sha l l
b e executed ; if a l ine- number follows the keywork THEN , then execution of the program
sha l l be continued at the l ine with that l ine-number . If the value of the relational
expres s ion i s false and an imperative-statement fo l low the keyword ELSE , then this
imperative-statement sha l l be executed ; if a l ine-number f o l lows the keyword ELSE ,
then execution of the program sha l l be continued at the l ine with that l ine-number ,
if no ELSE is present , then execution sha l l be continued in sequenc e , i . e . , with the
l ine f o l l owing that containing the if-statement .
I f - blocks sha l l be executed as fol lows . If a then-block, e l seif-block, or else-block
does not contain a block, the effect i s as if it d id contain a b lock consisting of a
remark- l ine . If the value of the relational-express ion in the if-then - l ine is true ,
then execution sha l l continue at the f irst l ine of the corresponding then-block . If
false, then the relational-express ions of each corresponding elseif- then- l ine , i f
any , sha l l b e evaluated i n order . A s soon a s a true relational-express ion is found ,
execution sha l l continue at the f irst l ine of the blocks of that elseif-block . If no
true relational-express ion is found in the elseif-then- l ines , then, if an else-block
is present , execution sha l l continue at the first l ine of the block of that else
b lock . I f there i s no e lse-block , execution sha l l continue at the l ine f o l lowing the
end - if - l ine . When execution reaches the end of a then-block, an elseif-block, or an
e lse-b lock , it sha l l continue at the line following the corresponding end - if - l ine .
The express ion in a se lect- statement in a select-block sha l l be evaluated and its
value compared with the case- items in the case s tatements until a match is found . A
match sha l l occur when
- the value of the express ion equals that of a constant appearing as a case-item, or
- the value is greater than or equal to that of the f irst constant appearing in a
range containing the word TO , but less than or equal to the second , or
- the value satisf ies the relationship indicated by the relation appearing before the
constant in a range .
If and when a match is found , the rest of the case-block headed by the case-statement
in which the match was found shall be executed . If no case- item is matched , then the
case-else-block, if it is present , sha l l be executed . When execution reaches the end
of a case-block or case-e lse-block, it sha l l continue at the l ine fol lowing the end
s e lect- l ine .
Nesting of b locks is permitted subj ect to the same nesting constraints as for- loops
( i . e . no overlapping b locks ) .

- 61

8.4.5

Exception
A select-block without a case-else-block is executed and no case-block is selected
( 10004 , fata l ) .

8.4.6

Remarks
None .

- 62 -

9.

P R O G RAM S E GME N TAT I O N

- 63 -

9.

PROGRAM SEGMENTATION
BASIC provides three mechanisms for the segmentation of programs. The first provides for
user-defined functions, whose values may be used in numeri c-expressi ons and string
exp ressions. The second enables subprograms to be defined, which communicate via p arameters
and which can be invoked via a call-statement. The third enables separate programs to be
executed sequentially without user intervention.
F uncti ons and subprograms (which we refer to collectively as " routi nes" ) are of two types:
internal and external . External routines are independent program-units lexically f ollowing
the main-program. I nternal routines are contained within a program-unit (the main-program
or an external routine) and are considered to be part of that program-unit. An internal
routine cannot contain another internal routine.
In general, an external routine does not share anything (i ncluding, but not limi ted to,
variables, DATA statements, internal routines, OPTIONs, and DEBUG status) with other
program-units. I nformation is exchanged between external routines and other program-units
by means of parameters and, in the case of external functions, returned values. In general,
an internal routine shares everything with its surrounding program- unit, with the exception
of its parameters. There are no local variables for internal routi nes. See Appendix 2 for
more detai l on scope rules.
\Vi thin a program-uni t, a routine must always be defined or declared in a line lexically
preceding its first invocation in that program-unit. It is not an error for a routine to be
defined or declared without being invoked. An external routine may be invoked throughout
the p rogram; an internal routine may be invoked only from within its containing program
unit.
No control- transfer within an internal or external routine may refer to a line-number
outside that routine, nor may a control-transfer outside a routine refer to a line-number
within it.

9.1

User-Def ined Functi ons

9.1.1

General Description
I n addition to the i mp lementati on-supp lied functions provided for the convenience of
the programmer (see 5 . 4 , 6 . 4 and elsewhere), BASI C allows the programm er to define
new f unctions w i thin a program-uni t or program.

9.1.2

Syntax
1. function-de
2 . internal-function- de
3 . i nternal-def-line
4 . def-statement
5 . numeric-def- statement
6. numeri c-defi ned-function
7 . string-def-statement

8. string-defined-function
9. functi on-parm-list
10. functi on-parameter
11. formal-array
12 . internal-function- line

internal-function-de I external-function-de
internal-de -line I internal-function-line block>'<
end-functi on-line
line-number def-statement tail
numeric-def-statement stri ng-def-statement
> DEF numeric-defined-function f unction-parm-list?
equals-sign numeric-expression
numeri c-identi fier
DEF string-def ined-function length-max?
f unction-parm-list? equals-sign
stri ng-expression
string-identifier
left-parenthesis f unction-parameter (comma
functi on-parameter)>'< right-p arenthesis
> simple-variable I f ormal-array
array-name left-parenthesis comma' right-parenthesis
> line-number FUNCTION (numeric-defined-function I
(stri ng-defi ned-function length-max? ))
function-parm-list? tail

- 64 -

13 . end- function - line

line-nu mber END FUNCTION tail

14 . external- function- de
15 . external- function- line

16.
17 .
18.
19.
20 .
21.
22.
23 .
24.

external- function- line unit- block>'< end- function- line


> line-number EXTERNAL FUNCTION
(numeric- defined- function I
(string- defined- function length- max? ))
function - parm- list? tail
numeric- function- let- statement = LET numeric- defined- function equals- sign
numeric- expression
string- function- let-statement = LET string- defined- function equals- sign
string- expression
EXIT FUNCTION
exit- function- statement
> def- type I internal- function- type
type- declaration
external- function- type
def- type
DEF function- list
FUNCTION function - list
internal- function-type
external- function- type
EXTERNAL FUNCTION function- list
function- list
defined- function (comma defined- function)1<
defined- function
> numeric- defined- function I string- defined- function

No line-number in a control-transfer outside an internal- function- de shall refer to


a line in an internal- function- de other than to an internal- function - line, nor shall
a line-number in a control- transfer inside an internal- function- de refer either to a
line outside that internal- function- de or to the associated internal- function- line.
A line-number in a contr ol-transfer inside an external- function- de shall not refer
to the associated external- function- line.

If a defined- function is defined by an external- function - de , it shall not be defined


more then once in the program. If a defined- function is defined by an internal
function- de , it shall not be defined more than once in the containing program-unit.
\Hthin a program- unit, no more than one function (internal or external) of a given
name shall be declared or defined.
If a defined- function is defined by an external- function - de , then a declare
statement with external- function- type containing that defined- function shall occur in
a lower-numbered line than the first reference to that defined- function in the same
program- unit .
If a defined- function is defined by an internal- function- de other than an internal
deE- line, then either the internal- function - de , or a declare- statement with
internal- function- type naming tl1at defined- function , shall occur in a lower-numbered
line tl1an the first reference to that defined- function in the same program-unit.
If a defined- function is defined by an internal- def-line, then either the internal
deE- line, or a declare- statement with def- type naming that defined- function , shall
occur in a lower-numbered line than the first r eference to that defined- function in
the same program- unit .
Self- recursive functions need not declare themselves ; that is, if a function - de con
tains a reference to itself, that reference does not require a type- declaration con
taining the defined-function in a lower - nu mbered line. An exit- function statement
shall occur only within a function- de .
Within each function- de (other than an internal- def- line) shall occur at least one
numeric- function - let- statement or string- function- let- statement with defined- function
the same as the defined-function in the internal- function- line or external- function
line of the function - de .

- 65 -

The number and type of function-arguments in a numeric- function-ref or string


function-ref sha l l agree with the number and type of function-parameters in the cor
responding function-de . That is ,
- The number of function-arguments sha l l be the same as the number of function
parameters .
The function-arguments in the function-arg- l ist sha l l be associated with the corre
sponding function-parameters in the function-pam- l ist ( i . e . , the f irst with the
first, the second with the second , etc . ) , and the types sha l l correspond as fo l
lows :
Parameter

Argument

s imp le-numeric -variable


s imp le - string-variab le
forma l -array ( numeric)
forma l -array ( string )

numeric - express ion


string-expression
actua l -array ( numeric)
actual -array ( string)

The number of d imens ions of an actual - array sha l l be one more than the number of com
mas in the correspond ing formal-array . A f o rma l -array sha l l have no more than three
dimensions ( two commas ) .
Whenever a numeric argument is passed to a corresponding numeric parameter in a d i f
ferent program-unit , the ARITHMETIC options i n effect f o r the two program-units must
agree .
The ARITHMETIC option externa l -function-de of numeric type must agree with that of
the invoking program-unit .
A given function-parameter sha l l occur only once in function-pam- list . Function
parameters sha l l not be exp l ic itly dec lared or d imensioned within the internal
function-de or externa l - function-de .
A def ined- function appearing in a def-type or interna l - function-type sha l l be defined
e l s ewhere in the same program-unit by an interna l -def - l ine or interna l - function-de
( other than an internal -def - l ine ) , respectivel y .
A def ined- function appearing i n an externa l -function- type sha l l b e defined e l sewhere
in the program by an externa l - function-de .
9.1.3

Ex2!!!Q l es
5 . DEF E = 2 . 7 182818
DEF AVERAGE( X , Y ) = ( X+Y ) / 2
7 . DEF FNA$ ( S$ , T$) = S$ & T$
DEF Right $ ( A$ , n ) = A$ ( Len(A$) - n+1
14 . 100 EXTERNAL FUNCTION ANSWER(A$)
SELECT CASE UCASE$ (A$ )
120
CASE " YES"
130
LET ANSWER= 1
140
CASE "NO"
150
LET ANSWER=2
160
CASE ELSE
170
LET ANSWER=3
180
END SELECT
190
200 END FUNCTION
2 1 . FUNCTION AVERAGE , REVERSE$

Len ( A $ ) )

- 66 -

9 . 1 .4

Semantics

A function-def specifies the means of evaluating a function based on the values of


the parameters appearing in the function-parm- l i s t and poss ibly other variab les or
constants .
Function Parameters
When a defined- function is referenced ( i . e . , when an express ion invo lving the func
tion is evaluated ) , then the arguments in the function reference, if any , sha l l be
evaluated from left to right and their values sha l l be assigned to the parameters in
the function-parm- l ist for the function-def ( i . e . , arguments sha l l be passed by value
to the parameters of the function) . The number of d imensions in a forma l -array is one
more than the number of commas in the forma l-array . Upon invocation of a function
def , a forma l -array has the same bounds as tl1e corresponding actua l - array . A s imp le
string-variabl e or string-array which is a function-parameter sha l l have the
implementation-defined default as its maximum length .
Function Evaluation
If a function is defined in a def- s tatement , then the expression in that statement
s ha l l be evaluated and its value assigned as tl1e value of the function . If a function
i s def ined in an internal - function-def or externa l - function-de f , then the l ines fo l
lowing the internal - function- l ine o r external -function- l ine sha l l be executed in se
quential order until
some other action is d ictated by execution of a l ine , or
- a fatal exception occurs , or
a chain-statement or stop-statement i s executed , or
- an exit-function- statement is executed , or
- an end-function- l ine is reached .
The value of the defined-function sha l l be set by execution of one or more numeric
function- let- statements or string- function- let-statements . Upon exit from the
function-def , the value sha l l be that most recently ass igned to the defined-function
in tllat invocation . I f , upon exit , no such value has been ass igned , then the result
sha l l be cons istent with the imp l ementation-defined po l ic ies for uninitia l i zed vari
ab les . A l ength-max f o l l owing a string-defined- function estab l ishes the maximum
l ength o f the string value to be returned by that function-def . If no length-max is
spec if ied , then the maximum lengtll sha l l be the same as for a string-variab le without
a l ength-max .

An exit- function-statement , when executed , sha l l terminate tlle execution of the


function-def in which it is immediate ly contained . An end- function - l ine marks the
textual end of a function-block , ru1d also sha l l terminate execution of tlle function
b lock . Execution of a stop-statement in a function-block sha l l terminate execution of
the entire program .
A function-def may refer , d irectly or indirect l y , to the function being def ined ;
i . e . , recursive function invocations are permitted .
Lines in a function-def sha l l not be executed unless the function it defines is ref
erenced . If the execution of a program reaches an internal -def - l ine, it sha l l proceed
to the next l ine without furtller effec t . If execution reaches an interna l - function
l ine , it sha l l proceed to the l ine f o l l owing the associated end- function- l ine without
further effect .
Scopes of Variables , Arrays , Channel Numbers , and Data

A function-parameter appearing in the ftmction-parm- l ist of a function-def sha l l be


local to each invocation of tllat function-def ; i . e . , it sha l l name a variable or ar
ray distinct from any variabl e or array with tlle same name outside tlle function- ref .

- 67 -

The treatment of variables and arrays which are not named as funct ion-parameters in a
function-def sha l l depend upon whether the function-def is internal or external . If
the function-def is external , then such variables and arrays sha l l be local to each
invocation of that program-unit , i . e . , they shal l be distinct from objects with the
same names outside that function-def or within other invocations of that function
def ; in add ition , they s ha l l be initia l i zed or not initial ized in a manner cons istent
with the imp l ementation-defined pol icies for the main-program each time the function
def is invoked . If the function-def i s interna l , then those variables and arrays
sha l l be g l obal to the containing program-unit and s ha l l retain their assigned values
each t ime the funct ion-def is invoked ; if these values are changed during the course
of executing the interna l - function-def , the changes remain in effect when execution
is returned to the surrounding program-unit .
With one exception, the scope of channe l - numbers ( see 9 . 2 ) is a lways the program
unit . Nonzero channel - numbers within a function-def sha l l be local to each invocation
of that function-def if it is external , and sha l l be g l obal to the containing
program-unit in which it occurs if it is interna l . Channe l zero shal l be global to
the entire program . Fi les sha l l be ass igned to nonzero channel s within a program-unit
by means of an open-statement before use . Fi les ass igned to channel s local to a
function-def sha l l be c losed upon exit from that function-def .
The scope of internal data is a lways the program-unit . Thus , data within an externa l
function-def s ha l l b e local t o each invocation of that program-unit . Hence read
statements and restore - statements within such a function-def sha l l refer only to data
in data-statements within that function-de and not to data in other program-units .
Upon invocation of such a function-def , the po inter for the data within that
function-def sha l l be reset to the beginning of the data ( see 10 . 1 ) . Data within an
internal- function-def sha l l be part of the data sequence for the containing program
unit , and read- statements and restore- s tatements within such a function-de s hal l re
fer to the entire sequence of data in that program-unit .
9.1.5

Exception s
A string- function- let- s tatement attempts to assign a value whose length exceeds the
maximum for the s tring-def ined-function ( 1 106 , fata l ) .

9.1.6

Remarks
Incompatible COLLATE options are a l l owed between an invoking and invoked program-unit
( even if they communicate via string parameters ) because COLLATE does not d ictate the
internal representation of strings , but only their order in a string comparisons and
the values of the CHR$ and ORO functions .
It is not an error for an internal-function-def to appear before a declare-statement
with def- type or interna l -funct ion-type containing the name of that internal func
tion . It is not an error for a function to be defined by an internal- function-def or
to appear in a dec l are - s tatement , but not to be referred to in that progran1-unit .
An internal - function- type or def- type may be omitted if the corresponding definition
appears before first reference . An external- function- type is always required when an
external-function is referenced in a program-unit .
It is not an error for a function to be def ined by an interna l - function-def or to ap
pear in a dec lare - s tatement , but not to be referred to in that program-unit .
It is not an error for an interna l - function-def to appear before a declare-statement
with def - type or interna l - function- type containing the name of that internal func
tion .

- 68 -

An internal- function- type or def- type may be omitted if the corresponding definition
appears before the f irst reference to that functio n . An external- function-type is a l
ways required when a n external - function i s referenced in a program-unit o ther than
its own.
The requirement that both internal and external functions be dec lared or defined be
fore they are used al lows several program-units within a program each to contain an
internal function with the same name as an external functio n . This facilitates the
use of function libraries where the programmer may not know the names of a l l the
externa l - funct ion-defs in the l ibrary .
9.2

Subprograms

9.2.1

General Description
Subprograms provide a mechanism for the logical segmentation o f programs, allowing
parameter s to be passed between program segments. Subprograms, like defined
functions, may be internal or external to a program-unit .

9.2.2

Syntax
1.
2.
3.
4.
5.
6.

subprogram-de
interna l - sub-de
interna l - sub- l ine
sub- statement
subprogram-name
procedure-parm- list

7 . procedure-parameter
8 . channel-number
9 . end - sub - l ine
10 . end - sub- statement
11 . exit - sub- statement
12 . external - sub-de
1 3 . externa l - sub - l ine
14 . cal l - statement
15 . procedure-argument- list
16 . procedure-argument
17 . type-dec laration
18 . inte rna l - sub- type
19 . externa l - sub- type
20 . sub- l ist

internal - sub-de I externa l - sub-de


internal - sub- line b l ock>'< end- sub - l ine
line-number sub- statement tail
SUB subprogram-name procedure-parm- list?
routine- identifier
left-parenthesis procedure-parameter ( comma
procedure-paramete r ) >'< right - parenthesis
> simp le-variab le I formal-array I channe l-number
number- sign integer
l ine-number end - sub- statement tail
END SUB
EXIT SUB
externa l - sub- l ine unit-block>'< end - sub- line
l ine-number EXTERNAL sub- statement tail
CALL subprogram-name procedure-argument- l ist?
left-parenthesis procedure-argument ( comma
procedure-argument ) >'< right-parenthesis
expression I actual -array I channel -expression
> interna l - sub-type I externa l - sub-type
SUB sub- list
EXTERNAL SUB sub- l ist
subprogram-name ( comma subprogram-name ) >'<

No line- number in a contro l - transfer outside an internal - sub-de sha l l refer to a


line in an internal - sub-de other than to an interna l - sub - l ine, nor sha l l a l ine
number in a contro l -transfer inside an interna l - sub-de refer either to a line out
side that interna l - sub-de or to the associated interna l - sub- line .

A l ine-number in a contro l - transfer inside an externa l - sub-de shal l not refer to the
associated externa l - sub- l ine .
If a subprogram-name is defined by an external - sub-de, it sha l l not be defined more
than once in the program . If a subprogram-name is defined by an interna l - sub-de, it
shal l not be defined more than once in the containing program-unit .
Within a program-unit, no more than one subprogram ( internal or external ) of a given
name shal l be dec lared or defined .

- 69 -

I f a subprogram-name is defined by an external-sub-def, then a declare-statement with


external-sub-type containing that subprogram-name shall occur in a lower-numbered
line than the first reference to that subprogram-name in a call-statement in the same
program- unit.
If a subprogram-name is defined by an internal-sub-def, then either the i nternal-sub
def, or a declare-statement with internal-sub-type containing that subprogram-name,
shall occur in a lower-numbered line than the first reference to that subprogram-name
in the same program-unit.
Self-recursive subprograms need not declare themselves; that is, if a subprogram-def
contains a reference to itself in a call-statement, that reference does not require a
type-declaration containing that subprogram-name in a lower-numbered li ne.
An exit- sub-statement shall occur only within a subprogram-def.
The number and type of procedure-arguments in a call-statement shall agree with the
number and type of procedure-parameters in the corresponding subprogram-def. That is,
- The number of procedure-arguments shall be the same as the number of procedure
parameters.
The procedure-arguments in the procedure-arg-list shall be associated with the cor
responding procedure-parameters in the procedure-parm-list (i.e., the first with
the first, the second with the second, etc.) , and the types shall correspond as
follows :
Parameter

Argument

simple-numeric-variable
simple-string-variable
formal-array (numeric)
formal-array (string)
channel-number

numeric-expression
string-expression
actual-array (numeric)
actual-array (string)
channel-expression

An actual-array shall have the same number of dimensions as the corresponding formal
array. The number of dimensions in a formal-array is one more than the number of com
mas in the formal-array.
Whenever a numeric argument is passed to a corresponding numeric parameter in a dif
ferent program-uni t, the ARITHMETIC option in effect for the two program-uni ts must
agree.
A given procedure-parameter shall occur only once in a procedure-parm-list.
P rocedure-parameters shall not be explicitly declared or dimensioned within the
internal-sub-def or external-sub-def.
The channel-number zero shall not be used as a procedure-parameter.
A subprogram-name appearing in an i nternal-sub-type shall be defined elsewhere in the
same program-unit by an internal-sub-def.
A subprogram-name appearing in an external-sub-type shall be defined elsewhere in the
program by an external-sub-def.
9.2.3

Examples
2 . 100 SUB exchange(a, b)
LET t = a
l lO
120
LET a
b
LET b
130
t
140 END SUB
4 . SUB CALC(X , Y , Z$ )
SUB SORT(A(), B(, ) , A$ , #3 )

- 70 -

1 3 . 2000 EXTERNAL SUB OPEN ( # 1 , f name s $ , result )


14. CALL CALC ( 3itA+2 , 7 7 15 , "NO" )
CALL SORT ( Zvec t , Ymat ) , ( L$ ) , #N)
9 . 2 .4

S emantics
When a cal l - statement i s executed , contro l sha l l be transferred to the subprogram
named in to cal l - s tatement . Execution of the subprogram sha l l begin at the l ine fol
lowing the sub- l ine and sha l l continue in sequential order until
- some other action is d ictated by execution of a l ine , or
- a fatal exception occurs , or
- a chain-statement is executed , or
- a stop- statement or exit- sub-statement is executed , or
- an end-sub - l ine i s reached .
The end- sub- l ine serves both to mark the textual end of a subprogram and , when exe
cuted , to terminate execution of the subprogram . The exit- sub-statement , when exe
cuted , sha l l terminate the execution of the innermost subprogram in which it is con
tained . When execution of a subprogram terminates , execution sha l l continue at the
l ine fo l lowing the cal l - s tatement which initiated execution of the subprogram .
Execution of a stop- s tatement in a subprogram sha l l terminate execution of the entire
program .

A subprogram may cal l its e l f , either d irectly or indirectly through another proce
dure ; i . e . , recurs ive subprogram invocations are permitted .
Lines in a subprogram-de sha l l not be executed unless the subprogram it defines is
referenced through a cal l - s tatement . If execution reaches an interna l - sub - l ine , it
s ha l l proceed to the l ine fo l lowing the assoc iated end-sub- l ine without further ef
fec t .
Subprogram parameters
When a cal l - s tatement is executed , its procedure-arguments sha l l be ident ified , from
left to right , with the corresponding procedure-parameters in the sub-statement for
the subprogram .
Procedure-arguments
which
are
numeric -variab les
or
string-variables
without
substring-qual ifiers sha l l be passed by reference , i . e . , any reference to the corre
sponding procedure-parameter within the subprogram sha l l result in a reference to the
procedure-argument , and any ass ignment to the procedure-parameter shal l result in an
assignment to the correspond ing procedure-argument .
If a procedure-argument is an array e l ement , its subscripts sha l l be evaluated once
at each entry to the subprogram .
A procedure-argument which is an express ion , but not a numeric -variab le or a string
variab l e without a substring-qua l if ier , sha l l be evaluated once at each entry to the
subprogram and the value so obtained s hal l be ass igned to a location local to the
subprogram. This local value sha l l be used in any reference to the correspond ing
procedure-paramete r , and this local location sha l l be used as the destination of any
assignment to the procedure-parameter . Any necessary evaluation of procedure
arguments sha l l take p lace from left to right .
References within a subprogram to the procedure-parameters which are formal-arrays
s ha l l result in interferences to the corresponding arrays in the procedure-argument
l i s t ; ass ignments to or redimensioning of such arrays sha l l resul t in assignments to
or redimensioning of the corresponding arrays in the procedure-argument- l ist . Upon
entry to the subprogram , a forma l -array as a procedure-parameter has the same bounds
as the corresponding procedure-argument .

- 71 -

For a procedure-parameter which is a s imple-string-variabl e or string-array, the as


soc iated maximum length sha l l be the imp l ementation-def ined defau l t , in the case of
passing by value ; when passing by referenc e , the maximum length sha l l be that of the
corresponding procedure-argument .
If both an array and one of its e lements are named as procedure-arguments in a cal l
statement and the array is red imensioned during execution of the subprogram , then any
subsequent reference within the subprogram to the procedure-parameter assoc iated with
the array-element sha l l produce impl ementation-defined results .

A procedure-argument which is a channe l - expression shal l be evaluated once on entry


to the subprogram and the resulting channel sha l l be used whenever the value of the
corresponding procedure-parameter is referenced in the subprogram .
The attributes of the f i l e ( see 11 . 1 . 4 ) ass igned to this channe l sha l l be passed un
changed to the subprogram , and changes to attributes and contents of the f i le within
the subprogram must be immed iately effective , regard less of which of the channe l
numbers i s used i n t h e subsequent reference , and sha l l remain i n effect upon exit
from the subprogram .

A f i l e need not be ass igned to a channel des ignated by a procedure-argument when a


cal l - s tatement is executed . If an open- statement within a subprogram ass igns a f i le
to that channel , then that ass ignment sha l l remain in effect upon exit from the sub
program .
Scopes of variab les , arrays , channel numbers , and data

A procedure-parameter appearing in the procedure-parm- l ist of a subprogram-clef which


has been passed by value sha l l be local to each invocation of the subprogram-clef ;
i . e . , it sha l l name a variable or array distinct from an variable or array with the
same name outside the subprogram-clef .
For a procedure-parameter which has been passed by reference , its name sha l l be local
to each invocation of the subprogram-clef , but that name refers to the same object as
the corresponding procedure-argument see Subprogram parameters , above ) .
The treatment of variab les and arrays which are not named as parameters in a
subprogram-clef shal l depend upon whether the subprogram-clef is internal or external .
If the subprogram-clef is external , then such variab les and arrays sha l l be local to
each invocation of that program-unit , i . e . , they sha l l be distinct from obj ects with
the same names outs ide that subprogram-clef or within other invocations of that
subprogram-clef ; in add ition , they sha l l be initia l i zed or not initia l i zed in a manne r
cons istent with the implementation-defined pol icies for the main-program each time
the subprogram-clef is invoked . If the subprogram-clef is internal , then those vari
ables and arrays sha l l be global to the containing program-unit and shal l retain
their ass igned values each time the subprogram-clef is invoked ; if these values are
hanged during the course of executing the subprogram-clef , the changes remain in ef
fect when execution is returned to the surrounding program-unit .
With one exception, the scope of channe l -numbers which are not procedure-parameters
is always the program-unit . Nonzero channe l-numbers within a subprogram-clef shall be
local to each invocation of that subprogram-clef if it is external , and shall be
g l obal to the program-unit in which it occurs if it is internal . Channe l zero sha l l
b e g lobal t o the entire program . Fi les sha l l b e ass igned to nonzero channe ls within a
program-unit by means of an open-statement before use . Fi les ass igned to channe ls l o
c a l to a subprogram-clef sha l l b e c losed upon exit from that subprogram-clef .
The scope of internal data is always the program-unit . Thus , data within an externa l
sub-clef sha l l b e local t o each invocation of that program-unit . Hence read -statements
and restore-statements within such a subprogram-clef sha l l refer only to data in data
statements within that subprogram-clef and not to data in other program-units . Upon

- 72 -

invocation of such a subprogram-de , the pointer for the data within that subprogram
de sha l l be reset to the beginning of the data ( see 10 . 1 ) . Data within an internal
sub-de sha l l be part o f the data sequence for that program-unit, and read- s tatements
and restore-statements within such a subprogram-de sha l l refer to the entire se
quence of data in that program-unit .
9.2.5

Exceptions
None .

9.2.6

Remarks
Imp lementations may extend the l anguage by making the use of an interna l - sub-type op
tiona l , even when the internal - sub-defs occur after the ca l l - s tatements referring to
them .
An a l ias is said to exist for an object whenever two or more distinct names exist for
the object within the same scope . When parameters are passed by reference , a l iases
may be created in certain circumstances . Parameter pass ing by value does not create
a l iases , s ince distinct objects are created for each parameter .
Any cal l - statement creates a l iases whenever
- channel -expressions which round to the same integer value are passed to different
formal channe l -numbers ,
- the same actual -array is passed to different forma l -arrays ,
the same s imp l e variab le or array e l ement is passed to different formal s imp le
variables ,
- an array is passed to a forma l -array and an e l ement of that array is passed to a
formal s imp le-variab l e ,
a channel -expression is passed t o an internal subprogram , o r
- an argument which is not a channe l -expression is passed by reference t o an internal
subprogram .
In the f irst four cases , the a l ias arises because two or more formal parameters name
the same obj ect , or parts of the same obj ec t . In the latter two cases , the a l ias
arises because an obj ect is "visible" to an internal subprogram , both as a parameter
and as an obj ect g l obal to the entire program-unit .
When the state of an obj ect referred to by an a l iased procedure-parameter is changed ,
that change must be immed iately effective in every subsequent reference to the ob
ject, regard less of which of the object 1 s names is used in the reference . Events
which potentia l ly affect the state of the obj ect referred to by a procedure-parameter
include ass ignment , input/ output operations , and array redimensioning .
Thus , the program :
100 DECLARE INTERNAL SUB S
l lO LET A = 0

120
130
140
150
160
170
180
190
200
210

CALL S ( A, A )
SUB S ( B , C )
1
LET A
LET B
2
LET C
3
IF A <> B OR B <> C OR A <> C THEN
PRINT "This shouldn ' t happen . "
END IF
END SUB
END

- 73 -

would never p rint the error message in a conforming imp l ementation .


Remarks about the fo l lowing topics in 9 . 1 . 6 app l y ana logous ly to subprograms ( 9 . 2 . 6 ) :
- Program-units with different COLLATE options ;
- Funct ions which are defined or dec lared , but not referenced ;
- Functions which are def ined before they are dec l ared ;
The requirement that externa l , but not interna l , functions aiways
( rather than defined ) ;
- Internal functions with the same name in d ifferent program-units .
9.3

be decl ared

Chaining

9.3.1

General Description
The chain-statement a l lows separate programs to be executed seria l l y without program
mer intervention . Such a fac i l ity is useful for segmenting large programs .

9.3.2

Syntax
1 . chain-statement
2 . program-des ignator

CHAIN program-des ignator (WITH function-arg- l i st ) ?


string-expression

The association of the function-arguments in the function-arg - list in the chain


s tatement with the function parameters in the funct ion-parm- l ist in the program-name
l ine shall f o l low the same ru les set down for def ined-functions ( see 9 . 1 ) .
9.3.3

Examples
1 . CHAIN "PROG2"
CHAIN A$ WITH ( X , FILENAMES$ )

9.3.4

S emantics
A chain- statement sha l l terminate execution of the current program , c lose a l l fi les ,
and initiate execution of the program des ignated by the program-des ignator . The way
in which a program is associated with its program-des ignator is imp lementation
def ined .
I f the program being chained to contains a program-name- l ine , then the arguments of
the chain-statement are evaluated and assigned to the corresponding parameters in the
program-name- l ine ( i . e . , parameters are passed by value ) . The bounds of a forma l
array sha l l therefore b e adjusted t o equal those o f the corresponding actual -array ,
in accordance with the rules for pass ing array parameters to functions ( see 9 . 1 ) .
I t is imp lementation-defined whether upper- case- letters and lower-case- l etters are
treated as equivalent in a program-des ignator .
The initial values of variables in a chained- to program are imp l ementation-defined .

9.3.5

Exceptions
- The program identified by the program-des ignator is not avail ab l e ( 10005 , fatal ) .
- The number and type of arguments in a chain-statement do not agree with the number
and type of the corresponding parameters in the program-name- l ine of the program
being chained to , or a program-name - l ine with a function-parm- l is t is not present
( 4301 , fata l ) .
- An actua l -array does not have the same number of d imensions as the corresponding
forma l -array ( 4302 , fatal ) .
- Numeric parameters are passed between programs with a chain- statement and the
ARITHMETIC options of the program-units d isagree ( 4303 , fata l ) .

- 74 -

9.3.6

Remarks
I n a typical impl ementation a program-des ignator wi l l be the name of a f i le contain
ing that program . The program chained to need not be a BASIC program .
I f exception 4 30 1 , 4302 , or 4303 occur s , it may be reported by the chained- from pro
gram, the chained-to program, or some intermediate system p rogram .

- 75 -

10.

I N P U T AND

OUTPUT

- 76 -

10 . I NPUT AND OUTPUT


Input and output fac i l ities are provided for the interaction of a BASIC program with c o l
lections of data . Data may b e obtained b y a program from s tatements within that program,
from a standard source external to that program, or from a named source external to that
program ( see 11 . 4 ) . Output data may be d irected to a standard destination external to that
program or to named destination external to that program ( see 11 . 3 and , for BASIC-2 only ,
ll. 5) .
10 . 1 Internal Data
10 . 1 . 1 General Description
The read - statement provides for the ass ignment of values to variables from a sequence
of data created from one or more data-statements . The restore-statement a l lows data
in a program to be reread .
10 . 1 . 2 Syntax
1.
2.
3.
4.
5.
6.
7.
8.
9.

read - statement
variab le- l is t
miss ing-recovery
io-recovery-action
restore-statement
data - statement
data- l ist
datum
unquoted-string

> READ ( miss ing-recovery colon ) ? variable- l is t


variab l e ( comma variable ) 1'<
IF MISSING THEN io- recovery-action
exit-do-statement I exit-for- s tatement I l ine- number
RESTORE l ine-number?
DATA data- l i s t
datum ( comma datum) '<
constant I unquoted - s tring
p lain-s tring-character I p lain-string-character
unquoted- string-character>'<
p lain-string-character

An io- recovery-action containing an exit- for-statement s ha l l occur only within a for


body . An io-recovery-action containing an exit-do- s tatement s ha l l occur only within a
do-body .
If a l ine- number occurs in a restore - s tatement , the l ine-number sha l l refer to a l ine
containing a data-statement .
10 . 1 . 3 Examples
1. READ X, , Z
READ IF MISSING THEN 1 3 50 : X( 1 ) , A$
5 . RESTORE
RESTORE 1000
6 . DATA 3 . 14159 , PI , 5E- 3 0 , " , I I
9 . COMMAS CANNOT OCCUR I N UNQUOTED STRINGS .
10 . 1 . 4 Semantics
Data f rom the total ity of data-stat ements in each program-unit shal l behave as if
col lected into a s ingl e data sequence . The order in which data appear textua l ly in
the tota l ity of a l l data- s tatements determines the order of the data in the data se
quence .
If the execution of a program reaches a l ine containing a data-statement , then it
sha l l proceed to the next l ine with no further effec t .
Execution of a read - s tatement s ha l l cause variables i n the variab l e - l i s t t o b e
s igned value s , in order , from the sequence of data in the program-unit containing
read - statement . A conceptual pointer is associated with this data sequence . At
initiation of execution of the program-unit , this conceptual pointer points to

as
the
the
the

- 77 -

f ir s t datum in the data sequence .

Each time a read - statement is executed ,

each var i

ab l e i n the variab le- l ist i n sequence is ass igned the value o f the datum ind icated by
the po inter and the po inter advanced to point beyond that datum .
If an attempt is made to read data beyond the end of the data sequence , an exception
s ha l l occur unless a m i s s ing-recovery is present in the read - s tatement .
the

specified

i o - recovery-action

sha l l

be

taken .

If

the

I n that cas e ,

io- recovery-action

is

an

exit- d o - s tatement or exit-for-statement , that statement sha l l have its normal effect

( see 8 . 3 ) .

I f the io- recovery-action is a

l ine- number ,

then execution sha l l continue

at the l ine having that l ine-number .


The type of a datum in the data sequence sha l l correspond to the type of the variable
to which it i s
data and

to be

as s igned ;

string-variables

i.e. ,

require

numeric-variables require numer ic-constants as

string-constants

or

unquoted - s trings

as

data .

An

unquoted - s tring which is a l s o a numeric-constant may be ass igned to either a string


variab le or a numeric -variable by a read - s tatement .
If the evaluation of a numeric datum causes an underf low, then its value sha l l be re
p laced by zero .
Subscripts

and

substring - qua l ifiers

in

the

variab le- l ist

values have been ass igned to the variables preceding them

shal l

(i.e. ,

be

evaluated

after

to the left of them )

in the variab le- l i s t .


Execution

of

restore - s tatement

program-unit containing

the

resets

the

restore-s tatement

that the next read - statement executed wi l l


quence .

If

a l ine -number

is present,

to

read

the

for

the

data

beginning

sequence

of

the

l ine-number ,

so

in

sequenc e ,

data from the beginning

then the po inter for the data

program-unit containing the restore-statement


s tatement with the given

po inter

of

the

sequence

the
so
se

in the

is set to the first datum in the data

that the next read - s tatement executed wi l l

read data from the beginning o f the des ignated data-s tatement .

10 . 1 . 5

Exceptions
The variab le- l is t
remainder

of

i n a read - statement requires more data than are present

the data - l ist

and a

miss ing- recovery has

not been

specified

in

the

( 8001 ,

fatal ) .

- An

attempt

is made

to assign a value

n o t a numeric- constant

( 8 10 1 ,

to a numer ic-variable from a datum which

is

fatal ) .

- The evaluat ion of a numeric datum causes an overf low

( 1006 ,

fatal ) .

- The ass ignment of a datum to a string-var iab le results in a string overf low

( 10 5 3 ,

fatal ) .

10 . 1 . 6

Remarks
Imp lementations may choose to treat underflows as exceptions
zero and cont inue ) .

I n BASIC-2

impl ementat ions ,

this permits

( 15 0 6 ,

nonfata l :

supp ly

interception by excep

tion hand lers .

10 . 2

I nput

10 . 2 . 1

General Description
Input-s tatements provide for user interaction with a program by al lowing var iables to
be

ass igned

values

s tatement enab les

supp l ied

from

the entry of mixed

source

external

to

the

program .

The

input

string and numeric data, with data items being

separated by commas .
A prompt

for

p l ementation .

input may be specified to replace the usual prompt supp l ied by the

im

- 78 -

The l ine- input- statement enables an entire l ine of input , including embedded spaces
and commas , to be assigned as the value of a string-variable .
10 . 2 . 2 Syntax
1.
2.
3.
4.
5.
6.
7.
8.
9.
10 .
11.

input-statement
input-modif ier- list
input-modifier
prompt-speci f ier
t imeout-expression
numeric-time-express ion
t ime - inquiry
l ine- input-statement
input-prompt
input-rep ly
l ine- input- rep ly

> INPUT input-mod ifier- l is t ? variable- list


input-modif ier ( comma input-mod if ier ) :'' co lon
prompt-specif ier I t imeout-expression I time- inquiry
PROMPT string-expression
TIMEOUT numeric- time-express ion
numeric-express ion
ELAPSED numeric-variabl e
> LINE I NPUT input-modifier - l ist? s tring-variable- l ist
( implementation-def ined )
data- l is t comma? end-of - l ine
characterl'' end-of - l ine

At mos t one prompt-specifier , one timeout- express ion, and one time- inquiry sha l l oc
cur in an input-modifier- l i s t . These may occur in any sequence .
10 . 2 . 3 Examples
1. I NPUT X
INPUTA$ Y ( 2 )
INPUT PROMPT "What i s your name? " : N$
INPUT TIMEOUT 31'N, ELAPSED T, PROMPT Pstring$ : N$
8 . LINE I NPUT A$
LINE INPUT PROMPT 1 1 1 1 : A$ , B$
10 . 2 , SMITH , - 3
2 5 , o, - 10 . 2
11 . He said , "Don ' t" .
10 . 2 . 4 Semantics
Execution of input- statement sha l l cause execution of the program to be suspended un
t i l a val id input-rep l y , as specified below , has been supp l ied . An input- statement
sha l l cause variables in the variable- l is t to be ass igned , in order , values from the
input- rep ly .
I n interactive mode , the user o f the program sha l l be informed o f the need to supply
data by the output of an input-promp t .
Input modifier l is t
I f a prompt- specifier is present in the input- statement , then the imp lementation
defined input-prompt shal l not be outpu t ; instead , the value of the string-expression
in the prompt-specifier sha l l be output ( unless the input -rep ly is terminated by a
comma , s ee below ) . In batch mod e , the input -rep ly sha l l be requested from the exter
nal source by an imp lementation-def ined means .
If a timeout-express ion is present in an input-mod ifier- list , then the numeric - t ime
expre s s ion contained therein sha l l be evaluated to obtain a (poss ibly fractional )
number S of seconds . If no va l id input -rep ly or l ine- input- rep ly has been supp l ied
within S second s , then an exception sha l l occur . A time- inquiry returns the ( possibly
fractiona l ) number of seconds elapsed between the issuance of the input-prompt and
the reception of the end - of - l ine of the last input-rep ly for this input- statement .
This value is ass igned to the numeric -variable in the time - inquiry . If no c lock is
provided by an imp lementation , then a timeout-expression sha l l have no effect . If a

- 79 -

c lock is provided , a time- inquiry result sha l l a lways be positive .

If no c lock is

provided , a time-inquiry result sha l l be - 1 . The values (minimum and maximum) and
reso lution of both timeout express ions and time- inquiries are imp l ementation-defined .
Ass ignment of Values
The ass ignment of a value from the input-reply to the corresponding variable sha l l
take p lace as soon as an item o f data i n the input-rep ly has been val idated with re
spect to the type of the datum and the al lowable range of values for that datum .
Subscripts and substring-qual ifiers in a variable- l ist or string -variab le- l ist sha l l
be evaluated after values have been ass igned t o the variab les preceding them ( i . e . ,
to the left of them) in the variable- l ist or string-variable- l is t .
TI1e type of each datum in the input-rep ly sha l l correspond to tBe type of the vari
able to which it is to be ass igned ; i . e . , numeric-cons tants sha l l be supp l ied as in
put for numeric -variables , and either string-constants or unquoted -strings sha l l be
supp l ied as input for s tring-variab les . An unquoted-string which is also a numeric
constant may be ass igned to either a string-variabl e or a numeric-variable by an
input- statement .
If the evaluation of a numeric datum causes an underf l ow, then its value sha l l be re
p laced by zero .
If an input- reply supp l ied in response to a reques t for input does not end with a
comma , then the number of data in a l l the input- rep l ies submitted s ha l l equa l the
number of variables requiring values .
If the last character other than a space before the end-of - l ine in an input-rep ly is
a comma , then this sha l l be taken to s ignify that further data are to be supp l ied . As
many values as are contained in that input-rep ly sha l l be ass igned to variables in
the variable- l ist . The input-prompt ( but not the string-express ion of the prompt
specifier, if there is one ) sha l l then be reissued , and execution of the program
sha l l remain suspended unt i l another val id input-rep ly has been supp l ied , from which
further data sha l l be obtained .
When a line - input-statement is executed , a l ine- input-reply sha l l be requested for
each string-variabl e in the string-variable- l ist in the same fashion as an input
rep ly is requested . That is , the value of the f irst line- input-rep ly sha l l be as
s igned to the first var iable in the variable- l i s t . If there are further variables in
the variable- l ist , the input-prompt ( but not the string-expression of the prompt
spec if ier , if there is one ) sha l l then be reissued , and execution of the program
shal l remain suspended unti l a second val id l ine- input-reply has been suppl ied and
ass igned to the second variab le in tl1e variable- list . This process continues unti l a
val id l ine- input-rep ly has been supp l ied for each variab le in the variable- l is t . The
characters of each l ine- input-rep l y , including any leading and trail ing spaces , sha l l
b e concatenated to form a s ingle string , which sha l l become the value o f the corre
sponding string-variab le , except tl1at the end - of - l ine , which terminates a l ine- input
rep l y , sha l l not be included . Quotation marks within a l ine- input-rep ly are treated
as actual characters . Thus , two adj acent quotation-marks are taken as two characters ,
not as one .
10 . 2 . 5 Exceptions
- The l ine supp l ied in response to a reques t for an input- rep ly is not a syntact i
c a l ly correct input-rep ly ( 8 102 , nonfata l : request that a new input-reply b e sup
p l ied ) .
- A datum supp l ied as input for a numeric -variabl e is not a numeric-constant ( 8103 ,
nonfatal : reques t that the current input-rep ly be resupp l ied ) .

- 80 -

- There are insuffic ient data in an input- rep ly not containing a f inal comma ( 8002 ,
nonfatal : request that the current input- rep ly be resupp l ied ) .
There are too many data in an input- rep ly or there are just enough data and the
input-rep ly ends with a comma ( 8003 , nonfatal : reques t that the current input
rep ly be resupp lied ) .
- The evaluation of a numeric datum causes an overflow ( 1007 , nonfatal : request that
the current input - rep ly be resupp l ied ) .
- The assignment of a dattun or a l ine- input-reply to a string-variab le resul ts in a
string overf low ( 1054 , nonfatal : request that the current input- rep ly or l ine
input- rep ly be resupp l ied ) .
The value of a numeric-time-express ion is less than zero ( 8402 , fatal ) .
- A val id input-rep ly or l ine- input-reply has not been supp l ied within the number of
seconds spec i f ied by a timeout-expression in an input-modifier- l i s t ( 8401 , fatal ) .
10 . 2 . 6 Remarks
This Standard requires that users in the interactive mode always be g iven the option
of resupplying erroneous input-rep l ies ; in batch mode this may be treated as a fatal
exception . This Standard does not require an imp l ementation to provide fac i l ities for
correcting erroneous input- rep l ies , though such fac i l ities may be provided .
It is recommended tat the default input-prompt cons ist of a question-mark fo l lowed by
a s ing l e space .
This Standard does not require an imp l ementation to output ( i . e . echo ) an input- rep ly
or l ine- input-rep ly .
Implementations may choose to treat underf lows as exceptions ( 1 507 , nonfatal : supp ly
zero and continue) . In BASIC-2 imp lementation, this permits interception by exception
hand lers .
If an input datum is an unquoted- string , leading and trail ing spaces are ignored ( see
4 . 1 ) . If it is a quoted-string , then a l l spaces between the quotation-marks are sig
nificant ( see 6 . 1 ) .
10 . 3 Output
10 . 3 . 1 General Description
The p r int- statement is designed for generation of tabular output in a cons istent for
mat . The set-statement with MARGIN can be used to specify the width of output- l ines .
The set-statement with ZONEWIDTH can be used to specify the width of print zones
within a print - l ine . The ask- statement is used to inquire about the current MARGIN
and ZONEWIDTH . General izations of the print- statement are described in 10 . 4 , 10 . 5 ,
and 11 . 3 .
10 . 3 . 2 Syntax
1.
2.
3.
4.
5.
6.
7.
8.
9.
10 .

print - statement
print - l ist
print - i tem
tab-ca l l
print - s eparator
set-statement
set-obj ect
ask-statement
ask- io - l is t
ask- io- item

> PRINT print- l is t


( pr int- item? print-separato r ) l't print- item?
express ion I tab - ca l l
TAB left-parenthesis index right-parenthes is
comma I semico lon
SET set-obj ect
> ( MARGIN I ZONEWIDTH) index
> ASK ask- io - l i s t
ask - io - item c o mma ask- io- item ) *
( MARGIN I ZONEWIDTH) numeric-variabl e

- 81 -

A g iven ask- io- item must appear at most once in an ask- s tatement .
10 . 3 . 3 Examples
1 . PRINT X
PRINT X , Y
PRINT X , Y , Z ,
PRINT , , X
PRINT
PRINT "X EQUALS" , 10
PRINT X , ( Y+Z ) / 2
PRINT TAB ( 10) ; A $ " I S DONE."
6 . SET MARGIN 120
SET ZONEWIDTH 20
10 . 3 . 4 Seman tics
The execution of a print- statement sha l l generate a string of characters and end-of
l ines for transmission to an external device . This string of characters sha l l be de
termined by the success ive evaluation of each print - i tem and print-separator in the
print- l i s t .
I f a n expression i n a p r int- l ist invokes a function which causes a print-statement to
be executed which transmits characters to the same device as the original print
statement , then the effect is imp l ementation-defined .
Printing numeric values
Numeric- express ions sha l l be evaluated to produce a string of characters cons isting
of a lead ing space if the number is positive , or a leading minus - s ign if the number
is negative , f o l lowed by the decimal representation of the absolute value of the num
ber and a tra i l ing space . The possible decimal representations of a number are the
same as those described for numeric-constants in 5 . 1 and sha l l be used as f o l l ows .
Each imp lementation s ha l l def ine two quantities , a s ignif icance-width d to contro l
the number of s ignif icant decimal d igits printed in numeric representations , and an
exrad-width e to contro l the number of d igits printed in the exrad component of a nu
meric representation . The value of d sha l l be at least s ix and the value of e sha l l
be at l east two .
Each expression whose value is exactly an integer and which can be represented with d
or fewer decimal d igits sha l l be output using the imp l icit po int unsealed representa
tion .
Al l other values s ha l l be output using either exp l icit point unsealed representation
or exp l icit po int scal ed representation . Values which can be represented with d or
fewer d igits in the unsealed representation no less accurately than they can in the
scaled representation sha l l be output using the unsealed representatio n . For examp l e ,
6 , then 10- ( - 6 ) i s output a s . 000001 and 10- ( - 7 ) i s output a s 1 . E- 7 .
if d
=

Values represented in the exp l icit point tmscaled representation sha l l be output with
up to d s ignif icant dec imal digits and a period ; tra i l ing zeros in the fractional
part ny be omitted . A number with a magnitude less than 1 shal l be represented with
no d igits to the l eft of the period . This form requires up to d+3 characters counting
the s ign , the period and the tra i l ing space . Values represented in the exp l icit point
sca led representation s ha l l be output in the format
s ignif icand E s ign integer
where the value x of the s ignif icand is in the range 1 < x < 10 and is to be repre
sented with exactly d d igits of precis ion , and where the exrad component has one to e
digits . Tra i l ing zeros may be omitted in the fractional part of the s ignificand and

- 82 -

leading zeros may be omitted from the exrad . A period sha l l be printed as part of the
s ignif icand . This form requires up to d+e+S characters counting the two s igns , the
period , the "E" and a tra i l ing space .
Printing string values
String-expressions s ha l l be evaluated to generate the corresponding string of charac
ters .
Print separators and tabs
The evaluation of the semico lon separator
string of zero length .

s ha l l generate the nul l string ,

i.e. ,

The evaluation of a tab-ca l l or a comma separator depends upon the string of charac
ters a lready generated by the current or previous print-s tatements . The "current
l ine" is the ( possibly empty ) string of characters generated s ince the beginning of
execution or s ince the last end-of- l ine was generated .
The "co lumnar position" of the current l ine is the print pos ition that wi l l be occu
pied by the next character output to that l i ne . Print positions sha l l be numbered
consecutive ly from the left, starting with pos ition one . Each time a character in po
s it ions 2 / 0 through 7 / 14 of the standard character set is generated , the columnar po
s ition sha l l be increased by one . Each t ime an end - of - l ine is generated , the columnar
position s ha l l be reset to one . The effect of other characters on the columnar pos i
t i o n i s imp lementation-defined .
The "margin" is the max imum columnar pos ition in which a character may appear . Prior
to execution of a set-statement with MARGIN , the margin sha l l be imp lementation
defined , but mus t be not l ess than the defau l t zone width . A marg in of sha l l
indicate that the co lumnar pos ition may b e arbitrari l y large .
Each print - l ine is divided into a fixed number of print zones where the number of
zones and the length of each zone is implementation-def ined . A l l print zones , except
possibly the last one on a l ine , which may be shorter , sha l l have the same width . The
defau l t width of a zone sha l l be at least d+e+6 print positions . The zone width may
be changed by the execution of a set-s tatement with ZONEWIDTH . ZONEWIDTH may be set
to any value greater than zero , but not greater than the current marg in .
The purpose of the tab-ca l l is to set the co lumnar posit ion of the current line to
the specif ied value prior to printing the next print- item. More prec ise l y , the argu
ment of the tab-ca l l sha l l be evaluated and rounded to the nearest integer n . If n is
l ess than one , an exception sha l l occur . If n is greater than the margin m, then n
sha l l be reduced by an integral multip l e of m so that it is in the range 1 < n < m ;
i . e . , n sha l l b e s e t equal t o MOD ( n- l , m ) + l .
I f the columnar pos ition o f the current l ine is less than or equal to n , then spaces
sha l l be generated , if necessary , to set the columnar pos ition to n; if the co lumnar
pos ition of the current l ine is greater than n , then an end-of - l ine sha l l be gener
ated f o l l owed by n- 1 spaces to set the columnar pos ition of the new current l ine
to n .
The evaluation o f the comma print-separator depends upon the columnar pos ition . If
this pos ition is neither in the last print zone on a l ine nor beyond the margin, then
one or more spaces sha l l be generated to set the columnar pos ition to the beginning
of the next print zone on the l ine . If the initial co l umnar posit ion is in the last
print zone on a l ine , then an end - of - l ine sha l l be generated . Fina l l y , if the initial
columnar position is beyond the margin ( as it wou ld be if evaluat ion of the last
print- item exact ly f i l led the l ine ) , then an end-of- l ine sha l l be generated .

- 83 -

Over length output l ines


Whenever the colwnnar pos ition is greater than one and the generation of the next
print - item would cause a character to appear beyond the margin, then an end-of - l ine
sha l l be generated prior to the characters generated by that print- item .
During tl1e generation of a print- item , whenever that generation would cause a charac
ter to appear beyond the margin , an end - of - l ine sha l l be generated prior to that
character , resetting the colwnnar pos i tion to one .
End of print- list
When evaluation of a print- list is comp leted , if that print- l is t d id not end with a
print - separator , then a f inal end-of - l ine sha l l be generated ; otherwise , no such f i
nal end -of- l ine sha l l b e generated .
A comp l etely empty print- l is t sha l l generate an end-of - l ine , thereby comp leting the
current l ine of output . If this l ine contained no characters , then a b l ank l ine sha l l
resu l t .
Setting the margin
Execution of a set- s tatement with a MARGIN sha l l cause its index to be evaluated and
to become the new margin . The change in the margin sha l l take effect immediate l y ,
even if a l ine of output is partial ly f i l led . The set-statement with a MARGIN affects
only unformatted output .
Sett ing the zone width
Execution of a set-statement with a ZONEWIDTH sha l l cause its index to be evaluated
and to become the new zone width . The change in the zone width sha l l take effect im
mediatel y , even if a l ine of output is partia l ly f i l led . The set-statement with a
ZONEWIDTH affects only unformatted output .
Ask-statement
Execution of an ask-statement sha l l cause the variab les in the ask- io - l is t to be as
s igned values corresponding to the current margin , if MARGIN is present , or current
zonewidth , if ZONEWIDTH is present . If the co lwnnar pos ition may be arbitrarily
large , then the value MAXNUM sha l l be returned to the numeric-variab l e in the ask
statement with MARGIN .
10 . 3 . 5 Exceptions
- The value of the index in a tab-cal l is less than one ( 4005 , nonfata l : supp l y one
and continue) .
- The value of the index in a set- statement with a MARGIN is less than the current
zonewidth ( 4006 , fata l ) .
The value of the index in a set - s tatement with a ZONEWIDTH is less than one or
greater than the current margin ( 4007 , fatal ) .
10 . 3 . 6 Remarks
The character string generated by printing the value of a numeric-expression contains
a s ing le tra i l ing space . If the generation of that space woul d cause the co lwnnar po
s ition to exceed the margin by more than one , then imp l ementations may choose not to
generate that spac e , thereby a l l owing the number to be printed in the final print
zone on a l ine .

- 84 -

Imp lementations may choose to use a lower-case "e" in printing numerical values us ing
the exp l icit point scaled representation .
The print- separator fo l lowing a tab-cal l is s ignificant in the same manner that it is
s ignificant f o l lowing an express ion .
10 . 4 Formatted Output
10 . 4 . 1 General Description
A print- statement may control the format of output by specifying an image to which
tl1at output must conform . The image is specif ied either within the print-statement or
in a separate image - l ine .
10 . 4 . 2 Syntax
1.
2.
3.
4.
5.
6.
7.
8.

print- statement
formatted-print- l ist
image
output - l ist
image- l ine
format- string
l itera l - string
l itera l - item

9 . format- item
10 . justif ier
11 . f l oating-characters
12 . i-format- item
13 . digit-place
14 . - format- item
15 . e-format- item

>

PRINT formatted-print- l ist


USING image ( co lon output - l ist ) ?
l ine-number I string-express ion
express ion ( comma expression ) >': semico lon?
l ine-number IMAGE colon format - string end-of - l ine
l itera l - string ( format- item l itera l - string ) >'<
l i tera l - i tern>'<
l etter I digit I apostrophe I co lon I equa l s - s ign I
exc lamation-mark I left-parenthesis I
question-mark I right-parenthes is I
semico lon I s l ant I space I underl ine
( justifier? f loating-characters ( i -format- item
-format- item I e- format- item) ) I justifier
greater-than-sign I less-than-s ign
( p lus - s ign>'< I minus - s ign) dol lar-s ign? I d o l lar-s ign>'<
( p lus - s ign I minus -sign ) ?
d igit-p lace digit-place>'< ( comma digit-p lace
digit-p lace>'< )>'<
asterisk I number-s ign I percent - s ign
period number- s ign number- s ign>'< I i -format- i tem
period number - s ign>'<
( i- format- item I - format- item) circumf lex-accent
circumf lex-accent c ircumf lex-accent
circumf lex-accent>'<

An image which is a l ine- number sha l l refer to an image- l ine in the same program
unit . Any l eading spaces fo l lowing the co lon in an image- l ine are part of the format
string .
Al l digit-places in an i - format- item sha l l be the same characte r , i . e . , a l l sha l l be
number- s igns , a l l sha l l be percent- s igns , or a l l sha l l be asteri sks .
10 . 4 . 3 Examples
10 LET sum
20
20 PRINT USING "The answer is #tNI . tl" : sum
produces
"The answer is 20 . 01 1
=

30 PRINT USING 40 : 342 , 42 . 02 1


4 0 IMAGE : RATE O F LOSS #### EQUALS #### . ## POUNDS
produces "RATE OF LOSS 342 EQUALS
42 . 02 POUNDS" .
10 LET A$
" <##tl#tf ttll## . ###tl ###tl . #### - - - - ,
20 PRINT USING A$ : 1 , 1 , 1
produces
"
1
l . 0000 1000 . OOOOE-0311
=

- 85 -

60 PRINT USING 7 0 : " ONE" , "TWO" , "THREE"


70 IMAGE : Z<####>#### ########Z
produces "ZONE
TWO
THREE Z" .
80 LEI A$ = "Pay $>'t>'t . #It on ### %% 19%%"
90 PRINT USING A$ : 1 , "May" , 2 , 8 3
produces
"Pay $>'tl . OO on May 02 1983 11
10 PRINT USING " <%% . If# > - - -$## . ## $$$+>'ddt" : 3 . 1 , - 12 34 . 567 , 2
produces
"003 . 10 - $ 1234 . 5 7
$+>':>'c2" .
10 PRINT USING " < $ $$$ . #It $ $ $ $ . 11##- - - - - " : - . 02 , - . 02
11
produces
$ - . 02
$ - . 200E-001" .
10 PRINT USING "$>':>':>': , >'t>'o . #It" : 1234 . 7 7 7 7
1 1 $>':>'' 1 , 234 . 7 8 11

produces

10 . 4 . 4 Semantics
A print-statement with a formatted-print- l ist identifies a format- s tring to be used

to contro l the output generated by the evaluation of the output - l i s t . If the image is
specified via a l ine-number , then the format- s tring is contained in the image- l ine
with the indicated l ine-number ; otherwise , it is the value of the string-expres s ion .
Format string analys i s
The selected format- string sha l l b e analyzed a s a number of format- i tems separated by
possibly zero - length l itera l - s tr ings .
Format- items sha l l be found within the format-string by scanning the latter from left
to right . A search sha l l be made for the f irst character which is the start of a syn
tactica l ly correct format- item, and the longest such format- item starting at that
character identif ied . The scan for format- items shal l continue in this way up to the
end of the format-string , the search for the start of each new format- item beginning
at the character immediately beyond the previous ly identified format- item . Corre
sponding to each format-item sha l l be an output field whose length equa l s the number
of characters in the format- item ( inc luding the justifier , f loating-characters ,
digit-p laces , commas , period , number-s igns , and circumf lex-accents ) . Characters which
are not part of any format- item s ha l l be l iteral - items .
Format-strings which are defined in image- l ines sha l l be interpreted as ending with
the last character in the l ine which is not a space or end-of- l ine .
Literal strings and output fields
A sequence of values to be output sha l l be generated by evaluating each expression in

the output - l ist in sequence . As each value is generated , the l iteral - string preceding
the next format- item in the format- string sha l l first be cop ied unchanged into the
string of characters being generated . Then a number of cl1aracters equal to the l ength
of the output field determined by that format-item sha l l be generated , as fo l l ows .
Formatted numeric output
Numeric values

sha l l be rounded and represented in a manner corresponding to the

format- item used . If a j ustif ier is present in the format- item , it shal l be replaced
by the character immediately to its right . If , however , the character to its right is
a period , or if there is no character to its right , then the justifier sha l l be re
p laced by a number - s ign .
First , a representation for the magnitude of the value sha l l be generated .
- For an i-format- item , the value sha l l be rounded to the nearest integer and repre
sented using imp l icit po int unsealed notation .

- 86 -

For an f - format- item , the value sha l l be represented us ing exp l icit point unsea led
notation, rounding the representation or extending it on the right with zeros in
accordance with the number of number - s igns fo l l owing the period in the format
item .
- For both i - format- items and f - format- items , leading zeros to the left of the im
p l icit or exp l icit decimal point s ha l l not be generated , unless this resu lts in no
d igits being generated . In that cas e , the character 1 10 11 sha l l be generated immedi
ately to the left of the exp l icit or imp l icit decimal point . After this , if there
remain unf i l led digit-p laces , then leading zeros sha l l be generated in the integer
or to the left of the period when a percent-s ign is used as a d igit-p lace , lead ing
asterisks when an asterisk is used as a d igit-p lac e , and leading spaces when a
number-s ign is used as a d igit-p lace , such that the number of characters to the
left of the imp l icit or exp l icit decimal po int is equa l to the number of digit
p laces in the format - item .
For an e- format- item , the value sha l l be represented us ing exp l icit or imp l icit
point scaled notation, corresponding to the use of an f - format- item or i - format
item , respectivel y , within the e-format- item . The s ignif icand for nonzero values
sha l l be scaled by powers of ten such that the leftmost d igit-place or number- s ign
pos ition is occupied by a nonzero digit . In a l l other respects , the s ignificand
sha l l be generated according to the above rules for i - format- items and - format
items . The number of circumf lex-accents in an e- format- item sha l l determine the
number of characters in the exrad . The f irst of these characters s ha l l be the let
ter E, the next a mandatory s ign, and the remaining characters the representation
of the magnitude of the exrad , with leading zeros being generated so that the num
ber of characters in the exrad equa ls the number of circumf lex-accents in the
format- item . If the exponent is zero , the mandatory s ign is positive ; the exponent
of zero is zero .
Second , commas sha l l be inserted in the numeric representation wherever a comma oc
curs in the format- item , provided at least one d igit has been generated to the left
of the point of insertion; if no d igit has been generated to tl1e left of th is point ,
then an asterisk sha l l be inserted if the digit-p lace immediately to the left is an
asterisk, and a space inserted if the d igit-p lace immediately to the left is a
number- s ign .
Third , leading characters composed of s ign , dol l ar - s ign , and space s ha l l be generated
according to the fol lowing table :
Floating - characters

Leading Characters Generated

Firsu'<

Non-negative
I I $ 11
I I$ I I
II II
1 1 +$ 11
I I $+"
11 +11
1 1 $ 11
1111

Last
$

$
+
$
+
$
none

none
$
+
none
none
none

Negative
1 1 _ $ 11
11 $ _ 1 1
"-"
" - $"
11 $ - "
"-"
"$-"
11_11

,., may be several occurrences


Fina l l y , the representation of the numeric value so generated sha l l be extended by
spaces on the left so that its length equal s that of the format- item . This has the
effect of right- j ustifying a numeric- representation in an output fie l d .

- 87 -

Formatted string output


A string value may be output us ing any type of format- item . The string s ha l l be ex
tended by spaces so that its l ength equals that of the format- item . These space sha l l

be added o n the l eft ( for right-justif ication ) if the format- item begins with a
greater- than - s ign , on the right ( for left-justif ication) if it begins with a less
than- s ign, and equa l ly on e i ther s ide ( for centering ) otherwise ; if the number of
spaces required in the last case is odd , the extra space sha l l be added on the right .
Formatted Output Completion
If the number of values to be output exceeds the number of format- items in the
format- s tring , an end-of- l ine sha l l be generated each time the end of the format
string is reached and the format- string reused for the remaining expressions . I f
format- i tems remain i n the format-string after a l l values have been output , then the
next l itera l - s tring , if any , sha l l be output . Generation of characters is a lways ter
minated beginning at the first unused format- item . Fina l l y , an end-of- l ine sha l l be
generated after a l l other character generation is completed , unless the output- l is t
ends with a semico lon , in which case n o such end - of - l ine sha l l b e generated .
The current margin sha l l not affect the output ; in particular , no end-of - l ine sha l l
b e generated upon formatted output j ust because the margin i s exceeded . If the execu
tion of a program reaches an image- l ine , it sha l l proceed to the next l ine with no
further effec t .
10 . 4 . 5 Exceptions
- An inva l id format- string is specif ied in a formatted-print- l is t ( 82 0 1 , fatal ) .
- A formatted -print - l ist contains an output- l i s t , but there is no format- item in the
format-string ( 8202 , fatal ) .

An output string , whether generated from a string-expression or a numeric


expression, is longer than its corresponding format- item ( 8203 , nonfatal : f i l l the
output field with asterisks , report the unformatted representation of the value on
the next l ine , and continue printing on the fo l lowing l ine in a pos ition identical
to the pos i tion which woul d have resulted if no exception had occurred ) .
- The exrad for numeric output exceeds the space a l located by circumf lex-accents in a
format- item ( 8204 , nonfatal : f i l l the output f ie ld with asterisks , report the un
formatted representation of the va lue , and continue ) .
10 . 4 . 6 Remarks
Since format-strings may be evaluated dynamical ly , errors in them ( even if occurring
in an image- l ine and therefore statical ly determined ) may be treated as exceptions .
Imp lementations may choose to use a lower case "e" in printing numerical values using
the exp l ic it point scaled representation .
The integer part of a number generated with an i - format-item or - format- item may
val id ly contain more digits than there are digit-p laces in the format- item , as long
as the f l oating-characters provide suf ficient room .
Negative numeric values a lways generate a minus - s ign . The corresponding format- item
must provide room for this minus - s ign with f loating-characters , s ince d igit-p laces
are comp lete ly f i l led by d ig its , or by leading spaces , zeros , or asterisks . In par
ticular , a format- item with no f l oating-characters , or with only a s ingl e d o l lar - s ign
as a f loating-character , w i l l cause exception 8203 if an attempt is made to f i l l that
field with a negative value .

- 88 -

10 . 5 Array Input and Output


10 . 5 . 1 General Description
Statements are provided which enable entire arrays to be input or output . These
statements general ize the input and output statements which manipulate s ingl e values
( see 10 . 1 to 10 . 4 ) .
10 . 5 . 2 Syntax
1.
2.
3.
4.
5.
6.

7.
8.
9.
10 .
11.

> MAT READ ( missing- recovery colon ) ? redim-array- l ist


red im-array ( comma redim-array ) '''
array-name redim?
> MAT INPUT input-modifier- list? ( redim-array- l is t
variab le- length-vector )
array-name l eft-parenthesis question-mark
variab le- length-vector
right-parenthes is
array - l ine- input-statement> MAT LINE INPUT input-mod if ier- l is t ?
redim- string-array - list
redim- string-array- l ist
redim-string-array ( comma redim-string-array ) >'<
redim-string-array
string-array redim?
array-print - statement
> MAT PRINT ( array-print - l ist I ( USING image co lon
array-output - l i st ) )
array-name ( print- separator array-name ) >'<
array-print - list
print- separator ?
array-output- l ist
array-name ( comma array- name ) >'< semico lon?
array - read - statement
redim-array- list
redim-array
array - input-statement

A red im and the array in its redim-array s ha l l have the same number of dimens ions .
A variab l e - length-vector must be one-d imensiona l .
10 . 5 . 3 Examples
1 . MAT
MAT
4 . MAT
MAT
MAT
8 . MAT
9 . MAT

READ A
READ A ( M , N ) , B
INPUT A$ ( 3 , 4 )
INPUT X ( ? )
INPUT PROMPT "Enter data :
LINE INPUT A$
PRINT A ; B , C ;

"

X( ? )

1 0 . 5 . 4 Semantics
The array read s tatement
Execution of an array- read - s tatement s ha l l cause arrays in the redim-array- l is t to be
ass igned , in order , values from the data sequence created by data-statements in the
program-unit containing that statement . Values sha l l be ass igned to a l l e lements in
each array in row maj or order , ( i . e . , the last subscript varying most rap i d l y , then
the next to last subscrip t , if any , etc . ) with each success ive value being obtained
from the datum in the data sequence indicated by the po inter for the sequence and the
pointer being advanced beyond that datum .
The type of each datum in the data sequence sha l l correspond to the type of the
array-element to which it is to be ass igned ( see 10 . 1 ) .
I f a redim is present then dynamic redimensioning sha l l take p l ace before values are
ass igned to the redimensioned array . The redimens ioning sha l l be done accord ing to
the rules for bounds in array-dec l arations . The values of the indices sha l l be used
as the new lower and upper bounds for the array . If an exception occurs when attempt
ing to redimens ion an array , it sha l l retain its o l d d imens ions . Redims in the redim-

- 89 -

array-list shal l be evaluated after values have been ass igned to the arrays preceding
them (i . e . , to the l eft of them) in the redim-array-lis t .
The handl ing o f insufficient data with o r without a miss ing-recovery shal l work as
des cribed in 10 . 1 .
If the evaluation of a numeric datum causes an underfl ow then its value shal l be re
pl aced by zero .
The array input statement
Execution of an array-input-statement shal l cause execution of the program to be sus
pended until a valid input-reply, as s pecified bel ow, has been supplied. An array
input-statement shal l cause arrays in the redim-array-list to be ass igned, in order,
values from the input-repl y . Values shal l be ass igned to al l el ements in each array
in row maj or order .
In the interactive mode, the user of the program sha l l be informed of the need to
supply data by the output of an input-prompt . The prompt is identical to that of the
input-prompt of the input-statement .
The input-modifier-list, if present, s hal l work as described in 10 . 2 .
The type of each datum in the input-reply shall correspond to the type of the array
element to which it is to be ass igned .
If a redim is present then dynamic redimensioning shal l take pl ace as described above
for the array-read-statement before values are ass igned to the redimensioned array .
Redims in the redim-array-list sha l l be evaluated after values have been ass igned to
the redim-arrays preceding them (i . e . , to the l eft of them) in the redim-array-l is t .
I f the recovery procedure for an input exception causes input data t o b e re-supplied
to an array which was redimensioned after tl1e original ass ignment of data to it, but
before the exception occurred, the effect is implementation-defined . Data in res ponse
to a request for array input need not be supplied in a single input-reply. If the
array-list has not been completely supplied with data and the input-reply contains a
final comma , then the input-prompt shal l be issued and a further input-reply shal l be
requested to obtain more data.
If the evaluation of a numeric datum causes an underfl ow then its value shal l be re
pl aced by zero .
Input of variable l ength vectors
If a variabl e-length-vector occurs in an array-input-statement, then as many data as
are present in the input-reply (or sequence of input-repl ies up to and incl uding the
first which does not end with a comma) shal l be s uppl ied as input for that vector.
As s ignment of data shal l begin with the current l ower bound for the vector . After as
s ignment, the vector shal l be redimens ioned dynamically by s etting the upper bound
for its s ubs cript equal to the subs cript of the element receiving the l ast datum. The
number of data values ass igned to the variable-l ength-vector shal l not exceed the
original s ize for that vector as s pecified in its array-decl aration.
The type of each datum in the input-reply sha l l correspond to the type of the array .
The array-l ine-input-statement
When an array-l ine-input-statement is executed, a l ine-input-reply shal l be requested
for each element of each string-array in the string-array-list in the same fashion
that an input reply is requested and shal l assign the entire contents of successive
l ine-input-repl ies (excluding their end-of-l ines ) in row major order to el ements of
the string-arrays in the string-array-l is t . The number of l ine-input-repl ies re
quested shal l equal the number of elements requiring values .

- 90 -

In the

interactive mod e ,

the user

of

the program

shal l

be

informed

of

the

need

to

supp ly data by the output of an input-promp t .


The input-mo d i f ier - l i s t ,

if present,

sha l l work as descr ibed in

10 . 2 .

If a redim is present then dynamic redimensioning sha l l take p lace as described above
for the array-read - s tatement before values are ass igned to
Redims

in

the redim-string-array- l i s t

sha l l be

the redimensioned array .

eva luated after

s igned to the redim-string-arrays preceding them

(i.e. ,

to the

values have been as


left of them )

in the

of a l l elements

in a l l

red im-string-array - l is t .
The array print s tatement
Execution of

an array-print - s tatement

sha l l

cause

An

arrays in the array-print- l is t t o be printed .

the values

end - of - l ine sha l l b e generated prior

to any characters generated by an array-print - s tatement if the current l ine o f output


is nonempty .
For an array-print - s tatement with an array-print - l is t ,

the characters

generated

for

transmi s s ion to an exte rna l device by the printing of a two - d imensional array are a l
most prec i s e l y those that would be generated
l isted , row by row ,

if the e l ements

in the print- l i st of a print-statement ,

tor which fo l lows the array-name in the array-print- l i s t


no separator f o l lows the array name ) .

in that array had been

separated by the separa

( or separated by a co mma if

The only additional characters generated sha l l

b e a n end - of - l ine each time a row of the array has been printed

( i f such a n end -of

l ine has not a lready been generated ) . A three - d imens ional array sha l l be printed l ike
a series

of two - d imensional

arrays ,

one

for each value

of the first subscr ipt ,

with

an extra end - o f - l ine generated between each value of the f irst subscrip t . When a one
dimens ional array

if it were a
Final l y ,

an

is printed ,

it sha l l

be treated

l ike a row-vector ,

and printed as

x N array .

extra

end - of - l ine

sha l l

be

generated

between

the output

for

success ive

arrays in an array-print - l i s t .
For a n array-print - s tatement with a n array- output- l is t ,
transmis s ion to an external device are
elements

of

output - l is t
statement .
using an

each array
of
No

had been

a print - s tatement ,

l i sted
us ing

add i t iona l end - of - l ines

image ,

if

there

is

the characters generated for

exac t ly those that would be generated


array
the

by array ,

same

image

in
as

sha l l be generated .

row-maj or
that

in

order ,

if the
in

the

the array-print

As with a print - s tatement

no tra i l ing semicolon in the array-output- l i s t ,

a f inal

end - of - l ine sha l l be generated after a l l other output from the array-print - s tatement .
If there is such a semicolon ,

10 . 5 . 5

then this fina l end - of - l ine sha l l not be generated .

Exceptions
The redim- array- l i st in an array - read - s tatement requires more data
in the remainder of the data sequence and no

( 8001 ,
- An

miss ing- recovery has

than

are present

been

specified

fata l ) .

attempt i s made to assign a value to an element of a numeric-array from a datum

in the data sequence which is not a numer ic- constant

( 810 1 ,

fatal ) .

The a s s i gnment o f a datum during execution of an array-read - s tatement results


string overf low

( 10 5 3 ,

- The eva luat ion of a numeric datum in a data- l i s t causes an overflow


- The

l ine

supp l ied

in response to a request for array input

correct input -reply


- A

datum

nonfata l :

supp l ied

as

in a

fatal ) .

( 8102 ,
input

nonfata l :
for

( 1006 ,

fata l ) .

is not a syntactica l ly

request that a new input-reply be supp l ied ) .

numeric-array

is

not

numer ic- constant

request that the current input -reply be resupp l ied ) .

( 8 103 ,

- 91 -

- There are insufficient data in an input- rep l y not containing a final comma ( 8002 ,
nonfatal : request that the current input-rep l y be resupp l ied ) .
- There are too many data in an input-rep ly or there are j ust enough data and the
input- rep l y ends with a comma ( 8003 , nonfatal reques t that the current input-repl y
be resupp l ied ) .
The evaluation of a numeric datum in an input-rep ly causes an over f l ow ( 1007 ,
nonfata l : reques t that the current input-rep l y be resupp l ied ) .
- The assignment of a string datum during execution of an array- input-statement or an
array- l ine- input-statement causes a string overf low ( 1054 , nonfatal : request that
the current input-rep ly or l ine- input-rep ly be resupp l ied ) .
- The total number of e l ements required for a redimensioned array exceeds the number
of e l ements reserved by the array ' s origina l d imensions ( 5001 , fatal ) .
The f irst index in a redim-bounds is greater than the second index ( 6005 , fata l ) .
- A redim-bounds cons ists of a s ingl e index which is less than the defau l t lower
bound in effect ( 6005 , fata l ) .
- A val id input-rep ly or l ine- input-rep ly has not been supp l ied within the number of
seconds specified by a t imeout- expression in an input-mod if ier - l is t ( 8401 , fata l ) .
- The value of numeric-expression used as a time-expres sion is less than zero ( 8402 ,
fatal ) .
- An invalid format-string is specif ied in an array-print-statement ( 8201 , fata l ) .
- An array-print-statement contains an array-output - l is t , but there is no format- item
in the format-string ( 8202 , fata l ) .
10 . 5 . 6 Remarks
This S tandard does not require an imp l ementation to output ( i . e . , echo ) the input
rep l y or l ine- input-rep l y .
This S tandard does not require an imp lementation t o provide fac i l ities for correcting
erroneous input-rep l ies , though such fac i l ities may be provided .
Implementations may choose to treat underflows as exceptions ( 1507 , nonfatal : supp ly
zero and continue ) . I n BASIC-2 imp l ementations , this permits interception by
exception hand lers .

- 92 -

1 1.

F I LE S

- 93 -

1 1 . FILES
Two d i fferent leve l s of f i le processing are defined for BASI C - 1 and BASIC- 2 .
combinations

of

f i le organization

and

record

types

permitted

for the two

The d i fferent

leve l s

are

de

tailed below.
The production rules pe rmitted
indentation

permits

to

in BASIC-2 only are so identified .

d i stinguish

the

parts

of

the

BASIC - 2 only from the parts of text va l id for both leve l s .


in

BAS IC- 1

are

true

subset

these features would be

of

those

too difficult

permitted

in

to present

In the tex t , the usage of

text valid

for

BAS IC- 1

only

or

for

A l though the features permitted

BASIC- 2 ,

in a s ingle

when

the

tex t ,

identification

this

text

is

of

repeated

for each of the two leve l s and so identified .


By conventi o n , production rules referring to BASIC- 1 and BASIC-2 are cal led core rules and
production rules referring only to BAS I C - 2 are cal led enhanced rules .
Fi les are organized c o l lections

of data external to BASIC programs .

They provide the user

with a means of saving data developed during execution of a program and then retr ieving and
modifying that data during subsequent execution of BASIC programs . The process by which ex
ternal data is transferred to or from a program i s cal led input or output , respective l y .
imp lementat ion-def ined means must be provided
of f i l es .

for the creation ,

An

preservation and retrieval

Input and output operations to these f i les must perform as specif ied in this sec

tion .
This

section describes the

some

cases ,

these

Standard makes

logical appearance

attributes

no

may

presumptions

reflect

of

f i les

physical

and devices to a BASIC program .

characteristics ,

concerning the physical

but

representation

in

or

general

In

this

organization

of

f i les or devices .
The meaning

of certain

terms used

throughout this

section is as f o l lows .

is an entity, a sequence of which constitutes a f i l e .


a f i l e e l ement is a record ,
a

value .

Assoc iated

with

Thus ,

for relative f i les it is a record area ,

each

file

during

execution

is

A " f i le e l ement"

for keyed and sequential f i les ,

"file

f i l e e l ement upon comp letion of

for s tream f i les ,


po inter" ,

unique ly identifies

a particular

to the end of f i le .

I f the po inter is at the beginning of the f i l e , then it

f irst f i l e e l ement ,

if any .

If a f i l e is an empty sequence ,

f i l e are the same , and the po inter identifies this


the " next" f i l e e l ement,
stituted .

the

s tatement ,

or

it is
always
points

identifies

the

then the beginning and end of


Whenever reference

is made to

it is understood that if none such exists , the end of f i le is sub

For sequentia l ,

ately f o l lowing

location .

any

which

stream and keyed f i les ,

l a s t f i le

e l ement .

the "end of f i le" is the location immed i

F o r relative

files ,

the

" end

of

f i l e"

immediately

fo l lows the last existing record , and thus identifies an empty record area .
BASIC- 1
There are

two

kinds

of

f i l e - organizatio n :

sequential

and

stream .

sequential

f i l e is a sequence of records . A s tream f i le is a sequence of values .


There are two kinds of record- type :
sequence

of

characters .

An

disp lay and

internal record

is a

internal . A d i sp lay record

is a

sequence of typed values .

Dis

p lay records provide for the exchange of data between systems emp loying d i ffer
ent internal representations for numeric and string values , and also manipulate
data in human- readab le form.

Internal records provide for effic ient manipulation

of data within a s ingle system.


The fo l lowing combinations of f i le- organization and record- type are supported :
- sequential d i sp lay
- sequential internal
- stream internal
A l l o ther combinations of f i le-organization and record- type are imp lementation
defined .

- 94 -

There are f ive statements which operate on the f i l e as a who le and are thus
cal led " f i l e operations" : OPEN , CLOSE , ERASE , SET and ASK . There are f ive
s tatements which app ly to individual f i l e elements and are known as "record
operations" : INPUT , PRINT , READ , WRITE and SET with pointer-contro l , inc luding
the variations using MAT and LINE . References to " INPUT operations" , "WRITE
operations" , and so forth should be understood to inc lude any of the statements
us ing the keyword in question, e . g . "WRITE operations" includes WRITE and
MAT WRITE . The f ive record operations can affect data within a f i l e , variables
within the program and the file pointer .
PRINT and WRITE affect f i le data and the po inter , READ and INPUT affect program
variables and the pointer . SET with po inter-items obvious ly affects only the
pointer .
BASIC-2
There are four kinds of f i le -organization : sequential , stream, relative and
keyed . Sequential and keyed f i les are sequences of records . A relative f i le is a
sequence of record areas , each of which may or may not contain a record . A
stream f i le is a sequence of values .
There are three kinds of record - typ e : disp lay, internal and native . An internal
record is a sequence of typed values . A native record is a sequence of field s ,
a s described by a programme -spec if ied temp late . Disp lay records provide for the
exchange of data between systems emp loying different internal representations
for numeric and string values , and also manipulate data in human- readab le form .
Internal records provide for efficient manipulation o f data within a s ingle sys
tem . Native records provide for the exchange of data among d ifferent language
processors within a s ingle system .
The f o l lowing combinations of f i le-organization and record- type are supported :
-

sequential d isplay
sequential internal
stream internal
relative internal ( enhanced internal )
keyed internal ( enhanced internal )
sequential native ( enhanced native )
relative native ( enhanced native )
keyed re lative ( enhanced native )

A l l other combinations of f i l e -organization and record-type are imp lementation


defined .
W ithin each subsection , the syntax rules for sequential d isp lay , sequential in
ternal and stream internal are presented f irst , f o l lowed by additional syntax
productions which pertain to enhanced f i les . Some of the enhanced productions
apply only to enhanced native f i les : these are preceded by an "N" .
There are f ive statements which operate on the f i l e as a who le and are thus
cal led " f i l e operations" : OPEN, CLOSE , ERASE , SET and ASK . There are seven
s tatements which app ly to individual f i le elements and are known as "record
operations" : INPUT, PRINT , READ , WRITE, REWRITE , DELETE and SET with pointer
contro l , inc luding the variations using MAT and LINE . References to " INPUT
operations " , "WRITE operations " , and so forth should be understood to include
any of the statements using the keyword in question, e . g . "WRITE operations" in
c ludes WRITE and MAT WRITE . The seven record operations can affect data within a
f i l e , variables within the program and the f i le po inter . PRINT , WRITE , REWRITE
and DELETE affect f i le data and the pointer , READ and INPUT affect program vari
ables and the pointer . S ET with pointer- items affects only the pointer .

- 95 -

Devices
Not all input or output is to or from a f i l e , as defined above . An imp lementation may al low
f i le process ing statements to apply as wel l to devices , such as a termina l , a l ine p rinter
or commun ications l ine .
When the term " f i le" is used throughout chapter 1 1 , it should general ly be understood to
mean any source or destination of external data, i . e . either a true f i l e or a device . In
certain contexts where it is necessary to distinguish between the two , the terms "true
f i le" and "Device"w i l l be used for emphasis .
Devices differ from f i les in the fol lowing ways :
- It is imp lementation-defined whether data written to any given device is stored there and
may later be retrieved by input operations ( see 1 1 . 1 ) .
- It is imp lementat ion-def ined whether a given device is erasab le ( see 11 . 1 ) .
- RELATIVE and KEYED f i le-organizations are not a l l owed for devices ( see 1 1 . 1 ) . ( not re levant to BASIC - 1 )
- A device need not support a l l access modes ( see 1 1 . 1 ) .
- A device need not support the minimum record s ize of 13 2 ( see 11 . 1 ) . However , the
imp lementation must document the minimum record - s i z e for each device supported .
- It is imp lementation-defined whether a given device has record- s etter capabi l ity ( see
11 . 2 ) .
- It is imp l ementation-def ined what condition causes the data-found condition to be set
true or false for a g iven device ( see 1 1 . 2 ) .
- For interactive terminal devices only, the s emantics of the input-contro l - i tems prompt
speci f ier , timeout-express ion, and time enquiry must be supported . The imp lementation
must define which devices , if any , are interactive terminal devices . The effect of these
input-contro l - items on other devices and on true f i les is imp lementation-defined ( see
11.4) .
- I t is imp l ementation-defined whether the f o l lowing cond itions are treated as fatal excep
tions , as defined in 1 1 , or as nonfatal , as defined in 10 ( in which case the recovery
procedure is app l ied ) , when these cond it ions occur within INPUT operations on a device
( see 1 1 . 4 ) .
Section 1 1

Section 10

8105
8101

8102
8103

8012
8013
1008
1 105

8002
8003
1007
1054

Condition
Syntax error in input-rep ly
Datum from a numeric-variable not
a numer i c -constant
Too few data in input - rep ly
Too many data in input-rep ly
Numeric overf low on input
String overflow on input

The f o l l owing tables provide an overview of the various f i l e fac i l ities . For the ful l spec
i f i cations , see 1 1 . 1 through 1 1 . 4 .
- TABLE 1 FILE-ORGANIZATION VERSUS OPERATIONS AND RECORD- SETTERS .
This table i l lustrates which combination of record operations and record-setter are le
gal under a given f i le -organ i zation , thus the organization i s defined by the capab i l i
ties of record manipulation it a l l ows . Combinations of operations and record- setters
which do not appear in the table are syntax errors . Organizations permitted in BASIC- 1
and BASIC-2 are identi fied by l'c , those permitted only in BASIC-2 are identified by **

- 96 -

F i l e Organization

STREAM

RELATIVE

l'<OK
l'<OK 4
lOK

t rD 2
' ID 2
< ID 2
l'<ID 2
l'< ID 2

rlq D 2
l''< ID 2
l''< ID 2
l'm iD 2
r'' ID 2

'n ID
l'n'< ID
'n'< ID
'rl< ID
'rl< ID

2
2
2
2
2

l'<OK
l'<OK
l'<OK
l'<OK
<oK

l'< ID
l'< ID
l'< ID
l'< ID
:'< ID

'< ID
ID
l'<l't i D
l' ID

l'n'< ID
d< ID
l'<l'< ID
:'ti'< ID
l'd< ID

2
2
2
2
2

SEQUENTIAL
Operation
record- s etter

KEYED

INPUT
absent
NEXT
BEGIN
END
SAME

<oK
<oK

PRINT
absent
NEXT
BEGIN
END
SAME

2
2
2
2
2

2
2
2
2
l'ri<ID 2

READ
absent
NEXT
BEGIN
END
SAME
RECORD
KEY

l'<OK
<oK
l'<OK
'oK 4
<oK
'd<
) EX 1
lh'<EX 1

l'<OK
>'<OK
:'<OK
l'<OK 4
l'<OK
,'d<EX 1
,'o'<EX 1

l''<OK
'rl<O K
lh'<OK
h'<OK
>bO K
rl<OK

l''OK
l''OK

:oK
l''OK
:''OK
:''OK
'''OK

l't>'<O K
l'd'OK

lh'< EX 1

l'<l'<OK
:'<l'<OK
l'ri<OK
l'ri<OK
:oK
,'col<EX 1
r:l''O K

WRITE
absent
NEXT
BEGIN
END
SAME
RECORD
KEY ( exact)

l''OK
l''OK
l''OK
,'d<EX 1
,'d<EX 1

l'<l''OK
::'<OK
:''<OK

,'d<EX 1
,'d<EX 1

l'<l''OK
')'d<EX 1

l'(l ID
>'rl' ID
>'t>'' ID
d' ID

>'rl'O K
>'d'O K

:'tl''EX 3
'J'cl<EX 3
lh''EX 3
)'(:'<EX 3
'J'd<EX 3
)'d<EX 1 , 3
,'n'<QK

REWRITE and DELETE


absent
NEXT
BEGIN
END
SAME
RECORD
KEY

l'(l ID
>'rl'ID
>'rl' ID
>'<l'< ID
,.,,., ID

5
5
5
5
5
l'(l'< ID 5
>'<>'< ID 5

5
5
5
5
l't>'' ID 5
>'d< ID 5
l'<l'< ID 5

>'<l''OK
>'n''OK 4
>'rl' OK
>'n'<O K
,.,,,,EX 1

l'<OK
:''OK
:''OK
l''OK
,oK
M< EX 1
,'d<EX 1

l'd<OK
:'d<OK
l''<OK
'<>'<OK
n'<OK
i'<OK
')'()'< EX 1

>'<l''OK
>'n'<OK
>'<l''OK
>'d'OK 4
:'d<OK
,'d<EX 1
l'<l'<OK

SET with pointer- items


absent
NEXT
BEGIN
END
SAME
RECORD
KEY

l'<OK
>''OK
l'<OK
<oK
l''OK
,c;'<EX 1
>'<>EX 1

l'd<O K
>'rl'O K
>'rl<OK
'd<O K
M<OK
M<EX 1
>h'<OK

- 97 -

OK
EX
ID
c
de

- Semantics defined by Standard


-

Exception
Imp l ementation-defined
BASIC- ! and BASIC-2
BASIC-2 only

Notes to the Tab le 1


1 . RECORD is val id only with RELATIVE f iles and KEY with KEYED f i les . ( BASIC-2 only)
2 . INPUT and PRINT are defined for record-type DISPLAY , and DISPLAY is defined only for
SEQUENTIAL .
3 . WRITE to a KEYED f i le must specify an exact key search . ( BASIC-2 only)
4 . END imp l ies that data-found wi l l be false .
5 . REWRITE
and
DELETE
are impl ementation-def ined for f i le-organizations
RELATIVE and KEYED ( BASIC-2 only)

other

then

- TABLE 2 RECORD OPERATIONS VS CONTROLS


This table i l lustrates which contro l features are allowed syntactical ly with the various
operations . SET is only al lowed with pointe r - items . The permitted record setting are
NEXT, BEGIN , END , SAME .

CONTROLS
record- s etter

io-recovery
missing

INPUT
PRINT

cA
cA

'A

READ
WRITE

cA
cA

cA

ricA
>'t'I'< A
l'CA

cl'CA
)'t)'<A
l'CA

REWRITE
DELETE
SET
A
l'c
)'de

interpretation

not
miss ing
cA

image

temp late

)'CA
)'n'cA
ricA

)'CA

-.'cl'<A
l'CA

a l l owed
BASIC - ! and BASIC-2
BASIC-2 only

- TABLE 3 FILE-ORGANIZATION VS RECORD-TYPE


This table i l lustrates which combination of f i le-organization and record-type are defined
by this s tandard .

Record- type
ORGANI ZATION

DISPLAY

SEQUENTIAL
STREAM
RELATIVE
KEYED
A
)'c
l'cic

a l l owed
BASIC-1 and BASIC-2
BASIC-2 only

l'CA

INTERNAL
)'CA
l'CA
'l'dcA
l'ricA

NATIVE
ldtA
'l'o'<A
lc,''A

- 98 -

1 1 . 1 F i le Operations
1 1 . 1 . 1 General Description
There are four statements which affect a f i l e as an entity . The open-statement makes
a f i l e accessible to the program , estab l ishing the connection between the f i le and
the program . S ince the format for identifying f i les may vary with the operating sys
tem , it is as sumed only that with each f i le is assoc iated a string of characters ,
cal led its name , which identif ies the f i le to the operating system . A f i l e is identi
fied within a program by the number of a channel through which it is accessed . The
close-statement terminates the acces s ib i l ity effected by they open-statement . The
erase - statement deletes al l or part of the data within a true f i l e , but may have no
effect on a d evice . The ask- statement is used to inquire about the current status of
the f i l e .
1 1 . 1 . 2 Syntax
BASIC-1 and BASIC-2
1 . open- statement
2.
3.
4.
5.
6.
7.

channel- setter
channel - express ion
f i le-name
f i le-attribute- l ist
f i le-attribute
core - f i le-attribute

>

8 . access-mode
9 . f i le-organization
10 .
11.
12 .
13 .
14 .
15 .

f i le-organization-value
core- file-org-value
record- type
record- type-value
core-record- type-value
record - s ize

16 .
17 .
18 .
19 .
20 .
21.
22 .

c lose- statement
erase-statement
ask-statement
ask- item - l ist
ask- item
ask-attribute-name
core-attribute-name

>

>

>

>

OPEN channel - s etter NAME f i le-name


f i le-attribute - l ist
chann e l - expression colon
number- s ign index
string-expression
( comma f i le-attribute ) :'<
core - f i le-attribute
access -mode I file-organization I record- type I
record- s ize
ACCESS ( INPUT / OUTPUT / OUTIN / string-expres s ion)
ORGANIZATION ( f i le- organization-value
/ string-expression)
core- f i l e-org-value
SEQUENTIAL / STREAM
RECTYPE ( record- type-value I string- express ion)
core-record- type-value
DISPLAY / INTERNAL
RECSIZE ( VARIABLE / string-express ion) ( LENGTH
index ) ?
CLOSE channe l - express ion
ERASE REST ? channel -express ion
ASK channel- setter ask- item - list
ask- item ( comma ask- item ) :'<
ask-attribute-name variable variable:'<
core-attribute-name
ACCESS / DATill1 / ERASABLE / FILETYPE / MARGIN / NAME
I ORGANIZATION I POINTER I RECSIZE I RECTYPE /
SETTER I ZONEWIDTH

BASIC-2 only
23 .
24 .
N25 .
N26 .
27 .
28 .
29 .
30 .
31.

f i le -organization-value
>
enhanced - f i le-org-value
>
record- type-value
enhanced-record-type-value=
f i le -attribute
>
enhanced - f i le-attribute
col late- sequence
ask-attribute- name
>
enhanced-attribute-name

enhanced- f i le-org-value
RELATIVE I KEYED
enhanced-record- type-value
NATIVE
enhanced- f i le-attribute
col late- sequence
COLLATE ( STANDARD I NATIVE I string-expres s ion)
enhanced-attribute-name
RECORD I KEY I COLLATE

- 99 -

A given f i le-attribute must appear at most once in a f i le-attribute - l ist .


A given ask-attribute- name must appear at most once in a ask- item- l ist .
The number and types of variab les in an ask- item must agree with the table below in
Semantics .
11 . 1 . 3 Examples
1. OPEN t/3 : NAME "myf i le"

OPEN tiN : NAME A$ , ACCESS OUTIN , ORGANI ZATION STREAM , RECTYPE INTERNAL , RECSIZE
VARIABLE LENGTH N
OPEN I!N+ l : NAME "MY" & F$ , ORGANIZATION ORG$
16 . CLOSE liN
1 7 . ERASE 113
ERASE REST 114
18 . ASK t/3 : ACCESS AC$ , DATUM DT$ , NAME NM$ , ORGANIZATION ORG$ , POINTER P$ , RECSIZE
RS $ NUMCHARS , RECTYP RT$
ASK

liN : KEY K$

1 1 . 1 . 4 S emantics
F i les are accessed through channels to which they may be assigned during execution of
a program-un i t . A channe l is a logical path through which external data may be trans
ferred to or from a BASIC program . Within a program-unit , a channel is identi f ied by
a channel number local to that program-unit . The channel number is an integer from 0
up to and includ ing some imp lementation-defined maximum . This maximum must be at
least 99 . A f i l e , identified by its f i le-name , is open if it is currently ass igned to
a channel and c losed o therwis e . A channe l is active if it currently has some f i l e as
s igned to it and inactive otherw is e . At the initiation of execution of a program , a l l
channe ls except channe l zero sha l l b e inactive . Channel zero shal l always b e active .
Execution of the open-statement , close-statement , or erase- s tatement ( see below) for
channe l zero sha l l cause a nonfatal exception .
Input and output from and to channel zero shal l have the same source and destination
as input-statements and print-statements which do not contain channe l -express ions .
Channe l zero sha l l behave as a device with the f i le-attributes sequential , d isplay ,
and out in , and w i thout record- setter o r erase capab i l ity .
Open-statement
The open-statement makes the f i l e identified by the f i le-name acces s ible to the pro
gram through the channel number spec if ied in the channel -express ion . I t is
imp lementation-defined whether f i le names d i f fering only in the case of the letters
( upper or lower ) denote the same f i l e or d ifferent f i les . Fo l lowing a successful
open-statement , the associated channel sha l l be active and the f i le open . An attempt
to open a f i l e on a chru1ne l which is already active causes an exception . The effect
of attempting to open a f i l e which is a l ready open is imp lementation-def ined . The
number of channel s other than channel zero which may be active s imultaneous l y is at
least one .
After a successful open, a true f i l e shal l be accessible in accordance with the asso
c i ated f i le-attr i butes , whether exp l ic itly speci fied or in effect by defau l t . This
access ib i l ity consists of the abi l ity to perform certain operations and manipulate
the f i le pointer in certain ways . See the preceding section for an overview of which
statements are a l lowed under which attributes . If an attempt is made to OPEN a f i le
which cm1not be made accessible with the requested attributes ( i . e . , if not a l l the
associated operations can be successfully executed for this f i le ) , then an exception
results .

- 100 -

For a devic e , a successful open guarantees that , with two exceptions , al l the f i l e
processing statements w i l l have the same effects a s f o r a true f i le . In particular ,
on output , the same data w i l l be generated , and on input , values and characters wi l l
be interpreted and ass igned to variables in the same way . A device , however , might
not support the s emantics associated with the recorder- setter ( see Section 11 . 2 ) or
the erase- s tatement (below ) . The ask-statement may be used to determine whether a
particular device supports these capab i l ities .
BASIC- 1 only
If a f i l e is opened successfu l ly with a given f i le-organization, record-typ e ,
and record - s i ze , then c l osed , and then opened a t a later time with a different
value for one of these f i l e - attributes , then it is imp l ementation-defined
whether the f i l e is thus acces s i b l e . Also , for f i les with record-type INTERNAL ,
if a d ifferent ARITHMETIC option is in effect for the two executions , it is
imp l ementation-defined whether the file is thus access ible . Conversely, if a
true f i l e is reopened at a later time with the same values for the f i l e
attributes mentioned and , f o r f i les with record-type INTERNAL , the same
ARITHMET I C option is in effect , and the user has emp loyed the imp l ementation
defined means to preserve the f i l e unchanged in the interim, then the f i l e must
be accessible and the contents of the file faithful ly preserved . Devices are not
required to preserve data . In the foregoing , "same ARITHMETIC option" refers to
DECIMAL or NATIVE .
If a f i l e with record- type INTERNAL opened in one program-unit is accessed by
another program-unit with a d i fferent ARITHMETIC option, the results are
imp lementation-defined .
Implementations must provide true f i les for which a l l access-modes are avai l
abl e . Imp l ementations may also support true f i les for which some access -modes
are not availab l e . A device need not support a l l access-modes .
Imp l ementations conforming to this standard need only to accept and process the
f o l lowing combinations of f i l e -organization-value and record- type-value :
- sequential d isplay ,
- sequential internal ,
- stream internal .
The effect of the other combination is imp lementation-defined .
When a string-expression is used as an attribute value , its value must be one of
the assoc iated keywords for that attribut e . Upper-case-characters and lower
case-characters sha l l be treated as equivalent within such string values . Imp le
mentations may def ine additional f i l e attribute values .
BASIC-2 only
If a f i l e is opened successfu l ly with a given fi le-organization, record-typ e ,
and record - s i ze , then c losed , and then opened a t a later time with a different
value for one of these f i l e - attributes , then it is imp lementation-defined
whether the f i l e is thus accessib l e . Also , for fi les with record-type INTERNAL
or NATIVE, if a different ARITHMETIC option is in effect for the two executions ,
it is imp l ementation-defined whether the f i l e is thus accessible . Conversel y , if
a true f i l e is re-opened at a later time with the same values for the f i le
attributes mentioned and , f o r f i les with record- type I NTERNAL or NATIVE , the
same ARITHMETIC option is
in effect , and the user has emp loyed the
imp l ementation-def ined means to preserve the f i l e unchanged in the interim, then
the f i l e must be accessible and the contents of the f i l e faithful ly preserved .
Devices are not required to preserve data . In the foregoing , "same ARITHMETIC

- 101 -

option" refers to DECIMAL , NATIVE or FIXED ( see 15 . 1 ) , not to the default


specif ication in the FIXED option . If a KEYED f i le is re-opened with a d ifferent
c o l late-sequenc e , an exception results .
If a f i le with record- type INTERNAL or NATIVE opened in one program-unit is
accessed by another program-unit with a different ARITHMETIC option, the results
are imp l ementation-defined .
Implementations must provide true f i les for which a l l access -modes are ava i l
ab l e . Imp lementations may a l s o support true f i les f o r which some access -modes
are not availab l e . A device need not support a l l access -modes .
Implementations conforming to this standard need only to accept and process the
f o l lowing combinations of f i le-organization-value and record-type-value :
-

sequential display
sequential internal
s tream internal
relative internal
keyed internal
s equential native
relative native
keyed relative

The effect of the other combinations is imp lementation-def ined .


When a string-express ion is used as an attribute value , its value must be one of
the assoc iated keywords for that attribute . Upper-case- characters and lower
case-characters shal l be treated as equivalent within such string values . Imp le
mentations may define add itional f i le attribute values .
Access-mode
An access-mode speci f ies the direction in which data may be transferred from and to a
f i l e , e i ther by one of the keywords INPUT , OUTPUT , or OUTIN , or by a string
expression whose value is one of these keywords .
If access-mode is I NPUT , then it sha l l be poss ible to read data from the f i l e , but
not to change the f i le . In particular , READ , SET with pointer- items , and INPUT
s tatements ( includ ing variations with MAT and LINE ) are a l l owed , but not PRINT ,
\</RITE , RE\</RITE or DELETE . RE\</RITE and DELETE app ly only to BASIC- 2 .
I f the access-mode i s OUTPUT , then it sha l l be poss ible to add new data to the file ,
but not to change existing data in i t , nor to retrieve data from it . In particular ,
PRINT , SET with po inter- items , and \</RITE are al lowed , but not READ , INPUT , RE\</RITE
or DELETE . REWRITE or DELETE app ly only to BASIC-2 .
If the access -mode is OUTIN , then al l record-operations ( inc luding RE\</RITE and DELETE
for BASIC-2 ) are a l l owed for the f i l e .
The erase-statement sha l l b e al lowed only f o r a f i le with an access -mode o f OUTIN .
I f no access -mode is specified exp l icitly in the f i l e-attribute - l is t , then the
access-mode shal l be OUTIN if the f i le 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 f i l e opened with access -mode OUTPUT , the pointer sha l l be set to the end of the
f i l e fol lowing the OPEN , otherwise , it sha l l be set to the beginning of f i l e .

- 102 -

F i le-organ ization
The f i le-organization specif ies the logical relationship between f i le elements , and
the means by which the f i le pointer can be manipulated to identify the elements . The
organ i zation is spec if ied with one of the keywords SEQUENTIAL , STREAM , RELATIVE or
KEYED , or w ith a string-expression whose value is one of these keywords . Devices are
accessed as e i ther SEQUENTIAL or STRKM1 , RELATIVE and KEYED are al lowed only for true
f i les . RELATIVE and KEYED app ly only to BASIC-2 .
If no f i le-organ i zation is exp l ic itly spec ified in the open-statement , then the orga
nization sha l l be determined from avai lable system information about the f i l e . If
such information is insuffic ient , the sys tem shall attempt to open the f i le as
SEQUENTIAL . Channel zero sha l l behave as if opened with SEQUENTIAL .
A sequential f i le is a sequence of records . The order of the records is establ ished
by the order in which they were wr itten . Records can be added only to the end of
the f i le . The only meru1s for identifying records with the f i l e pointer is relative
to the current pos ition of the pointer , and the two spec ial locations BEGIN ( which
identifies the first record in the sequence , if any ) , and END , immed iately f o l l ow
ing the last record ( the only location where it is pos sible to add records ) . A
s ing le record operation may affect several DISPLAY records , but only one INTERNAL
o r , for BASIC- 2 , NATIVE record .
- A stream f i l e is much l ike a sequential f i l e , except that it is a sequence of indi
vidual values , rather than of records . The order of values is estab l ished b y the
order in which they were written . Values cru1 be added only to the end of the f i le .
The only means for identifying values is relative to the current pointer position ,
or BEGIN and END ( spec ifying respective l y , the f irst value , if any , in the se
quence, and the location immediately fo l lowing the last value ) . One record opera
tion may typ ical ly read or write a contiguous series of values within a stream
f i le .
BASIC- 2 only
- A relative f i l e is a sequence of record-areas , each of which may or may not
contain a record . The record-areas are numbered sequentially beginning with
1 . Thus the order of the record-areas and the records within them is estab
l i shed by the identifying integer associated with each . The f i l e pointer may
be manipulated with the use of this record number as wel l as by those means
provided for sequential f i les . For relative f i les , the beginning of f i l e is
the first record-area, regard less of whether it contains a record . The end of
f i le immed iately f o l lows the last exis ting record . Thus if the highest exist
ing record number is 44 , end of file refers to record-area 4 5 . If there are
no records in the f i le , end of f i l e refers to record-area number 1 . Records
within a relative f i l e may not only be read and written, but also changed
( with REWRITE ) and deleted ( with DELETE ) . Moreover , records may be added , not
only at the end of f i le , but also at any empty record-area , including those
past the end of f i l e . A record operation proces ses at most one record .
A keyed f i l e is a sequence of records , each of which is identified by a string
cal l ed a key . The logical sequence of records is estab l ished by the c o l lating
order of their keys . ( See co l late- sequence , below . ) The f i l e pointer may be
manipulated with respect to the keys , as wel l as by the means provided for
sequential f i les . As with sequential f i les , beginning of f i le refers to the
first existing record in the sequence ( if any ) , and end of f i le refers to the
location immed iately fo l lowing the last record . Records may be added anywhere
within the sequence . An exact key , however , must always be speci f ied for
record creation , and no dup l icate keys are a l lowed . Records may also be read ,
changed or de leted . A record operation processes at most one record .

- 103 -

Record- tyPes
A record- type specifies the logical representation of data within a record or as an
individual f i l e e l ement . The record- type affects how data is interpreted and trans
formed when being transferred between a program and a f i l e . A record- type is speci
f ied with one o f the keywords DISPLAY , INTERNAL or NATIVE or with a string-expression
whose value is one of these keywords . NATIVE app ly only for BASIC - 2 .
If no record- type is exp l ic itly spec if ied on the OPEN, the record-type is determined
from avai lab le system information about the f i l e . If such information is insuf f i
c ient , then the f i le sha l l b e opened a s DISPLAY . Channe l zero behaves a s i f opened
with DISPLAY .
- The disp lay type spec if ies that a record is a sequence of characters . On output ,
the characters are processed in accordance with the semantics of the PRINT
statement , and on input with those of the INPUT statement ( see 10) . READ and WRITE
are also a l l owed for d isp lay records ; they fol low the semantic rules for I NPUT and
PRINT , respective ly .
- The internal type spec ifies that a record is a sequence of typed values ( o r that
each f i l e e l ement is a value ) , in the same sense that a program var iable contains
a value . The essential aspect of internal format is that ( for a true f i l e ) values
are preserved and retrievable . Thus , if a numeric or string value is written from
a program variab l e , and later read into another variabl e , the two variables must
be strictly equal ( assuming the o r iginal variable to be unchanged ) . S ince I NPUT
and PRINT statements are essentially character-oriented , they cause an exception
when used on a f i l e opened as internal .
BASIC-2 only
- The native type spec i f ies that a record is a sequence of f ie lds , as described
by a program- spec if ied TEMPLATE . This TEMPLATE , in conjunction with the l ist
of operands of the associated record operation, speci f ies the s ize , typ e ,
number , and order of f ie lds within the record . This a l lows data i n a f i le to
be put in a form suitable for exchange with other language processors which
have s imilar record speci fication capab i l ities . Values are preserved subj ect
to certain restrictions regarding the s i ze of the f ields in the record . As
with the internal type , INPUT and PRINT cause an exception when used on a
f i l e opened as native .
Record - s i ze
A record - s ize spec i f ies the maximum length of records in a f i l e . It is spec i fied ex
p l i c itly with the keyword LENGTH .
Unless an enhancement to this Standard provides for f ixed- length records , a l l f i les
sha l l be composed of variable- length records , i . e . , of records whose l engths are in
dependent of each other . The length of a record of type DISPLAY sha l l be the number
of characters in that record . The length of records of other types ( INTERNAL o r , for
BASIC-2 only, NATIVE) sha l l be imp lementation-def ined . An attempt to perform a record
operation for a record whose length exceeds the maximum set ( either exp l ic it ly or by
defau l t ) in the OPEN operation sha l l use an exception . A speci fied LENGTH index must
be greater than zero .
If no record - s ize is exp l icitly speci fied in the open- s tatement , then the record - s ize
is determined from available system information about the f i l e . I f such information
is insuf f icient , then the f i l e sha l l be opened as VARIABLE . If the index is omitted ,
then the maximum length of records sha l l be impl ementation-defined . Channe l zero
sha l l behave as if opened with VARIABLE and the length index omitted .
Imp l ementations must support record- s i zes of at least 1 3 2 for true f i les .

- 104 -

Co l late-sequence ( BASIC- 2 only)


The col late- s equence specifies , for a KEYED f i l e , the c o l lating sequence of the
record keys . A c o l late- s equence is speci fied 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 KEYED f i l e . For other file-organizations , it has no
effect .
The col late-sequence of a f i l e governs a l l record operations for that f i l e and the
f i l e-operation ERASE . Thus , the logical appearance of the f i l e , when operated on by
READ , WRITE , REWRITE , DELETE , SET with pointer-contro l , ERASE and ASK must be in ac
cordance with the specified col late- sequence ( see f i l e -organization, above and 1 1 . 2 ) .
The col late- sequences STANDARD and NATIVE imp ly exactly the same ordering as in the
option-statement ( see 6 . 6 ) . Thus , if the col late- sequence associated with a f i l e and
a program-unit agre e , it fo l lows that an earl ier key in the f i l e wi l l always compare
as less than a later key .
hold . Nonetheless , it must
sequence to access a KEYED
of the records , not their
both c o l l ate-sequences .

When the sequences disagree , this re lationship may not


be possible for a program-unit with a different col late
f i l e ; the col late- sequence affects only the logical order
contents . Imp l ementations with KEYED f i les must support

If no c o l late-sequence is specified in the open-statement , then the co l late- sequence


sha l l be determined from avai lable system information about the f i l e . If such infor
mation is insufficient , the system sha l l attempt to open the f i l e with the same
c o l late-sequence as that in effect for the program-unit containing the open
statement . Since channe l zero has f i le-organization SEQUENTIAL ( not KEYED ) , it has no
associated col late- sequence .
Close- statement
Execution of a c lose-statement sha l l c lose the f i l e ass igned to the specified chan
nel , caus ing the channel to become inactive . If no f i l e is ass igned to the channel ,
no action occurs . Upon exit from an externa l - sub-def or externa l -function-def , any
f i l es opened by such a procedure whose channe ls are not formal parameters shal l be
c losed . Upon program termination, any f i les sti l l open shal l be c losed .
Erase-statement
For a true f i l e , execution of an erase-statement sha l l de lete al l or part of the data
within the f i l e ass igned to the specified channel . The f i le-attributes associated
with the f i l e are not changed . If the REST option is omitted , then al l f i l e e lements
are deleted , the f i l e becomes empty , and the f i l e pointer points to the end of f i le
(which is the same as the beginning f i le ) .
If the REST option is specified , then a l l f i l e e l ements at or beyond the current lo
cation of the file pointer are de leted . All file elements preceding it are left un
changed . The f i l e pointer is then set to end of f i l e .
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 .

An erase-statement executed for channe l zero sha l l cause an exception, but no other
effect sha l l occur .
An erase-statement is al lowed only for a f i l e opened with access -mode OUTIN . For
other access-modes , there is no effect on the f i l e and an exception results .
Ask - s tatement
Execution of an ask-statement sha l l cause the variables in the ask- item- l ist to be
assigned values corresponding to the attributes of the f i le currently ass igned to the
specified channel , as indicated in the fo l lowing table . If the channe l is inactive ,

- 105 -

then a l l such string-variables sha l l be assigned the nul l string , and al l such
numeric variables sha l l be ass igned 0 . In al l cases below , A$ represents a string
variable and N represents a numer ic-variabl e .
I n BASIC-2 the fol lowing responses can b e expected :
Ask-item
Values
ACCESS A$
The access-mode of the f i l e , i . e . , " I NPUT" , "OUTPUT" , or "OUTIN" .
COLLATE A$
The c o l late-sequence assoc iated with a KEYED f i le , i . e . "STANDARD" or
"NATIVE" . For f i le-organizations other than KEYED , the nul l s tring is as
s igned .
DATUM A$
The type of the next datum in the f i l e fol lowing the current pointer pos i
t ion, i . e . , "NUMERIC" , "STRING" , "NONE" ( if n o data fo l low ) , o r "UNKNOWN" ( if
it is impossible to determine the type or whether more data f o l low ) . DATUM is
wel l -defined only for STREAM INTERNAL f i les . For other f i le organizations , it
is imp lementation-defined .
ERASABLE A$
"YES" or "NO" depending on whether or not this f i l e is erasab l e , i . e . , if the
ERASE s tatement can delete f i le e l ements .
FILETYPE A$
"FILE" or "DEVICE" depending on whether this is a true f i le capable of pre
serving data , or is a device .
KEY A$
The key associated with the record identified by the f i le pointer in a keyed
f i le . If the pointer is at the end of f i l e or if this is not a keyed file ,
the nul l string is ass igned .
MARGIN N
The current margin for a d isp lay f i l e ( MAXNUM if the record may be of arbi
trary length ) . If the file is not DISPLAY , zero is ass igned .
NAME A$
The name of the f i le ass igned to the channe l .
ORGANIZATION A$
The f He-organization of the f i l e , i . e . , "SEQUENTIAL" , "STREAM" ,

"RELATIVE"

or "KEYED" .
POINTER A$
The current pointer position for the f i l e , i . e . , "BEGIN" , "MIDDLE" , or "END" ,
where MIDDLE s ha l l mean neither BEGIN nor END, and END shal l be the pointer
pos ition for an f i l e , or a position beyond the end , in the case of a RELATIVE
f i le . UNKNOWN may be returned in the case of devices for which an imp lemen
tation cannot determine which of the above values is correct .

- 106 -

RECORD N
The number of the record-area identi fied
relative f i les , zero is ass igned .

by

the

f i le -po inter .

For

non

RECSIZE A$ N
The record - s i ze of the f i le , i . e . "VARIABLE" and the maximum length for its
records ( MAXNUM if there is no effective l imit on record- length , e . g . , a com
munication line ) .
RECTYPE A$
The record- type for the f i l e , i . e . "DISPLAY" , " INTERNAL" or "NATIVE" .
SETTER A$
"YES" or "NO" depending on whether or not this f i le has record- setter capa
b i l ity .
ZONEWIDTH N
For DISPLAY f i les , the current zonewidth . For non-DISPLAY f i les , zero is re
turned .
In BASIC- 1 , the fol lowing responses can be expected :
ask-attribute

value

ACCESS
COLLATE
DATUM
ERASABLE
FILE TYPE
KEY
MARGIN
NAME
ORGANIZATION
POINTER
RECORD
RECSIZE
RECTYPE
SETTER
ZONEWIDTH

as BASIC-2
nul l string
as BASIC-2
as BASIC-2
as BASIC-2
nul l string
as BASIC-2
as BASIC-2
SEQUENT IAL or STREAM
as BASIC- 2 , except that END means an empty f i le
zero
as BASIC-2
DISPLAY or INTERNAL
as BASIC-2
as BASIC-2

The effect of executing an ask - statement for channe l zero is as fol lows :
ask-attribute
ACCESS
COLLATE
DATUM
ERASABLE
FILETYPE
KEY
MARGIN
NAME
ORGANIZATION
POINTER
RECORD
RECSIZE
RECTYPE
SETTER
ZONEWIDTH

value
OUT IN
nul l string
UNKNOWN
NO
DEVICE
nul l string
current margin
imp lementation-def ined
SEQUENT IAL
UNKNOWN
zero
VARIABLE MAXNUM
DISPLAY
NO
current zonewidth

- 107 -

1 1 . 1 . 5 Exceptions
- The value of a channe l -expression is not between 0 and the implementation-defined
maximum ( 7001 , fatal ) .
- Channe l zero is speci fied in an open-statement , a close-statement , or an erase
s tatement ( 7002 , nonfatal do nothing and continue ) .
- A nonzero channe l specif ied in an open-s tatement is already active ( 7003 , fata l ) .
- A string-express ion used to specify a f i le-attribute does not have a recognizable
value ( 7 100 , fata l ) .
Access to a f i le in an open-statement is not possible in accordance with the spec i
f ied or defau l t f i le-attributes ( 7 1xx fatal : the values and meanings f o r x x are
imp l ementation-defined ) .
- A KEYED f i l e is re-opened with a different col late-sequence from that of an ear l ier
open ( 7050, fatal ) . ( BASIC-2 only)
- A LENGTH index is not greater than zero ( 705 1 , fata l ) .
- A device is opened as RELATIVE or KEYED ( 7052 , fata l ) . ( BASIC-2 only )
- A nonzero channe l spec i f ied in an erase-statement is inactive ( 7004 , fata l ) .
- An erase-statement is used on a f i le which has not been opened as OUTIN ( 7 301 ,
fatal ) .
- An erase-statement is used on a device without erase capab i l ity which has been
opened with OUTIN ( 7 3 1 1 , nonfatal : do nothing and continue ) .
1 1 . 1 . 6 Remarks
It is recommended that implementations recognize as f i le-names at least those strings
of characters cons isting of an upper-case- letter f o l lowed by at most three more
upper-case - l etters or d igits . It is also recommended that information required by the
operating system , for the purpose of protecting the security of fi les be considered
part of the f i le-name .
It is recommended that imp lementations use the f i le-name to distinguish between the
opening of a true f i l e , and opening of non- f i le devices , such as a communications
l ine or a l ine printer .
It is recommended that the number of channel s which may be active s imultaneous ly be
at least four in addition to channel zero .
It is recommended that the default maximum length of records in a f i l e be infinite ,
i . e . , that records be a l lowed to be of any length .
It is also recommended that record - s i ze for I NTERNAL and , for BASIC-2 only , NATIVE
f i les has a meaning comparabl e to that for DISPLAY , i . e . , that it specif ies the maxi
mum number of characters or bytes within the record .
Add itional values may be returned by an ASK statement if an imp lementation supports
access - modes , f i le-organizations , record- types , record- si zes and co l late-sequences in
add ition to those spec if ied in this Standard .
If imp lementations return a status code fo l lowing various f i le operations , it is rec
ommended that this be made accessible through an additional ASK attribute to be
cal led IOSTAT which returns a singl e string value , e . g . , "ASK IOSTAT S$11 returns a
val ue in S$ ref l ecting the status of the f i l e f o l lowing the last attempted operation .
The maximum length of a KEY is imp lementation-defined . ( BASIC-2 only)

- 108 -

1 1 . 2 F i l e Pointer Manipulation
1 1 . 2 . 1 General Description
The pointer for an open f i l e can be altered in certain ways , without also performing
any data transfer . The rules for pointer manipulation with the set - s tatement with
pointer - items also apply when used in conjunction with o ther record operations .
11 . 2 . 2 Syntax
BASIC- 1 and BASIC-2
1 . set-object
2 . pointer-items
3 . pointer-control
4 . record-setter
5 . core -record-setter
6 . io- recovery
7 . not-missing-recovery

> channel - s etter pointer- items


( po inter -control I io- recovery I pointer-control
comma io-recovery)
> POINTER core-record- setter
> core-record- setter
BEGIN I END I SAME
missing -recovery I not-missing-recovery
IF THERE THEN io-recovery-action

BASIC-2 only ( Enhanced Files productions ) :


8 . pointer-contro l
9 . record-setter
10 . enhanced-record-setter
1 1 . exact-search
12 . inexact- search

> enhanced- record- setter


> enhanced-record- setter
RECORD index I KEY ( exact-search I inexact-search)
string-express ion
equa l s - s ign?
greater-than-s ign I not- less

11 . 2 . 3 Examples
1 . SET #N : POINTER BEGIN, IF MISSING THEN EXIT DO
SET # 3 : RECORD N+l , IF MISSING THEN 1200
SET #4 : KEY "Jones" , IF THERE THEN EXIT DO
11 . 2 . 4 Semantics
Execution of a set- statement with pointer- items shal l set the pointer for the f i le
assigned to the specified channel . After the pointer has been set , an optional io
recovery may take effect . The semantics assoc iated with the record-setter and when
the io-recovery takes effect are uniform for al l the record operations ( see 11 . 3 ,
11 . 4 and , for BASIC- 2 , 11 . 5 ) . If any of the exceptions l isted below in 11 . 2 . 5 occurs ,
the file pointer remains unchanged from its state before the SET with pointer
contro l . A device may not be able to achieve the effect of a record-setter . The ask
statement may be used to determine whether a device has record-setter capab i l ity .
Record-setters
BASIC- 1

An absent record-setter l eaves the file pointer unchanged from its previous
state . The io- recovery ( see below ) , if present , sti l l has its usual effec t .
A record- s etter of NEXT indicates that the po inter is t o b e s e t to the next
record ( for SEQUENTIAL f i les ) or value ( for STREAM files ) at or beyond the cur
rent location . For a SEQUENTIAL f i l e , the only case in which NEXT would have
some effect is if there were a partial record pending ( see 1 1 . 3 ) . In this case ,
an end-of- record sha l l b e generated and the pointer left a t end o f f i l e .

- 109 -

BASIC-2
An absent record- setter l eaves the f i l e pointer unchanged from its previous
state . The io-recovery ( see below ) , if present , s t i l l has its usual effect .
A record - setter of NEXT indicates that the pointer is to be set to the next ex
isting record ( for non-STREAM f i le s ) or value ( for STREAM f i les ) at or beyond
the current location . In the case of a RELATIVE f i l e , NEXT shall therefore cause
the po inter to skip over any empty record areas to the next existing record . If
the pointer is a lready at or beyond the end of f i l e , or is po inting to an exist
ing record , NEXT sha l l leave the po inter unchanged . This capab i l ity a l l ows
RELATIVE f i les to be processed as if they were SEQUENTIAL . In the case of STREAM
and KEYED f i les , the pointer is a lways pointing to an existing f i l e element or
end of f i l e and so is left unchanged . For a SEQUENTIAL f i l e , the only case in
which NEXT would have some effect is i f there were a partial record pending ( see
Section 1 1 . 3 ) . In this cas e , an end-of- record sha l l be generated and the po inter
left at end of f i l e .
A record - s etter of BEGIN causes the pointer to b e set t o the beginning o f f i le , i . e . ,
to the f irst f i l e element . If the f i l e is emp ty , the location is also the end of
f i le .
A record - s etter of END causes the pointer to be set to end of f i l e , defined as imme
diately beyond the last f i le element ( if any ) in the case of SEQUENTIAL, STREAM , and
KEYED f i les , and as immed iately beyond the last existing record in the case of a
RELATIVE f i l e ( or at record-area number 1 , if no records exist ) .
A record- setter of SAME a l lows the user to access the same f i le-element ( s ) that have
most recently been processed s ince the OPEN for that channe l . Its use is val id only
if the most recently executed record operation which accessed the channel meets these
cond itions : it was not a delete-statement , and no exception occurred during its
execution at least unti l after the f i l e pointer had been set .
If these conditions are not met , no pointer manipulation takes p lace and an exception
results . If they are met and the most recent operation was a READ, INPUT , SET with
pointer- items , or REWRITE , then the f i le po inter is reset to the same f i le e l ement it
was j ust set to by the record- setter of that operation . If this operation had no
record- setter , then SAME resets the pointer to the same location it had at the
beginning of that operat ion . If the most recent operation was a WRITE or PRINT , then
SAME sets the pointer to the f irst f i le element created by that operation .
A record - setter with RECORD is val id only for use with RELATIVE f i les . If an attempt
is made to use this record-setter on a f i le not opened as RELATIVE , the pointer is
left unchanged and an exception results . The index is evaluated by rounding to an
integer, and the pointer set to the correspond ing record-area , whether or not it con
tains a record . If the index evaluates to an integer less than one , the pointer is
left unchanged and an exception is generated .
A record- setter with KEY is va lid only for use with a KEYED f i le . If an attempt is
made to use this record- setter on a f i l e not opened as KEYED , the pointer is left un
changed and an exception results . For an exact- search the pointer is set to the
record whose key equals that of the string - express ion ; if none such exists , the
pointer i s set to the f irst record whose key is greater than the ring-express ion . If
there is no such record , the pointer is set to end of f i le . For an inexact- search
with not- less , the pointer is set exactly as for an exact-search , except for the set
ting of the data- found cond ition ( see below ) . For an inexact-search with greater
than - s ign, the pointer is set to the f irst record whose key is strictly greater than
the string-expression; i f none exists , it is set to end of f i l e .

- l lO -

Io-recovery
At the comp letion o f pointer manipulation there sha l l be set a condition cal led data
found , which is either true or false . If data-found is true , and if a not-miss ing
recovery has been specif ied , then the io-recovery-action takes effect . If the data
found condition is false and a miss ing- recovery has been speci f ied , then the io
recovery-action also takes effec t . Except for these two cases , the io- recovery
action, if any , is ignored . The data-found condition is false if :
- in BASIC-2 only, an exact-search has been specif ied , but no record was found whose
key was equal to the string-expression, or
- after the pointer is set , it points to end of f i l e , or
- in BASIC-2 only, after the pointer is set, it points to an empty record-area, or
- for a device , there is an imp lementation-def ined condition s ignifying that no data
is ava i lable for input ; otherwise, the data-found cond ition is true .
If the io-recovery-action is an exit-do-statement or exit- for-statement , the
statement sha l l have its normal effect ( see 8 . 3 ) . If the io-recovery-action is a
l ine-number then execution shall continue at the speci fied l ine .
11 . 2 . 5 Exceptions
- A set- statement with pointer- items
fatal ) .
- A record - setter
continue ) .

is

used

with

is

channe l

executed
zero

for an inactive channe l

( 7002 ,

nonfatal :

do

( 7 004 ,

nothing

and

A record- s etter is used on a device without record- setter capabi l ity ( 7 20 5 , nonfa
tal : do nothing and continue ) .
- The record- s etter SAME is used , and the most recently executed operation for the
channel was a d elete- statement ( 7 204 , fata l ) . ( BASIC-2 only )
- The record- setter SAME is used , and the most recently executed operation for the
channel caused an exception before po inter manipulation took p lace ( 7 204 , fatal ) .
- The record - s etter SAME is used , and no record operation has been executed on that
channel s ince the OPEN ( 7 204, fatal ) .
- The record - setter RECORD is used on a f i l e opened with a file-organization other
than RELATIVE ( 7 202 , fatal ) . ( BASIC-2 only)
- The record - s etter KEY is used on a f i l e opened with a f i l e -organization other than
KEYED ( 7 203 , fata l ) . ( BASIC-2 only)
- The index of a RECORD record- setter evaluates to an integer less than one ( 7 206 ,
fata l ) . ( BASIC-2 only)
- A record - setter
( BASIC- 2 only)

spec ifies an exact-search for

the nul l

string

( 7 207 ,

fata l ) .

l l . 2 . 6 Remarks
For devices , data-found could be set false by such cond itions as no more cards in a
card reader , control-Z sent from a terminal ( which s igni fies end-of- f i l e for some
systems ) , or that the device is for output only, e . g . , a l ine printer .

- 111 -

BASIC-2
Given a RELATIVE f i l e , with three existing records , numbers 2 , 5 , and 6 :
1

RECORD

RECORD

RECORD

pointer
If READ RECORD 2 has just taken p lace , then the f o l lowing record-setters w i l l
have the described effect :
record- setter

resulting pointer position in front of

BEGIN
E
s
NEXT
absent
RECORD n

1
7
2
5
3
n

1 1 . 3 F i le Data Creation
1 1 . 3 . 1 General Description
Statements are provided to a l low the user to send data developed within the program
to an external destination . In the case of true f i les , such data can be retrieved and
mod i f ied by later programs . The fac i l ities generalize the output capab i l it ies pre
sented in Section 10 to f i les . New fac i l ities are also defined to a l low output to the
various record-types . The set-obj ects MARGIN or ZONEWIDTH are not part of a data cre
ation statement , but are included in thi s section because of their interaction with
display records .
1 1 . 3 . 2 Syntax
BASIC - 1 and BASIC-2
1 . print-statement
2 . array-print - statement
3 . print-contro l
4 . print-contr o l - item
5 . set-obj ect
6 . write-statement
7 . array-write - statement

8 . write-contro l
9 . write-contr o l - item
10 . express ion- l ist
l l . array- l is t

> PRINT channel - expression print-contro l ( co l on


( print- l ist I output- l is t ) ) ?
> MAT PRINT channel - express ion print - contro l c olon
( array-print - l ist I array-output- l is t )
( comma p rint-contro l - item ) "'

core-record- setter I not-miss ing-recovery I USING


image
> channel - setter ( MARGIN I ZONEWIDTH) index
WRITE channel -express ion write-contro l co lon
express ion- l ist
MAT WRITE channel - expression write-control c ol on
array- l is t
( comma write-contr o l - i tem) )'c
> record-setter I not-miss ing-recovery
express ion ( comma expression ) >''
array-name ( comma array-name ) *

- 112 -

BASIC-2 only ( Enhanced F i les productions ) :


Nl2 .
N13 .
Nl4 .
N l5 .
Nl6 .
Nl7 .

write-contro l - i tem
template- ident ifier
declarative-statement
temp late-statement
template- e l ement - l ist
template-element

Nl8 .
N19 .
N20 .
N2 1 .
N22 .
N23 .

f ixed-field -count
variable-field-count
f i e ld-spec i f ier
numeric-speci f ier
numeric- f ield- s i ze
f i xed-point-s ize

N24 .
N25 .
N26 .
N27 .

integer- s ize
fraction-size
string- speci fier
string- f ie l d - s ize

> temp late- identif ier


WITH ( l ine-number I string-express ion)
> temp late-statement
TEMPLATE co lon template-element - l ist
template-element ( comma temp late - e lement) l'<
f ixed - f ield-count ( f ield-specifier I left-parenthes is
temp late-element- l ist right-parenthes i s ) I
variable-field-count field-specifier
SKIP? ( integer OF ) ?
question-mark OF
numeric- specifier I string-speci fier
NUMERIC asterisk numer ic - f ield-s i z e
f ixed-point-s i ze I E
integer- s ize period? I integer - s i ze? period
fraction - s i ze
integer
integer
STRING asterisk string-field-s i ze
integer

W i thin a print-statement or array-print-statement , an image must not be used with a


p rint- l is t , i . e . , only an output- list may be used when an image is p resent as a
print-contro l .
The l ine-number of a temp late- identi fier must refer to a temp late- statement in the
same p rogram-unit . ( BASIC-2 only)
The integer in a f ixed - f ield-count must be greater than zero . ( BASIC-2 only)
In a f ixed -point-s ize ,
zero . ( BASIC-2 only)

the

integer- s ize

or

fraction- s ize

must

be

greater

than

String - f ield - s i ze must be greater than zero . ( BASIC-2 only)


The record-setter in a write-contro l must not specify an inexact-search .
only)

( BASIC-2

A given print-contro l - item must appear at most once in print-control .


A given write-contro l - item must appear at most once in write-contro l .
1 1 . 3 . 3 Examples
1 . PRINT # 3 : A, B, C
PRINT #3 , END , USING 123 : A$ , B+C ;
2 . MAT PRINT # N , SAME , IF THERE THEN EX I T FOR : A$ , B$ , C
5 . # 3 : MARGIN N+ 1
6 . WRITE 113 , RECORD 4 7 , IF THERE THEN 666 : A+B , C$ & D$
WRITE #X+Y WITH TEMPLATES3$ : X , Y , Z + W
7 . MAT WRITE 113 , KEY "Whoever" , IF THERE THEN 666 ,
WITH 1 1 1 : A, B$
N 1 5 . TEMPLATE : STRINGl'< 5 , 2 OF NUMERICi<3 . 4
TEMPLATE : ? OF NUMERICi<5 . 2 , ? OF STRINGl'< 5
N16 . 5 OF STRING>'<22 , 3 OF NUMERICl'<E , ? OF NUMERIC>'< . 6
1 1 . 3 . 4 Semantics
All data creation statements fo l low a general pattern which w i l l be described here .
In a l l cases , the function of a data creation statement is to add one or more new
f i l e e l ements to a f i l e . Previously existing f i l e elements are not affected . Details

- 113 -

on aspects pecul iar to each of the various forms are presented below, under the head
ings of each statement type .
First , the channel to which the data wi l l be sent is determined from the channel
expre s s ion . The f i le-attributes are checked against the intended operations . A l l data
creation s tatements require an access -mode of OUTPUT or OUTIN . If the channel is ac
tive and the f i l e- attributes are compatible with the data creation statement , then
the next phase begins . Otherwise , an exception results and the f i l e , the f i le
pointer , and a l l program variables remain unchanged .
The s econd phase of process ing invo lves setting the f i le pointer , based on the
record-setter ( o r its absence ) . This is done exactly as described in 11 . 2 . The data
found condition is now set , again as described in 11 . 2 . If data-found is true and a
not-miss ing- recovery is present , then the io- recovery-act ion is taken . If data-found
is true , and a not-miss ing-recovery is absent , then an exception results . In either
cas e , no furti1er change is made to the po inter pos ition or the f i l e .
I f data-found is false, then the third phase begins , the actual output o f data a t the
location indicated by ti1e pointer . The operands are evaluated in succession from left
to right until enough data to f i l l a f i le-e lement has been generated . Only then is
the f i le-element actua l ly added to the f i l e and the po inter advanced immed iately be
yond the f i le-element just created . In particula r , this means that an exception dur
ing data transfer w i l l never result in a partial f i le-element being added to the
f i le . However , i f a statement can create several f i le-elements , those which have al
ready been created before the exception occurs continue to exist in the f i le . Fol low
ing ti1e comp letion of data transfer , the f i le po inter is always left pointing at the
next f i le-element ( or end of f i l e if none such exists ) beyond the last one created .
If an exception prevented the creation of any f i l e elements , the pointer is left as
it was set in the second phase .
Print - statement
The transfer of data with the print-statement works just as described in 10 . 3 and
10 . 1 , except that the sequence of characters generated constitutes a record of a
DI SPLAY f i l e , rather ti1an current l ine , and end -of- record is generated in p lace of
end-of - l ine . Note that it is poss ible to create records containing zero characters .
End-of-record is the imp lementation-def ined means whereby it is indicated that the
storage of a f i le-element in a f i l e is completed , i . e . , no change or addition to this
record is possible with a data creation statement . Except for the special case d i s
cussed below, n o data is actua l ly added t o the f i le unti l a va l id end-of- record has
been generated , i . e . , partial records are not added to the f i l e . The effective margin
for ti1e f i l e , which is used to control when end-of-record is generated , is taken from
the value of RECSIZE estab l ished when the f i l e was opened , or from a set-statement
with MARGIN for this channe l executed s ince the open ( see below) .
In one special case , a partial record is added to a f i l e . If the print- list or
output- list contains a tra i l ing print- separato r , then upon successful comp letion of
the statement , a partial record has been created at the end of f i le , with the pointer
left at end of f i l e , i . e . just beyond the partial record . Note that if there is an
exception before comp letion of the statement , then the partial record is not added to
the f i l e , as would also be true of a comp lete record . If and only if the next opera
tion for the channel is a print-statement with an absent record- setter , then the se
quence of characters it generates is appended to the end of the partial record , in
accordance with the usual rules regarding the margin. If the next operation for that
channel is anything other than such a print- statement , then before any other process
ing takes p lace , an end-of-record is added to complete the partial record , and the
po inter left at end of f i l e .

- 1 14 -

Array-print- statement
The transfer of data with the array-print - statement works just as described in 10 . 5 ,
except that the sequence of characters generated constitutes a record of a DISPLAY
f i l e , rather than the current l ine , and end-of-record is generated in p lace of end
of - l ine . Note that by the rules of 10 . 5 , a partial record is never created by the
array-print-statement with an array-print - l is t , but may be created with an array
output- list containing a trai ling semico lon . S ince an array-print-statement always
starts a new l ine , it may not be used to comp lete a partial record . The effective
margin is contro l led as described under print - statement and "Setting the margin"
( below ) .
Setting the margin
Associated with each open DISPLAY f i le . is a margin, the maximum number of characters
which a record can contain . The margin is used by print- statement and array-print
statement to determine when an end-of-record should be generated . Upon open, the ef
fective margin is the LENGTH index in RECSIZE , or the imp lementation-defined length ,
which must be not less than the default zone width , if LENGTH is not specif ied ex
p l ic i t l y . The set-statement with a MARGIN changes the margin for the active channe l
to the specif ied index . If a partial record exists in the f i l e affected by the mar
gin, the new margin is used when subsequently attempting to comp lete the partial
record . A margin of MAXNUM indicates that a record may be arbitrar i ly large . The mar
gin index must evaluate to greater than zero . The effect of a set-statement with
MARGIN ends when the f i l e is c losed .
The maximum margin supported is imp lementation-defined .
Setting the zone width
Assoc iated with each open DISPLAY f i l e is a zone width , which contro ls the effect o f
PRINT a s described i n 10 . 3 . Upon open, the zone width for a f i le is set t o the
implementation-defined default value , which sha l l be at least d + e+ 6 . The set
statement with ZONEWIDTH changes the zone width for the active channe l to the
spec i fied index .
A l l zones are the same width, except possibly the last, which may be shorter . If a
partial record exists in the f i l e affected by the set-statement with ZONEWIDTH, the
new zone width is used when subsequently attempting to comp lete the partial record .
In a set-statement with ZONEWIDTH the index must evaluate to greater than zero . The
effect of the set-statement with ZONEWIDTH ends when the f i le is closed .
The maximum zone width is imp lementation-defined .
Display record- type
DISPLAY records are sequences of characters ; the characters generated by the PRINT
operations are as described in Section 10 . The accuracy of numeric values is l imited
only by the imp lementation-def ined s ignif icance-width or length of the format- item ,
and by the ARITHMETIC option in effect .
Channel zero
PRINT to channel zero works in accordance with the semantics for a device without
record-setter or erase capab i l ity . The destination of the output data is the same as
i f the channe l -expre s s ion had been omitted . Also , i f there is an exception for which
a d if ferent recovery procedure is spec if ied in Section 10 than in 1 1 , the procedure
of Section 10 sha l l be used . A set-statement with MARGIN or ZONEWIDTH specifying
channe l zero has the same effect as if the channe l - s etter were omitted .

- 115 -

Write operation
The write-statement and array-write-statement are used to create records of any type.
Success ive expression values are arranged in corresponding sequences of values or
fields o r characters , and written out to the f i l e . Partial records are never created .
File organization
For STREAM f i les , one statement may create several f i le-elements , spec if ical ly one
f i le - e l ement is created for each express ion or array-e l ement evaluated . If an excep
tion occurs during internal evaluation, previous ly created values remain in the f i l e ,
the pointer is left at end o f f i l e , and any remaining values are ignored .
For INTERNAL SEQUENTIAL or NATIVE f i les , the values or fields generated by the ex
press ions or arrays form one record . Thus , if an exception occurs before the state
ment is completed , no record is added to the f i le , and the f i l e pointer is left un
changed from phase two . NATIVE f i les app ly only to BASIC- 2 .
BASIC-2 only
Since records in a KEYED f i l e are identified by their keys , it is necessary when
creating a new record that an exp l ic it key be assoc iated with i t ; thus when at
tempting to write to a KEYED f i l e , an exact- search must always be spec ified in
the record- setter . If data-found is fals e , then a new record is inserted into
the f i l e , with a key equal to the string-expression of the exact-search .
Display record- type
A WRITE operation type on a d isp lay record generates exactly the same sequence of
records and characters as would a PRINT operation with the same express ion- l ist or
array- l is t . Note , however , that not a l l PRINT fac i l ities are avai labl e for WRITE ,
which is record-oriented , rather than l ine-oriented .
For DISPLAY f i les , one statement may create several fi le-elements in the case of mar
gin overflow . If a fatal exception occurs during generation of an e l ement, any
e l ements previous ly created by that s tatement remain in the f i l e , the pointer i s left
at the end of the f i l e , and any remaining expressions are ignored .
Internal record- type

An internal record ( o f a STREAM f i l e ) 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 express ions and array-elements from which the values
are generated . When a value stored in a f i l e is later retrieved , the effect is as if
the expression or array-e l ement with which it was created were ass igned to the input
variabl e with a let-statement . The l ength and content of string values are preserved .
Numeric values are also preserved cons istent with the usual l imitations on preci s ion
associated with the prevai l ing ARITHMETIC option .
Native record-type ( BASIC-2 only)
The TEMPLATE describes the location, s i z e , and type of fields within a record . When
writing to a native f i l e , a TEMPLATE must a lways be used . It must not be used with
any other record-type . A TEMPLATE is associated with a particular data creation
statement by means of the temp late- identifier in the statement which spec ifies the
temp late - statement to be used or a string-expression whose value must be a syntacti
cally correct temp late - e l ement- l ist . The string-expression, is evaluated before the
express ion- l is t or array - l ist of the write-statement or array-write-statement .
Several s tatements may use the same temp late- s tatement .
When generating data for a native record , each express ion within the expression- l ist
i s assoc iated with a numeric-spec if ier or string- specifier within a TEMPLATE ; the
spec i f ier is then used to transform the value of the expression into a field within a

- 1 16 -

record . The association takes p lace from left to right within the expression - l is t and
te temp lates-element - l is t , each express ion us ing the next avai lable field-speci fier .
If the type of the express i on ( numeric or string ) disagrees with the type of the
spec ifier , an exception results . The number of expressions must not be greater than
the number of speci fiers . Extra spec ifiers beyond the last express ion are ignored .
The contents of the field are determined by the value of the express ion and the s i ze
characteristics of the spec ifier.
For string values , the string-field-size i s the number of characters in the field .
The string value is left-justified within the field . If the value ' s length exceeds
that of the field , an exception results . If shorter , the f ield is padded on the right
with spaces .
Numeric f ields are used to retain numeric values ( both magnitude and s ign ) . The s ign
is a lways stored in the field , but the numeric-field - s i ze exp l ic itly describes only
the storage of the number ' s magnitude . For a numeric-field-size of E, the value is
retained with the imp lementation-defined number of s ignificant digits for the pre
vai l ing ARITHMETIC option . For a f ixed-point- s iz e , the integer- s ize describes the
number of ava i lab le d igit p laces to the left of the dec imal po int , and the fraction
s i z e , to the r ight of the dec imal point . An omitted integer- si z e or fraction- s i ze is
treated as equivalent to zero . The numeric value is stored in accordance with these
s i zes . I f the value contains s ignif icant d ig its to the right of the avai lable field
positions , the value is rounded when stored . This may result in a field with a value
of zero . If the value contains s igni f icm1t d igits to the left of the avai lable f ield
pos itions , an exception results .
The f ixed - field-count in a temp late-statement indicates skipping and /or repetition
for individual specif iers or a series of spec ifiers . The integer of the fixed - f ield
count indicates the number of repetitions and the keyword SKIP indicates that the af
fected spec i fiers sha l l generate skipped fields . A field-count app l ies to the entity
( either a f ie l d - spec i f ier or a parenthesized temp late-element- l is t ) in the same
temp late - e lement . For an integer field-count ( indicating repetition) the effect is
just as i f the entity governed by the field-count had been written out exp l icitly the
equivalent number of times . When SKIP is used within a fie ld-count , it indicates that
the spec i f iers governed by it are not assoc iated with values from the expression - list
or array- list . Ratl1er , as the record is being generated , f ields within the record are
ass igned the value zero if numeric and spaces if string , corresponding to the usual
s ize and type of the field-spec if ier in question . If a field-spec if ier is governed by
several SKIPs ( from various leve ls above it) the effect is just as if it were gov
erned by only one , as described above . For examp l e , given the f o l lowing express ion
l ists and temp lates -element - l ists ,
A, B , C and NUMERIC>'<4 , NUMERIC>'< S , NUMERIC>'<6
D, E
and NUMERIC>'<4, SKIP NUMERIC>'c s , NUMERIC>'<6
A and D w i l l occupy equivalent field locations , as wi l l C and E . The second field in
the second record wi l l be the same s ize as occupied by B in the f irst record , with a
value of zero .
As an i l lustration of the preceding
e l ement - l ists are shown below :

description ,

equivalent

pairs

of

temp late

1 - STRING>'<4 , STRING>'<4 , STRING>'<4


2 - 3 OF STRING>'<4
STRING>'<S , STRING>'<4 , NUMERIC' 2 , NUMERIC>'<2 ,
NUMERIC>'<2 , NUMERIC>'<2
2 - STRING>S , 2 OF ( STRIN<4 , 3 OF NUMERIC>'< 2 )
1

NUMERIC>'<2 ,

STRING>'<4 ,

NUMERIC>'<2 ,

- 117 -

1 - SKIP

NUMERI0''3 ,

SKIP NUMERIC>': 3 , NUMERIC>':4 , SKIP STRING>'c s , SKIP STRING>6

2 - SKIP 2 OF NUMERIC>': 3 , NUMERIC>'c4 , SKIP ( STRING>'cs , SKIP STRING''' 6)


Note that in 2 o f the last examp l e , the SKIP immediately in front of STRING>':6 is su
perf luous . A variab l e - f ield-count is used only in conjunction with arrays ( see
be l ow) .
If execution reaches a temp late - s tatement , it proceeds to the next l ine with no fur
ther effect .
Array-write-statement
An array-write-statement behaves just l ike the wr ite-statement would if the arrays
were written out exp l icitly as array-elements in row maj or order ( the last subscript
varying most rapid ly) . Thus , for examp l e , if "DIMA ( 3 ) , B ( 2 , 2 ) " and OPTION BASE 1 are
in effec t , the fol lowing two s tatements 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- l ist can use the variable
field-count . I f a f ixed - f ie l d -count is used , then the number and type of the
spec if iers must match the array-elements as with WRITE . When the first element
of an array is to be assoc iated with a field-specifier , and if a temp late
e l ement has j us t been comp leted ( or if this is the f irst array in the l is t ) , and
if the next temp late-element has a variab le-field-count , then the field
spec ifier i s used for all the e l ements of the array . When evaluation of the
array is comp l ete , the next array , if any , uses the next temp late-element which
may or may not also have a variab le-field-count . An array mus t use either a
temp late-element with a variable-field-count or temp late-elements with f ixed
field-counts , but not both .
1 1 . 3 . 5 Exceptions
- The value of the index in a set-statement with MARGIN is less than the current
zonewidth for that f i l e ( 4006 , fata l ) .
- The value of the index in a set-statement with a ZONEWIDTH is less than one , or
reater than the current margin for that f i le ( 4007 , fata l ) .
- A set - s tatement with MARGIN or
fatal ) .

ZONEWIDTH

spec ifies an

inactive channel

( 7 004 ,

- A set- s tatement with MARGIN or ZONEWIDTH specifies a f i l e not opened as DISPLAY


( 7 3 1 2 , fatal ) .
- A set - statement with a MARGIN or ZONEWIDTH spec i f ies a f i l e opened as INPUT ( 7 313 ,
fatal ) .
The f o l l owing exceptions for data creation s tatements are grouped according to the
phase of process ing during which they are detected . Phase 1 exceptions imp ly no
change to the f i l e or f i l e pointer . Phase 2 exceptions imply no change to the f i le .
Phase 3 exceptions imp ly that some f i l e - elements may have been created .
Phase 1 Exceptions :
- A data creation statement attempts to access an inactive channel ( 7004 , fata l ) .
- A print - s tatement or array-print-statement attempts to access a f i le opened as
INTERNAL o r , for BASIC-2 only , NATIVE ( 73 1 7 , fata l ) .

- 1 18 -

The record-setter cannot be processed correctly, as described in 1 1 . 2 . 5 , exceptions


7 002 and 7 202 - 7 207 ( use the procedure of 1 1 . 2 . 5 ) .
- A data creation statement attempts to access a f i le opened as I NPUT ( 7 302 , fatal ) .
- A write-statement or array-write-statement attempts to access a KEYED f i l e , but
does not spec ify an exact-search in its record- setter ( 7 3 14 , fatal ) . ( BASIC-2
only)
- The string-expression of a temp late- identif ier is
temp l ate - e lement- l is t ( 825 1 , fatal ) . ( BASIC-2 only)
- A temp late- identifier is used on a
fata l ) . ( BASIC- 2 only)

not a syntactical ly correct

file opened as DISPLAY or INTERNAL

(7315,

- A write - statement or array-write - statement does not have a temp late- ident if ier when
attempting to access a f i l e opened as NATIVE ( 7 3 1 6 , fatal ) . ( BASIC-2 only)
Phase 2 Exceptions :
- For a data creation statement , the condition data-found is true , and a not-miss ing
recovery has not been specif ied ( 7 308 , fata l ) .
Phase 3 Exceptions :
- An attempt is made to create a record larger than the value of RECSIZE ( 8301 ,
fatal ) .
- An expression or array-e lement does not agree in type ( numeric or string) with its
associated TEMPLATE field - spec i f ier ( 8252 , fatal ) . ( BASIC-2 only)
- A temp late-e lement with a variable-field-count does not coincide with the f irst e l
ement o f an array ( 82 5 3 , fata l ) . ( BASIC-2 only)
- There are not enough field-speci f iers in a temp late - statement
expressions or array-elements (8254, fata l ) . ( BASIC-2 only)

for

all

the

- A numeric value has s ignif icant digits to the left of the ava i lable d igit p l aces in
the f ield of a temp late ( 82 5 5 , fatal ) . ( BASIC-2 only)
- A string value is longer than the length of its f ield in the temp late ( 8256 ,
fata l ) . ( BASIC-2 only)
11 . 3 . 6 Remarks ( BASIC-2 only)
Implementations may provide syntactic enhancements to temp late - e lement- li s t , e . g . , to
a l low for add itional data types . The exception for incorrect syntax then appl ies to
the enhanced definition of temp late-element - l i s t .
The variable- f ield-count i s especial ly useful when writing an array whose s i ze may
change in the program, s ince the use of the f ixed - f ield-count imp l ies knowing the ex
act s i ze in advance .
1 1 . 4 File Data Retrieval
1 1 . 4 . 1 General Description
Statements are provided to a l low the program to retrieve data from a f i l e to which i t
has previous ly been written or from a device . The fac i l ities general ize the input ca
pab i l ities presented in Section 10 to f i les . New fac i l ities are also def ined to a l low
input from the various record-types .

- 119 -

1 1 . 4 . 2 Syntax
BASIC-1 and BASIC-2
1. input- s tatement
2.
3.
4.
5.
6.

7.
8.
9.
10 .

> INPUT channe l - express ion input- control c o lon


variable- l is t ( comma SKIP REST ) ?
array - input - s tatement
> MAT INPUT channel -express ion input- control co lon
( redim-array- l ist I variable- length-vector )
l ine- input-statement
> LINE INPUT channel - expression input- control c o lon
string-variab l e - l ist
array- l ine- i nput-statement> MAT LINE I NPUT channel - expression input- control co lon
redim-string-array - l is t
( comma input- contro l - item ) )'(
input- contro l
input-contro l - item
core-record- setter I miss ing-recovery I
prompt-spec i fier I timeout-express ion I
time- inquiry
> READ channel - express ion read-control co lon
read- statement
variab l e - l ist ( comma SKIP REST ) ?
array-read - statement
> MAT READ channel -express ion read- control colon
redim-array- l i s t
read - c ontro l
( c omma read - control - item) )
read- contro l - item
> record- setter I missing- recovery

BASIC-2 only ( Enhanced F iles productions ) :


N l l . read - contro l - item

> temp late- ident i f ier

A g iven input-contro l - item must appear at most once in input-contro l . ( BASIC-2 only)
A given read-contro l - item must appear at most once in read-contro l . ( BASIC-2 only)
A variabl e - length-vector must be declared as one-d imens iona l . ( BASIC-2 only)
1 1 . 4 . 3 Examples
1 . I NPUT # 3 : A, B, C, A$
2 . MAT INPUT #W , BEGI N , I F MISSING THEN EX IT DO: A, B$
3 . LINE I NPUT #G , NEXT: A$ , B$ , C$
MAT LINE INPUT #4, IF MISSING THEN 123 4 : A$ , B$ ( N ) , C$ ( 8 )
4 . MAT LINE I NPUT #4 , I F MISSING THEN 123 4 : A$ , B$ ( N ) , C$ ( 8 )
7 . READ # 3 , SAME , WITH 3 3 3 : W$ , SKIP REST
8 . MAT READ #N , RECORD W+2 , IF MISSING THEN 1 1 1 , WITH 222 : N, W ( Q )
1 1 . 4 . 4 . Semantics
A l l data retrieval statements fol low a general pattern, which will be described here .
Deta i l s on the aspects pecul iar to each of the various forms are presented below , un
der the headings for each statement typ e .
Firs t , the channel from which data w i l l b e retrieved i s determined f rom the channel
expre s s ion . Then , the f i le-attributes are checked against the intended operation . Al l
data retrieval s tatements require an access -mode of I NPUT or OUTIN . If the channel is
active and the f i le-attributes are compatible with the data retrieval statement , then
the next phase begins . Otherwise , an exception results and the pointer and a l l pro
gram var i ab les remain unchanged .
The second phase of process ing involves setting the f i le pointe r , based on the
record-setter if present . In the absence of a record-setter the f i l e pointer does not
change . This is done exactly as described in 1 1 . 2 . The data- found condition is now
set , again as described in 11 . 2 . If data- found is false and a miss ing-recovery is
present , then the io- recovery-action is taken, otherwise an exception results . In e i
ther cas e , n o further change is made t o the pointer pos ition .

- 120 -

If data-found is true , then the third phase begins , the actual input of data from the
e l ement indicated by the pointer . Data is transferred from the file element ( s ) to
each of the operands (variables or arrays ) , from left to right , with successive data
or values or fields from the file being ass igned to successive variab les or arrays .
Note in particular that evaluation of subscripts , substring-qualifiers , and redims is
delayed unti l after ass ignment of data to previous operands , but occurs before as
s ignment of data to the operand to which they apply . Note also that assignment of a
string value to a string variable with a substring-qualifier takes place in accor
dance with the usual s emantics of string ass ignment described in 6 . 5 . If an exception
occurs during data transfer , variab les and array-elements for which a legal ass ign
ment has been made retain their new values , but al l subsequent variab les and array
e lements retain their original values . Fol lowing a successfu l data retrieval
operation, the pointer is advanced to the next file element, i . e . , the next record ,
record-area, or value in the file .
One data retrieval operation usua l ly affects only one file element . The three cases
in which several file elements may be processed are :
- LINE or MAT LINE INPUT,
- READ from a STREAM f i l e , and

- INPUT or READ from a DISPLAY f i l e with records with trailing commas ( indicating
continuation of data ) .
The SKIP REST option is allowed only for non-stream files . It causes the remainder of
the record from which the last datum or value or field was taken to be ignored . I t is
s ti l l mandatory that the record contain enough data to satisfy the variables or
arrays in the list.
During this third phase of processing ,
Each such exception is associated with
pointer i s advanced to the file element
exception is associated . The fo l lowing
fi le-element they app ly to .

a number of exception conditions may arise .


a particular file element . In a l l cases , the
immediately following the one with which the
table s ummari zes these exceptions and which

Exception

Associated file-element

File-element larger than RECSIZE

The overs ize file-element

Invalid redim, subscrip t ,


substring-qualif ier, redim too
large .

The file-element from which


data would have been taken

Bad TEMPLATE : wrong type ,


field-count of " ? " on other
than first element of an array,
too few specifiers ( BASIC-2 only)

The file-element from which


data would have been taken

Bad data: wrong type , syntax,


overflow

File-element containing the


bad data

Insufficient data in file-element

The file-element with


insufficient data

Insufficient data in file

End of file ( i . e . no associated


file-e lement)

Excess data in fi le-element

The file-element with excess


data

- 121 -

Input- statement
The effect of a prompt-spec if ier , t imeout-express ion , and t ime-enquiry is as de
scribed in 10 . 2 . These input-contro l - items app ly only to interactive terminal
devices . For other devices and true f i les , their effect is imp lementation-defined .
The transfer of data with the input- statement also works just as described in 10 . 2 ,
except that records are treated l ike input- rep l ies , and end-of-record i s treated l ike
end-of- l ine . Each datum ( as defined in 10 . 1 ) is ass igned in order to a variable in
the variable- list . A l l the INPUT operations ( as opposed to the READ operations ) are
val id only for a f i l e opened as DISPLAY . For any other record-typ e , an exception re
sults . The input- statement may process several records if the last non-blank charac
ter in a record is a comma . I f , following a record with a trail ing comma, end of f i le
is encountered before al l variables have been ass igned values , then the remaining
variables sha l l retain their o l d values , the f i l e pointer sha l l be positioned to end
of f i l e , and an exception sha l l resu l t .
When any of te INPUT statements is executed for a device and a phase 3 exception oc
curs , imp lementations may use the recovery procedures speci f ied for true f i les in
this s ection, o r , i f an equivalent exception is speci f ied in Section 10 , that recov
ery procedure may be used instead . This is to allow input from several interactive
devices to use the nonfatal recovery procedures .
Array- input- s tatement
The array- input- statement behaves just l ike the input- statement wou ld if the arrays
were written out exp l ic itly as array-elements in row maj or order ( the last subscript
varying most rapid l y ) . The only additional capabi l ity is that of a l l owing a redim to
change the d imens ions of the array in accordance with the redim rules for the array
input- statement without a channel -express ion ( see 10 . 5 ) . Thus , for examp l e , if "DIM
A( 3 ) 11 and OPTION BASE 1 are in effec t , the f o l lowing two statements are equivalent :
INPUT liN : A
INPUT #N : A ( l ) , A ( 2 ) , A( 3 )

MAT

The f o l lowing two s tatements are also equivalent :


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 )

MAT

However , the effect of


MA T

INPUT #N : A( 1 ) , B ( A ( l ) )

depends on the first datum encountered , s ince i t contro ls the effective s ize o f array
B . Nonethe les s , it behaves exactly as would an input-statement for which the appro
priate number of array-elements for B had been coded . If an array is encountered
whose redim yields a s ize less than 1 in any d imens ion, then i t , and a l l subsequent
arrays , sha l l retain their o l d values , and an exception sha l l result .
Variab l e - length-vectors
The transfer of data and consequent redimens ioning of the array of a variable- length
vector takes place just as described in 10 . 5 .
Line - input- statement
The l ine- input-statement behaves exactly as described in 10 . 2 , except that records
are treated l ike input- rep l ies , and end-of-record l ike end - of - l ine . The content of
each success ive record i s assigned as the value of success ive string-variab les , in
c luding any leading or trai l ing spaces . A record may contain a nul l string , and it

- 122 -

shal l be ass igned in the normal way . If end of f i l e is encountered before a l l vari
ables have been assigned values , then the remai ning variables sha l l retain their o l d
values , the f i le pointer sha l l b e positioned t o end of f i l e , and a n exception sha l l
result .
Array- l ine- input-statement
The array - l ine- input-statement behaves just as would a l ine- input statement for which
the array-elements had been coded out exp l ic i t l y , instead of as arrays . See semantics
above for array- input-statements . Note that here too , the size of a later array may
depend on the value ass igned to an earl ier array , e . g . :
MAT LINE INPUT #N : A$ ( 1 ) , B$ ( VAL( A$ ( 1 ) ) )
I f the f irst record contained the string 1 1 12 " , then twelve subsequent records would
be read into the array B$ . If an array is encountered whose redim yie lds a s ize less
than 1 in either d imens ion , then i t , and all subsequent arrays , sha l l retain their
old value s , and an exception results .
Input-statements for channe l zero
Input from channel zero works in accordance with the semantics for non - f i l e devices .
For those exceptions for which a d ifferent recovery procedure is speci f ied in Section
10 than in 1 1 , the procedure of Section 10 sha l l be used .
Read-operation
The read - s tatement and array-read- s tatement are used to retrieve data from f i les with
records of any type . Success ive data or values or f ie lds are assigned to success ive
variab les or arrays in the operand list . READ may access several f i l e elements for
SEQUENTIAL or STREAM f i les , but only one for RELATIVE and KEYED f i les . RELATIVE or
KEYED fi les are provided only in BASIC- 2 .
File organi zations
For non- STREAM f i les ( SEQUENTIAL f i les in BASIC- 1 and RELATIVE and KEYED f i les in
BASIC- 2 ) , the variables receive values from the sequence of data or values or fields
within a record . There must be just enough data within the record (or records in the
case of DISPLAY records with trail ing commas ) to satisfy the variable- l ist ( except
for SKIP REST , see above ) . For STREAM f i les , the variables receive thei r values d i
rectly from the sequence that constitutes the f i l e , beginning with the f i le-element
indicated by the pointe r , and so f i le-element boundaries are insignif icant . If end of
f i l e is encountered before al l variables have been ass igned values , then the remain
ing variables sha l l retain their old values , the f i le pointer sha l l be positioned to
end of f i l e , and an exception sha l l result .
Display record- type
Records in DISPLAY f i les are sequences of characters . The retrieval of string data
sha l l take p lace as described in 10 . 2 . Note that retrieving data from a record cre
ated with PRINT does not necessarily preserve the same value , s ince , for instance ,
leading and tra i l ing spaces are not saved in unquoted strings n input. For numeric
data , the accuracy sha l l be cons istent with the usual semantics for assignment of a
numeric-constant to a numeric-variab l e , i . e . at least six s ignif icant d ig its for
OPTION ARITHMETIC NATIVE and at least ten d igits for OPTION ARITHMETIC DECIMAL . For a
numeric-constant with no more s ignif icant d ig its than the imp lementation-def ined pre
c i s ion , the exact value i s ass igned with OPTION ARITHMETIC DECIMAL .
A READ operation on a DISPLAY record ass igns values exactly as would an INPUT opera
tion with the same variable- l ist or redim-array - l is t . Note , however , that not a l l the
INPUT fac i l it ies are available for READ , wl1ich is record-oriented .

- 123 -

Internal record-type
An internal record ( and a stream f i le ) is a sequence of values . There are two types
of value , numeric and string . For INTERNAL f i le e l ements , the values must be re
trieved with a variabl e of the same type as that of the value , otherwi s e an exception
results . Thus , the contents of an INTERNAL f i le e l ement are self-typed . The sequence
of values and thei r types are determined by the record operation which created or
modified the f i l e - e l ement ( s ) . When a value i s retrieve d , the effect is as i f the ex
pression with which it was created were ass igned to the input variable with a let
statement . The length and content of string values are preserved . Numeric values are
also preserved , consistent with the usual l imitations on precis ion and type associ
ated with the preva i l ing ARITHMETIC option .
Native record- type ( BASIC-2 only)
The TEMPLATE describes the location and type of fields within the record . When read
ing from a native record , a TEMPLATE must always be used . It must not be used with
any other record- typ e . A TEMPLATE is assoc iated with a particular data retrieval
statement by means of the temp late- identi f ier in the statement , which specif ies the
temp late - statement to be used , or a string -express ion whose value must be a syntact i
c a l l y correct temp late-e lement- l ist . The string-expression is evaluated before any
input takes p lace and before any redims , substring qua l i f iers , or subscripts are
evaluated . Several s tatements may use the same template-statement .
When retrieving data from a native record , each variab le within the variab l e - l ist is
assoc iated with a f i e l d - specifier within a temp late ; the spec if ier is then used to
return data from a f ield within a record . This association takes p lace from left to
r ight , within the variable- l ist and temp late - e l ement- l is t , each variable using the
next ava i l ab l e f i e l d - speci f ier . A variable is assoc iated with a spec i fier after a
value has been ass igned to the previous variab l e , and any subscripts , substring
qual i f i ers , or redims for this variable have been evaluated . If the type of the vari
ab le ( numeric or string ) disagrees with the type of the spec ifier , a n exception re
sults . The number of spec i fiers must not be less than the number of variables . Extra
spec if iers beyond the variables are ignored . The contents of the next field in the
record is interpreted according to the speci fier , and the resulting value p laced in
the variab l e .
When retrieving data , the spec if iers o f al l fields within a record must b e compatible
with the speci fiers with which they were created , otherwise the results are
implementation-def ined . In order to be compati b l e , the creating and retrieving speci
f iers for a field must both be of type STRING , with equal string - f i e l d - s i zes , or both
NUMERIC with a numeric-field-s ize of E, or both NUMERIC with equal integer- s i zes and
fraction- s i zes . An omitted integer-size or fraction- s i ze is treated as equivalent to
zero .
\fuen the TEMPLATE specif iers are compatible with the record , then the values are re
tr ieved in accordance with the field s izes . For strings , a value is as s igned with
length equal to the string - field- s iz e , and contents as origina l ly stored in the
record , includ ing any spaces used for padding . For numbers , a value is assigned whose
accuracy is l imited only by the numeric - f i e l d - s i ze and ARITHMETIC option . For numbers
stored with a field s ize of E, or with a f ixed-point - s ize and with no more s ignif i
cant d i gits than the imp lementation-def ined prec i s ion, the exact value is retained
under OPTION ARITHMETIC DECIMAL . Otherwise, the numbers are rounded according to the
OPTION in effect and stored in the variable . Section 1 1 . 3 . 4 describes how values are
stored in the fields of native records an the effect of field-counts . The only d i f
ference upon retrieval is that SKIP speci f iers d o not generate f i e l d s of zero or
spaces , but cause the affected f ields s imp ly to be skipped over . As befor e , such
speci f iers are not assoc iated with variab les .

- 124 -

Array-read- statement
In general , an array-read- statement behaves just l ike the read- statement would if the
arrays were written out exp l icitly as array-e lements . As with INPUT , there is delayed
evaluation of redims .
BASIC-2 only
For this reason , when reading from a native record , a variable-field-count is
provided . I f a f ixed -field-count is used , then the number and types of the
specifiers must match the array-e l ements , as with READ . When the first e l ement
of an array is to be associated with the next specifier , however , and if a
t emp late-el ement has just been comp leted ( or if this is the first array in the
l is t ) , and the next temp late-element is a variab l e -field -count , then the associ
ated specif ier is used for a l l the e l ements of the array . When the array has
been f i l led , the next array , if any , uses the next temp late - e lement, which may
or may not also have a variabl e - f i e l d - count . An array must either use a
template - e l ement with a variable-field-count or temp late- e lements with f ixed
f i e l d - counts , but not both .
11 . 4 . 5 Exceptions
The exceptions are grouped according to the phase of process ing during which they are
detected . Phase 1 exceptions imp ly no change to the f i l e pointer or variab les . Phase
2 exceptions imp ly no change to the variab les . Phase 3 exceptions imp ly that some
variables may have received values from the f i l e .
Phase 1 Exceptions :
- A data retrieval attempts to access an inactive channel ( 7004, fata l ) .
- An input-statement , array- input- statement , l ine- input-statement , or array- l ine
input- statement attempts to access a f i l e opened as INTERNAL or , in BASIC-2 only,
NATIVE ( 7 3 18 , fatal ) .
The record-setter cannot be processed correctl y , as described in 11 . 2 . 5 , exceptions
7002 and 7202 - 7 207 ( us e the procedure of 11 . 2 . 5 ) .
- A data retrieval s tatement attempts to access a f i le
fatal ) .
The string-expression o f a temp late- identifier is
temp late- e l ement- l ist ( 8 2 5 1 , fata l ) . ( BASIC- 2 only)

opened

as

OUTPUT

( 7 303 ,

not a syntactical ly correct

- A temp late- identifier is used on a f i l e opened as DISPLAY or


fata l ) . ( BASIC- 2 only)

INTERNAL

(7315,

- A read- statement or array-read- s tatement does not have a temp late-identifier when
attempting to access a f i le opened as NATIVE ( 7 3 1 6 , fata l ) . ( BASIC-2 only)
- The SKIP REST option is used on a f i l e opened as STREAM ( 7 3 2 1 , fatal ) .
Phase 2 Exceptions :
For a data retrieval statement , the condition data-found is false and a miss ing
recovery has not been specified ( 7 305 , fata l ) .
Phase 3 Exceptions :
- An attempt is made to access a record l arger than the value of RECSIZE ( 8302 ,
fata l ) .
- The first index in a redim-bounds is greater than the second ( 6005 , fata l ) .
- A s ingl e index used in redim bounds is less than the default lower bound in effect
for the program unit ( 6005 , fatal ) .

- 125 -

- The total number of e l ements required for a redimensioned array exceeds the number
of e l ements reserved by the array ' s original d imensions ( 5001 , fata l ) .
- A variable or array-element does not agree in type ( numeric or string) with its as
sociated TEMPLATE specifier ( 82 5 2 , fata l ) . ( BASIC-2 only)
- A variable- field-count in a template - e l ement does not coincide with the first ele
ment of an array ( 82 5 3 , fata l ) . ( BASIC-2 only)
- There are not enough TEMPLATE specifiers for a l l the variables or array-elements
( 82 5 4 , fatal ) . ( BASIC- 2 only)
- A data retrieval statement , other than a l ine- input- statement or an array- l ine
input-statement , attempts to access a DISPLAY record that is not a syntactically
legal input-rep ly ( 8105 , fata l ) .
The datum of a DISPLAY record to be ass igned to a numeric variab le is not a
numeric-constant ( 8101 , fata l ) .
A value in an I NTERNAL record does not agree in type ( numeric or string ) with the
variabl e to which it is to be ass igned ( 8120, fatal ) .
A value , datum , or field ( for BASIC-2 only) in a f i l e causes numeric overflow upon
ass ignment to the variabl e ( 1008 , fatal ) .
A value , datum , or field ( fo r BASIC-2 only) in a f i le causes string overflow upon
ass ignment to a variabl e ( 1105 , fata l ) .
- There are not enough data, values , or fields ( for BASIC-2 only) within a record of
a non- S TREAM f i l e for the operands of a data retrieval statement and the record is
not DISPLAY with a tra i l ing comma ( 8012 , fata l ) .
- End of f i l e is encountered whi l e seeking further data for the operands of a data of
a data retrieval s tatement ( 8011 , fata l ) .
- There are too many data in a record for the operands of a data retrieval statement
and SKIP REST is not specified ( 8013 , fatal ) .
- There is just enough data in a DISPLAY record with a tra i l ing comma to satisfy a
reques t for input , and SKIP REST is not specified ( 8013 , fata l ) .
1 1 . 4 . 6 Remarks
Impl ementations may choose to treat underf lows as exceptions ( 1508 , nonfatal : supp ly
zero and continue) . In BAS IC - 2 , this permits interception by exception hand lers .
1 1 . 5 F i l e Data Modification (BASIC-2 only)
1 1 . 5 . 1 General Description
Statements are provided to a l low the user to modify data previous ly s tored in a f i le .
Such data can either be changed or deleted . The modifications are always done at the
record leve l .
l l . 5 . 2 Syntax
Core productions
None .

- 126 -

BASIC- 2 only ( Enhanced Files productions ) :


1 . imperative - statement
2 . rewrite-statement
3 . array-rewrite- s tatement
4.
5.
6.
7.
8.
N9 .

rewrite-control
rewrite-contro l - item
delete-statement
delete-control
delete-contro l - item
rewrite-contro l - item

> rewrite - statement I array-rewrite - statement I


delete-statement
REWRITE channel - express ion rewrite-control co lon
express ion- l i s t
MAT REWRITE channe l -express ion rewrite-control co lon
array- list
( comma rewrite-contro l - item ) '
> miss ing-recovery I record-setter
DELETE channel -expression delete - control
( comma del ete-contro l - item) )'<
miss ing- recovery I record-setter
> temp late-identifier

The l ine-number of a temp late-identifier must refer to a temp late- statement in the
same program-un i t .
A given rewrite-contro l - item must appear at most once in rewrite-contro l .
A given de lete-contro l - item must appear at most once in delete-contro l .
1 1 . 5 . 3 Examples
2 . REWRITE #N , KEY = B$ , IF MISSING THEN 666 : A , B , C$
3 . MAT REWRITE 113 , RECORD N- 1 , WITH 111 : X , Y , Z
6 . DELETE 113 , KE Y "JONES"
1 1 . 5 . 4 Semantics
The data modification statements are modeled c losely on certain aspects of data re
trieval statements and data creation statements . Like the data retrieval statements ,
they operate on existing records . Like the data creation statements , they can alter
the state of a f i le . The data modification statements are specif ied only for f i le
organizations RELATIVE and KEYED . For other f i le-organizations , their effect is
imp lementation-def ined . The data modification statements may be used only with
access -mode OUTIN . Except for access -mode , the f irst and second phase of process ing
( i . e . checking of f i l e attributes and setting the f i l e pointer) for these statements
is exactly l ike that for the data retrieval statements ( see 1 1 . 4 . 4 ) , because they op
erate on existing record s . The third phase of process ing , undertaken only if the op
eration is lega l , the f i le pointer successfully set , and data- found is true , is de
scribed below under the individual headings .
Rewrite - statement
The rewrite-statement generates exactly one record , and that record is identical to
the one that would be generated by a write- statement with the same expression- list or
array- l ist and temp late- identif ier , if any ( see 11 . 3 . 4 ) , with one exception : for a
NATIVE record , fields governed by SKIP are not f i l led with zero or spaces , but rather
the previous contents of the f ields are left unchanged . This effect of SKIP occurs
only if the TEMPLATE used by the REWRITE is compatible with TEMPLATE last used to a l
ter the record ( see 11 . 4 . 4 for the definition o f "compatib l e" ) . The result o f using
an incompatibl e TEMPLATE containing SKIP is imp lementation-def ined . The use of an in
compatible TEMPLATE without SKIP is defined above since the entire record is re
p laced .
If no exceptions occur during the generation of data to be used for modification of
existing data , then the record pointed to by the f i le pointer is replaced by the
record j ust generated , and the f i le pointer advanced to the next f i le-element . This

- 127 -

imp l ies that the identifying record-number in a RELATIVE f i l e , or identifying key in


a KEYED f i le 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 f i le is un
changed .
Array-rewrite - statement
An array-rewrite-statement behaves just l ike rewrite - statement would if the array
e l ements were w ritten out exp l icitly . The rules for matching arrays and spec ifiers in
a TEMPLATE are exactly the same as for the array-write - s tatement ( see 11 . 3 . 4 ) .
Delete-statement
The delete-statement causes the record
and the f i le po inter advanced to the
RELATIVE f i l e , the affected record-area
f i l e , the affected record is e l iminated
file .

indicated by the f i l e pointer to be de lete d ,


next f i le-element . This imp lies that f o r a
no longer contains a record , and for a KEYED
f rom the sequence of records constituting the

11 . 5 . 5 Exceptions
The f o l l owing exceptions are grouped according to the phase of processing during
which they are detected . Phase 1 exceptions imply no change to the f i le or f i le
pointer . Phase 2 exceptions imp ly no change to the f i l e . Phase 3 exceptions also im
p ly no change to the f i le .
Phase 1 Exceptions :
- A data modification statement attempts to access an inactive channel ( 7004 , fata l ) .
- A data modification statement attempts to access channe l zero ( 7 32 0 , fatal ) .
- The record- setter cannot be processed correctl y , as described in 1 1 . 2 . 5 , exceptions
7002 and 7202 - 7 207 ( us e the procedure of 11 . 2 . 5 ) .
- A data modification statement attempts to access a f i le opened as INPUT or as
OUTPUT ( 7 322 , fatal ) .
The string-expression of a temp late- identifier
temp late- e lement - list ( 8 2 5 1 , fata l ) .
- A temp l ate- identifier
fatal ) .

is

is used on a f i l e opened as

not a syntactica l l y correct

INTERNAL or DISPLAY

( 7315 ,

- A rewrite - statement or array-rewrite - statement does not have a temp late- identifier
when attempting to access a f i l e opened as NATIVE ( 7 316 , fatal ) .
Phase 2 Exceptions :
- For a data modif ication statement , the condition data- found
miss ing-recovery has not been specified ( 7 305 , fata l ) .

is

fals e ,

and

Phase 3 Exceptions :
- An attempt is made to rewrite a record larger than the value of RECSIZE ( 83 0 1 ,
fatal ) .
An expression or array-element does not agree in type ( numeric or string) with its
associated TEMPLATE specifier ( 82 5 2 , fata l ) .
- A temp late-e l ement with a variable-field-count does not coincide with the f irst e l
ement of an array ( 82 5 3 , fatal ) .

- 128 -

There are not enough TEMPLATE specifiers for a l l the expressions or array-elements
( 82 5 4 , fata l ) .
A numeric value has s ignificant digits to the left of the availabl e digit p laces in
the f i e l d of a template ( 82 5 5 , fatal ) .
- A s tring value i s longer than the l ength o f its field in the template ( 8 2 5 6 , fatal )
1 1 . 5 . 6 Remarks

Note that the DELEIE and REWRITE w i l l affect the record indicated by the f i l e
pointer , even i f the po inter i s s e t with NEXT o r l e f t a s is from previous operation
( i . e . if the record-setter is absent ) .

- 12 9 -

1 2.

E XC E P T I ON

HAN D L I N G AND

D E BU G G I NG

- 130 -

12 . EXCEPTION HANDLING AND DEBUGGING


12 . 1 Exception Hand l ing ( BASIC-2 only)
12 . 1 . 1 General Description
Exception hand l ing fac i l ities provide a means of regaining control of a program af
ter an exception has occurred .
12 . 1 . 2 Syntax
BASIC-2 only
1 . protection-block
2 . when-use-block
3.
4.
5.
6.
7.
8.
9.
10 .
11.
12 .
13 .
14 .
15 .
16 .
17 .
18 .
19 .

when-use-block I when-use-name-block
when- l ine when- block use - l ine exception-hand ler
end-when- l ine
l ine-number WHEN EXCEPTION IN tail
b lockl't
l ine-number USE tai l
b lockl't

when- l ine
when-block
use- l ine
exception-hand ler
l ine-number END WHEN tai l
end-when- l ine
when-use-name - l ine when-block end-when- l ine
when-use-name- block
l ine- number WHEN EXCEPTION USE handler-name tai l
when-use-name - l ine
routine- identifier
hand ler-name
hand ler-return- s tatement
RETRY I CONTINUE
exit-hand ler-statement
EXIT HANDLER
CAUSE EXCEPTION exception- type
cause - statement
index
exception-type
hand l er - l ine exception-hand ler end-hand ler- l ine
detached - hand ler
l ine-number HANDLER hand ler-name tai l
hand ler- l ine
l ine- number END HANDLER tai l
end-hand ler - l ine
numeric - supp l ied- function > EXLINE I EXTYPE
string-supp l ied-function > EXTEXT do l lar - s ign

Hand ler- return-statements and exit-hand ler-statements sha l l only occur within
exception-hand lers . The no -argument numeric - supp l ied- functions EXLINE and EXTYPE
sha l l be invoked only within exception-hand lers . EXTEXT$ takes a s ing le numeric argu
ment , which is an index .
No l ine-number in a contro l - transfer outside a protection-block sha l l refer to a l ine
in that protection-block other than its when- l ine or when-use-name- l ine . No l ine
number in a contro l -transfer inside an exception-hand ler sha l l refer to a l ine out
side that exception-handler other than its own end- hand ler- l ine or end-when- l ine , nor
sha l l a l ine-number in a contro l -transfer outside an exception-hand ler refer to a
l ine inside that exception-hand ler or to its end-handl er - l ine or end-when- l ine .
A detached-hand ler referred to in a when-use-name- l ine within an internal - proc -def
must be defined in the same internal -proc-def . A detached-hand ler referred to in a
when-use-name- l ine that is not within an internal -proc- def must be defined in the
same program-unit but not within an interna l - proc-def . No two hand ler - l ines in the
same program unit sha l l have the same hand ler-name . A detached-hand ler may not appear
within a protection-b lock .
A protection-block may not appear within an exception-hand ler .
12 . 1 . 3 Examples
Examp l e 1

hand l ing errors in input - rep l ies by a l lowing the input - repl y to be
resupp l ied after issuing a suitabl e message

100 WHEN EXCEPTION IN


PRINT "Enter your age and weight"
110

- 131 -

INPUT a , w
120
IF a > 10 THEN
130
140
PRINT "What is your height"
I NPUT h
150
END IF
160
170 USE
PRINT "Please enter numbers only"
180
190
RETRY
200 END WHEN
Exampl e 2 : dynamic f i le opening
100 HANDLER f i l e_troubl e
LET f i l e_ok$ = " false"
1 10
120
IF EXTYPE = 7 107 THEN
LET message$ = "doesn ' t exist"
130
ELSEIF EXTYPE = 7 102 THEN
140
LET message$
" is the wrong type"
150
ELSE
160
LET message$
"couldn ' t be used"
170
END IF
180
PRINT " f i le" ; f i l ename$ ; message$ ; " try again"
190
200 END HANDLER
500 DO
5 10
INPUT f i l ename$
LET f i l e_ok$ = "true"
520
530
WHEN EXCEPTION USE f i le- troubl e
540
OPEN #n : NAME f i lename$ ! other parameters omitted
550
END WHEN
560 LOOP UNTIL f i l e_ok$ = 11true"
Exampl e 3 : Nested handlers
100 WHEN EXCEPTION IN
1 10
DO
120
READ # 1 , IF MISSING THEN EXIT DO: A
LET I = I+l
130
! I initial ized outside loop
WHEN EXCEPTION IN
140
LET B ( I ) = lOOOiW''A
150
USE
160
! Assume it is numeric overflow
170
LET B ( I ) = MAXNUM
180
CONTINUE
190
200
END WHEN
LOOP
2 10
220 USE
non-numeric data
8101 THEN
230
IF EXTYPE
get next data item
240
RETRY
give up
ELSE
250
260
PRINT "Unabl e to process f ile"
STOP
270
280
END IF
290 END WHEN
13 . CAUSE EXCEPTION I

- 132 -

12 . 1 . 4 S emantics
When an exception occurs during the execution of a program-unit, the action taken
sha l l depend upon whether or not the exception occurs within a when-block . If the ex
ception occurs outside a when-block, then the default exception hand l ing procedures
specif ied in this S tandard sha l l be app l ied ( see 2 . 4 ) . If the exception occurs within
a when - block, then the default exception hand l ing procedures , which require that an
exception be reported , sha l l not be app l ied ; instead , control sha l l be transferred to
the exception-hand ler associated with the inner-most protection-b lock within which
the exception occurred .
When the protection-b lock is a when-use-b lock , the assoc iated exception- handler is
that which f o l lows the use - l ine of the protection-b lock . When the protection-block is
a when-use-name-block, the associated exception-hand ler is the detached-hand ler named
in the when-use-name- l ine of the protection-b lock . In a l l respects , a detached
hand ler behaves semantical ly as though it were an exception-hand ler in the when-use
b lock of the when-block with the exception .
Within an exception-hand ler , the type of the exception which caused that hand ler to
be executed shal l be obtainabl e as the value of the parameter less function EXTYPE .
The values of EXTYPE for a l l exceptions defined in this Standard are specified in
Tab le 2 , along with the description of each exception in this Standard . The l ine-num
ber of the l ine whose execution caused the exception sha l l be obtainabl e as the value
of the parameter less function EXLINE .
There are four means of exiting from an exception-hand ler .
- Execution of the handler-return- statement CONTINUE sha l l cause contro l to be trans
ferred to the statement lexical ly f o l lowing that which caused the exception . If
the exception occurred in a l ine which begins or is part of a structure ( such as a
do- l ine , loop - l ine , for - l ine , if-then- l ine , e l seif-then- l ine , se lect - l ine , or
case - l ine ) , then control sha l l be transferred to the statement lexical ly fol lowing
the entire structure of which the l ine is a part .
- Execution of the hand ler- return- statement RETRY sha l l cause contro l to be trans
ferred to the statement or l ine which caused the exception , causing the statement
or l ine to be re-executed ; if that statement was performing data retrieva l , then
the previous input- rep ly or l ine- input-rep ly sha l l be discarded and a new one re
quested .
- If contro l reaches an end-when- l ine which terminates an exception-hand ler or
reaches an end - hand l er - l ine , then control sha l l be transferred to the l ine fol low
ing the end-when- l ine of the protection-b lock within which the exception occurred
with no further effect .
- Execution of an exit-hand ler- s tatement sha l l cause the exception to be propagated
to the lexical environment surrounding the innermost protection-block containing
the exception ( also note the effect of cal ls and function invocations - see
below ) ; i . e . the effect on handl ing the exception is as if the exception-hand ler
did not exist ( except for the effect of any statements already executed in the
hand l er ) , and the rules for hand l ing the original exception depend upon whether or
not the exception occurs within some outer when-block .
If execution reaches a use - l ine in a when-use-b lock, or an end-when- l ine in a when
use-name- b lock, then control sha l l be transferred to the l ine fo l lowing the
protection-block of which the use - l ine or end-when- l ine is a part . I f execution
reaches an end -hand ler- l ine of a detached-hand ler , control sha l l continue at the l ine
fo l lowing the end-when - l ine of the when-use-name-b lock causing the exception . If exe
cution reaches a hand ler- l ine of a detached-hand ler other than by the occurrence of
an excep t ion , control sha l l then continue at the l ine immed iately fo l lowing the end
hand ler- l ine .

- 133 -

A separate GOSUB stack is associated with each exception-hand ler ( see 8 . 2 ) so RETURN
never attempts to transfer control into or out of an exception handler .
Execution of a cause - statement sha l l result in the occurrence of a fatal exception
and the s etting of EXTYPE to the rounded value of the exception- type .
If an exception is caused by a statement lexical ly within an exception-hand ler , then
this new exception sha l l be hand led by the defau l t exception-hand l ing procedures .
If a fatal exception occurs in a procedure-part or internal-proc- def and either :
- the l ine causing the fatal exception is not contained in a when-block and therefore
no exception-hand ler is entered , or
an exception-hand ler is entered , an exit-hand ler-statement is executed with the
hand ler, and there is no lexically surrounding when-b lock to intercept the
exception ,
then the fatal exception sha l l be propagated back to the l ine that invoked the
procedure-part or internal-proc-def . This propagation sha l l continue to occur until
either :
- a user- def ined exception-hand ler resolves the exception by execution of a handler
return- statement o by causing contro l to pass to an end-hand ler- l ine or to an end
when- l ine which terminates the exception-hand ler , or
the main program or a para l l e l - section is reached , in which case the default
exception-hand l ing procedures are app l ied .
If an exception-hand ler is invoked as a resul t of this process , then the value re
turned by the EXTYPE function sha l l be 100000 p lus the value that wou l d have been re
turned by EXTYPE in the procedure-part or integral -proc-def in which the exception
origina l ly occurred . The value of EXLINE sha l l be the l ine-number of the most recent
l ine to which the exception was propagated , i . e . , the l ine lexical ly within the when
b lock associated with the exception-hand ler, not the l ine of the original exception .
The default exception-hand l ing procedures sha l l always report the EXTYPE and EXLINE
of the original exception .
The value of EXTYPE for exceptions defined by local enhancements to this Standard
s ha l l be negative. When negative values of EXTYPE are propagated , the value sha l l be
- 100000 p lus the value that would have been returned by EXTYPE for the original
exception .
Values of EXTYPE from 1 to 999 wi l l not be used by future enhancements to this
Standard , nor sha l l they be used by local enhancements to this Standard .
The value of EXTEXT$ sha l l be the text part of the error message provided by the sys
tem for the exception number obtained by rounding its argument to an integer . If its
argument is not the exception number of a standard system exceptio n , the value of
EXTEXT$ sha l l be the nul l string .
If the main-program is reached and no exception-hand ler is invoked there as a resul t
of the original exception , then the exception sha l l be hand led b y the default excep
tion hand l ing procedures specif ied in this Standard .
12 . 1 . 5 Exceptions
A cause - statement is executed ( exception-typ e , fata l ) .
12 . 1 . 6 Remarks
Users should note that there are two kinds of exception propagation specified in this
section . First , there is " l exical" propagation, outward to surrounding protection
b l ocks within a program-unit or interna l -proc - de f . If this process propagates the ex
ception outside of any such protection-b lock, "invocation" propagation takes effect,
pass ing the exception back to invoking s tatements .

- 134 -

The function EXLINE should be used with caution , as the use of editing faci l ities
which renumber lines in a program ( see 16 . 2) may inval idate computations invo 1ving
EXLINE . For examp l e , the program fragment
1000 SELECT CASE INT ( EXLINE / 100)
1010 CASE 1, 2
1100 CASE 3 TO 7

would probably behave differently if l ines 100 through 800 were renumbered .
When a fatal exception is propagated back to invoking statements and the default
exception-hand l ing procedure is app l ied as a resul t , only the original exception 1 s
EXTYPE and EXLINE must be reported . Imp l ementations may , however , also report the
l ine-numbers of the l ines through which the exception was propagated , or any other
information deemed usefu l .
It is not pos s ible to pass a nonfatal exception back to a cal l ing routine since it
wi l l be hand l ed either by an exception-handler in the cal led routine or by the system
hand ler . An exception hand ler may, however , cause a fatal exception with a cause
statement .
The cause-statement is
rather to raise a fatal
the spec ified EXTYPE is
not app ly the recovery
curred . It is presumed
receive and process the

not intended actual ly to s imulate any given exception , but


exception with a specified value of EXTYPE . In particular , if
the s ame as for some nonfatal exception, imp l ementations need
procedure as though that nonfatal exception had actua l ly oc
that a program wi l l norma l ly contain an exception-hand ler to
exception .

A l l positive values of EXTYPE are reserved for future versions of this Standard . Ex
ceptions def ined by local enhancements to this Standard shoul d be identified by nega
tive values for EXTYPE , fo l lowing the categories establ ished in Tab l e 2 . The value
returned by EXTYPE for an exception defined in a local enhancement and occurring in a
procedure-part or interna l -proc-def shoul d be - 100000 p lus the negative value identi
fying that exception . For examp le , if an imp lementation chose an EXTYPE value of
-4029 for an invalid argument in a new built-in function, and if that exception oc
curred in a subprogram , but was not hand led there , then the value of EXTYPE in an
exception-hand ler in a cal l ing program should be - 10402 9 .
It is recommended that imp l ementations use the " zero -th" value in a c lass of EXTYPE
values to represent "other exceptions of this type" . For examp l e , an EXTYPE value of
1000 might represent a l l overf l ows not defined in this Standard .
Values of EXTYPE from 1 to 999 may only occur from cause-statements in app l ication
programs . These values should be encouraged for use , s ince they wi l l not be ass igned
standard meanings in future enhancements to this Standard .
CONTINUE should be used with caution. For instance , if an exception occurs within a
def-statement , on-gosub - s tatement , on-goto- s tatement , or if-statement , CONTINUE w i l l
transfer contro l t o the l ex ical ly fol lowing l ine . Such action may not be equivalent
to resumption of normal f low of control .

- 135 -

The f o l lowing examp l e i l lustrates the effect of CONTINUE with contro l structures :
100 WHEN EXCEPTION IN
INPUT PROMPT "enter your age and weight" : a, w
120
130
DO WHILE a > 1
IF a < 9999999999 THEN
140
INPUT PROMPT "What is your height 11 : h
150
PRINT " Check the f o l lowing : 11
160
PRINT "Age : " ; a , "Weight : " ; w, "Height : " ; h
170
I NPUT PROMPT "Enter your age" : a
200
END IF
2 10
PRINT "Lexical ly fo l lowing IF"
220
230
LOOP
240
PRINT "Lexical ly f o l lowing DO WHILE"
For exception in l ine :

CONTINUE transfers contro l to l ine :


130
240
220
160

120
130
140
150

The precise format of the values of the EXTEXT$ function is imp l ementation-defined .
In particul ar , imp lementations may choose to omi t , or to mark in a special way , those
fields in an error message that are spec ific to a particular instance of an excep
tion, such as the l ine number at which the exception occurred or the value of an out
of-range subscript .
12 . 2 Debugging ( BASIC- 1 and BASIC- 2 )
12 . 2 . 1 General Description
Debugging
points to
points , to
off within

fac i l ities are provided by l anguage statements in order to al low test


be bui lt into a program . These statements a l l ow the user to set break
trace the action of the program, and to turn the debugging system on and
each program-unit .

12 . 2 . 2 Syntax
1 . debug - statement
2 . break-statement
3 . trace-statement

DEBUG ( ON I OFF )
BREAK
TRACE ON ( TO channel - express ion ) ? I TRACE OFF

12 . 2 . 3 Examples
3. TRACE ON
TRACE ON TO 113
12 . 2 . 4 S emantics
Each program-unit sha l l have a debugging status , which is either active or inactive
at any given time . The debugging status of a program-unit sha l l persist between invo
cations of that program-unit ( with the exception of the main program ) . Changes in the
debugging status of one p rogram-unit sha l l not affect the debugging status of any
other program-un i t . At the beginning of execution of the program, debugging sha l l be
inactive for a l l program-units .
Execution of the debug- statement DEBUG ON sha l l cause debugging to become active for
the program-unit in which that debug- statement occurs . Debugging shal l remain active
for the remainder of that invocation of that program-unit , and for each subsequent
invocation of that program-unit , until the debug-statement DEBUG OFF is executed in
that program-unit . Execution of the debug- statement DEBUG OFF sha l l cause debugging
to become inactive for the remainder of that invocation of that program-unit , and for

- 136 -

each subsequent invocation of that program unit , unti l the debug- statement DEBUG ON
is executed in that program-unit .
The execution of a break- statement when debugging is active sha l l cause an exception .
The standard recovery procedure from this exception sha l l be to report the l ine
number of the break-statement and to s ignify to the user that interaction with the
debugging system is pos s ib l e . The actions a l l owed by the debugging system , inc luding
the method for continuing execution or terminating execution of the program, are
imp lementation- def ined . If the execution of a program reaches a l ine containing a
break- statement , and debugging is inactive , then it sha l l proceed to the next l ine
with no other effect .
The execution of a trace-statement when debugging is active shall turn tracing on ( if
ON is speci fied ) or off ( if OFF is speci f ied ) in the program-unit containing the
trace-s tatement . Prior to the execution of any trace- s tatement upon each separate en
try to a program-unit, tracing sha l l be off . If the execution of a program reaches a
l ine containing a trace-statement , and debugging is inactive , then it sha l l proceed
to the next l ine with no other effect .
The execution of a trace- statement sha l l not affect the debugging status , nor sha l l
the execution of a debug- statement affect the tracing status ( ON or OFF ) .
Whenever tracing is on and debugging is active in a program-un i t , the following
actions sha l l occur each time a l ine of the speci f ied type is executed
for any l ine which interrupts the sequential order of execution of l ines in a pro
gram, both the l ine- number of that l ine and the l ine-number of the next l ine to be
executed sha l l be reported ; and
- for any l ine which ass igns a value to a variable or to an element of an array , both
the l ine-number of that l ine and any values assigned by execution of that line
sha l l be reported . Whenever tracing has been turned on via a trace-statement with
a channe l - express ion, trace reports sha l l be d irected to the ( d isp lay format ) f i le
ass igned to the speci fied channel . If no channel - expression has been spec if ied ,
the trace report sha l l be d i rected to the device assoc iated with channel zero .
The contents of the trace report are imp lementation-defined , but sha l l include at
least the name of the variab le traced , as that name lexical ly appears in the state
ment causing the TRACE report , and its value ; if the variable is an array element ,
the value ( s ) of its subscripts sha l l also be included .
12 . 2 . 5 Exceptions
A break - s tatement is executed when debugging is active ( 10007 , nonfatal : the recov
ery procedure is to report the line-number of the statement and to permit interac
tion with the debugging system ) .
- An attempt is made to direct a trace report to an inactive channel . ( 7401 , fatal ) .
- An attempt is made to direct a trace report to a f i le which is not d isp lay format
opened with access OUTPUT or OUTIN ( 7402 , fata l ) .
12 . 2 . 6 Remarks
Since an array-as s igrunent ass igns a value to each element of an array, tracing an
array-ass igrunent causes reporting of a l l new array e l ement values .
The form of a l l trace reports is imp lementation-def ined .
Imp l ementations may provide debugging fac i l ities through commands in add ition to
statements . It is recommended that such command s use the same keywords as the
statements .

- 137 -

13.

G RA P H I C S

- 138 -

1 3 . GRAPHICS
The fac i l ities provided in section 13 . 1 through 13 . 3 are a subset of those provided by
level Ob of the Graphical Kernel System (GKS ) as def ined in ISO 7942 . The values of the
EXTYPE function for exceptions defined in GKS are 11000 p lus the value of the GKS error
number .
In GKS terms , any BASIC program that includes statements from Section 13 of this Standard
has imp l ied c a l l s to the functions OPEN GKS , OPEN WORKSTATION ( tiO , 11Maindev11 , 1 ) , and
ACTIVE WORKSTATION #0 before any graphics statements are executed , and cal l s to the func
tions DEACTIVE WORSTATION #0 , CLOSE WORKSTATION #0 and CLOSE GKS as the program terminates .
13 . 1 Coordinate Systems
13 . 1 . 1 General Description
The coordinates used to produce graphic output may be chosen to suit the app l ication .
The range of this system of "probl em coordinates" ( world coordinate s ) is establ ished
by a SET WINDOW s tatement . This range is mapped into a rectangular portion of an ab
stract viewing surface which can be specified by a SET VIEWPORT statement . It is pos
sible to spec ify what part of this abstract viewing surface will be presented to the
user on the d isp lay surface by a SET DEVICE WINDOW statement . This rectangle , in
turn, may be located on the disp lay surface by a SET DEVICE VIEWPORT s tatement .
No output wi l l be produced outside the device viewport . It is possible to guarantee
that a l l graphic output which l ies outside the viewport w i l l be e l iminated by en
ab l ing c l ipping .
Ask statements are provided to determine the current values for the parameters estab
l ished by execution of one of the set statements or by default .
13 . 1 . 2 Syntax
1 . set-obj ect

2.
3.
4.
5.
6.

boundaries
boundary
ask-statement
statu s - c l ause
ask-object

7 . boundary-variables

> WINDOW boundaries I VIEWPORT boundaries I DEVICE


\<liNDOW boundaries I DEVICE VIEWPORT boundaries
I CLIP string-express ion
boundary comma boundary comma boundary comma boundary
numeric- express ion
> ASK ask-obj ect status -c lause ?
STATUS numeric-variabl e
> WINDOW boundary-variab les I VIEWPORT
boundary-variab les I DEVICE WINDOW
boundary-variab les I DEVICE VIEWPORT
boundary-variab les I DEVICE SIZE
numeric-variabl e comma numeric-variable comma
string-variabl e I CLIP string-variable
numeric -variabl e comma numeric-variable comma
numeric-variab le comma numeric -variable

13 . 1 . 3 Examples
1. WINDOW O , PP''2 , - 1 , 1
VIEWPORT . 5''width , width, . 5)''height , height
DEVICE WINDOW O, . 8 , O, 1
DEVICE VIEWPORT . 3 , . 5 , . 1 , 1
CLIP "Off"

- 139 -

4 . ASK WINDOW X1 , X2 , Y 1 , Y2

ASK
ASK
ASK
ASK
ASK

VIEWPORT L , R , B , T
DEVICE WINDOW XMIN , XMAX, YMIN , YMAX
DEVICE VIEWPORT LEFT , RIGHT , BOTTOM , TOP
DEVICE SIZE Width, Height , Unit$
CLIP CLIP_STATE$

13 . 1 . 4 Semantics
Graphic output is specif ied in problem coordinates . A normal ization transformation
defines the mapping from the problem coordinate system onto the norma l ized device co
ord inate ( NDC) space which can be regarded as an abstract viewing surface .
The normal i zation transformation is specified by defining the l imits of a rectangular
area, cal led a window , in problem coordinates . The window is mapped l inearly onto a
specified rectangular area, cal led a viewport , in NDC space .
Execution of a set-statement with the keyword WINDOW sha l l estab l ish the boundaries
of the window . The parameters represent the probl em coordinates of the left , right ,
bottom, and top edge s , in that order , of the window rectangl e . At the start of pro
gram execution the window values are ( 0 , 1, 0 , 1 ) .
Execution of a set- statement with the keyword VIEWPORT sha l l establ ish
boundaries . The parameters represent the norma l ized device coordinates
right, bottom , and top edges , in that order , of the viewport rectang le .
ord inates must not be less than zero not more than one . The value of the
nate sha l l be less than the ri1t , and the bottom less than the top . At
program execution the viewport values are ( 0 , 1, o, 1 ) .

the viewport
of the left ,
Viewport co
left coordi
the start of

The viewport may also be used to define a c l ipping rectang l e . Execution of a set
statement with the keyword CLIP sha l l enab le or disable c l ipping to the viewport
boundary ( see Section 13 . 3 ) depending on whether the value of the string-expression
is "ON" or "OFF" . The letters in the value of the string-expression may be any combi
nation of upper-case and lower-case . At the start of program execution, c l ipping
sha l l be enabled .
A device transformation is used to map a rec tang le in NDC space cal led a device win
dow uniformly onto a rectang le on a phys ica l surface cal led a device viewport . This
transformation sha l l perform equal scal ing with a positive scal e for both axes . To
ensure equal scal ing , the device transformation maps the device window onto the
largest rectang le that can f it within the device viewport such that the aspect ratio
of the device window is preserved and the lower- left corner of the device window is
mapped onto the lower- left corner of the device viewport .
Execution of a set-statement with the keyword DEVICE WINDOW sha l l estab l ish the
boundaries of the device window . The parameters represent the norma l ized device coor
dinates of the left , right , bottom, and top edges , in that order , of the device widow
rectang l e . These coordinates sha l l not be less than zero not greater than one . The
value of the left coordinate sha l l be less than the right , and the bottom less than
the top . At the start of program execution , the device window values are ( 0 , 1 , o,
1 ) . To ensure that no output outside the device window is disp layed , c l ipping takes
p l ace at the device window boundaries . This c l ipping may not be disab l ed . Execution
of a set-statement with the keywords DEVICE WINDOW sha l l cause the disp l ay surface to
be c leared if it is not a lready c l ear .

- 140 -

The f i gure below i l lustrates the relationship between the window, the viewport, the
device window, and the device viewport ; c l ipping is assumed "ON" .

\Hndow

V i ewport
Device v i ewport

Device window

Problem coordinates

NDC Space

DC Space

Execution of a set - statement with the keywords DEVICE VIEWPORT sha l l establ ish the
boundaries of the device viewport . The parameters represent the coord i nates of the
left , r i ght , bottom, and top edges , in that order of the device viewport rectangle .
Units for the device viewport shal l be meters on a device capable of producing a pre
cisely scaled image and appropriate device dependent coord inates otherw i s e . The left
and bottom edges of a d isp lay surface are represented by the coordinate value zero .
At the start of program execution, the device viewport is the entire screen . Execu
tion of a set-statement with the keywords DEVICE VIEWPORT sha l l cause the d isp lay
surface to be c leared if it is not a lready c l ear .
If a statu s - c lause is inc luded in an ask-statement , a status assoc iated with the exe
cution of the ask-statement sha l l be returned in the numeric-variable . If the
statement returned meaningful values for the ask-object, a value of zero sha l l be re
turned in the status - c lause . I f the ask-statement could not return meaningful values
for the ask-obj ect a nonzero value shal l be returned in the status - c lause that is de
fined with the semantics of the particular ask-objec t . If an ask- s tatement with a
particular ask-object is always expected to return meaningful values , the semantics
for that ask-object do not spec ify a lternate status values and zero sha l l a lways be
returned .
Execution of an ask- statement with one of the keywords WINDOW, VIEWPORT ,
WINDOW, or DEVICE VIEWPORT sha l l provide the current values for the spec i fied
gle . Values for the left , right , bottom and top s ides , respectively, sha l l
s igned to the boundary-variab les equal to the values last establ ished by
statement , or , if no appropriate set- statement has been executed , equal
default value .

DEVICE
rectan
be as
a set
to the

Execution of an ask-statement with the keywords DEVICE SIZE sha l l ass ign to the f irst
numeric variabl e the s i ze in the hor izontal direction and shal l ass ign to the second
numeric variable the s i ze in the vertical d irection of the ava i lable display surfac e .
The string-variable sha l l b e ass igned the value "METERS" i f the s i zes are i n meters
or the value " OTHER" if the units of measure are device coordinates of other units .
The values "METERS" and "OTHER" sha l l cons ist of upper - case- letters .
Execution of an ask- statement with the keyword CLIP sha l l ass ign the value 110N11 to
the string-variable if c l ipping is enab led and the value 110FF11 if it is d isabled . The
values returned sha l l be al l upper-case- letters .

- 141 -

13 . 1 . 5 Exceptions
The boundaries in a set-statement specify a rectangle of zero width or height
( 1105 1 , nonfata l : continue with current values ) .
- The boundaries in a set-statement with the keywords VIEWPORT , DEVICE WINDOW , or
DEVICE VIEWPORT specify a rectangle of negative width or height ( 1 105 1 , nonfatal :
continue with current values ) .
A boundary of the viewport is not in the range [ 0 , 1 ]
with current values ) .

( 11052 nonfatal : continue

A boundary of the device window is not in the range [ 0 , 1 ] ( 1105 3 , nonfatal : con
tinue with current value s ) .
A boundary of the device viewport is not in the disp lay space ( 11054 , nonfatal :
continue with current values ) .
The value of the str ing-expression in a set-statement with the keyword CLIP is nei
ther "ON" nor "OFF" after convers ion t o upper-case ( 4101 , nonfatal : continue with
current value) .
13 . 1 . 6 Remarks
The manner in which a particular graphic d isp lay device is selected by a program is
implementation-def ined .
The meaning of a window with the left edge greater than the right or the bottom edge
greater than the top is imp l ementation-def ined . If possible , imp lementations should
provide appropriately inverted images . The effect of a l l graphic output is defined in
terms of the abstract problem space , in which lower values are to the left and down,
and higher values to the right and up . When this problem space is mapped to NDC , it
may be inverted as indicated by the order of the WINDOW boundaries . This relaxes the
GKS rule that s tates that reversal window coordinates causes an error .
SET WINDOW, SET VIEWPORT , SET DEVICE WINDOW , and SET DEVICE VIEWPORT correspond to
the GKS functions SET WINDOW, SET VIEWPORT , SET WORKSTATION WINDOW, and SET
WORKSTATION VIEWPORT , respective ly. The GKS transformation number is one in these
statements as defined above . The GKS workstation number is #0 in these statements .
SET CLIP corresponds to the GKS function SET CLIPPING INDICATOR .
ASK WINDOW and ASK VIEWPORT correspond to the GKS function INQUIRE NORMALIZATION
TRANSFORMATION for norma l i zation transformation one .
ASK CLIP corresponds to the GKS function INQUIRE CLIPPING INDICATOR .
ASK DEVICE WINDOW and ASK DEVICE VIEWPORT correspond to the current workstation win
dow and current workstation viewport parameters , respectively, of the GKS function
INQUIRE WORKSTATION TRANSFORMATION with a workstation identi f ier of one .
ASK DEVICE VIEWPORT before any SET DEVICE VIEWPORT may be used to f ind the device co
ordinates of the ful l ava i labl e device surface .
ASK DEVICE SIZE corresponds to the device coord i nate units and maximum display sur
face s i z e in device coordinate units parameters of the GKS function INQUIRE MAXIMUM
DISPLAY SURFACE SIZE .
1 3 . 2 Attributes and Screen Control
13 . 2 . 1 General Description
A graphical d isp lay device may possess several styles of l ines or points , each with a
particular width or texture . A particular style may be selected for graphic output . A

- 142 -

graphic device also may be abl e to draw lines and / or f i l l areas in a variety of col
ors . Particular co lors may be selected for l ine drawing and screen background .
The current style and co lor of the geometric object may be determined by ask
statements . The number o f colors and the number of l ine or point styles avai lable may
also be determined by ask-statements .
The c lear- s tatement c lears the entire screen , returning it to its background co lor .
For hard- copy devices , the c lear- s tatement causes the paper to advance , the pen to
move aside , or s imi lar action .
This Standard provides text of one style and s ize that sha l l be output horizontal ly
with the initial -po int at the left .
13 . 2 . 2 Syntax
1.
2.
3.
4.
5.
6.
7.

imperative- statement
c l ear- s tatement
set-obj ect
primitive- 2
primitive- 1
rgb- l ist
ask-object

8 . mix- l is t
9 . text-facet

> c lear - s tatement


CLEAR
> primitive- 1 STYLE index I primitive-2 COLOR index
primitive - 1 / TEXT I AREA
POINT / LINE
> [ deleted ]
> primitive - 1 STYLE numeric-variable I primitive-2
COLOR numeric -variabl e I MAX primitive - 1 STYLE
numeric-variable I MAX COLOR numeric-variable
[ deleted ]
[ de leted ]

13 . 2 . 3 Examples
3 . LINE STYLE 2
TEXT COLOR 5
7 . Max color color_max
Max point style PtStyles
1 3 . 2 . 4 Semantics
Execution of a c lear- s tatement sha l l c l ear the graphic disp lay if not already clear .
For soft-copy devices , it sha l l erase the screen . For hard-copy devices , it shal l ad
vance the medium or a l low the device operator to change it .
Execution of a set-statement with the keywords LINE STYLE or POINT STYLE sha l l cause
the index to be evaluated by rounding to obtain an integer N and sha l l estab l ish the
style for subsequent l ines or points to be the Nth one of the set of avai lab le line
or point styles . The number of l ine styles avai lable is imp lementation-def ined , but
sha l l be at least three . A l ine style of one mus t correspond to drawing of s o l id
l ines . A l ine style of two sha l l correspond to drawing of dashed l ines . A line style
of three sha l l correspond to dotted l ines . All other values for l ine style are
imp l ementation-defined . At the initiation of program execution , the l ine style sha l l
b e one .
Point styles produce centered symbol s . The number of point styles is imp l ementation
defined , but sha l l be at least three . A point style of one must correspond to a
dot ( . ) , a point style of two to a p lus s ign ( + ) , a point style of three to an
asterisk ( }'< ) . A l l other values for point- style are imp l ementation-def ined . At the
start of program execution , the point styl e sha l l be three .
Execution of an ask- statement with the keywords LINE STYLE or POINT STYLE sha l l as
s ign the number of the actual current l ine style or point style to the numeric
variabl e .

- 143 -

Execution of an ask-statement with the keywords MAX LINE STYLE or MAX POINT STYLE
sha l l ass ign to the numeric-variable the largest value of LINE STYLE or POINT STYLE ,
respective ly, available .
A l l values for style sha l l be val id from one to the number returned by ASK MAX POINT
STYLE or ASK MAX LINE STYLE .
Execution of a set-statement with the one of the keyword pairs POINT COLOR , LINE
COLOR , TEXT COLOR, or AREA COLOR sha l l cause the index to be evaluated by rounding to
obtain an integer N and shall estab l ish the color index of subsequent po ints , lines ,
tex t , or f i l led areas to be the Nth one of the set of co lors , if possible with the
current graphics device . This color is cal led a foreground color . At the initiation
of execution , the color associated with each index is imp lementation-def ined , and the
foreground co lor indi ces sha l l a l l have the value one . The number of co lors avai lable
is imp lementation-def ined .
Execution of an ask-s tatement with one of the keyword pairs POINT COLOR , LINE COLOR ,
TEXT COLOR , or AREA COLOR sha l l ass ign to the numeric-variable the current value of
the color index for points , l ines , text or f i l led areas , as appropriate .
Execution of an ask-statement with the keywords MAX COLOR sha l l ass ign to the
numeric -variab le the largest distinct value ava i lab le as an index for SET POINT
COLOR , SET LINE COLOR, SET TEXT COLOR, or SET AREA COLOR . A l l values for color index
from zero to thi s value should be val id .
13 . 2 . 5 Exceptions
- A co lor index in a set-statement with the keywords POINT COLOR , LINE COLOR , TEXT
COLOR , or AREA COLOR is less than zero or greater than the maximum color index for
the imp l ementation ( 1 108 5 , nonfatal : use the imp lementation defau l t ) .
- The value of the numeric-expression in a set- statement with the keywords LINE STYLE
is less than or equal to zero or greater than the maximum style avai lable ( 1 1062 ,
nonfatal : use the value one ) .
The value of the numeric-expression in a set - statement with the keywords POINT
STYLE is less than or equal to zero or greater than the maximum style avai lable
( 11056 , nonfata l : use the value three ) .
13 . 2 . 6 Remarks
It is recommended that implementations make the value returned by ASK MAX COLOR the
same as the number of co lors ( not counting background color ) avai lable for s imultane
ous d isplay , not the total number of different co lors ava ilable on the device .
The CLEAR statement corresponds to the GKS function CLEAR WORKSTATION ( #0 ,
CONDITIONALLY ) . SET LINE STYLE and SET POINT STYLE corresponds to the GKS functions
SET LINETYPE and SET MARKER TYPE , respectively . SET LINE COLOR, SET POINT COLOR , SET
TEXT COLOR , and SET AREA COLOR correspond to the GKS functions SET POLYLINE COLOUR
INDEX , SET POLYMARKER COLOUR INDEX, SET TEXT COLOUR INDEX, and SET FILL AREA COLOUR
INDEX, respectively .
The f o l lowing ask-objects correspond to various parameters of the GKS function
INQUIRE CURRENT INDIVIDUAL ATTRIBUTE VALUES : LINESTYLE is l inetyp e , POINSTYLE is
marker typ e , LINE COLOR is polyl ine colour index , POINT COLOR is polymarker colour
index , TEXT COLOR is text co lour index and AREA COLOR is f i l l area colour index .
13 . 3 Graphic Output
13 . 3 . 1 General Description
The statements described in this section are used to generate various kinds of
graphic output . The user may cause points , l ine segments , or f i l led- in areas to be

- 144 -

drawn on the screen . There is a faci l ity for including text within the drawing . The
effect of the graphic output statements depends on the current values of the various
set-objects described in section 13 . 1 and 13 . 2 .
1 3 . 3 . 2 Syntax
1.
2.
3.
4.
5.
6.
7.
8.
9.
10 .
11.

imperative- statement
graphic - output- s tatement
geometric- statement
graphic-verb
geometric-object
point - l ist
coordinate-pair
array-geometric-statement
size-select
array-point- l ist
graphic - text- s tatement

12 . initial-point
13 . array-cel ls - statement
14 . point-pair

> graphic-output-statement
> geometric- statement I graphic-text-statement
> graphic-verb geometric -obj ect colon point - l ist
> GRAPH
POINTS I LINES I AREA
coordinate-pair ( semico lon coordinate-pai r ) )''
numeric- expression comma numeric-expression
[ deleted ]
[ de leted ]
[ deleted ]
graphic-verb TEXT initial -point ( comma USING image
co lon express ion- list I colon
string-expression)
comma AT coordinate-pair
[ deleted ]
[ de leted ]

A graphic-output- s tatement with LINES as the geometric-object must contain at least


two coordinate-pairs in its point- l is t . A graphic -output- statement with AREA as the
geometric-object must contain at least three coordinate-pairs in its point- list .
13 . 3 . 3 Examples
3 . GRAPH LINES : 3 , 4 ; 5 , 6 ; 66 . 66 , 7 7 . 7 7
11 . GRAPH TEXT , AT XP , Y P : "here is the labe l : 11 & TEXT$
GRAPH TEXT , AT O , Y_VALUE , USING "INt . 1!/t - - - - , : Y_VALUE
1 3 . 3 . 4 Semantics
The graphic-output-statement
Graphic- output-statements are the means by which the user generates a l l graphic out
put . The geometric- statement is used to draw a series of marked points , a contiguous
set of l ine segments , or a f i l led polygon area . The graphic-text-statement produces
alphanumeric labe l s .
The geometric-statement
The geometric-statement makes use of a sequence of points specified in problem
coord inates . That sequence is determined by the coordinate-pairs in the point- list,
the first coordinate-pair des ignating the first point and so on through the end of
the point- l i s t .
If the geometric-object is POINTS , then a point marker of the style and co lor ind i
cated b y the current value of POINT STYLE and POINT COLOR sha l l be drawn a t each
point in the sequence . If the geometric-object is LINES , then a l ine segment sha l l be
drawn connecting each success ive pair of points in the sequence , the f irst to the
second , the second to the third , and so on . Thus , the number of line segments sha l l
b e one fewer than the number of points i n the sequence . The style and co lor of the
segments are determined by the current value of LINE STYLE and LINE COLOR . If the
geometric-obj ect is AREA , then a f i l led po lygon is drawn whose edges cons ist of the
sequence of l ine segments as described above for LINES . If the first and last points
in the sequence are not coincident , then the l ine segment joining them comp letes the
out l ine . The color of the interior and edge is determined by the current value of
AREA COLOR . The interior of the polygon is defined as the set of a l l points ( p ixel s )

- 145 -

such that any l ine segment beginning at that point and extended indef initely in any
d i rection w i l l cross the po lygon boundary an odd number of times . The f i l l pattern
sha l l be s o l id on devices where this is possib l e .
The graph ic - text-s tatement
The graphic - text- statement draws a label consisting of the string of characters gen
erated by its string-expres s ion, or by its image and express ion- l is t . The characters
used for label s sha l l have an imp lementation-defined size and s tyle . The effect of
c l ipping on characters which lie partly in and partly out of the viewport on the
screen is imp lementation-defined .
1 3 . 3 . 5 Exceptions
- A graphic-output- statement with LINES as the geometric- object specifies fewer than
two points ( 11 100 , fata l )
- A graphic-output- statement with AREA a s the geometric-object specifies fewer than
three points ( 1 1100 , fata l )
1 3 . 3 . 6 Remarks
The graphic- text- statement is des igned to give easy access to a device 1 s hardware
generated character set .
Text is described with respect to problem coordinates and may become distorted when
the aspect ratio of the window and viewport differ .
If a device is unabl e to f i l l a po lygon , it is recommended that the out l ine of the
polygon be drawn and the interior be hashed or shaded in a manner corresponding to
the current color number .
It is recommended that the result of f i l l ing an area cons isting solely of co l inear
points be a l ine segment through those points , that f i l l ing or drawing a l ine through
a s et of coincident points result in a dot being drawn .
GRAPH POINTS correspond to the GKS function POLYMARKER . GRAPH LINES correspond to the
GKS function POLYLINE . GRAPH AREA correspond to the GKS function FILL AREA GRAPH
TEXT is an extension of the GKS function TEXT in that it al lows formatting of text
with USING .
.

- 146 -

15.

F I XE D

D E C I MAL

NUMB E RS

- 147 -

15 . FIXED DECIMAL NUMBERS ( BASIC-2 only)


This Section specifies an option in which the values of a l l numeric variables behave logi
cal ly as fixed-point decimal numbers with program-defined precis ions . Use of this option
a l so imp l ies that numeric- constants and numeric-express ions general ly , are represented as
f ixed-point dec imal numbers . Implementation of this Section is mandatory in BASIC- 2 .
The main intent of this data type is to provide an interface with non-BASIC processors , and
as a result , the precis ion and accuracy requirements for numeric -expressions are not speci
f ied .
15 . 1 Fixed Decimal Precis ion
15 . 1 . 1 General Description
An option is provided which a l lows definition of a l l numeric variables in a program
unit as having f ixed-point decimal numbers as values . The specification of this op
tion defines a default precision for the values of variables . In addition, other pre
cis ion attributes can be specified for individual variables .
15 . 1 . 2 Syntax
1 . option
2 . f ixed-point- type
3 . numeric - type
4 . fixed-dec laration

> ARITHMETIC FIXED f ixed-point- type


asterisk f ixed-point - s ize
> NUMERIC f ixed-point- type? f ixed-dec laration ( comma
fixed- dec laration)i<
s imp le-numeric-variable fixed-point-type? I
numeric-array-declaration f ixed-point- type?

An option-statement with an ARITHMETIC FIXED option , if present at al l , sha l l occur


in a lower-numbered l ine than any numeric-expression , numeric -variab l e , or any
declare- statement with NUMERIC in the same program-unit .
A fixed-declaration, if present at a l l , sha l l occur in a lower-numbered l ine than any
reference to the variable or array dec l ared therein .
A fixed-point - s i ze may appear in a declare-statement only if the ARITHMETIC FIXED op
tion has been specified for the program-unit .
Variables and arrays sha l l not be described more than once, in either a dec lare
statement , a dimension-statement , or as a function-parameter or procedure-paramete r .
15 . 1 . 3 Examples
1 . ARITHMETIC FIXED1'<8 . 2
3 . NUMERIC1'<5 . 2 A , B, Cl'<5 . 5 , D ( 1 TO 8 ) 1'<6 . 6
NUMERIC
E ( 1 TO 10, 1961 TO 1981)
15 . 1 . 4 Semantics
When the ARITHMETIC FIXED option is specified , then the values of numeric constant s ,
variab les , and express ions sha l l behave logica l ly as f ixed-point decimal numbers . In
the case of variables , this means that the set of values they are capab l e of assuming
are exactly those values which can be expressed with integer-size decimal d ig its to
the left of the decimal point and fraction- size digits to the right , together with
the s ign . The s ign is not counted in the s ize of the representation . Each imp lementa
tion sha l l define a maximum precis ion , P , which contro l s the number of decimal digits
avai lab le for the representation of numeric values . This precis ion sha l l not be less
than 18 .
The semantics for numeric-cons tants are as specif ied in Section 5 . 1 , except
lows . Each numeric constant has a precis ion attribute defined by the number
nificant decimal digits . The f irst s ignif icant digit is e ither the first
digit, or the digit immediately to the right of the decimal point , whichever

as fo l
of s ig
nonzero
is far-

- 148 -

ther left . The last s ignificant digit is the last exp l icitly written or the digit im
mediatel y to the left of the decimal point , whichever is farther right . In the spe
cial c a s e o f zero , there is a t least o n e s ignificant digit , namely immediately to the
left of the decimal point . A numeric-constant written in scaled notation is inter
preted as i f expressed in the equivalent unsealed notatio n .
F o r examp l e :
constant as written
12 . 34
12 . 300
12 . 300E-4
12 . 300E7
OO . OOE - 3
O . OE3

s ignificant digits
12 . 34
12 . 300
. 0012300
123000000 .
. 00000
0.

I f the number o f s ignificant digits exceeds P , the imp l ementation sha l l round the
value to no fewer than P d igits . If the number of s ignificant digits to the left of
the decimal point exceeds P , an overf low exception results .
Each s imp l e - numeric-variabl e and numeric-array has a precision attribute defined in
terms of the number of digits maintained in the integer part and the fraction part ,
namely integer-size and fraction - s ize . The representation of variables and arrays is
governed by ( in descending order of precedence ) :
- the fixed-point - s ize specified in the fixed - dec l aration of the variabl e or array,
or,
- the f ixed-point-size fol lowing DECLARE NUMERIC in a dec lare-statement containing a
fixed- dec l aration for the variabl e or array, or
- the default f ixed-point- s ize specified in the ARITHMETIC FIXED option .
The precis ion attribute of a numeric-array app l ies to each of its e l ements . The s ig
nificant digits for a numeric-variabl e a r e the same a s if the variabl e were written
out with its ful l precis ion as a numeric-constant .
The semantics of numeric- expressions and numeric- supp l ied- functions are as specified
in 5 . 3 and 5 . 4 , except a fol lows . The precis ion attribute of the resul t obtained by
evaluating a numeric- supp l ied- function or numeric-expression is imp l ementation
defined . The accuracy of such evaluation is also imp lementation-defined .
Ass ignment of a numeric value to a numeric-variabl e , whether done by internal ass ign
ment ( such as with LET ) , or from an external source ( such as with INPUT ) , proceeds as
f o l lows . The integer part and fraction part of the value are moved to the integer
part and fraction part of the variab l e , a l igned on the decimal point . If any nonzero
d igits are truncated on the left of the integer part, an overf low exception results .
If any d igits are truncated on the right of the fraction part , the resul ting value in
the variabl e is rounded to the preci s ion of the variab l e . If necessary, the value is
extended with zeros on the left of the integer part, or the right of the fraction
part so as to f i l l a l l the digit p laces of the receiving variabl e .
The semantics f o r input and output are a s specified i n Section 10 , except a s fo l lows .
When a numeric-expression is used as a print- item in a print-statement , its value is
a lways printed in unsealed representation, either imp l ic it point or exp l icit point .
The digits p r inted are exactly the s ignificant digits , as defined above . Note that
for numeric-expressions other than variab les and constants , significant digits are
imp lementation-defined . Imp l icit point representation sha l l be used when there are no
s ignificant digits to the right of the decimal point ; otherwise exp l icit point repre
sentation sha l l be used .
The semantics for f i l e areas are as specified in Section 1 1 , with the fo l lowing
additions . For DISPLAY records , the rules given above for input , output , and

- 149 -

assignment are used . For INTERNAL records , the values are self-typed , and so input
and output takes p lace as defined above . Thus , the resul t of WRITE A and READ B,
where they access the same value in the file, is the same as LET B = A. Note that it
is imp l ementation-defined whether an INTERNAL f i le accessed with one ARITHMETIC
option is accessible with another . The ARITHMETIC FIXED option with different default
prec1s 1ons is not considered to be a different option for the purposes of
accessibil ity . For NATIVE records , ass ignment of values to and from fie lds of fixed
po int- size takes p lace in accordance with the usual rules for fixed-point ass ignment .
When a value is moved to a field with a size of E ( indicating f loating-point ) , at
least the first P significant digits must be retained exac t l y . When a value obtained
from such a field is ass igned to a variabl e , the field is treated as a scaled
numeric-constant , as described above . Again, note that it is imp l ementation-def ined
whether a NATIVE f i l e accessed with one ARITill1ETIC option is access ible with another .
The ask-attribute DATUM returns the type of the next datum in a file . For numeric
data in STREAM INTERNAL f i les written with the FIXED option , the type returned by the
ask-attribute DATUM sha l l be :

where ii is the two digit number for integer- s ize and ff the two digit number for
fraction- size .
1 5 . 1 . 5 Exceptions
The number of significant
exceeds P ( 1001 , fata l ) .

digits

in

the

integer

part

of

- In an option-statement or a dec lare- statement , the sum


fraction-s ize in a f ixed-point-size exceeds P ( 1010 , fatal ) .

of

numeric-constant

integer-size

and

- Upon ass ignment of a numeric value to a variable , the number of significant digits
in the integer part exceeds the variable ' s integer- s ize ( 1011, fata l ) .
15 . 1 . 6 Remarks
It is recommended that the accuracy of transcendental functions such as LOG , COSH ,
ATN , SIN, and EXP be no less than that specified for OPTION ARITHMETIC DECIMAL . It is
recommended that for non- transcendental functions , such as ABS INT , and f1AX , and for
the operations + , - , ,., , I , and , an intermediate result be maintained as f loating
point decimal with P+2 s ignificant digits . This would imp ly that whenever a l l the
intermediate results of a numeric-expression are exact within P+2 decimal digits and
the final result is exact within P dec imal digits , then the final result is exactly
correct .
-

1 5 . 2 Fixed Decimal Program Segmentation


1 5 . 2 . 1 General Description
When the fixed decimal option is specified for a program-un i t , it app l ies to al l nu
meric entities in the scope of that unit, including parameters , formal parameters ,
and ( in the case of an externa l -function-def ) the result of function evaluation .
1 5 . 2 . 2 Syntax
1 . function-parameter
2 . procedure-parameter
3 . numeric-f ixed- parameter
4 . fixed- fo rma l -array
5 . interna l - function- l ine

> numeric - fixed-parameter


> numeric - fixed-parameter
s imp le - numeric-variable fixed-point-type I
fixed - forma l - array
forma l -array f ixed -po int- type
> l ine-number FUNCTION fixed-defined- function
function-pam- l ist? tai l

- 150 -

6 . externa l - function- l ine


7 . numeric-def - s tatement
8 . defined-function
9 . fixed - defined- function

> l ine-number EXTERNAL FUNCTION fixed-defined- function


function-parm- list? tai l
> DEF f ixed -defined- function function-parm- l ist?
equa l s - s ign numeric-express ion
> fixed-def ined- function
numeric- defined- function f ixed -point- type

A numeric -variab le or actual -array appearing in a cal l - statement sha l l have the same
integer - s ize and fraction- s ize as the correspond ing procedure-parameter . For a l l
other numeric function-argument o r procedure-arguments and their corresponding
function-parameters or procedure-parameters , it is necessary only that the ARITHMETIC
options of their respective program-units agree , i . e . , that both be DECIMAL or NATIVE
or FIXED .
An option-statement with an ARITHMETIC FIXED option sha l l occur in a lower-numbered
l ine within the program-unit than any interna l - function-def that dec lares a numeric
defined-function or spec ifies numeric parameters .
A fixed-point- type may appear in an interna l - function- l ine or numeric-def - statement
only if the ARITHMETIC FIXED option has been specified for the program-unit .
A numeric-fixed-parameter may be used only if the ARITHMETIC FIXED option has been
specified for the program-unit .
When a fixed -defined- function is dec lared in a function-typ e , the fixed-point-s i zes
specified either exp l icitly or by default in the declaration and the corresponding
definition must agree .
15 . 2 . 3 Examples
3 . A( ) l'C8 . 2
B( ' ) l'C4 . 4
5 . 123 FUNCTION SUMVECTQRl'c5 . 2 ( V ( ) >'< 5 . 2 )
6 . 234 EXTERNAL FUNCTION ANSWERll ( A$ )
7 . DEF AVERAGEl'c 10 . 3 ( X>'c10 . 3 , Y>'c1Q . 3 )
( X+Y ) / 2
=

15 . 2 . 4 Semantics
When the ARITHMETIC FIXED option is specified for a program-unit , the values of nu
meric procedure-parameters ,
numeric
function-parameters ,
and
numeric-defined
functions sha l l be represented and manipulated as fixed-point decimal numbers . If the
fixed-point-s ize of one of these is not exp l icitly specif ied in the appropriate
procedure-parameter or function-paramete r , internal-def - l ine or interna l -function
l ine or external - function- l ine , then it is assumed to be the default specified in the
ARITHMETIC FIXED option . The fixed -point-size of a normal -array app l ies to each of
its e lements .
The evaluation and ass ignment of the arguments in a function reference to the parame
ters of the function-def proceed as described in 9 . 1 , with the following addition . I n
the case where the f ixed-point - s ize of a n argument differs from that of the corre
sponding parameter , the ass ignment rules given in 15 . 1 . 4 app l y .
The association o f the procedure-arguments i n a ca l l - statement with the procedure
parameters in the corresponding sub - s tatement proceeds as described in Section 9 . 2 ,
with the fo l lowing addition . In the case where the fixed -point-size of a procedure
argument which is a numeric- expression, but not a numeric-variab l e , differs from that
of the corresponding procedure-parameter , the ass ignment rules given in 15 . 1 . 4 app ly .

- 151 -

15 . 2 . 5 Exceptions
- In a numeric - f ixed-parameter or f ixed-defined- functio n , the sum of the integer- si ze
and fraction - s ize in a fixed-point-size exceeds P ( 10 10 , fatal ) .
- Upon ass ignment of a numeric value to a numeric - f ixed-parameter or fixed- defined
function, the number of significant digits in the integer part exceeds the
integer- s ize of the numeric- fixed-parameter of fixed-def ined-function ( 10 1 1 ,
fatal ) .
1 5 . 2 . 6 Remarks
None .

- 152 -

TABLE 1
Standard BASIC Character Set

The name of the characters indicated in the tabl e correspond to the name of the characters in
Standard ECMA- 6 . \fuere different names are used in this Standard for the syntax of BASI C , these
names are indicated between parentheses .

ORDINAL
POSITION

CODE

0.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10 .
11 .
12 .
13 .
14 .
15 .
16 .
17 .
18 .
19 .
20 .
21.
22 .
23 .
24 .
25 .
26 .
27 .
28 .
29 .
30 .
31.
32 .
33 .
34 .
35 .
36 .
37 .
38 .
39 .
40 .
41.
42 .

0/0
0/1
0/2
0/3
0/4
0/5
0/6
0/7
0/8
0/9
0 / 10
0 / 11
0 / 12
0 / 13
0 / 14
0 / 15
1/0
1/1
1/2
1/3
1/4
1/5
1/6
1/7
1/8
1/9
1 / 10
1 / 11
1 / 12
1 / 13
1 / 14
1/15
2/0
2/1
2/2
2/3
2/4
2/5
2/6
2/7
2/8
2/9
2 / 10

GRAPHI C

ACRONYM

NAME

NUL
SOH
STX

NULL
START OF HEADING
START OF TEXT
END OF TEXT
END OF TRANSMISSION
ENQUIRY
ACKNOWLEDGE
BELL
BACKSPACE
HORIZONTAL TABULATION
LINE FEED
VERTICAL TABULATION
FORM FEED
CARRIAGE RETURN
SHIFT OUT
SHIFT IN
DATA LINK ESCAPE
DEVICE CONTROL ONE
DEVICE CONTROL TWO
DEVICE CONTROL THREE
DEVICE CONTROL FOUR
NEGATIVE ACKNOWLEDGE
SYNCHRONOUS IDLE
END OF TRANSMISSION BLOCK
CANCEL
END OF MEDIUM
SUBSTITUTE
ESCAPE
FILE SEPARATOR
GROUP SEPARATOR
RECORD SEPARATOR
UNIT SEPARATOR
SPACE
EXCLAMATION MARK
QUOTATION MARK
NUMBER SIGN
DOLLAR S IGN
PERCENT SIGN
AMPERSAND
APOSTROPHE
LEFT PARENTHESIS
RIGHT PARENTHESIS
ASTERISK

ETX

EOT
ENQ
ACK
BEL
BS
HT
LF
VT

FF
CR
so
SI
DLE
DC1
DC2
DC3
DC4
NAK
SYN
ETB
CAN
EM
SUH
ESC
FS
GS
RS
us
SP
II

II

$
%

&

";''

- 153 -

43 .
44 .
45 .
46 .
47 .
48 .
49 .
50 .
51.
52 .
53 .
54 .
55.
56.
57 .
58 .
59 .
60 .
61 .
62 .
63 .
64 .
65 .
66 .
67 .
68 .
69 .
70.
71.
72.
73.
74.
75.
76 .
77 .
78.
79 .
80 .
81 .
82 .
83 .
84 .
85 .
86 .
87 .
88 .
89 .
90 .
91.
92 .
93.
94 .
95.
96 .
97 .
98.

2 / 11
2 / 12
2 / 13
2 / 14
2 / 15
3/0
3/1
3/2
3/3
3/4
3/5
3/6
3/7
3/8
3/9
3 / 10
3 / 11
3 / 12
3 / 13
3 / 14
3 / 15
4/0
4/1
4/2
4/3
4/4
4/5
4/6
4/7
4/8
4/9
4 / 10
4/11
4/12
4 / 13
4 / 14
4 / 15
5/0
5/1
5/2
5/3
5/4
5/5
5/6
5/7
5/8
5/9
5 / 10
5 / 11
5 / 12
5 / 13
5 / 14
5 / 15
6/0
6/1
6/2

0
1
2
3
4
5
6
7
8
9

<

>
?
@

A
B
c
D
E
F
G
H
I
J
K
L
M
N
0
p

Q
R
s
T
u
v
w

X
y
z

[
\
l

A
b

PLUS SIGN
COMMA
MINUS SIGN
FULL STOP ( Period )
SOLIDUS ( S lant)
DIGIT ZERO
DIGIT ONE
DIGIT TWO
DIGIT THREE
DIGIT FOUR
DIGIT FIVE
DIGIT SIX
DIGIT SEVEN
DIGIT EIGHT
DIGIT NINE
COLON
SEMICOLON
LESS-THAN SIGN
EQUALS SIGN
GREATER-THAN SIGN
QUESTION MARK
COMMERCIAL AT
CAPITAL LETTER ( Upper-case ) A
CAPITAL LETTER ( Upper- case) B
CAPITAL LETTER ( Upper-case ) c
CAPITAL LETTER ( Upper-case ) D
CAPITAL LETTER ( Upper-cas e ) E
CAPITAL LETTER ( Upper-cas e ) F
CAPITAL LETTER ( Upper-cas e ) G
CAPITAL LETTER ( Upper-case ) H
CAPITAL LETTER ( Upper-case) I
CAPITAL LETTER ( Upper-case) J
CAPITAL LETTER ( Upper-cas e ) K
CAPITAL LETTER ( Upper-case ) L
CAPITAL LETTER ( Upper-case ) M
CAPITAL LETTER ( Upper-cas e ) N
CAPITAL LETTER ( Upper-cas e ) 0
CAPITAL LETTER ( Upper-case) p
CAPITAL LETTER ( Upper-case ) Q
CAPITAL LETTER ( Upper-cas e ) R
CAPITAL LETTER ( Upper-cas e ) s
CAPITAL LETTER ( Upper-case ) T
CAPITAL LETTER ( Upper-case ) u
CAPITAL LETTER ( Upper-case ) v
CAPITAL LETTER ( Upper-case ) w
CAPITAL LETTER ( Upper-case ) X
CAPITAL LETTER ( Upper-cas e ) y
CAPITAL LETTER ( Upper-cas e ) z
LEFT SQUARE BRACKET
REVERSE SLANT ( Reverse so l idus )
RIGHT SQUARE BRACKET
CIRCUMFLEX ACCENT
UNDERLINE
GRAVE ACCENT
SMALL LETTER ( Lower-case) a
SMALL LETTER ( Lower-case) b

- 154 -

99 .
100 .
101 .
102 .
103 .
104 .
105 .
106 .
107 .
108 .
109 .
no .
lll .
ll2 .
113 .
ll4 .
ll5 .
ll6.
ll7 .
ll8 .
ll9 .
120 .
12 1 .
122 .
123 .
124 .
125 .
126 .
127 .

6/3
6/4
6/5
6/6
6/7
6/8
6/9
6 / 10
6/11
6 / 12
6 / 13
6 / 14
6 / 15
7/0
7/1
7/2
7/3
7 /4
7/5
7/6
7/7
7/8
7/9
7 / 10
7 / 11
7 / 12
7 / 13
7 / 14
7 / 15

c
d
e
f
g
h
i
j
k
1
m
n
0

p
q
r
s
t
u
v
w
X

{
}
DEL

SMALL LETTER ( Lower-case) c


SMALL LETTER ( Lower-case ) d
SMALL LETTER ( Lower-cas e ) e
SMALL LETTER ( Lower-cas e ) f
SMALL LETTER ( Lower-cas e ) g
SMALL LETTER ( Lower-case) h
SMALL LETTER ( Lower-case ) i
SMALL LETTER ( Lower-cas e ) j
SMALL LETTER ( Lower-cas e ) k
SMALL LETTER ( Lower-case ) 1
SMALL LETTER ( Lower-case ) m
SMALL LETTER ( Lower-case ) n
SMALL LETTER ( Lower-cas e ) o
SMALL LETTER ( Lower-cas e ) p
SHALL LETTER ( Lower-cas e ) q
SMALL LETTER ( Lower-cas e ) r
SMALL LETTER ( Lower-cas e ) s
SMALL LETTER ( Lower-cas e ) t
SMALL LETTER ( Lower-cas e ) u
SMALL LETTER ( Lower-case ) v
SMALL LETTER ( Lower-case) w
SMALL LETTER ( Lower-cas e ) x
SMALL LETTER ( Lower-cas e ) y
SMALL LETTER ( Lower-cas e ) z
LEFT CURLY BRACKET ( Left brac e )
VERTICAL LINE
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 may occur in C1
and/ or G1 set ( see ECHA- 3 5 ) . The number of other-characters is imp lementation-dependent .

- 155 -

TABLE 2
Exception Codes

The f o l lowing tab le speci f ies the values of the EXTYPE function corresponding to the exceptions
spec i fied in thi s Standard . Nonfatal exceptions are des ignated by an exc lamation-mark ( ! ) . The
numbers in parentheses f o l l owing each exception refer to the sections in which that exception is
specif ied .
Overf low ( 1000)
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1051
1052
1053
1054
1105
1 106

Overf low
Overflow
Overflow
Overflow
Overflow
Overf low
Overf low
Overflow
Overf low
Too ny
Overf low
Overflow
Overflow
Overflow
Overf low
Overf low
Overf low

in evaluating numeric- constant ( 5 . 1 , 15 . 1 )


in evaluating numeric-expression ( 5 . 3 )
in evaluating numeric- supp l ied- function ( 5 . 4 )
in evaluating VAL ( 6 . 4 )
in evaluating numeric-array-express ion ( 7 . 2 )
in numeric datum for ( MAT ) READ ( 10 . 1 , 10 . 5 )
in numeric datum for ( MAT) I NPUT from terminal ( 10 . 2 , 10 . 5 )
in numeric data for f i le input ( 11 . 4 )
during evaluation o f DET or DOT ( 7 . 2 )
digits declared for f ixed decimal ( 15 . 1 , 15 . 2 ) ( BASIC-2 only)
in f i xed decimal assignment ( 15 . 1 , 15 . 2 ) ( BASIC-2 only)
in evaluating string-express ion ( 6 . 3 )
in evaluating string-array-express ion ( 7 . 3 )
in string datum for ( MAT ) READ ( 10 . 1 , 10 . 5 )
in string datum for ( MAT) ( LINE) INPUT ( 10 . 2 , 10 . 5 )
in string datum for f i le input ( 1 1 . 4 )
i n string ass ignment ( 6 . 5 , 9 . 1 , 7 . 3 )

Underf low errors ( 1500 )


The f o l lowing exceptions are recommended in the Remarks Sections , and are not mandatory .
1501
1502
1 503
1504
1505
1506
1507
1508

Numeric constant underf low ( 5 . 1 )


Numeric express ion underflow ( 5 . 3 )
Function value underf low ( 5 . 4 )
VAL underf low ( 6 . 4 )
Array expression underf low ( 7 . 2 )
Numeric DATA underf low ( 10 . 1 )
Numeric input underf low ( 10 . 2 , 10 . 5 )
F i l e numeric input under f l ow ( 1 1 . 4 )

Subscript errors (2000 )


2001

Subscript out of bounds ( 5 . 2 , 6 . 2 )

Mathematical error ( 3000)


3001
3002
3003
3004
3005
3006
3007
008
3009

Division by zero ( 5 . 3 )
Negative number raised to nonintegral power ( 5 . 3 )
Zero raised to negative power ( 5 . 3 )
Logarithm of zero o r negative number ( 5 . 4 )
Square root o f negative number ( 5 . 4 )
Zero divisor speci fied for MOD o r REMAINDER ( 5 . 4 )
Argument o f ACOS o r ASIN not in range - 1 < = x < = 1 ( 5 . 4 )
Attempt t o evaluate ANGLE ( O , O ) ( 5 . 4 )
Attempt t o invert a s ingular matrix , o r loss of a l l s ignif icance i n such attempt ( 7 . 2 )

- 156 -

Uninit ia l ized errors ( 3 10 0 )


The f o l l owing exceptions are recommended i n the Remarks Sections , and are n o t mandated .
3 10 1
3 102

Uninitialized numeric-variable ( 5 . 2 )
Uninitial ized string-variable ( 6 . 2 )

Parameter error ( 4000)


4001
4002
4003
4004
4005
4006

Argument of VAL not a numeric -constant ( 6 . 4 )


Argument of CHR$ out o f range ( 6 . 4 )
Argument of ORO not a valid character o r mnemonic ( 6 . 4 )
Index of SIZE out of range ( 7 . 1 )
Index in TAB less than one ( 10 . 3 )
Margin setting less than current zonewidth ( 10 . 3 , 1 1 . 3 )

4007
4008
4009
4010
4101
4301

Index o f ZONEWIDTH out o f range ( 10 . 3 , 11 . 3 )


Index o f LBOUND out of range ( 7 . 1 )
Index of UBOUND out of range ( 7 . 1 )
Second argument of REPEAT $ < 0 ( 6 . 4 )
Value o f the string-express ion i n a set- statement ( 13 . 1 )
Parameter type or count mismatch between chain-statement and corresponding program-name
l ine ( 9 . 3 )
Mismatched d imensions between chain array parameter and corresponding forma l -array ( 9 . 3 )
Numeric parameters passed in chain having d ifferent ARITHMETIC options ( 9 . 3 )

4302
4303

Storage exhausted ( 5000)


5001

S i ze of redimensioned array too large ( 7 . 2 , 7 . 3 , 10 . 5 , 11 . 4 )

Matrix errors ( 6000)


6001
6002
6003
6004

Mismatched s izes in
Argument of DET not
Argument of INV not
Arguments to IDN do

numeric-array-expression ( 7 . 2 )
a square matrix ( 7 . 2 )
a square matrix ( 7 . 2 )
not specify square matrix ( 7 . 2 )

6005

First index greater than second in redim, or index less trull1 lower bound ( 7 . 2 , 7 . 3 , 10 . 5 ,
11 . 4 )

6101

Mismatched s izes in string-array- express ion ( 7 . 3 )

File use errors ( 7000)


7 00 1
7002
7 003

Channel number not in range 0 < = c < = max ( 1 1 . 1 )


Channe l zero in OPEN , CLOSE , ERASE , or with record - s etter ( 11 . 1 , 11 . 2 )
Nonzero channel in OPEN already active ( 11 . 1 )

7004

Inactive channel in f i l e statement other than OPEN or ASK ( 11 . 1 , 11 . 2 , 1 1 . 3 , 11 . 4 , 11 . 5 )

7050
7051
7052
7 100
7 1xx

Keyed f i l e OPEN with wrong c o l late sequence ( 1 1 . 1 ) ( BASIC-2 only )


LENG11! not greater than zero on OPEN ( 11 . 1 )
A device is opened as RELATIVE or KEYED ( 11 . 1 ) ( BASIC-2 only )
Unrecognizable f i le attribute in OPEN ( 11 . 1 )
Imp lementation-defined failures to provide access toe inaccordance with f i l e attribute
( 11 . 1 )

- 157 -

7202

The record- setter RECORD is used on a f i le opened with a f i l e -organization other than

7 3 17

RELATIVE ( 11 . 2 ) ( BASIC-2 only)


The record- setter KEY is used on a file opened with a f i l e -organization other than KEYED
( 1 1 . 2 ) ( BASIC-2 only)
Record - s etter SAME f o l lowing DELETE , OPEN , or exception ( 11 . 2 )
Record - setter used on device without that capabi l ity ( 11 . 2 )
The index o f a record- s etter evaluates to an integer less than one ( 1 1 . 2 ) BASIC-2 only)
A record-setter spec ifies an exact-search for the nul l string ( 11 . 2 ) ( BASIC-2 only)
Attempt to ERASE f i l e not opened as OUTIN ( 1 1 . 1 )
Output not possible to INPUT file ( 11 . 3 )
Input n o t possible from OUTPUT f i le ( 11 . 4 )
Attempt to input nonexistent record ( 11 . 4 )
Attempt to write existing record ( 1 1 . 3 )
Attempt to erase a device without erase capabi l ity ( 1 1 . 1 )
Zonewidth or margin set for non-d isp lay f i l e ( 11 . 3 )
Zonewidth or margin set for I NPUT f i le ( 11 . 3 )
A write-statement or array-write-s tatement attempts to access a KEYED f i l e , but does not
specify an exact-search in its record - setter ( 1 1 . 3 ) ( BASIC-2 only)
A temp late- identif ier is used on a f i le opened as DISPLAY or INTERNAL ( 1 1 . 3 ) ( BASIC-2
only)
A write-statement or array-write - statement does not have a temp late- identifier when
attempting to access a f i l e opened as NATIVE ( 11 . 3 ) ( BASIC-2 only)
( MAT ) PRINT to INTERNAL file ( 11 . 3 )

7 3 18
7321

( MAT) ( LINE) INPUT from INTERNAL f i le ( 11 . 4 )


SKIP REST on s tream f i le ( 11 . 4 )

7 322

A data modification s tatement attempts to access a f i le opened as INPUT or as OUTPUT


( 1 1 . 5 ) ( BASIC-2 only)
Attempt to trace to inactive channel ( 12 . 2 )
Attempt to trace to non-display-format or I NPUT f i le ( 12 . 2 )

7203
7204
7205
7206
7207
7 30 1
7 302
7 30 3
7 30 5
7 308
7 3 11
7312
7 3 13
7 3 14
7 3 15
7 3 16

7401
7402

Input-output errors ( 8000)


8001
8002
8003
8011
8012
8013

(MAT) READ beyond end of data ( 10 . 1 , 10 . 5 )


Too few data in input- reply ( 10 . 2 , 10 . 5 )
Too many data in input- rep ly ( 10 . 2 , 10 . 5 )
End - o f - f i l e encountered on input ( 11 . 4 )
Too few data in record ( 11 . 4 )
Too many data in record ( 11 . 4 )

8101
8102
8103
8105
8120
8201
8202
8203
8204

Nonnumeric datum for ( MAT) READ or INPUT o f number from DISPLAY record ( 10 . 1 , 10 . 5 , 11 . 4 )
Syntact ical ly incorrect input-reply from terminal ( 10 . 2 , 10 . 5 )
Nonnumeric datum for ( MAT ) INPUT o f number ( 10 . 2 , 10 . 5 )
Syntac t ically incorrect input reply from f i le ( 11 . 4 )
Type mismatch o n INTERNAL input ( 11 . 4 )
Invalid format-string ( 10 . 4 , 10 . 5 )
No format- item in format- string for output list ( 10 . 4 , 10 . 5 )
Format- item too short for output string ( 10 . 4 )
Exrad overf low ( 10 4 )

8251

The string- expres s ion o f a temp late-identifier is not a s yntactical ly correct temp late
e l ement- l is t ( 11 . 3 , 11 . 4 , 1 1 . 5 ) ( BASIC-2 only)
An expression or array-element does not agree in type ( numeric or string ) with its
associated TEMPLATE field- specifier ( 11 . 3 , 11 . 4 , 1 1 . 5 ) ( BASIC-2 only)
A temp late- e lement with a variable-field-count does not coincide with the first e lement
of an array ( 1 1 . 3 , 11 . 4 , 1 1 . 5 ) ( BASIC-2 only)
There are not enough field- speci fiers in a temp late-statement for all the express ions or
array - elements ( 11 . 3 , 1 1 . 4 , 11 . 5 ) ( BASIC-2 only )
A numer ic value has s ignificant d igits to the left of the avai lable d igit p laces in the
f ield of a temp late ( 11 . 3 , 11 . 5 ) ( BASIC- 2 only)

8252
8253
8254
8255

- 158 -

8256

A string value is longer than the length of its field in the temp late ( 11 . 3 , 1 1 . 5 )

8301
8302
8401
8402

( BASIC - 2 only)
Record length exceeded on output to f i l e ( 11 . 3 , 1 1 . 5 )
Input from a record longer than RECSIZE ( 11 . 4 )
Timeout on (MAT) ( LINE) I NPUT ( 10 . 2 , 10 . 5 )
I l legal numeric value speci fied for time-express ion ( 10 . 2 , 10 . 5 )

Device errors ( 9000)


9xxx

Imp lementation-def ined device failures

Control errors ( 10000)


10001
10002
10004
10005
10007

Index out o f range , no ELSE in on-goto- or on-gosub ( 8 . 2 )


Return without corresponding gosub o r on-gosub ( 8 . 2 )
No case-block selected and no CASE ELSE ( 8 . 4 )
Attempt to chain to unavai lable program ( 9 . 3 )
Break s tatement executed when debugging active ( 12 . 2 )

Graphical errors ( 11000)


110 5 1
11052
110 5 3
11054
11056

Set-statement boundaries with zero width or height ( 13 . 1 )


Viewport boundary not in range ( 13 . 1 )
A boundary of the device window is not in the range [ 0 , 1 ] ( 13 . 1 )
A boundary of the device viewport is not in the d isp lay space ( 13 . 1 )
Set-statement point style out of range ( 13 . 2 )

11062 Set-statement l ine s tyle out of range ( 13 . 2 )


11085 Set s tatement color index out of range ( 13 . 2 , 13 . 3 )
11100 Graphi c -output with LINES and fewer than two points , or with AREA and fewer than three
points ( 13 . 3 )
When an exception occurs in a program-unit and is not handled by an exception-hand ler in that
program-un i t , the exception which results at the l ine which invoked the program-unit sha l l be
identified by the value 100000 p lus the value speci fied above for the exception .

- 159 -

AP P END I C E S

- 160 -

APPENDIX 1
ORGANI ZATION OF THE STANDARD

This Standard is organized into a number of sections , each of which covers a group of related
features of BAS I C . Each section is d ivided further to treat particular features of BASIC . The
f inal subdivisions of each section are used as f o l lows .
Subsection 1

General Description
This subsection brief l y describes the features of BASIC to be treated .
Subsection 2

The exact syntax of features of the language is describes in a mod ified context-free
grammar o r Backus -Naur Form . The details of this method of syntax spec ification are
described in 3 . 1 .
In order to keep the s yntax reasonably s imp le the syntax specif ication w i l l al low some
constructions which , strictly speaking , are not legal according to this Standard ; e . g . , it
will al low the generation of the statement
LET X = A ( + l ) + A ( l , 2 )
in which the array A occurs with differing numbers of subscripts . Rather than rul ing such
construct ions out by a more comp l icated formal syntax, this Standard instead rules them out
by p lacing restrictions on that syntax .
The primary goa l of the syntax is to def ine the notion of a program and its constituent
parts . In addition the syntax def ines several other items which are not needed for the
definition of a program . These include the input-prompt , which is output to reques t input ,
the input- rep ly and l ine- input- rep l y , which are strings suppl ied in response to a request
for input .
Subsection 3

Examples
A short l is t of val i d examp les that can be generated by the productions in Subsection 2 is
given . The numbering of the examp les corresponds to the numbering of the productions , and
wi l l not be consecutive if examp les are not given for al l rules .
Subsection 4

Semantics
The semantic rules in this
according to the syntax .

S tandard

ass ign a

meaning to

the constructions

generated

- 161 -

SUbsection

Exceptions
This subsection contains a l i s t of those exception conditions which a s tandard-conforming
implementation must recognize . Exception numbers ( values of the EXTYPE function) are also
given .
SUbsection 6

Remarks
This subsection contains remarks which point out certain features of this Standard as wel l
as remarks which make recollllllendations concerning the implementation of a BASIC l anguage
processor in an operating environment .

- 162 -

APPENDIX 2
SCOPE RULES

The scope of an entity is that part of the program where its name is recognized as referring to
that obj ect ( as opposed to not being recognized at al l , or recognized as referring to some other
object ) . In general , an entity is known by only one name , and so the scope of recognition of its
name is also the scope in which the object itself can be accessed . In the special case of parame
ter pass ing by reference , the same object is known by two different names , and so the object it
self may be accessed outs ide the scope of its name .
In a l l cases , the indicated scope is the scope of the name of the object in question .
Object
1.
2.
3.
4.
5.
6.
7.
8.
9.
10 .
11 .

12 .
13 .
14 .
15 .
16 .
17 .
18 .
19 .

Scope

non-parameter variabl e
non-parameter array
program-unit parameter

program-unit
program-unit
program-unit ( ,'' )

inter-proc -def-parameter
inter-proc - def
program-unit
DATA
channe l -number ( non- zero )
chann e l zero
IMAGE , TEMPLATE
GOSUB stack

internal -proc-def U' )


program-un it

OPTIONs
f i lenames
RND sequence
[ deleted ]
[ deleted ]
Graphic and PRINT
set-obj ect
l ine-number
DEBUG and TRACE state

program
program-unit
program-unit
program
program-unit ( BASIC-2 only for TEMPLATE )
smal ler of program-unit , internal-proc-def , when- lock
( BASIC-2 only ) , or exception-hand ler ( BASIC-2
only)
program-unit
program
program

program
program-unit
program-unit

Even though the name is known only to the program-unit or internal -proc -def , when a parameter is
passed by referenc e , the object denoted is common to both the invoked and invoking unit .

- 163 -

APPENDIX 3
IMPLEMENTATION-DEFINED FEATURES

A number of the features defined in this Standard have been left for def inition by the imp le
menter . However , this wil l not affect portab i l ity, provided that the l imits recommended in the
various sections are respected .
The way these features are imp lemented shal l be def ined in the user or system manual of the spe
c ific imp lementation .
The following is a l ist of implementation-defined features .
Subsection 2 . 3
- interpretation of syntactical ly i l legal constructs
- format of error messages
Subs ection 2 . 4
- format o f exception messages
- hardware dependent exceptions
- order of exception detection in a l ine
Subsection 3 . 2
- certain semantic rules for native data
Subsection 4 . 1
- other-character
- coding for the native col lating sequence
Subsection 4 . 2
- end-of- l ine
- maximum physical l ine length
- effect of parameter list in program-name - l ine of program not initiated by a chain-statement
- relationship of program-designator and program-name
- effect of non- standard programs
Subsection 4 . 4
- restrictions on identifiers for procedures comp iled independently from the main program
Subsection 5 . 1
- precision and range of numeric-constants
Subsection 5 . 2
- initial value of numeric variab les
Subsection 5 . 3
- order of evaluation of numeric -expressions

- 164 -

Subsection 5 . 4
-

accuracy of evaluation of numeric functions


value of MAXNUM and EPS
pseudo-random number sequence
avai lab i lity of calendar and c lock
time zone for DATE and TIME
Subsection 5 . 6

- preci s ion and range of


- precis ion and range of
- precis ion and range of
accuracy of evaluation

numeric values
f l oating decimal arithmetic
native arithmetic
of numeric express ions
Subsection 6 . 2

- maximum length of undeclared string-variables


- initial value of string-variables
Subsection 6 . 4
- values of CHR$ for the native character set
- values of ORO for the native character set
- avai lab i l ity of calendar and c lock
- time-zone for DATE$ and TIME$
- effect of UCASE$ and LCASE$ for other-characters
Subsection 6 . 6
- co l l ating sequence under OPTION COLLATE NATIVE
- maximum length of dec lared 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 l ength 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 l ength-max
- effect of redimensioning an array parameter when an e l ement of that array is also a parameter
- initial values of variables which are not formal parameters to a procedure
Subsection 9 . 3
- interpretation of the program-des ignator in a chain-statement
- interpretation of upper-case- letters and lower-cas e - l etters in a program - des ignator
- initial values of variables in a chained- to program
Subsection 10 . 2
- input-prompt
- means of requesting input in batch mode
- values ( minimum and maximum ) and reso lution of timeout-expression and time- inquiry

- 165 -

Subsection 10 . 3
- effect of invoking a function which causes printing whi le printing
-

s ignif icance width for printing numeric representations


exrad width for printing numeric representations
effect of nonprinting characters on co lumnar position
default margin
default zonewidth
treatment of tra i l ing space at end of print l ine
use of upper-case or lower-case "E" in exrad
Subsection 10 . 5

- treatment o f re- supp ly of input to a re-dimens ioned array


Section 11
- effect of some f i le operations on devices
- effect of certain combinations of f i l e organization and type
Subsection 11 . 1
- maximum channel number
- whether a f i le name with different case letters ( lower or upper) denotes the same f i le or different f i les
- effect of attempting to open an already oper. f i le
- number of channe l s which can be active s imultaneous ly
- attempting to open a f i l e with attributes different from those under which it was created
- attempting to reopen a f i le under a d ifferent ARITHMETIC option
- two program-units attempting to open a f i le under different attributes or options
- means of insuring preservation of f i l e contents between runs
- effect of certain combinations of f i l e organization and type
- length of records in INTERNAL and NATIVE ( for BASIC-2 only) f i les
- maximum length of records when not specif ied or avai lable
- value of DATUM for a SEQUENTIAL ( BASIC- 1 ) or non-STREAM ( BASIC-2 only) f i le
- value of ask-attribute NAME for channe l zero
- meaning of exception codes 7 101-7 199
- maximum length of keys for KEYED f i l e ( BASIC-2 only)
Subsection 11 . 2
- method o f s ignifying that data i s not avai lable for input on a non- f i le device channe l
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 f i les
Subsection 11 . 4

number o f s ignificant d igits for values received from a numeric field in a NATIVE ( for BASIC-2
only) f i le
effect of input-contr o l - items on f i les and nonterminal devices
prec is ion of numeric contents received from disp lay f i les
precis ion of numeric-values that can be retrieved without loss of precis ion from a NATIVE file
( BASIC-2 only)
retrieving a record from a NATIVE file having contents which are incompatible with the TEMPLATE
( BASIC-2 only)
use of fatal or nonfatal exception procedure on i l l egal input- rep ly

- 166 -

Subsection 11 . 5 ( BASIC-2 only )


- effect of data modif ication s tatements on f i les that are not RELATIVE or KEYED
- use of SKIP in incompatible temp late for REWRITE
Subsection 12 . 1 ( BASIC-2 only)
- value of EXTYPE for loca l ly defined exceptions
- format of EXTEXT $ values
Subsection 12 . 2
- actions al lowed by debugging system
- form of trace reports
Subsection 13 . 1
- manner of selecting a particular graphic disp lay device
- effect of " inverted" windows
Subsection 13 . 2
-

number o f l ine styles avai lable for graphics


effect of l ine styles other than 1
number of point styles available for graphics
effect of point s tyles other than 3
the number of color values avai labl e
the color as soc iated with each color value
Subsection 13 . 3

- character s ize , style , and orientation for graphic label s


Subsection 15 . 1 ( BASIC-2 only)
-

the maximum precis ion avai lable for f ixed decimal arithmetic
the precis ion of f ixed decimal expression and function evaluation
the accuracy of fixed decima l express ion and function evaluation
definition of " s ignif icant d igits"
the access ibi l i ty o f an INTERNAL format file to programs having different ARITHMETIC options

- the accessibil ity of a NATIVE format f i l e to programs having different ARITHMETIC options
Tab le 1
- The number of additional other- characters .
It should be noted that implementation-defined features may cause the same program to produce
different results on different imp lementations , for these and possibly other reasons :
- The logical f low of a program may be affected by the algorithm used for the pseudo -random num
ber sequence .
- The logical f low of a program may be affected by the value of machine infinites imal and /or the
value of MAXNUM and / or the precis ion for numeric values .
- The initial value of variables may affect the logical f low of a program which contains logical
errors .
The order of evaluation of numeric-expressions may affect the logical f low of a program .

- 167 -

APPENDIX 4
INDEX OF SYNTACTIC OBJECTS

This Appendix indexes a l l occurences of terminal symbo ls and metanames in the syntax . Each refer
ence has the form cc . s -pp , where cc . s indicates the section and subsection in which the
metaname occurs and pp indicates the number of the production . An asterisk f o l l owing a reference
indicates that the metaname is def ined in that product ion . Symbols and etanaJIIf!s used only in
BASIC-2

are

shown in bold .

Examp l e : 4 . 1-07 refers to Section 4 . 1 , Subsection 4 . 1 . 2 ( the Syntax subsection ) , production


rul e 7 .

0
1
2
3
4
5
6
7
8
9
A
ABS
ACCESS
ACOS

AND
ANGLE

4 . 1-07
4 . 1-07
4 . 1 -07
4 . 1-07
4 . 1-07
4 . 1-07
4 . 1-07
4 . 1-07
4 . 1-07
4 . 1-07
4 . 1-09
5 . 4 -01
11 . 1-08
5 . 4-01
8 . 1-03
5 . 4-01

ASIN
ASK
AT
ATN

13 . 2 -04
5 . 6-03
5 . 4-01
10 . 3 -08
13 . 3 - 12
5 . 4 . 01

B
BASE
BEGIN
BREAK

4 . 1-09
7 . 1-09
11 . 2 - 0 5
12 . 2-02

AREA
ARITHMETIC

c
CALL
CASE
CAUSE
CEIL
CHAIN
CHR
CLEAR
CLIP
CLOSE
COLLATE
COLOR
CON

4 . 1 -09
9 . 2 - 14
8 . 4- 1 3

7 . 1 -09
7 . 1 -09

11 . 1-22

5 . 6-03
13 . 3 -05
15 . 1-01
11 . 1 - 18

13 . 1-04

8 . 4 - 16

8 . 4-21

12 . 1-13

5 . 4-01
9 . 3-01
6 . 4-01
13 . 2-02
13 . 1-01
11 . 1 - 16
6 . 6-01
13 . 2-03
7 . 2 -06

13 . 1-06
11. 1-29

13 . 2-07

11. 1-31

- 168 -

CONTINUE
cos
COSH
COT
esc

12 . 1-11
5 . 4- 0 1
5 . 4- 0 1
5 . 4-01
5 . 4 . 01

D
DATA
DATE
DATUM
DEBUG
DECIMAL
DECLARE
DEF
DEG
DEGREES
DELETE
DET
DEVICE
DIM
DISPLAY
DO
DOT

4 . 1-09
10 . 1-06
5 . 4- 0 1
11 . 1-22
12 . 2-01
5 . 6-03
5 . 6 - 04
9 . 1-05
5 . 4- 0 1
5 . 6- 0 3
11 . 5-06
7 . 2 - 10
13 . 1-01
7 . 1-01
11 . 4- 14
8 . 3-04
7 . 2 - 10

E
ELAPSED
ELSE
ELSEIF
END

4 . 1-09
10 . 2 -07
8 . 2-03
8 . 4-07
4 . 2 - 18
11. 2-05
5 . 4-01

EPS
ERASABLE
ERASE
EXCEPTION
EXIT
EXLINE
EXP

EXTERNAL
EXTEXT
EXTYPE
F
FILETYPE
FIXED
FOR
FP
FUNCTION

G
GO
GOSUB
GOTO
GRAPH
H

11 . 1-22
11. 1-17
12 . 1-03
8 . 3 - 07
12 . 1-18
5 . 4- 0 1
9 . 1 - 15
12 . 1-19
12 . 1-18

6 . 4-01

9 . 1-07

9 . 1-20

15 . 2-07

13 . 1-06

8 . 3 - 07

5 . 1 -08

11.3-N22

8 . 2-06

8 . 4-01

8 . 4-09

8 . 4-21

8 . 4-10
12 . 1-07

8 . 4-22
12 . 1-17

9 . 1 - 13

9 . 2 - 10

12 . 1-09
8 . 3 - 18

12 . 1-13
9 . 1 - 18

9 . 2-11

12 . 1-12

9 . 1-22

9 . 2 - 13

9 . 2 - 19

15 . 2-06

9 . 1 - 13
15 . 2-05

9 . 1 - 15
15 . 2-06

9 . 1 - 18

9 . 1-21

8 . 2-03

8 . 2-04

8 . 2-06

4 . 1-09
1 1 . 1-22
5 . 6- 0 3
8 . 3-12
5 . 4-01
9 . 1 - 12
9 . 1-22
4 . 1 -09
8 . 2-02
8 . 2-04
8 . 2 - 02
13 . 3-04
4 . 1-09

15 . 1-01
8 . 3 - 18

8 . 2 -06
8 . 2 - 03

- 169 -

HANDLER

12 . 1-12

I
IDN
IF
IMAGE
IN
I NPUT

4 . 1-09
7 . 2-06
8 . 4-01
10 . 4-05
12 . 1-03
10 . 2 -01
1 1 . 4-01
5 . 4-01
11 . 1 - 14

INT
INTERNAL
INV
IP
IS
J

L
LBOUND
LCASE

4 . 1-09
7 . 1- 12
6 . 4-01
6 . 4 - 02
1 1 . 1-15
5 . 5 - 02
10 . 2 -08
13 . 3 -05
5 . 4-01
5 . 4-01
5 . 4-01
8 . 3 -09
6 . 4- 0 1

LOG
LOG10
LOG2
LOOP
LTRIM

MIN
MISSING
MOD

4 . 1-09
10 . 3 . 07
7 . 2-02
10 . 5 -09
11 . 4-04
5 . 4- 0 1
6 . 4- 0 3
5 . 4-01
7 . 1- 12
5 . 4-01
10 . 1-03
5 . 4-01

N
NAME
NATIVE
NEXT

4 . 1-09
1 1 . 1-01
5 . 6- 0 3
8 . 3 - 20

M
MARGIN
MAT

MAX
MAXLEN
MAXNUM
MAXSIZE

8 . 4 - 04

8 . 4 - 10

10 . 1-03

1 1 . 2-07

10 . 2 -08
11 . 4-02

10 . 5 - 04
1 1 . 4-03

10 . 5 -06
1 1 . 4-04

11 . 1-08

6 . 5 - 02
10 . 5 -06

9 . 1 - 16
11 . 4-03

9 . 1- 17
11 . 4 - 04

10 . 3 - 10
7 . 3 - 02
11 . 3 -02
1 1 . 4 -08
13 . 2 - 07

11 . 1-22
10 . 5-01
11 . 3 -07
11 . 5-03

11. 3-05
10 . 5 - 04
11 . 4-02

4 . 1-09
4 . 1-09
11 . 1-31
11 . 1-24

LENGTH
LET
LINE
LINES

12 . 1-17

7 . 2 -09
5 . 4-01
8 . 4 - 19

K
KEY
KEYED

LEN

12 . 1-16

11 .2-10

11 . 1-22
6 . 6- 0 1

11. 1-29

1L l-N26

13 . 2-05

10 . 5-06

- 170 -

NOT

8 . 1-04

NUL
NUMERIC

7 . 3 -05
5 . 6-06

0
OF
OFF
ON
OPEN
OPTION
OR
ORD
ORGANI ZATION
OUT IN
OUTPUT

4 . 1 -09
11. 3-Nl8
12 . 2 -01
8 . 2 - 03
11 . 1-01
5 . 6- 0 1
8 . 1-02
6 . 4-02
1 1 . 1-09
11 . 1 -08
11 . 1-08

4 . 1-09
5 . 4-01
13 . 2 -05
11 . 1-22
13 . 3 -0 5
6 . 4-02
10 . 3 -01
4 . 2-02
10 . 2 - 04

PI
POINT
POINTER
POINTS
POS
PRINT
PROGRAM
PROMPT
Q

4 . 1-09

R
RAD
RADIANS
RANDOMIZE
READ
RECORD
RECSIZE
RECTYPE
RELATIVE
REM
REMAINDER
REPEAT
REST
RESTORE
RETRY
RETURN
REWRITE
RND
ROUND
RTRIM

4 . 1 - 09
5 . 4-01
5 . 6-03
5 . 4- 02
10 . 1-01
11 . 1-31
11 . 1 - 1 5
11 . 1 - 12
11 . 1-24
4 . 3 -0 1
5 . 4-01
6 . 4-01
1 1 . 1 - 17
10 . 1-05
12 . 1-11
8 . 2-05
11. 5-02
5 . 4- 0 1
5 . 4-01
6 . 4-01

s
SAME
SEC
SELECT
SEQUENTIAL
SET
SETTER

4 . 1-09
11 . 2 -05
5 . 4-01
8 . 4- 1 3
11 . 1 - 1 1
10 . 3 -06
11 . 1-22

11 . 3 -N21

11 . 3 -N19
12 . 2 - 03
8 . 2 - 06

15 . 1-03

12 . 2-01

12 . 2 -03

10 . 4-01

10 . 5 -09

11 . 3 -0 1

10 . 5 . 0 1
11. 2-10
11 . 1-22
11 . 1-22

11 . 4-07

11 . 4 - 08

11 . 4-01

11 . 4-07

11 . 1-22

11 . 2-03

11. 5-03

8 . 4-22

1 1 . 3-02

- 17 1 -

SGN

5 . 4-01

SIN
SINH
SIZE
SKIP
SQR
STANDARD
STATUS
STEP
STOP
STR
STREAM
STRING
STYLE
SUB

5 . 4-01
5 . 4-01
7 . 1 - 12
11 . 3-N18
5 . 4-01
6 . 6-01
1 3 . 1-05
8 . 3 - 12
4 . 2 - 13
6 . 4-01
1 1 . 1-11
6 . 6-03
13 . 2 - 03
8 . 2 -04
9 . 2 - 18

T
TAB
TAN
TANH
TEMPLATE
TEXT
THEN
THERE
TIME
TIMEOUT
TO
TRACE
TRN
TRUNCATE

4 . 1 -09
10 . 3 -04
5 . 4-01
5 . 4-01
11. 3-N15
13 . 2 -04
8 . 4-01
11 . 2-07
5 . 4-01
10 . 2 . 05
7 . 1-06
8 . 4- 19
12 . 2-03
7 . 2 - 09
5 . 4-01

u
UBOUND
UCASE
UNTIL
USE
USING

4 . 1-09
7 . 1 - 12
6 . 4-01
8 . 3 -0 5
12 . 1-05
6 . 4-01

12 . 1-09
10 . 4-02

4 . 1 -09
6 . 4 - 02
11 . 1 - 15
13 . 1-01

13 . 1-06

VAL
VARIABLE
VIEWPORT
w

WHEN
WHILE
WINDOW
WITH
WRITE

4 . 1-09
12. 1-03
8 . 3 -05
13 . 1-01
9 . 3 -0 1
11 . 3 -06

4 . 1 -09

4 . 1 -09

13 . 1-06
11 . 4-01

11 . 4-07

11. 1-29

11 . 3-N26
13 . 2-07
8 . 2 - 06
9 . 2 - 19

13 . 3 - 11
8 . 4-04

9 . 2-04

9 . 2 - 10

9 . 2-11

8 . 4-07

10 . 1 - 0 3

11 . 2 - 07

8 . 2-02

8 . 2-03

8 . 3 - 12

10 . 5-09

11 . 3 - 04

13 . 3 - 11

6 . 4-01
7 . 2 -08
12 . 2-03

12 . 1-07
1 3 . 1-06
11 . 3-N13
11 . 3 - 07

12 . 1-09

- 172 -

ZER
ZONEWIDTH

a
access-mode
actual-array
ampersand
apostrophe
array-ass ignment
array-declaration
array- input-statement
array- l ine- input-statement
array- l ist
array-name
array-output- l ist
array-print- l ist
array-print-statement
array-read-statement
array-rewrite-statement
array-write-statement
ask-attribute-name
ask- io- item
ask- io- l ist
ask- item
ask-item- list
ask-object
ask-statement
asterisk

b
block

bound- argument
boundaries
boundary
boundary-variables
bounds
bounds-range
break-statement
c
cal l - s tatement
case-block
case-else-block
case-else- l ine
case- item
case- l ine
case- l ist
case-statement
cause-statement

4 . 1-09
7 . 2-06
10 . 3 -07

4 . 1 - 10
1 1 . 1-07
5 . 3 -09
4 . 1-03
4 . 1-03
4 . 2 - 12
7 . 1-02
4 . 2 - 12
4 . 2 - 12
1 1 . 3 -07
5 . 2 - lOl'<
10 . 5 -05
10 . 5 -09
10 . 5 -09
4 . 2- 12
4 . 2 - 12
11 . 5-01
4 . 2 - 12
11 . 1-20
10 . 3-09
10 . 3 -08
11 . 1 - 19
1 1 . 1 - 18
1 3 . 1-04
4 . 2 - 12
4 . 1-03
10 . 4- 1 3
4 . 1 - 10
4 . 2-05
8 . 4-06
9 . 1-02
7 . 1 - 12
13 . 1-01
13 . 1-02
1 3 . 1-06
7 . 1 -04
7 . 1-05
4 . 2 - 12
4 . 1 - 10
4 . 2-12
8 . 4- 1 1
8 . 4 - J.l
4 . 2 - 22
8 . 4- 17
4 . 2 - 22
8 . 4 - 16
8 . 4- 1 5
4 . 2 - 12

10 . 3 - 10

11 . 1-08l'<
5 . 3 - lOl'<
4 . 2 - 24
10 . 4-08
7 . 2 - 0ll'<
7 . l-03l'<
10 . 5 - 04)'(
10 . 5 - 06)'1
11 . 3 - 1 P'<
5 . 3 - 10
10 . 5 - 10
10 . 5 - l P
10 . 5 - lOl'<
10 . 5-09l'<
10 . 5 - 0 P'<
11 . 5-03*
11 . 3- 07l'<
ll . l - 2 ll'<
10 . 3 - 10l'<
10 . 3 -09l'<
11 . 1- 20l'<
ll . 1- l9l'l

11 . 1-22

11 . 3 - 0 5

7 . 1- 13
6 . 3-06

7 . 1 - 14

9 . 2 - 16

9 . 1-11
11 . 3 - 11

10 . 5-03

7 . 3- 0 ll'<
1 1 . 4-02)'(
1 1 . 4-04)'1
11. 5-03
6 . 2 -08)'(
10 . 5 - 1 1
11 . 3-02
11 . 3-02
11 . 3 -02l'<
1 1 . 4-08l'<

11. 1-30*

13 . 1-06'
10 . 3 - 08l'<
5 . 3 - 11
11 . 3-N21

13 . 2-07l'<
ll . l- l8l'l
6 . 6-04
11. 3-N26

4 . 2-07l':
8 . 4 - 08
9 . 2 - 02
7 . 1 - 14)':
13 . l -02l'<
13 . l-03l'<
13 . 1-07l'<
7 . 1-05'

8 . 3-06
8 . 4 - 14
12 . 1-04

7 . 1-08

7 . 1-06'
12 . 2 - 02

9 . 2 - l4l'<
8 . 4- 14'
8 . 4- 20)'(
8 . 4- 2 0
8 . 4- l8l'<
8 . 4- 14
8 . 4 - l 7 l'<
8 . 4- l6l'<
12 . 1-13*

8 . 4- 2 P''
8 . 4- 15:':

13 . l-04l'<
7 . 2 -04
15 . 1-02

8 . 3 - 17
8 . 4- 2 0
12 . 1-06

7 . 2-05

8 . 4-05

- 17 3 -

chain-statement
channe l - expression

channel-number
channel- setter
character
circumf lex-accent
c l ear-statement
close-statement
col late- sequence
colon

comma

4 . 2-12
9 . 2 - 16
11. 3-01
1 1 . 4-01
11 . 4-07
11. 5-06
9 . 2-07
1 1 . 1-01
4 . 1-01>'<
4 . 1-03
13 . 2 - 0 1
4 . 2 - 12
11. 1-28
4 . 1-03
10 . 4-05
1 1 . 1-02
1 1 . 3-07
1 1 . 4-03
11 . 5-02
4 . 1-03
5 . 6-06
7 . 1-05
8 . 2 - 03
9 . 1- 1 1
9 . 2-20
10 . 2- 10
10 . 4-12
1 1 . 1-05
11 . 3 -08

9 . 3 - 0 P'<
1 1 . 1-02
11 . 3 -02
11 . 4-02
11 . 4 - 08

11 . 1-03,
1 1 . 3-06
11-4-03
11. 5-02

1 1 . 1 - 16
1 1 . 3 -07
11 . 4 - 04
11 . 5-03

11. 1-17

11 . 1 - 18
10 . 2 - 1 1
10 . 4- 1 5

11 . 2 -0 1

11. 3-05

10 . 1-01
10 . 5 -01
11 . 3-02
1 1 . 4-01
1 1 . 4-07
13 . 3 -03
5 . 3 -08
6 . 6-03
7 . 2-07
8 . 4 - 17
9 . 2-06
10 . 1-07
10 . 3 -09
10 . 5-07
11 . 2 -02
11 . 3 - 1 1
11 . 4-07
13 . 1-02
13 . 3 - 11

10 . 2 -02
10 . 5 -09
1 1 . 3-06
1 1 . 4-02
1 1 . 4-08
13 . 3 - 1 1
5 . 5-03
7 . 1-02
7 . 2 - 10
9 . 1-09
9 . 2-15
10 . 2-02
10 . 4-04
10 . 5 - 1 1
11 . 3 -0 3
11 . 3 -N16
1 1 . 4-09
13 . 1-06
13 . 3 - 12

10 . 4-02

7 . 3 -0 3

7 . 3 - 05

8 . 4- 18

8 . 4- 19

10 . 1-08

11 . 3 - 04

1 1 . 4-06

12 . 2 - 0 3
9. 2 - 08)'(
11 . 1-02)'(
4 . 3 -02
5 . 3 -04
13 . 2 - 02)'(
1 1 . 1 - 16)'(
11 . 1-29*
6 . 2 - 06
10 . 4-08
11 . 3 - 0 1
11 . 3-N15
1 1 . 4 - 04
11. 5-03
5 . 2 - 06
6 . 5 - 03
7 . 1 - 14
8 . 2 - 06
9 . 1-23
10 . 1-02
10 . 3 - 0 5
10 . 5 - 02
1 1 . 1 - 19
11 . 3 - 10

comparison
concatenation
conditiona l - s tatement
conjunction
constant
contro l - transfer
contro l -variab le
coordinate-pair
core-attribute-name
core - f i le-attribute
core - f ile-erg-value
core-record-setter
core-record- type-value

1 1 . 4-01
11. 5-04
13 . 1-07
15 . 1-03
8 . 1-05
6 . 3 -02
4 . 2 - 10
8 . 1 -02
5 . 1-0 P'<
8 . 2-0P'<
8 . 3 - 12
13 . 3 -06
11 . 1 - 2 1
1 1 . 1-06
1 1 . 1 - 10
1 1 . 2-03
11. 1-13

8 . 3 - 13l'<
13 . 3 -07l'(
11 . 1 - 22'/:
11 . 1- 07>'<
11 . 1- 1P'<
11 . 2-04
11 . 1- 14)'(

8 . 3 - 20
13 . 3 - 12

d
data- list
data-statement
datum
debug-statement
declarative- statement
declare- statement
def- statement
def- type

4 . 1 - 10
10 . 1-06
4 . 2-11
10 . 1-07
4 . 2 - 12
4 . 2 - 10
4 . 2 - 11
9 . 1-03
9 . 1 - 19

10 . 1-07>'<
10 . 1 -06l'<
10 . 1- 08>'<
12 . 2 - 0 P'<
4 . 2 - 1 P'<
5 . 6 - 04)'<
9 . 1- 04>'(
9 . 1- 20)'(

10 . 2 - 10

1 1 . 4-05
11. 5-07
13 . 3 -07
8 . 1- 06>'(
6 . 3 - 06l'<
4 . 2 - 14)'(
8 . 1-03 l'(
6 . 1-01)'(

11 . 2-05>'<

11 . 3-N14*

5 . 6-02

- 174 -

defined-function
delete-control
delete-contro l - item
delete - s tatement
detached-hand ler
d igit
digit - p lace
dimens ion- list
dimens ion- statement
disjunction
do-body
do- l ine
do- loop
do-statement
dol lar - s ign
double-quote

9 . 1-23
11 . 5-06
11. 5-07
11. 5-01
4. 2-06
4 . 1-06
10 . 4-08
10 . 4- 12
7 . 1-01
4. 2-11
8 . 1-01
8 . 3-02
4 . 2-22
8 . 3-01
8 . 3-03
4 . 1-03
12 . 1-19
4 . 1-02

e
e-format- item
else-b lock
else- l ine
e l seif - block
elsei f - then- l ine
end -function- l ine
end-hand ler- line
end- i f - l ine
end - l ine
end - of - l ine

4 . 1 - 10
10 . 4-09
8 . 4-03
4 . 2 - 22
8 . 4-03
4 . 2 - 22
4 . 2 - 22
4. 2-22
4 . 2-22
4 . 2 -04

end - s e lect- l ine


end - statement
end -sub- l ine
end - sub- statement
end-when- l ine
enhanced-attribute-name
enhanced- f i l e-attribute
enhanced - f i l e-org-value
enhanced- record- setter
enhanced-record- type-value
equa l i ty-re lation
equa l s - s ign

4 . 2-22
4 . 2 - 17
4 . 2 - 22
9 . 2-09
4 . 2-22
11 . 1-30
11. 1-27
11. 1-23
11. 2-08
11 . 1-N25
8 . 1-07
4 . 1-03
8 . 1-08
9 . 1-05
10 . 4-08
4 . 2 - 12
11. 2-10
12 . 1-02
12 . 1-13
4 . 1-03
8 . 3 - 04
4 . 2 - 12
4 . 2 - 12
4 . 2 - 12
4 . 2-12

erase - statement
exact-search
exception-handler
except ion-type
exclamation-mark
exit-condition
exit-do-statement
exit-for-statement
exi t - function- statement
exit-hand ler-statement

4 . 2-15
10 . 4- 0 5

9. 1 - 24'(

15 . 2-08

11. 5-07*
11 . 5-0S:it
11 . 5- 06*
12 . 1-15*
4 . 1-07)'(

4 . 2 -09

4 . 4-03

5 . 1-06

7 . 3 - 05

10 . 4- 1 1

10 . 4- 13)'(
7 . 1 -02l'(
7 . l - O P''
8 . 1-02)'(
8. 3 -Q6l'C
8 . 3 -02
8 . 3 -02,
8 . 3 - 04,
4 . 4 - 04

8 . 3 - 0 3)'(

6 . 4-01

4 . 1-Q4l'C

10 . 4- 1 5)'(
8 . 4-08)'(
8 . 4-08
8 . 4-06)'(
8 . 4-06
9 . 1-02
12 . 1-15
8 . 4- 0 3
4 . 2- 17)'(
4 . 2 - 16)'(
8 . 4 - 11
4 . 2 - l8l'C
9 . 2 - 02
9. 2 - lQl'C
12 . 1-02
11 . 1-31*
11. 1-28*
11 . 1-24*
11. 2-09
11. 1-N26*
8 . 1-Q8l'C
5 . 5 - 02
8 . 1 - 10
9 . 1-07
11. 2-11
11 . 1- 17'(
11 .2-11*
12 . 1- 06*
12 . 1- 14*
4 . 3 - 04
8 . 3 -05)'(
8 . 3 -07it
8 . 3 - 18
9 . 1- 18)'(
12 . 1-12*

8 . 4- 09)'(
8. 4-07,
9 . l- 13l'C
12. 1-17*
8 . 4- 10)'(
4 . 2-22
4 . 2-21

9 . 1 - 14

10 . 2 - 10

10 . 2- 11

8 . 4- 22)'(
9 . 2- 09)

9 . 2 - 12

12 . 1-07*

12 . 1-08

11 . 2-10*

6 . 5- 02
8 . 1-11
9 . 1 - 16
15 . 2-07

12 . 1-15
10 . 4 - 08
8 . 3 -09
10 . 1 -04
10 . 1 -04

7 . 2 -02
8 . 3 - 12
9 . 1 - 17

7 . 3 -02

- 175 -

exit-sub - statement
express ion
expression - l is t
exrad
externa l -function-de
externa l - function- l ine
externa l - function-type
externa l - sub-de
externa l - sub- line
externa l - sub-type
f
-format- item
factor
field-specifier
f i l e-attribute
f i le-attribute - l is t
f i le-name
f i le-organization
f i le-organization-value
f ixed-dec laration
f ixed-def ined- function
fixed-field-count
f ixed- formal-array
f ixed-point - s ize
f ixed-point-type
f l oating-characters
for-body
for- l ine
for- loop
for - s tatement
formal-array
format- item
format - s tr ing
formatted-print - l i s t
fraction
fraction - s ize
function-arg- list
function-argument
function-de
function- list
function-parameter
function-parm- l is t

g
geometric -obj ect
geometric-statement
gosub-statement
goto -statement
graphic-output- statement
graphic- text- statement
graphic-verb

10 . 3 -03
11 . 3 - 0 6
5 . 1-04
4 . 2 - 20
4 . 2-22
9 . 1 - 19
4 . 2 - 20
4 . 2 - 22
9 . 2 - 17

9 . 2- 1 1'
5 . 3-09
10 . 4-04
11 . 3 - 10l'(
5 . 1- 08l'(
9 . 1-01
9 . 1 - 14
9 . 1- 22l't
9 . 2-01
9 . 2 - 12
9 . 2 - l9l'(

4 . 1 - 10
10 . 4-09
5 . 3-03

10 . 4- l4l'(
5 . 3 -04'

4 . 2 - 12
5 . 3 -01l'(

11 . 3-NH
11 . 1-05
11 . 1-01
11 . 1-01
11 . 1-07
11 . 1-09
15 . 1-03
15 . 2-05
11. 3-N17
15 . 2-03
11. 3-N22
15 . 1-01
15 . 2-04
10 . 4-09
8 . 3 - 10
4 . 2 - 22
8 . 3 -0 1
8 . 3 - 11
9 . 1 - 10
10 . 4 . 06
10 . 4 . 05
10 . 4-01
5 . 1-05
11 . 3-N23
5 . 3 -0 6
5 . 3 -08
9 . 1-0P't
9 . 1-20
9 . 1 -09
4 . 2-02
9 . 1 - 15
4 . 1 - 10
13 . 3-03
1 3 . 3 -02
4 . 2 - 12
4 . 2 - 12
13 . 3 -0 1
1 3 . 3 -02
13 . 3 - 0 3

11 . 3-N20*
11 . 1- 06l't
11 . 1-05l't
11 . 1-04l':
11 . 1-09l':
1 1 . 1- 10l':
15. 1-04*
15. 2-06
11. 3-NlS*
15 . 2-04*
11. 3-R23*
15 . 1-02*
15 . 2-09
10 . 4- l P't
8 . 3 - 17l'(
8 . 3 - 10
8 . 3 - 10l'(
8 . 3 - 12l'(
9 . 1- 1P
10 . 4-09l't
10 . 4 . 06l'(
10 . 4-02l'(
5 . 1-07l':
11. 3-N25l
5 . 3 -08'
5 . 3 -09l't
9 . 1- 2 1
9 . 1- 10l't
9 . 1-05
15 . 2-05

13 . 3 - 05l't
13 . 3 - 03'
8 . 2-01
8 . 2-01
1 3 . 3 -02l'(
13 . 3 - 11'
13 . 3 - 04l't

6 . 3 -0 P't
11 . 3 - 10
11. 5-02
9 . 1- 14l'(
9 . 1- l 5l't

8 . 4- 1 3

9 . 2 - 16

13 . 3 - 1 1

15 .2-06*

9 . 2 - l 2l'(
9 . 2 - 13l't

10 . 4 - 15

11. 1-27*

12 . 1-23*
15 . 2-07

15 . 2-08

15 . 2-09*

15 . 1-02
15 . 1-03

15 . 1-04

15 . 2-03

8 . 3 - 1P't

9 . 2-07

6 . 3 -04

9 . 1-22
15 . 2-01*
9 . 1-07
15 . 2-06

8 . 2 -04l'(
8 . 2 - 02l't

13 . 3 - 11

15 . 2-04

9 . 3-01

9 . 1 - 2 3l't
9 . 1-09l't
15 . 2-07

9 . 1 - 12

- 176 -

greater-than- s ign

4 . 1-03
11.2-12

h
hand ler- l ine
hand ler-name
handler-return-statement

4 . 1 - 10
4 . 2-22
12 . 1-09
4 . 2-12

i
i-format- item
identifier
identifier-character
if-block
if-c lause
if-statement
if-then - l ine
image
image- l ine
imperative-statement

4 . 1 - 10
10 . 4-09
4 . 4- 0P'<
4 . 4-02
4 . 2-07
8 . 4-01
4 . 2 - 14

implementation-def ined
increment
index

inexact-search
initial -point
initial -value
input-contro l
input-control - item
input-modifier
input-modifier- list
input-prompt
input-reply
input- statement
integer

4 . 2-22
10 . 4-02
4 . 2-07
4 . 2 - 10
11 . 5-01*
4 . 1-11
8 . 3 - 12
5 . 2-07
8 . 2-03
11 . 1-03
12 . 1-14
11 . 2-10
13 . 3- 1 1
8 . 3 - 12
11 . 4-01
11 . 4-05
10 . 2-02
10 . 2 -01
10 . 2 - 09)'(
10 . 2 - 10)'(
4 . 2 - 12
5 . 1-05
7 . 1-07
11 . 3 -N25
11 . 3 -N23

8 . 1-07

8 . 1-09

12 . 1-15
12 . 1-10*
12 . 1-11*

12 . 1-16*
12 . 1-16

10 . 4 - 12)'(

10 . 4- 14

10 . 4- 15

4 . 4- 03)'(
8 . 4-03)'(
8 . 4-02)'(
8 . 2-01
8 . 4-03
10 . 4-03)'(
4 . 2-22
4 . 2- 12)'(
13 . 2 - 01)'(
4 . 2 - 16
8 . 3 - 16)'(
5 . 2 -08)'(
8 . 2 -06
11 . 1 - 1 5
13 . 2-03
11 . 2-12*
13 . 3 - 12)'(
8. 3 - 14)'(

4 . 4-04

4 . 4-05

1 1 . 4-02
11 . 4-06)'(
10 . 2-03)'(
10 . 2-02)'(

8 . 4-0P'<
8 . 4-04j(
10 . 5 -09
10 . 4-05)'(
8 . 2-03
13 . 3 -01j(
10 . 2-09

8 . 1 - 10

10 . 4- 10

1 1 . 3 -04

13 . 3- 1 1

8 . 2 -06

8 . 4-02

6 . 2-06
10 . 3 -04
11. 2-10

7 . 1 - 14
10 . 3 -07
1 1 . 3-05

7 . 2 -08

11 . 4-03

11 . 4-04

11 . 4-05)'(

10 . 2-08

10 . 5 -04

10 . 5-06

integer-size
internal -def - l ine
internal - function-def
internal -function - l ine
interna l- function-type
internal -proc-def
internal- sub-def
interna l - sub- line
internal - sub- type
io-recovery
io-recovery-action

4 . 2-22
4 . 2 -06
4 . 2-22
9 . 1 - 19
4 . 2-05
4 . 2-06
4 . 2 - 22
9 . 2 - 17
8 . 2-01
10 . 1-03

10 . 2 -02)'( 11 . 4-0P'<
5 . 1- 06)'(
5 . 1-07
11. 3-N18
9 . 2 -08
11. 3-N27
11. 3-N24*
9 . 1-02
9 . 1-03)'(
9 . 1-01
9 . 1-02)'(
9 . 1- 12)'(
9 . 1-02
9 . 1-2P'<
4 . 2 -06)'(
9 . 2-01
9 . 2-02)'(
9 . 2-02
9 . 2 -03)'(
9 . 2 - 18)'(
1 1 . 2 -02
1 1 . 2 -06)'(
10 . 1-04)'( 1 1 . 2-07

j
justifier

4 . 1 - 10
10 . 4-09

10 . 4- 10)'(

5 . 1-08
11 . 3-N24

15 . 2-05*

6 . 6-04

- 177 -

4 . 1 - 10

4 . 1 - 10
4 . 1-03
6 . 3 -0 3
7 . 1 - 14
8 . 1-05
9 . 2-15
11 . 3-Nl7
6 . 6-03
9 . 1 - 12
4 . 1-03
4 . 2 - 12
4 . 1-06
4 . 4-05
8 . 3 - 12
4 . 2- 22>'(
4 . 2 . 24>'(
4 . 2 - 24>'(
10 . 2 - l l\'(
4 . 2 - 12
4 . 2-02
8 . 2-02
8 . 3 -0 3
8 . 4-02
8 . 4- 10
8 . 4-22

left-parenthesis

length-max
les s - than-s ign
let-statement
letter
l imit
l ine
l ine-continuation
l ine-continuation
l ine- input- rep ly
l ine- input- statement
l ine- number

9 . 1-15
10 . 1-04

l iteral- item
l itera l - string
loop
loop - l ine
loop - s tatement
lower-case- letter
m
main-program
maxs ize-argument
minus- s ign
miss ing-recovery
mul t ip l ier
n
next- l ine
next- s tatement
non-quote-character
not-equals
not-greater
not - less
not-miss ing-recovery

11 . 3-Nl3
12 . 1-09
15 . 2-06
10 . 4-07
10 . 4-06
4 . 2 - 07
4 . 2 - 22
8 . 3 -08
4 . 1 -08
4 . 1 - 10
4 . 2-01
7 . 1- 12
4 . 1-06
10 . 1-01
11 . 4- 10
5 . 3 -03
4 . 1 - 10
4 . 2 - 22
8 . 3 - 19
4 . 1-01
8 . 1 -08
8 . 1-07
8 . 1-07
11 . 2-06

5 . 2-06
6 . 4- 0 3
7 . 2 - 07
9 . 1-09
10 . 3 -04
6. 6-04>'(
9 . 1 - 15
8 . 1-07
5 . 5 -0 P''
4 . 1-08>'(

5 . 3 -0 5
7 . 1-05
7 . 2 -09
9 . 1-11
10 . 4 - 08

5 . 3 -08
7 . 1-13
7 . 2 - 10
9 . 2 -06
10 . 5-05

6 . 2-06

6 . 6-06

7 . 1 - 10

9 . 1-07

8 . 1 -09
6 . 5 - 0 P'c
4 . 4-02

8 . 1 - 11

10 . 4 - 10

4 . 4-03

4 . 4-04

4 . 2 - 17
8 . 2-06
8 . 3 - 19
8 . 4 - 09
8 . 4-21
9 . 1-13
9. 2 - 13
10 . 4-05
12 . 1-07
15 . 2-05

4 . 2-21

1 1 . 2-06

11 . 4-06

10 . 4-08
8 . 3 - 15>'(

10 . 2- 08>'c
4 . 2 - 08
8 . 2-03
8 . 3 - 08
8 . 4-04
8 . 4- 12
9 . 1-03
9 . 2-03
10 . 1-05
12 . 1-03
12 . 1-16
10 . 4- 08>''
10 . 4-07>'(
8 . 3 - 0 l>'c
8 . 3 -06
8 . 3 -09>'(
4 . 1- 10>'c

4 . 2 - 04>'(
7 . 1- 13>'c
5 . 1-03
10 . 1-03>'(

11 . 5-05
5 . 3 - 11>'c

8 . 3 - 17
8 . 3 - 20>'(
4 . 1 -02
8 . 1-09>'c
8 . 1- 111''
8 . 1- 10>'(
11 . 2-07>'(

11 . 4-03>'(
4 . 2 -09>'(
8 . 2 -04
8 . 3 - 11
8 . 4-07
8 . 4- 15
9 . 1 - 12
9 . 2-09
10 . 4-03
12 . 1-05
12 . 1-17

8 . 3 -08>'(

4 . 2-23
10 . 4- 1 1
10 . 5- 0 1

11. 5-08

8 . 3 - 19>'(
4 . 1-03>'(

11. 2-12
11 . 3 -04

11 . 3 -09

- 178 -

nul l -statement

4 . 2-11

4 . 2-21

number- s ign
numeric- array

4 . 1-03
5 . 2 -04
7 . 2- 0 3

9 . 2 - 08
5 . 2-05l'<

numeric-array-ass ignment
numeric-array-dec laration
numeric- array-element
numeric-array-express ion
numeric-array- function-ref
numeric-array-operator
numeric-array-value
numeric- constant
numeric -dec laration
numeric-def-statement
numeric-defined-function
numeric-expression

numeric- f ield-s i ze
numeric - f ixed-parameter
numeric- funct ion
numeric - function- let-statement
numeric- funct ion-ref
numeric- identifier
numeric - let-statement
numeric-rep
numeric- specifier
numeric- supp l ied- funct ion
numeric - t ime-express ion
numeric - type
numeric-variable

numeric-variable- l is t

7 . 2-01
7 . 1-03
5 . 2-02
7 . 2 -02
7 . 2-03
7 . 2- 0 3
7 . 2-03
5 . 1-01
5 . 6-06
9 . 1 -04
5 . 3 -0 7
9 . 1 - 16
5 . 2 - 08
8 . 1-06
9 . 1-05
13 . 3-07
11 . 3-N21
15. 2-01
5 . 3-06
4 . 2 - 12
5 . 3-05
4 . 4 . 01
5 . 5-01
5 . 1-02
11 . 3-N20
5 . 3 -07
10 . 2 -05
5 . 6-05
5 . 2 -01
10 . 3 - 10
13 . 2 - 0 7
5 . 5-02

on-gosub- statement
on-goto- statement
open-statement
option
option- l i s t
option- statement
other-character
output- l i s t

4 . 1 - 10
4 . 2 - 14
4 . 2 - 14
4 . 2- 12
5 . 6-02
5 . 6-01
4 . 2-11
4 . 1- l P''
10 . 4-02

p
percent-s ign
period
p l ain-string-character
p lus - s ign
point- l i s t
pointer-contro l
pointer - items
primary

4 . 1 - 10
4 . 1-03
4 . 1-06
4 . 1-05
4 . 1-06
13 . 3 -0 3
1 1 . 2-02
11 . 2-01
5 . 3 -04

7 . 2 -09
7 . 2 -02l'l
7 . l-04l'(
5. 2 -04l'l
7 . 2-03)'(
7 . 2 -09l'l
7 . 2 - 04l'(
7 . 2 - 06)'(
5 . 1-02)'(
5. 6-07)'(
9 . 1-05)'(
9 . 1-05

4 . 3-0V<
10 . 4- 13
5 . 2 - 10
7 . 2- 10

10 . 4 - 14
7 . 1 -04

7 . 1-11

15 . 1-04

7 . 1- lP'<
15 . 2-07*
9 . 1-06)'(
15 . 2-09
5 . 3 -02)'(
8 . 3 - 15
10 . 2 -06

9 . 1-24
5 . 3 -0 1
8 . 3 - 14
9 . 1 - 16
15 . 2-07
1 1 . 3-N22*
15 . 2-02
15 . 2-03*
5 . 3 - 0 7 )'(
9 . 1- 16)'(
6 . 4- 03l'(
5 . 3 - 06)'(
4 . 4-02)'(
5 . 2-03
5 . 5 - 02)'(
5 . 1- 04l'<
5 . 3-05

1 1 . 3-N21*
6 . 4-02l'(
5 . 4-0ll'l
10 . 2 -06)'(
5 . 6- 06l'l 15 . 1-03
5 . 3-05
5 . 2-02)'(
13 . 1-06
1 3 . 1-05

1 1 . 1-03
7 . 2 -02

9 . 1 - 12

9 . 1 - 15

5 . 3 -05
8 . 3 - 16
13 . 1-03

5 . 5 -02

7 . 1 - 12)'(
5 . 2-05

7 . 2 - 10)'(
9 . 1-06

12 . 1-18*

5 . 5 - 03
13 . 1-07

10 . 2-07

5 . 5-03)'(

8 . 2-01
8 . 2-01
1 1 . 1-0P'<
5 . 6- 03l'l
5 , 6- 02l'C
5 . 6- 0 P'<
10 . 4-04l'l

10 . 4- 13
5 . 1-05
4 . 1- 06l'(
5 . 1-03
1 3 , 3 - 06l'C
11 . 2 - 03)'(
1 1 . 2 - 02)'(
5 . 3 -05l'l

8. 2-06)'(
8 . 2-03l'l
6 . 6-0P''

7 . 1-09)'(

15 . 1 . -01*

11 . 3 - 0 1

5 . 1-07
10 . 1-09
10 . 4- 1 1

11 . 2-0B*
7 . 2-05

10 . 4- 14

11 . 3-N23

- 179 -

primitive - !

13 . 2-03

13 . 2 - 04

13 . 2 - 05l

p r imitive-2
p rint-contro l
print - contro l - item
p rint- item
print - l is t
print- separator
p rint- s tatement
procedure
procedure-argument
procedure-argument- l is t
procedure-parameter
procedure-parrn - l i s t
procedure-part
p rogram
program-des ignator
program-name
program-name - l ine
program-unit
prompt-specifier
protection-b l ock

13 . 2-03
1 1 . 3 -0 1
1 1 . 3 -0 3
10 . 3 . 02
10 . 3 - 0 1
10 . 3 - 02
4 . 2-12
4 . 2 - 19
9 . 2- 15
9 . 2 - 14
9 . 2-06
9 . 2-04
4 . 2-01
4 . 2 - 0 P''
9 . 3 -0 1
4 . 2-02
4 . 2-01
4 . 2 - 23l'(
10 . 2 -0 3
4 . 2-07

13 . 2 - 04l'(
11 . 3 -02
11 . 3 -04l'(
10 . 3 - 0 3>
10 . 3 -02>'(
10 . 3 - 05>'(
10 . 3 - 0 P''
4 . 2 - 20>'(
9 . 2 - 16>'(
9 . 2 - 15>':
9 . 2 - 0 7>'(
9 . 2 -06>':
4 . 2 - 19>'(

13 . 2 - 07
11 . 3 - 0 3l'(

10 . 2 - 04>'(
12 . 1-01*

11 . 4-06

q
question-mark
quotation-mark
quoted- string
quoted -string-character

4 . 1 - 10
4 . 1-03
4 . 1-01
6 . 1-02
4 . 1-02>':

10 . 4 - 08
4 . 1-04
6 . 1-03>'(
6 . 1-03

10 . 5 -05
6 . 1-03

r
randomize-statement
range
read -control
read-contro l - item
read- s tatement
record- setter
record- s ize
record- type
record- type-value
redim
redim-array
redim-array - l is t
redim-bounds
redim- string-array
red im- s tring-array - l i s t
re lation
relat ional-express ion
relationa l -primary
relat iona l -term
remark- l ine
remark- statement
remark-string
restore - s tatement
return- s tatement
rewrite-control

4 . 1 - 10
4 . 2- 12
8 . 4- 18
11 . 4- 0 7
11 . 4-09
4 . 2 - 12
11 . 2 -04>':
11 . 5-08
11 . 1-07
11 . 1-07
11 . 1 - 12
7 . 2-06
10 . 5 - 02
10 . 5 . 01
7 . 2 - 07
10 . 5 -07
10 . 5 -06
8 . 1-06
8 . 1 - 0 P''
8 . 4 -07
8 . 1 -04
8 . 1-03
4 . 2 - 19
4 . 2 - 11
4 . 3-01
4 . 2-12
4 . 2 - 12

11 . 5-02

9 . 3 -02>':
4 . 2 - 03'
4 . 2 - 02>':

5 . 4- 0 2>':
8 . 4- 19>':
11 . 4 - 08
11 . 4- 10>'(
10 . 1 - 01'
11 . 2-09*
11 . 1- 15>'(
1 1 . 1 - 12>'(
1 1 . 1- 1 3>'(
7 . 2 - 0 7>'(
10 . 5- 03>'(
10 . 5 - 02>':
7 . 2 - 08>':
10 . 5- 08>''
10 . 5-07>'(
8 . 1 - 07>'(
8 . 1-05
8 . 1-05>''
8 . 1- 04>'(
4 . 2 - 2 1'
4 . 2-21
4 . 3 -02>''
10 . 1-05>''
8 . 2- 0 5>''
11 . 5 -03

11 . 3 -0 1
10 . 5 - 10
10 . 4- 0 P''
4 . 2-23

13 . 2-07

11 . 3 - 0 P''

15 . 2-02*

4 . 2 - 22

11 . 3-Nl9

11 . 4-09>'(
11 . 4-Nl1*
11 . 4-07
1 1 . 3 -09
11 . 4- 10

11. 5-05

11. 1-N25*
7 . 3 -05
10 . 5 -03

10 . 5-08

10 . 5 - 04

11 . 4-02

11 . 4-08

11 . 4-04
8 . 4- 19
8 . 3 -0 5

8 . 4- 0 1

8 . 4 - 04

4 . 2 - 22
4 . 3 -0 1>'(
4 . 3 -04

11. 5-04*

8 . 4- 1 1

- 180 -

rewrite-control - item
rewrite-statement
right-parenthesis

routine- identifier
s
scalar-multip l ier
select-block
select- line
select-statement
semicolon
set-object
set-statement
s ign
s igned- integer
s ignif icand
s imp l e-numeric-variable
s imple-string-dec laration
s imple-string-variable
simp le-variable
s lant
space
statement
statement- line
status-c lause
stop-statement
string-array
string-array-assignment
string-array-dec laration
string-array-element
string-array-expression
string-array-primary
string-array-value
string-constant
string-dec laration
string-clef -statement
string-defined-function
string-expression

string-field- size
string-function
string-function- let-statement

11. 5-04
11. 5-01
4 . 1-03
6 . 3-03
7 . 1- 14
8 . 1-05
9 . 2- 1 5
11. 3-Nl7
4 . 2-03
4 . 1 - 10
7 . 2-03
4 . 2-07
4 . 2-22
8 . 4- 1 2
4 . 1-03
13 . 3-06
10 . 3 -06
13 . 2-03)'(
4 . 2 - 12
5 . 1-02
7 . 2 -04
7 . 1-06
5 . 1-04
5 . 2-02
15 . 1-04
6 . 6-05
6 . 2 -02
5. 2 - 09)'(
4 . 1 -03
4 . 1-05
4 . 2 -08
4 . 2 -07
1 3 . 1-04
4 . 2 - 12
6 . 2-04
7 . 3-02
7 . 3-01
7 . 1-03
6 . 2 -02
7 . 3-02
7 . 3-03
7 . 3-03
6 . 1-01
6 . 6-03
9 . 1-04
6 . 3-05
9 . 1- 17
6 . 3-01
9 . 1-07
10 . 4-03
11 . 1 - 12
11. 3-Nl3
11 . 3 -N26
6 . 3 - 04
4 . 2 - 12

11 . 5-05*
11. 5-02*
5 . 2 -06
6 . 4-03
7 . 2 -07
9 . 1-09
10 . 3 - 04

11.5-N9*

4 . 4-01

4 . 4-05>'(

7 . 2-05 >'(
8 . 4 - l P''
8 . 4- 1 1
8 . 4- 1 3>'(

7 . 2-06

5 . 3-05
7 . 1-05
7 . 2-09
9 . 1- 11
10 . 4-08

5 . 3 -08
7 . 1 - 13
7 . 2 - 10
9 . 2-06
10 . 5 -05

6 . 2-06

9 . 2-05

12 . 1-10

8 . 4-12:/(

10 . 3-05

10 . 4-04

10 . 4-08

10 . 5 - 1 1

10 . 3-07 >'(

1 1 . 2-0P''

11 . 3- 05:/(

13 . 1-01>'(

10 . 3 -061:
5 . 1-03>'(

5 . 1-08

5 . 3 -02

7 . 1-07

5 . 2-09

5 . 6-07

8 . 3-13

6 . 2-07
9 . 1-10
10 . 4-08

6 . 4-03
9 . 2-07

6 . 6-06

6 . 4-03

7 . 1-08

9 . 1 - 12

9 . 1 - 15

6 . 5-02
10 . 2 -04
1 1 . 1-09
11. 2-10

8 . 1-06

7 . 1-07 >'(
5 . 1-05 >':
5 . 2-03 >'(
15 . 2-03
6 . 6-06>'(
6 . 2-03 >'(
6 . 2 -07)'(
5 . 3 - 11
4 . 2- 24
4. 2 - 10>':
4. 2 -08>'(

10 . 4-08

4 . 2-22
13 . 1-05 >
4 . 2 - 1 3 >':
6 . 2 -05:/(
6 . 2-08
10 . 5-08
7 . 3 -04
7 . 3 -02 >'(
7 . 1-08 >'(
7 . 1- 10
6. 2-04 >'(
7 . 3 -03 >'(
7 . 3 -04>'(
7 . 3-05 >'(
6 . 3-03
6 . 1-02 >'(
6 . 6-05 >'(
7 . 1- 10>'(
9 . 1-0711
9 . 1-07
9 . 1-08:/(
9 . 1-24
6. 3 -02::
6 . 3-03
9 . 1-17
9 . 3-02
11 . 1 -04
11 . 1-08
11 . 1 - 15
11. 1-29
13 . 1-01
13 . 3 - 1 1
11. 3-N27*
6 . 3-05 >'(
9 . 1 - 17 >'(

- 181 -

string- function-ref
string-identifier
string- let-statement
string-primary
string-specifier
string-supp l ied- function
string-type
string-variabl e
string-variable- l ist
sub - l is t
sub - statement
subprogram-def
subprogram-name
subscript
subscript-part
substring-qua l i f ier
t
tab-cal l
tai l

6 . 3-03
4 . 4-01
6 . 5-01
6 . 3 - 02
11 . 3-N20
6 . 3 -05
6 . 6-02
6 . 2-01
6 . 5 - 02
9 . 2 - 18
9 . 2-03
9 . 2-0P'<
9 . 2 -04
5 . 2-06
5 . 2-04
6 . 2 - 02
4 . 1 - 10
10 . 3 -03
4 . 2-02
8 . 3 -0 3
8 . 4 - 04
8 . 4- 12
9 . 1-03
9 . 2 - 03
12 . 1-05

6 . 3 - 041<
6 . 2-03
4 . 4-04)'(
6 . 5- 02)'(
7 . 3 -0 3
6 . 3- 03)'(
11. 3-N26*
6 . 4-0P'< 12 . 1-19*
6 : 6-03)'(
6 . 2-02)'(
6 . 3 -0 3
6 . 5 -03)'( 10 . 2 -08
9 . 2 - 19
9 . 2 - 20)'(
9 . 2 - 04)'(
9 . 2 - 13
9 . 2 - 05)'(
5 . 2 - 07 )'<
5 . 2 -06)'(
6 . 2 - 06)'(

10 . 3 -04)'(
4 . 2-08
8 . 3 -08
8 . 4-07
8 .4-15
9 . 1 - 12
9 . 2 -09
12 . 1-07
15 . 2-05
4 . 3 -0 3

6 . 2-05
7 . 3 -0 5

6 . 5-03
1 1 . 4-03

9 . 2 - 14

9 . 2 - 20

6 . 2 -04
7 . 3-02

7 . 3 -04

4 . 2 - 15)'(
8 . 3-11
8 . 4-09
8 . 4- 2 1
9 . 1-13
9 . 2 - 13
12 . 1-09
15 . 2-06
4 . 3 -04)'(

tai l -comment
temp late- element
temp late-element - l ist
temp l ate- identi f ier
temp late-statement
term
then-block
time-enquiry
timeout-express ion
trace-statement
type-declaration

12 . 1-17
4 . 2-15
11 . 3-N16
11. 3-N15
11. 3-N12
11 . 3-N14
5 . 3 -02
8 . 4-03
10 . 2- 0 3
10 . 2-03
4 . 2 - 12
5 . 6 - 04

11. 3-N17*
11. 3-N16*
11. 3-Nl3*
11. 3-Nl5*
5 . 3 -03)'(
8 . 4- 05)'(
10 . 2-07)'(
10 . 2 - 0 5)'(
12 . 2-03)'(
5 . 6-05l'<

u
underl ine
unit-block
unquoted - s tring
unquoted- s tring-character
upper-case- letter
use- l ine

4 . 1 - 10
4 . 1-03
4 . 2 - 04
10 . 1-08
4 . 1-03
4 . 1 - 08
4. 2-22

4 . 4- 0 3
4 . 2 - 05)'(
10 . 1 -09)'(
4 . 1-05)'(
4 . 1-09)'(
12 . 1-02

v
variable
variable-field-count
variable- length-vector
variable- l is t

4 . 1 - 10
5 . 2 - 01)'<
11. 3-N17
10 . 5 -04
10 . 1-01

6 . 2 -0 11< 10 . 1-02
11. 3-N19*
10 . 5- 05)'( 11 . 4-02
10 . 1-02)'( 10 . 2-01

11 . 3 -Nl7
11 . 4-N11

9 . 1-08

4 . 2 - 17
8 . 3 - 19
8 . 4-10
8 . 4-22
9 . 1 - 15
12 . 1-03
12 . 1-16

13 . 1-06

4 . 2 - 24

11 . 5-N9

11 . 4-06
1 1 . 4-06
6 . 6- 02)'(

10 . 4-08
9 . 1 - 14

9 . 1- 19)'(

9 . 2 - 17)'(

9 . 2 - 12

10 . 1-09

12 . 1-05*

11 . 1-20

11 . 4-01

11 . 4-07

- 182 -

w
when-block
when- l ine
when-use-block
when-use-name- block
when-use-name- l ine
write-control
write-contro l - item
write - statement

4 . 1 - 10
12 . 1-02
4 . 2-22
12 . 1-01
12 . 1-01
4.2-22
11 . 3 -06
11 . 3 -08
4 . 2 - 12

4 . 1 - 10

4 . 1 - 10

4 . 1 - 10

12 . 1-0t.*
12 . 1-02
12 . 1-02*
12 . 1-08*
12 . 1-08
1 1 . 3 -07
1 1 . 3 -09 (
11 . 3 -06)'(

12 . 1-08
12 . 1-03*

12 . 1-09*
1 1 . 3-08(
11 . 3-N12*

- 183 -

APPENDIX 5
COMBINED LIST OF PRODUCTION RULES

access -mode
actual-array
array-ass ignment
array-dec laration
array- input-statement

array- l ine- input- statement

array- l is t
array-name
array-output- l is t
array-print - l i s t
array-print-statement

array- read - s tatement

array -rewrite - statement


array-write-statement
ask-attribute-name
ask-io- item
ask- io- l i s t
ask- item
ask- i tem- l i s t
ask-object

ask- s tatement
block
bound-argument
boundaries
boundary

ACCESS ( I NPUT I OUTPUT I OUTIN I string-express ion)


array-name
numeric-array-ass ignment I string-array-ass ignment
numeric-array-dec laration I s tring-array-dec laration
MAT INPUT input-modifier- list? ( redim-array- l is t I
variable- length-vector) I MAT INPUT
channel - express ion input-control colon
( redim-array- l i s t I variable- length-vector)
MAT LINE INPUT input-modifier - l ist?
redim-string-array- l is t I MAT LINE I NPUT
channel - express ion input-control colon
redim-string-array- l is t
array-name ( comma array- name) '''
numeric-array I string-array
array-name ( comma array- name ) >': semicolon?
array-name ( print - s eparator array-name) r:
print- separator?
MAT PRINT ( array-print - list I ( USING image colon
array-output- l ist) I MAT PRINT
channel -expres s ion print-control co lon
( array-print - l is t I array-output- l is t )
MAT READ ( miss ing-recovery colon ) ? redim-array- l is t
I MAT READ channel - expression read-contro l
colon redim-array- l ist
MAT REWRITE channel - expression rewrite-control co lon
array- l is t
MAT WRITE chann e l -express ion write-control colon
array- l ist
core-attribute-name I enhanced-attribute-name
( MARGIN I ZONEWIDTH) numeric-variabl e
ask- io- item ( comma ask-io- item ) '''
ask-attribute-name variable variable>':
ask-item ( comma ask- item ) '''
WINDOW boundary-variables I VIEWPORT
boundary-variables I DEVICE WINDOW
boundary-variables I DEVICE VIEWPORT
boundary-variab les I CLIP string variabl e
DEVICE SIZE numeric-variab l e comma
numeric-variabl e comma string-variable I
primitive- ! STYLE numeric-variable I
primitive- 2 COLOR numeric-variable I MAX COLOR
numeric-variabl e
ASK ask- i o - l i s t I ASK channel- setter ask- item- l is t
ASK ask-obj ect status - c lause?
s tatement- l ine I loop I if-block I s elect-block
image- l ine
left-parenthe s i s actual-array ( comma index) ?
right-parenthes i s
boundary c o mma boundary comma boundary c o mma boundary
numeric-express ion

- 184 -

boundary-variables

numeric-variable comma numeric-variable comma

bounds

left-parenthesis bounds-range ( comma bounds-range)''


right-parenthesis
s igned- integer TO s igned- integer I s igned- integer
BREAK
CALL subprogram-name procedure-argument- l ist?

numeric-variable comma numeric-variable

bounds -range
break-statement
cal l -statement
case-block
case-else-block
case-else- l ine
case- item
cas e - l ine
cas e - l is t
case-statement
cause-statement
chain- statement
channe l - express ion
channel -number
channel - setter
character
c l ear-statement

case- l ine block''


case-else- l ine block''
l ine-number CASE ELSE tail
constant I range
l ine-number case-statement tail
case- item ( comma case- item) '
CASE case- l ist
CAUSE EXCEPTION exception-type
CHAIN programm-designator ( WITH function-arg - l i st ) ?
number-sign index
number - s ign integer
channel - expression colon
quotation-mark I non-quote-character
CLEAR

c lose-statement
col late- sequence
comparison

CLOSE channel - expression


COLLATE ( STANDARD I NATIVE I string-expression)
numeric-expression relation numeric-express ion I
string-expres s ion relation string- expression

concatenation
conditional-statement

ampersand
if-statement I on-gosub-statement I on-goto-statement
relational-term (AND relational-term)''
numeric-constant I string-constant
gosub-statement I goto-statement I if-statement I
io-recovery I on-gosub-statement

conjunction
constant
contro l - transfer

contro l -variable
coordinate-pair
core-attribute-name

core-fi le-attribute
core-f i le-org-value
core-record-setter
core-record-type-value
data- list
data-statement
datum
debug-statement
dec l arative-statement

lon-goto-statement
s imp le-numeric-variable
numeric-express ion comma numeric-express ion
NAME
ACCESS I DATUM I ERASABLE I FILETYPE I MARGIN
I ORGANIZATION I POINTER I RECSIZE I RECTYPE I
SETTER I ZONEWIDTH
access-mode I f i le-organization I record-type I
record- size

decl are- s tatement


def- statement
def- type
def ined-function

SEQUENTIAL I STREAM
BEGIN I END I NEXT I SAME
DISPLAY I INTERNAL
datum ( comma datum ) l't
DATA data- list
constant I unquoted- string
DEBUG ( ON I OFF)
data-statement I declare-statement I
dimens ion-statement I nul l - statement I
option-statement I remark-statement I
temp late-statement
DECLARE type-dec laration
numeric-def - statement I string-def-statement
DEF function- list
numeric-def ined-function I string-defined-function

delete-control

f ixed-defined- function
( comma delete-control - item)''

- 185 -

delete-contro l - item

miss ing-recovery I record-setter

delete - statement

DELETE channel - expression delete-control


hand ler- l ine exception-hand ler end-hand l er- l ine
Ol l l 2 1 3 141 5 l 6 / 7 1 8 1 9

detached-handler
d igit
d igit- p lace
d imens ion- l ist
d imens ion-statement
d isjunction
do-body
do- l ine
do- loop
do-statement
double-quote
e- format- item

else-block
else- l ine
e l s e i f- block
elseif - then- l ine
end-function- l ine
end-hand ler- l ine
end- i f - l ine
end - l ine
end - of - l ine
end - s e lect- l ine
end - statement
end-sub - l ine
end - sub-statement
end-when- l ine
enhanced-attribute- name
enhanced- f i le-attribute
enhanced - f i le-org-value
enhanced- record-setter
enhanced-record- type-value
equa l i ty-relation
erase-statement
exception-hand ler
exception-type
exit-condition
exit-do-statement
exit-for-statement
exit-function- statement
exit-hand ler-statement
exit-sub-statement
expres s ion
express ion- list
exrad
external - function-de
external -function- l ine

asterisk I number- s ign I percent - s ign


array-dec laration ( comma array-dec laration ) >'<
DIM d imens ion- l ist
conjunction ( OR conjunction ) >'<
b lock>'< loop - l ine
l ine- number do-statement tail
do- l ine do-body

DO exit-condition?
quotation-mark quotation-mark
( i-format- item I - format- item) c ircumflex-accent
circumf lex-accent c ircumf lex-accent
circumflex -accent>'<
e l se - l ine block>'<
l ine- number ELSE tai l
else i f -then- l ine block>'<
l ine-number ELSEIF relational-express ion THEN tai l
l ine- number END FUNCTION tai l
l ine-number END HANDLER tai l
l ine- number END I F tai l
l ine-number end- statement tail
( imp lementation-defined )
l ine- number END SELECT tail
END
l ine- number end - sub- statement tail
END SUB
l ine- number END WHEN tai l
RECORD I KEY I COLLATE
col late- sequence
RELATIVE I KEYED
RECORD index I KEY ( exact-search I inexact-search)
string-expression
NATIVE
equa l s - s ign I not-equals
ERASE REST? channel - express ion
block<
index
( WHILE I UNTIL) relational-express ion
EXIT DO
EXIT FOR
EXIT FUNCTION
EXIT HANDLER
EXIT SUB
numeric-express ion I string-expression
express ion ( comma expression ) >'<
E s ign? integer
externa l - function- l ine unit-block>'< end- function- l ine
l ine- number EXTERNAL FUNCTION
( numeric -def ined- function I
( string-defined-function length-max? ) )
function-parm- l i st ? tai l I l ine-number
EXTERNAL FUNCTION f ixed-def ined- function
function-parm- l ist? tai l

- 186 -

external - function- type


externa l - sub-def
external - sub- l ine
externa l - sub-type
f - fonnat- item
factor
field-spec if ier
f He-attribute
f i le-attribute - l is t
f i le-name
f i le-organization
f i le-organization-value
fixed-declaration
f ixed-defined-function
fixed - f ield-count
fixed- formal-array
fixed-po int- s ize
fixed-po int-type
f l oating-characters
for-body
for- l ine
for- loop
for- statement
forma l -array
format- item
format- string
formatted-print- l is t
fraction
fraction- s ize
funct ion-arg- l is t
function-argument
function-def
function- l ist
function-parameter
function-parm- l ist
geometric- obj ect
geometric-statement
gosub-statement
goto - s tatement
graphic-output- statement
graphic - text- s tatement

graphic-verb
hand ler- l ine
hand ler-name

EXTERNAL FUNCTION function- l ist


externa l - sub - l ine unit-blockl'< end- sub- l ine
l ine- number EXTERNAL sub-statement tail
EXTERNAL SUB sub - l is t
period number - s ign number- s ignl'< I i - format- i tem
period number- s ignl'<
primary ( circumf lex-accent primary ) l'<
numeric-speci fier I string-speci f ier
core - f i le-attribute
( comma f ile-attribute ) )'<
string-express ion
ORGANIZATION ( fi le-organization-value
string-expression)
core - f i le-org-value I enhanced - f i le-erg-value
s imp le-numeric-variable fixed-po int- type? I
numeric-array-dec laration f ixed-po int-type?
numeric-defined- function
SKIP? ( integer OF ) ?
forma l -array f ixed -point-type
integer- s i ze period? I integer- s i ze ? period
fraction- s ize
asterisk f ixed-point - s ize
( plus - s ignl'< I minus - s ignl'< ) dol lar - s ign?
dol lar - s ignl'< ( p lus - s ign I minus - s ign) ?
blockl'< next- l ine
l ine-number for-statement tai l
for- l ine for-body
FOR contro l -variable equals- s ign initial -value TO
l imit ( STEP increment ) ?
array-name left-parenthesis c omma:!< right-parenthesis
( justif ier? f loating-characters ( i -fonnat- item I
f - format- item I e- format- item ) ) I justifier
l itera l - string ( fo rmat - item l itera l - string ) :!<
USING image ( co lon output- l i st ) ?
period integer
integer
left-parenthes is function-argument ( comma
function-argument ) l'< right-parenthesis
expression I actua l - array
interna l -function-def I externa l - function-def
defined- function ( c omma defined-function)l'<
s imple-variable I formal-array I
numeri c - f ixed-parameter
left-parenthesis function-parameter ( comma
function-parameter ) :!< right-parenthes is
= POINTS I LINES I AREA
graphics -verb geometr ic-obj ect colon po int- l is t
( GOSUB I G O SUB) l ine-number
( GOTO I GO TO) l ine-number
geometric-statement I graphic -text-statement
graphic-verb TEXT initial -point ( c omma USING image
co lon express i on- l ist I colon
string-expres s ion)
GRAPH
l ine- number HANDLER handler-name tai l
routine- identi fier

- 187 -

handler-return-statement

RETRY I CONTINUE

i- format- i tem

digit-p lace d igit-p lace* ( comma digit-p lace


digit -p lacel'< ) l'<
numeric- identifier I string- identifier
routine- identifier
letter I d igit I underl ine
if-then- l ine then-b lock elseif-blockl'< else-block?
end- if - l ine
imperative-statement I l ine-number
IF relational-express ion THEN if-c lause ( ELSE
if-c lause ) ?
line-number IF relationa l - expression THEN tai l
line-number I s tring-expression
line-number IMAGE co lon format- string end-of - l ine
array-ass ignment I array- input- statement I
array- line- input- s tatement I
array-print-statement I array- read - statement I
array-write- statement I ask-statement I
break-statement I cal l - s tatement I
cause- s tatement I chain-statement I

identif ier
identifier- character
if-block
if-c lause
if-statement
if-then - l ine
image
image- line
imperative- statement

c lose-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

increment
index
initia l -number
initial -point
initial -value
input-control
input-contro l - item

input-modifier
input-modifier- l is t
input-prompt
input - rep ly
input- statement

integer
integer-size
internal -def - l ine

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 - s tatement I
rewrite - statement I array- rewrite-statement I
delete - statement I c lear - statement I
graphic-output-statement
numeric-express ion
numeric-express ion
line-number
comma AT coordinate-pair
numeric-express ion
( comma input-contro l - item ) :'<
core-record- setter I missing-recovery I
prompt- specifier
timeout-expression I
time- inquiry
prompt- specifier
timeout-expression I time- inquiry
input-modif ier ( comma input-modifier ) l'< colon
( imp lementation-defined )
data-list comma? end-of- l ine
INPUT input-modifier - list? variable- list I INPUT
channel - express ion input-control co lon
variable- l ist ( comma SKIP REST ) ?
digit digit)
integer
l ine-number clef - statement tail

- 188 -

internal -function-def
internal-function- l ine

internal - function-type
internal -proc-def
internal - sub-def
interna l - sub - l ine
internal - sub-type
io-qua l if ier
io-recovery
io-recovery-action
justifier
length-max
let- s tatement
letter
l imit
l ine

l ine-continuation
l ine- input- reply
l ine- input - s tatement

l ine-number
l iteral- item

l itera l - string
loop
loop- l ine
loop - s tatement
lower-case- letter

main-program
maxsize-argument
missing-recovery
multip l ier
next- l ine
next-statement

internal-def - l ine I interna l - function- l ine block)'<


end-function- l ine
l ine-number FUNCTION ( numeric-defined-function I
( string-defined- function length-max? ) )
function-parm- l ist? tai l I line-number
FUNCTION fixed-defined-function
function-parm- l is t ? tai l
FUNCTION function- l ist
internal-function-def I internal-sub-def I
detached-handler
internal-sub- l ine b lock)'< end- sub- l ine
l ine-number sub-statement tail
SUB sub- list
INPUT / OUTPUT / OUTIN
missing-recovery I not-miss ing-recovery
exit-do - s tatement I exit-for-statement I l ine-number
greater-than-s ign I less-than- s ign
asterisk integer
numeric- let-statement I string- let-statement
upper-case- letter I lower-case- letter
numeric-express ion
case- line I case-else- line I do- line I else- l ine I
elseif-then- l ine I end- function- l ine I
end-hand ler- l ine I end-if- line I end - l ine I
end-select- l ine I end - sub- l ine I end -when- l ine
I externa l - function- l ine I externa l - sub- l ine I
for- l ine I hand ler- line I internal-def- l ine I
internal -function- l ine I internal-sub- l ine I
if-then- l ine I image- l ine I loop - l ine I
next- l ine I program-name- line I remark - l ine I
select- l ine I s tatement- l ine I use- l ine I
when-use-name- l ine
ampersand space)'< tai l ampersand
characteri< end - of - l ine
LINE INPUT input-modifier- l ist? string-variable- l ist
I LINE INPUT channel -express ion input-control
colon string-variable - l ist
digit d igit)'<
letter / d igit I apostrophe I colon I equals-sign I
exclamation-mark I left-parenthesis I
question-mark I right-parenthesis I semicolon
/ s lant I space I underl ine
l itera l - item)'<
do-loop I for- l oop
line-number loop - s tatement 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 THEN io- recovery-action
= asterisk I s lant
l ine-number next-statement tail
= NEXT control -variable

- 189 -

non-quote-character

not-equa l s
not-greater
not- less
not-missing- recovery
numeric-array
numeric-array-ass ignment
numeric-array-dec laration
numeric-array-element
numeric-array-expression

numeric-array-function-ref
numeric-array-operator
numeric- array-value
numeric-constant
numeric-dec laration
numeric-def-statement

numeric-def ined-function
numeric-expression
numeric- f ield-s i ze
numeric-fixed parameter

ampersand I apostrophe I asterisk I circumf l ex-accent


I co lon I comma I dol lar-s ign I equa l s - s ign I
exclamation-mark I greater- than-sign I
left-parenthes is I less -than-sign I
number- s ign I percent-s ign I question-mark
right-parenthes i s I semico lon I s lant I
underl ine I unquoted-string-character
less-than-s ign greater- than - sign I greater- than-s ign
less-than-sign
less - than-s ign equa l s - s ign I equa l s - s ign
less -than-s ign
greater-than - s ign equa l s - s ign I equa l s - s ign
greater-than - s ign
IF THERE THEN io- recovery-action
numeric- identif ier
MAT numeric-array equal s - s ign
numeric-array-express ion
numeric-array bounds
numeric-array subscript-part
( numeric-array numeric-array-operator ) ? numeric-array
I scalar-multip l ier numeric-array I
numeric-array-value I
numeric-array- function-ref
( TRN I INV ) left-parenthesis numeric-array
right-parenthes is
s ign I asterisk
scalar-multip l ier? ( CON I IDN I ZER) redim?
s ign? numeric- rep
s imp le-numeric-variable I numeric-array-dec laration
DEF numeric-def ined -function function-parm- l ist?
equa l s - s ign numeric-express ion I DEF
f ixed-def ined-function function-parm- l ist?
equals- s ign numeric-express ion
numeric- identifier
s ign? term ( s ign term) l'c

f ixed-point - s ize I E
s imp le-numeric-variable fixed-point-type I
f ixed- formal -array
numeric- function
numeric-defined- function I numeric-supp l ied- function
numeric - function- let-statement= LET numeric-def ined- function equa l s - s ign
numeric-express ion
numeric- function function-arg- l ist? I MAXLEN
numeric-function-ref
left-parenthesis ( s imp le- string-variable I
string-array) right-parenthesis I MAXSIZE
maxs ize-argument I SIZE bound-argument I
LBOUND bound-argument I UBOUND bound-argument
I DET ( left-parenthes is numeric-array
right-parenthes is ) I DOT left-parenthesis
numeric-array comma numeric-array
right-parenthes i s
letter identifier-characterl'c
numeric- identifier
numeric- let-statement
LET numeric-variab le- l ist equa l s - s ign
numeric-express ion
significand exrad?
numeric-rep
numeric- specif ier
NUMERIC asterisk numeric-field-size

- 190 -

numeric- supp l ied-function

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 EXP I FP I
MAXNUM I !NT I IP I LOG I LOGlO I LOG2 I MAX I
MIN I MOD I PI I RAD I REMAINDER I RND I ROUND
I SEC I SGN I SIN I SINH I SQR I TAN I TANH I
TIME I TRUNCATE I LEN I ORD I POS I VAL I

numeric - t ime-express ion


numeric- type

numeric-variable
numeric-variable- list
on-gosub - statement
on-goto- statement
open-statement
option

option- l i st
option-statement
other-character
output- l ist
p lain-string-character
point- l i s t
pointer - i tems
primary

primitive-1
primitive- 2
print-contro l
print-contro l - item
print- item
print- l is t
print-separator
print - statement

procedure
procedure-argument
procedure-argument- l ist
procedure-parameter
procedure-parm- list
procedure-part
program
program- des ignator

EXLINE I EXTYPE
numeric- express ion
NUMERI C numeric-dec laration ( comma
numeric-declaration) >'( I NUMERIC
f ixed-point-type? f ixed-dec laration ( comma
f ixed- dec laration) >'(
s imple-numeric-variable I numeric-array-e lement
numeric-variable ( comma numeric -variabl e ) '''
ON index ( GOSUB I GO SUB) l ine-number ( comma
l ine-number ) >'l ELSE imperative - statement ) ?
ON index ( GOTO I GO TO ) l ine-number ( comma
l ine-number ) >'l ( ELSE imperative-statement ) ?
OPEN channel - setter NA}ffi file-name
f i le-attribute - l ist
ARITHMETIC ( DECIMAL I NATIVE) I ANGLE ( DEGREES I
RADIAN S ) I COLLATE ( NATIVE I STANDARD ) I BASE
( 0 I 1 ) I ARITHMETIC FIXED f ixed-point- type
option ( comma option) >'l
OPTION option- list
[ imp lementation-def ined ]
express ion ( comma expression) >'( semicolon?
d igit I letter I period I p lus - s ign I minus- s ign
coordinate-pair ( s emicolon coordinate-pair ) ''1
( po inter-control I io- recovery I pointer-contro l
comma io-recovery)
numeric-rep I numeric-variable I numeri c - function-ref
I left-parenthesis numeric-expression
right-parenthes is
POINT I LINE
primitive - 1 I TEXT I AREA
( comma print-contro l - item)>'l
core-record- setter I enhanced-record-setter I
not-miss ing-recovery I USING image
express ion I tab - cal l
( print - i tem? print- separator ) >'( print - item?
comma I semicolon
PRINT print - list I PRINT formatted-print - l is t I PRINT
channel -expres s ion print-control ( co l on
( print - list I output- list ) ) ?
external - function-de I externa l - sub- de
express ion I actual -array I channel - express ion
left-parenthesis procedure-argument ( comma
procedure-argument) ''' r ight-parenthesis
s imple-variable I formal-array I channe l - number
numeric- f ixed-parameter
left-parenthesis procedure-parameter ( comma
procedure-parameter ) '''
remark- l ine''1 procedure
program - name- l ine? main-program procedure-part>'l
string-expression

- 191 -

program- l ine
program-name
program-name- l ine
program-unit
prompt-specifier
protection-b lock
quoted- s tring
quoted - s tring-character
randomize - statement
range
read -control
read-contro l - item
read -statement

record- setter
record - s ize
record- type
record - type-value
redim
redim-array
red irn-array- list
red im-bounds
redim-numeric-array
redim- string-array
redim-string-array- list
relation
relationa l - expression
relationa l -primary
relationa l - term
remark- l ine
remark-statement
remark- string
restore- statement
return-statement
rewrite-control
rewrite-contro l - item
rewrite- statement
routine-identifier
scalar-multip lier
select-block
select - l ine
select-statement

l ine-number ( character I l ine- continuation) it


end-of- l ine
routine- identifier
l ine-number PROGRAM program-name function-parm- l ist?
tail
main-program I procedure
PROMPT string-express ion
when-use-block I when-use-name-block
quotation-mark quoted- string-characterl't
quotation-mark
double-quote I non-quote- character
RANDOMIZE
( constant TO I IS relation) constant
( comma read-contro l - item) l't
record- setter I miss ing- recovery
temp late- identifier
READ ( miss ing-recovery colon ) ? variable- list I READ
channel-express ion read- control colon
variab le - l ist ( comma SKIP REST ) ?
core-record-setter I enhanced-record- setter
RECSIZE ( VARIABLE I s tring-expression) ( LENGTH
index ) ?
RECTYPE ( record- type-value I string-express ion)
core-record-type-value I enhanced-record-value
left-parenthesis redim-bounds ( comma redirn-bounds ) l't
right-parenthesis
array-name redim?
redim-array ( comma redirn-array ) l't
( index TO ) ? index
numeric-array redim?
string-array redim?
redim-string-array ( comma redim-string-array) l't
equal ity-relation I greater- than-s ign I
les s - than-s ign I not-greater I not- less
disjunction
comparison I left-parenthesis relational -expression
right-parenthesis
NOT? relationa l-primary
l ine-number ( nu l l - statement I remark- statement)
end-of- l ine
REM remark-string
characterl't
RESTORE l ine- number
RETURN
( comma rewrite-contro l - item) l't
missing- recovery I record- setter
temp late-identifier
REWRITE channel - express ion 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 -s elect - l ine
l ine- number select-statement tai l
SELECT CASE express ion

- 192 -

set-obj ect

set- s tatement
s ign
s igned- integer
s ignificand
s imp le-numeric-variable
s imp le-string-declaration
s imp le-string-variable
s imp le-variable
s tatement
s tatement- l ine
status - c l ause
stop-statement
string-array
string-array-ass ignment
string-array-dec laration
string-array-element
string-array-express ion

string-array-primary
string-array-value
string-constant
string-declaration
string-def- statement

string-defined- function
string-expression
string- field-s ize
string-function
string- function- let-statement
string-function-ref
string- identifier
string- let - s tatement
string-primary

string-specifier
string-supp l ied-function

( MARGIN I ZONEWIDTH) index I channel - setter


pointer-items I channel -setter ( MARGIN I
ZONEWIDTH) index I WINDOW boundaries I
VIEWPORT boundaries I DEVICE WINDOW boundaries
I DEVICE VIEWPORT boundaries I CLIP
string-express ion I primitive - 1 STYLE index I
primitive- 2 COLOR index
SET set-object
p lus - s ign I minus - s ign
s ign? integer
integer period? I integer? fraction
numeric- identifier
simp le-string-variab le length-max?
string-identifier
s imp le-numeric-variable I s imp le-string-variable
dec larative- statement I imperative-statement I
conditional-statement
line-number statement tail
STATUS numeric-variable
STOP
string- identifier
MAT string-array substring-qual ifier? equa l s - s ign
string-array-expres s ion
string-array bounds
string-array subscript-part
string-array-primary ( concatenation
string-array-primary) ? I string-primary
concatenation string-array-primary I
string-array-primary concatenation
string-primary I string-array-value
string-array substring-qualifier?
( s tring-primary concatenation ) ?
quoted- string
s imple-string-dec laration I string-array-decl aration
length-max?
DEF string-def ined- function length-max?
function-parrn- list? equals- sign
string-express ion
string-identifier
string-primary ( concatenation string-primary ) ,'c
integer
string-defined- function I string- supp l ied- function
LET string-defined- function equa l s - sign
string-express ion
string-function function-arg - l ist?
letter identifier-character,'c dol lar-s ign
LET string-variable- list equa l s - s ign
string-express ion
string-constant I string-variable
string- function-ref I left-parenthesis
string-expression right-parenthesis
STRING asterisk string- field-size
( CHR I DATE I LCASE I LTRIM I REPEAT I RTRIM I STR I
TIME I UCASE I USING) dol lar-sign I EXTEXT
dol lar - s ign

- 193 -

string-type
string-variab le
string-variable- l ist
sub - l ist
sub - statement
subprogram-def
subprogram-name
subscript
subscript-part
substring-qualifier
tab-ca l l
tai l
temp late-element

temp late-element- l ist


template- identifier
temp late-statement
term
then-b lock
time-express ion
time- inquiry
timeout-expression
trace-statement
type-dec laration

unit-block
unquoted - s tr ing

unquoted- string-character
upper-case- letter

use- l ine
variabl e
variable-field-count
variable- length-vector
variable- l is t
when-block
when- l ine
when-use-block
when-use-name-block
when-use-name- l ine
write-control
write-contro l - item
write - s tatement

STRING length-max? string-declaration ( comma


string-dec laration) ,''
( s imp le-string-variable I string-array-element)
substring - qualifier?
string-variable ( comma string-variable),.,
subprogram-name ( comma subprogram-name ) ,.,
SUB subprogram-name procedure-pam- l ist?
interna l- sub-def I externa l -sub-de[
routine- identifier
index
left-parenthesis subscript ( comma subscrip t ) ,''
right-parenthesis
left-parenthesis index colon index right-parenthesis
TAB left-parenthesis index right-parenthes is
tai l -comment? end-of - l ine
f ixed - field -count ( f ie l d - specif ier I left-parenthesis
temp late-element- l ist right-parenthesis ) I
variable-field-count field- specifier
temp late-element ( comma temp late-element ) *
WITH ( l ine- number I string-expression)
TEMPLATE colon temp late-e lement- list
factor ( multipl ier factor),'<
b lock'
numeric-time-express ion I string-time-express ion
ELAPSED numeric-variable
TIMEOUT numeric- time-expression
TRACE ON ( TO channe l -expression ) ?
numeric- type I string-type I def- type
internal-function-type I
external- function- type I internal-sub-type I
external - sub-type
internal -proc-def I block
p lain- s tring-character I p lain-string-character
unquoted- string-character,''
p lain- string-character
space I p lain-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
l ine-number USE tai l
numeric-variable I string-variable
question-mark OF
array-name left-parenthesis question-mark
right-parenthes is
variable ( comma variabl e ) '
b lock,''
l ine-number WHEN EXCEPTION IN tail
when- l ine when-block use - l ine exception-handler
end-when- line
when-use-name - l ine when-block end-when- l ine
l ine-number WHEN EXCEPTION USE hand ler-name tai l
= ( comma write-contro l - item),''
record- setter I not-miss ing- recovery
temp late- identifier
WRITE channe l -express ion write- contro l co lon
express ion- l ist

- 194 -

APPENDIX 6
DIFFERENCES BETWEEN MINIMAL BASIC AND ECMA BASIC

The differences between Minimal BASIC and ECMA BASIC ( either BASIC-1 or BAS I C - 2 ) may be
c lassified as either s yntactic incompatibil ities or semantic ( run-time ) d i fferences .
Syntactic Differences
With the f o l l owing exception , this Standard forms an upward compatible syntactic extension
of Standard ECMA- 5 5 , Minimal BASIC .

* A l l arrays in a standard conforming program must be dimensioned before use .


Programs written in Minimal BASIC may therefore produce errors when run on an imp lemen
tation that conforms to this Standard . Such programs may be modified to run correctly as
f o l lows :
- identify a l l arrays which are imp l icitly dimens ioned ;
- insert a d imens ion- statement covering each such array with upper bound equal to 10 .
Each such d imens ion- statement must fol low an option-base-statement , if any , and pre
cede any reference to the arrays contained in the d imens ion-s tatement .
For examp l e , if a vector A is used in a Minimal BASIC program but is not d imensioned there ,
inserting
DIM A( lO)
w i l l cause the program to run correctly with respect to the vector A. Since array-names in
Minimal BASIC are l imited to s ingle letters , there can be no more than 26 such changes
needed .
Semantic Differences
In addition , this Standard d iffers from Minimal BASIC in several other ways that may be
classif ied as "run-time" . As a result , a Minimal BASIC program run under a BASIC imp lemen
tation might produce s l ightly different results .
: The default lower bound for arrays is 1 , not 0 as in Minimal Bas ic . Programs in Minimal
Basic can be made to run correctly if the f o l lowing statement is introduced p rior to any
DIM statement .
OPTION BASE 0
: This Standard spec ifies that arithmetic be carried out using a f l oating-point decimal rep
resentation, with at least ten decimal d igits of prec i s ion, whereas Minimal BASIC is more
permiss ive in al lowing arithmetic to be carried out using other representations ( e . g . ,
f l oating-point binary ) , with at least s i x decimal digits of precis ion ( see 5 . 6 ) . The only
effect should be that the program gives more precise results , which should not cause prob
lems for the user . An option is provided which permits NATIVE arithmetic , which might be
def ined as in Minimal BASIC for a given imp lementation .
: The default maximum length for strings must be at least 132 , not 18 as in Minimal BASIC .
The only d i fference is that a program might not get a string-overf low exception which it
would have gotten in Minimal BASI C . The old behavior can be restored by dec laring the maxi
mum length of the strings to b e the o l d maximum .

- 195 -

1(

I t is not necessary to preval idate an entire input-reply before assignment of values to


variab le s takes p lace , whereas this was required in Minimal BASIC . Thus , an input-reply of
11 2 , 4 , x11 in response to INPUT I , A ( I ) , J could change the value of A ( 2 ) , whereas this is not
a l l owed in Minimal BASIC .

)'( Certain exceptions - overf low,


tal exceptions in ECMA BASIC
BASIC Standard specifies that
circumstances , a Minimal BASIC

d ivision by zero , and ra1s1ng to a negative power - are fa


and nonfatal in Minimal BASIC . However , s ince the Minimal
nonfatal exceptions can be treated as fatal under certain
program should not rely on these exceptions being nonfatal .

- 196 -

APPENDIX 7

LANGUAGE ELEMENTS UNDER CONSIDERATION FOR FUTURE REMOVAL

The gosub-statement , on-gosub - s tatement , and the return- statement are under consideration
for future removal . It is recommended that as users write new programs , or maintain exist
ing programs , they refrain from us ing these statements , in order to improve compatibil ity
with future vers ions of this Standard .
The GOSUB fac i l ity is being cons idered for removal because it encourages poor programming
practice by al lowing the construction of subroutines with several entry points . Further
more , these " subroutines" are not delineated by any d istinctive syntax ; any line of a pro
gram may be the beginning of such a subroutine . Users are encouraged to avail themse lves of
the subprogram facil ities ( see 9 . 2 ) described in this Standard when they need subroutines .
Furthermore , the GOSUB fac i l ity interacts in a comp lex way with other aspects of the lan
guage ( e . g . , internal -proc-defs , exception-hand lers ) , thus making it more difficult to un
derstand source cod e , to imp lement conforming language processors , and to describe the lan
guage correct l y . Thus , programmers , imp lementors , teachers , and writers are a l l impeded in
their work with BASIC .

You might also like