Data processing — Programming languages — Minimal BASIC

Traitement de l'information — Langages de programmation — BASIC minimal

General Information

Status
Withdrawn
Publication Date
29-Feb-1984
Withdrawal Date
29-Feb-1984
Current Stage
9599 - Withdrawal of International Standard
Completion Date
15-Oct-1997
Ref Project

Relations

Buy Standard

Standard
ISO 6373:1984 - Data processing -- Programming languages -- Minimal BASIC
English language
33 pages
sale 15% off
Preview
sale 15% off
Preview

Standards Content (Sample)

i
International Standard @ 6373
INTERNATIONAL ORGANIZATION FOR STANDARDIZATlONOME~YHAPOflHAR OPrAHHJAUHR il0 CTAHflAPTH3AUIIM.OAGANlSATlON INTERNATIONALE DE NORMALISATION
Data processing - Programming languages - Minimal
BASIC
Traitement de l'information - Langages de programmation - BASIC minimal
First edition - 1984-03-15
w UDC 681.3.06 : 800.92 Ref. No. IS0 6373-1984 (E)
-
Descriptors : data processing, programming languages, information interchange.
Price based on 33 pages

---------------------- Page: 1 ----------------------
Foreword
IS0 (the International Organization for Standardization) is a worldwide federation of
national standards bodies (IS0 member bodies). The work of developing International
Standards is carried out through IS0 technical committees. Every member body
interested in a subject for which a technical committee has been authorized has the
right to be represented on that committee. International organizations, governmental
and non-governmental, in liaison with ISO, also take part in the work.
Draft International Standards adopted by the technical committees are circulated to
the member bodies for approval before their acceptance as International Standards by
the IS0 Council.
International Standard IS0 6373 was developed by Technical Committee ISO/TC 97,
information processing systems, and was circulated to the member bodies in
April 1982.
It has been approved by the member bodies of the following countries :
Belgium Germany, F. R. Romania
Canada Hungary South Africa, Rep. of
China Ireland Spain
Czechoslovakia Italy Sweden
Egypt, Arab Rep. of Japan Switzerland
Finland Netherlands USA
France Poland Yugoslavia
The member bodies of the following countries expressed disapproval of the document
on technical grounds :
Australia
United Kingdom
Q International Organization for Standardization, 1984 0
Printed in Switzerland
ii

---------------------- Page: 2 ----------------------
.........................................
1 Scope and tield ot application I I
2 Conformance . 1
3 References . 2
4 Definitions . 2
5 Characters and strings . 3
6 Programs . 4
7 Constants . 6
8 Variables . 7
9 Expressions . 9
10 Implementation-supplied functions . 10
11 User-defined functions . 11
12 Letstatement . 12
13 Control statements . 13
14 For and next statements . 15
15 Print statement . 17
16 Input statement . 19
17 Read and restore statements . 20
18 Datastatement . 21
19 Arraydeclarations . 22
20 Remark statement . 23
21 Randomize statement. . 24
Annexes
A Organization of the standard . 27
0 Method of syntax specification . 28
C Implementation-defined features . 29
D Index of syntactic metanames . 30

---------------------- Page: 3 ----------------------
INTERNATIONAL STANDARD IS0 6373-1984 (E)
Data processing - Programming languages -
Minimal BASIC
1 Scope and field of application A program conforms to this International Standard only when
- each statement contained therein is a syntactically valid
This International Standard is designed to promote the inter-
instance of a statement specified in this International Stan-
changeability of BASIC programs among a variety of automatic
dard:
data processing systems.
-each statement has an explicitly valid meaning specified
This International Standard establishes :
herein;
a) the syntax of a program written in Minimal BASIC;
- the totality of statements compose an instance of a
valid program which has an explicitly valid meaning
bl the formats of data and the precision and range of
specified herein.
numeric representations which are acceptable as input to an
automatic data processing system being controlled by a
An implementation conforms to this International Standard
program written in Minimal BASIC;
only when
- it accepts and processes programs conforming to this
c) the formats of data and the precision and range of
International Standard;
numeric representations which can be generated as output
by an automatic data processing system being controlled by
-
it reports reasons for rejecting any program which does
a program written in Minimal BASIC;
not conform to this International Standard;
d) the semantic rules for interpreting the meaning of a pro-
- it interprets errors and exceptional circumstances ac-
gram written in Minimal BASIC;
cording to the specifications of this International Standard;
e) the errors and exceptional circumstances which shall be
- its interpretation of the semantics of each statement of
detected and also the manner in which such errors and ex-
a standard-conforming program conforms ta the specifica-
ceptional circumstances shall be handled.
tions in this International Standard;
Subsequent International Standards for the same purpose will
0
- its interpretation of the semantics of a standard-
describe extensions and enhancements to this International
conforming program as a whole conforms to the specifica-
Standard. Programs conforming to this International Standard,
tions in this International Standard;
as opposed to extensions or enhancements of this International
Standard, will be said to be written in Minimal BASIC.
- it accepts as input, manipulates, and can generate as
output numbers of at least the precision and range specified
Although the BASIC language was originally designed primarily
in this International Standard;
for interactive use, this International Standard describes a
language that is not so restricted.
- it is accompanied by a reference manual which clearly
defines the actions taken in regard to features which are
The organization of the International Standard is outlined in an-
called "undefined" or "implementation-defined" in this In-
nex A. The method of syntax specification used is explained in
ternational Standard.
annex B.
This International Standard does not include requirements for
reporting specific syntactic errors in the text of a program.
2 Conformance
Implementations conforming to this International Standard
There are two aspects of conformance to this International may accept programs written in an enhanced language without
Standard : having to report all constructs not conforming to this Interna-
tional Standard. However, whenever a statement or other pro-
a) conformance by a program written in the language; gram element does not conform to the syntactic rules given
herein, either an error shall be reported or the statement or
b) conformance by an implementation which processes
other program element shall have an implementation-defined
such programs. meaning.
1

---------------------- Page: 4 ----------------------
IS0 6373-1984 (E)
Typical examples of end-of-line are carriage-return, carriage-
An exception occurs when an implementation recognizes that a
return line-feed, and end of record (such as end of card).
program may not perform or is not performing in accordance
with this International Standard. All exceptions described in
this International Standard shall be reported to the user unless
error : A flaw in the syntax of a line which causes it not
4.5
some mechanism provided in an enhancement to this Interna-
to be part of a standard program.
tional Standard has been invoked by the user to handle excep-
tions.
4.6 exception : A circumstance arising in the course of ex-
Where indicated, certain exceptions may be handled by the
a program which results from faulty data or computa-
ecuting
procedures specified in this International Standard; if no pro-
tions or from exceeding some resource constraint. Where in-
cedure is given, or if restrictions imposed by the hardware or
dicated certain exceptions (non-fatal exceptions) may be hand-
the operating environment make it impossible to follow the
led by the specified procedures; if no procedure is given (fatal
given procedures, then the exception shall be handled by ter-
exceptions) or if restrictions imposed by the hardware or
minating the program. Enhancements to this International
operating environment make it impossible to follow the given
Standard may describe mechanisms for controlling the manner
procedure, then the exception shall be handled by terminating
in which exceptions are reported and handled, but no such
the program.
mechanisms are specified in this International Standard.
This International Standard does not specify an order in which identifier : A character string used to name a variable or
4.7
exceptions shall be detected or processed. a function.
4.8 interactive mode : The processing of programs in an
3 References
environment which permits the user to respond directly to the
IS0 646, Information processing - Fbit coded character set actions of individual programs and to control the commence-
for information interchange. 1)
ment and termination of these programs.
IS0 4873, Information processing - 8-bit coded character set
4.9 keyword : A character string, usually with the spelling
for information interchange.
a commonly used or mnemonic word, which provides a
of
IS0 6093, Information processing - Specification for
distinctive identification of a statement or a component of a
representation of numeric values in character strings for infor-
statement of a programming language.
mation interchange. 2)
The keywords in Minimal BASIC are : BASE, DATA, DEF,
DIM, END, FOR, GO, GOSUB, GOTO, IF, INPUT, LET, NEXT,
4 Definitions
ON, OPTION, PRINT, RANDOMIZE, READ, REM, RESTORE,
RETURN, STEP, STOP, SUB, THEN, and TO.
For the purpose of this International Standard, the following
definitions apply.
line : A single transmission of characters which ter-
4.10
4.1 BASIC : A term applied as a name to members of a
minates with an end-of-line. 7
special class of languages which possess similar syntaxes and
sehantic meanings; acronym for Beginner's All-purpose Sym-
4.11 machine infinitesimal : The smallest positive value
bolic Instruction Code.
(other than zero) which can be represented and manipulated by
a BASIC implementation.
4.2 batch-mode : The processing of programs in an en-
vironment where no provision is made for user interaction.
4.12 machine infinity : The positive and negative values of
greatest magnitude which can be represented and manipulated
4.3 can : The word "can" is used in a descriptive sense to in-
by a BASIC implementation. It is not required that manipula-
dicate that standard-conforming programs are allowed to con-
tions of machine infinity yield non infinite results.
tain certain constructions and that standard-conforming im-
plementations are required to process such programs correctly.
4.13 may : The word "may" is used in a permissive sense to
4.4 end-of-line : The characteds) or indicator which iden-
indicate that a standard-conforming implementation may or
tifies the termination of a line. Lines of three kinds may be iden-
may not provide a particular feature.
tified in Minimal BASIC : program lines, print lines, and inpur-
reply lines. End-of-lines may vary between the three cases and
may also vary depending upon context. Thus, for example, the 4.14 overflow : With respect to numeric operations, the
end-of-line in an input-reply may vary on a given system depen- condition which exists when a prior operation has attempted to
ding on the terminal being used in interactive or batch mode. generate a result which exceeds machine infinity.
1) At present at the stage of draft. (Revision of IS0 646-1973,)
2) At present at the stage of draft.
2

---------------------- Page: 5 ----------------------
IS0 6373-1984 (E)
5.3 Examples
The following examples are taken from 5.2:
ANY CHARACTERS AT ALL (?I*!!) CAN BE USED IN A "REMARK".
7)
"SPACES, AND COMMAS, CAN OCCUR IN QUOTED STRINGS."
8)
COMMAS CANNOT OCCUR IN UNQUOTED STRINGS.
9)
5.4 Semantics
The letters shall be the set of uppercase roman letters contained in the IS0 7-bit coded character set in positions 411 to 5/10.
The digits shall be the set of arabic digits contained in the IS0 7-bit coded character set in positions 310 to 319.
The remaining string-characters shall correspond to the remaining graphic characters in positions 210 to 2/15,3/10 to 3/15, 5/14 and
5/15 of the IS0 7-bit coded character set.
The names of characters are specified in table 1.
The coding of characters is specified in table 2; however, this coding applies only when programs and/or inputloutput data are ex-
changed by means of coded media.
5.5 Exceptions
None.
5.6 Remarks
Other characters from the IS0 7-bit coded character set (including control characters) may be accepted by an implementation and
may have a meaning for some other processor (such as an editor), but have no prescribed meaning within this International Standard.
Programs containing characters other than the string-characters described in 5.4 and 5.2 and end-of-line characters are not standard-
conforming programs.
The various kinds of characters and strings described by the syntax correspond to the various uses of strings in a BASIC program.
Remark-strings may be used in remark-statements (see clause 20). Quoted-strings may be used as string-constants (see clause 7).
Unquoted-strings may be used in addition to quoted-strings as data elements (see clause 18) without being enclosed in quotation-
0
marks; unquoted-strings cannot contain leading or trailing spaces.
6 Programs
6.1 General description
BASIC is a line-oriented language. A BASIC program is a sequence of lines, the last of which shall be an end-line and each of which
shall contain a keyword. Each line shall contain a unique line-number which serves as a label for the statement contained in that line.
6.2 Syntax
The syntax shall be defined as follows:
1) program = biock" end-line
2) block = statement-line/for-block
3) statement-line = line-number statement end-of-line
4

---------------------- Page: 6 ----------------------
IS0 6373-1984 (E)
= digit digit? digit? digit?
4) line-number
= [implementation-defined1
5) end-of-line
6) end-line = line-number end-statement end-of-line
71 end-statement = END
8) statement = data-statement/def-statement/dimension-statement/gosub-statement/goto-statement/
if-then-statement/input-statement/let-statement/on-goto-statement/option-statement/
print-statement/randomire-statement/read-statement/remark-statement/restore-sta tementl
return-statement/stop-statement
9) line = statement-line/end-line/for-line/next-line
6.3 Examples
The following example is taken from 6.2:
* 6) 999 END
6.4 Semantics
A BASIC program shall be composed of a sequence of lines ordered by line-numbers, the last line of which shall be an end-line. Pro-
gram lines shall be executed in sequential order, starting with the first line, until
- some other action is dictated by execution of a control statement or for-block, or
- a fatal exception occurs, or
- a stop-statement or end-statement is executed.
The syntax as described generates programs which contain no spaces other than those occurring in remark-statements, in certain
quoted-strings and unquoted-strings, or where the presence of a space is explicitly indicated by the metaname space.
Special conventions shall be observed regarding spaces. With the following exceptions, spaces may occur anywhere in a BASIC pro-
gram without affecting the execution of that program and may be used to improve the appearance and readability of the program.
Spaces shall not appear
e
a) at the beginning of a line;
b) within keywords;
c) within the word TAB in a tab-call;
d 1 within numeric-constants ;
e I with in line-numbers ;
f) within function or variable names;
g) within multicharacter relation symbols.
In addition, spaces which appear in quoted-strings and unquoted-strings are significant.
All keywords in a program shall be preceded by at least one space and, if not at the end of a line, shall be followed by at least one
space.
Each line shall begin with a line-number, The values of the integers represented by the line-numbers shall be positive and non-zero;
Statements shall occur in ascending line-number order.
leading zeroes shall have no effect.
The manner in which the end of a statement line is detected is determined by the implementation; for example, the end-of-line may be
a carriage-return character, a carriage-return character followed by a line-feed character, or the end of a physical record.
5

---------------------- Page: 7 ----------------------
IS0 6373-1984 (E)
Lines in a standard-conforming program may contain up to 72 characters; the end-of-line indicator is not included within this 72
character limit.
The end-statement serves both to mark the physical end of the main body of aprogram and to terminate the execution of theprogram
when encountered.
6.5 Exceptions
None.
6.6 Remarks
Local editing facilities may allow for the entry oi statement lines in any order and also allow for duplicate line-numbers and lines con-
taining only a line-number. Such editing facilitiec; usually sort the program into the proper order; in the case of duplicate line-numbers,
the last line entered with that line-number is retained. In many implementations, a line containing only a line-number (without trailing
spaces) is deleted from the program.
7 Constants
7.1 General description
Constants can denote both scalar numeric values and string values.
A numeric-constant is a decimal representation in positional notation of a number. There are four general syntactic forms of numeric-
constants :
a) implicit point representation : sd . d
sd . drd . d
b) explicit point unscaled representation :
sd . drd . dEsd . d
c) explicit point scaled representation :
... dEsd ... d
sd
d) implicit point scaled representation :
where
d is a deciumal digit;
r is e full-stop;
s is an optional sign;
E is the explicit character E.
A string-constant is a character string enclosed in quotation-
7.2 Syntax
The syntax shall be defined as follows:
numeric-constant = sign ? numeric-rep
sign = plus-sign/minus-sign
= significand exrad?
numeric-rep
= (integer full-stop ?Illinteger? fractionl
significand
integer = digit digit"
fraction = full-stop digit digit*
exrad = E sign? integer
= quoted-string
string-constant
6

---------------------- Page: 8 ----------------------
IS0 6373-1984 (E)
7.3 Examples
The following examples are taken from 7.2:
1) -21.
3) 1E10
5E-1
.4E + 1
4) 500
1
6) .255
8) "XYZ"
"X - 362"
"1 E10"
7.4 Semantics
The value of a numeric-constant is the number represented by that constant. "E" stands for "times ten to the power"; if no sign
follows the symbol E, then a plus-sign is understood. Spaces shall not occur in numeric-constants,
A program may contain numeric representations which have an arbitrary number of digits, though implementations may round the
values of such representations to an implementation-defined precision of not less than six significant decimal digits.
Numeric-constants may also have an arbitrary number of digits in the exrad, though non-zero constants whose magnitude is outside
an implementation-defined range may be treated as exceptions. It is recommended that the implementation-defined range for
numeric-constants be approximately 1E - 38 to 1E + 38 or larger. Constants whose magnitudes are less than machine infinitesimal
shall be replaced by zero, while constants whose magnitudes are larger than machine infinity shall be reported as causing an overflow.
A string-constant has as its value the string of all characters between the quotation-marks; spaces shall not be ignored. The length of
a string-constant, i.e. the number of characters contained between the quotation-marks, is limited only by the length of a line.
7.5 Exceptions
The evaluation of a numeric-constant causes an overflow (non-fatal ; the recommended recovery procedure is to supply machine in-
finity with the appropriate sign, report it and continue).
7.6 Remarks
Since this International Standard does not require that strings with more than 18 characters be assignable to string-variables (see
clause 81, conforming programs can use string-constants with more than 18 characters only as elements in a print-list.
It is recommended that implementations report constants whose magnitudes are less than machine infinitesimal as underflows and
continue.
8 Variables
8.1 General description
Variables in BASIC are associated with either numeric or string values and, in the case of numeric-variables, may be either simple
variables or references to elements of one or two dimensional arrays; such references are called subscripted variables.
Simple-numeric-variables shall be named by a letter followed by an optional digit.
Subscripted numeric-variables shall be named by a letter followed by one or two numeric-expressions enclosed within parentheses.
String-variables shall be named by a letter followed by a dollar sign.
7

---------------------- Page: 9 ----------------------
IS0 6373-1984 (E)
explicit declarations of variable types are not required; a dollar-sign serves to distinguish string-variables from numeric-variables, and
the presence of a subscript distinguishes a subscripted variable from a simple one.
8.2 Syntax
The syntax shall be defined as follows:
1) variable = numeric-variable/string-variable
2) numeric-variable = simple-numeric- variable/numeric-arra y-element
3) simple-numeric-variable = ietter digit?
4) numeric-array-element = numeric-arra y-name subscript
5) numeric-array-name = letter
6) subscript = left-parenthesis numeric-expression (comma numeric-expression)?
right parenthesis
7) string-variable = letter dollar-sign
8.3 Examples
The following examples are taken from 8.2:
3) x
A5
4) V(3)
W(X,X + Y/2)
7) SÇ
8.4 Semantics
At any instant in the execution of a program, a numeric-variabe is associated with a single numeric value and a string-variable is
associated with a single string value. The value associated with a variable may be changed by the execution of statements in thepro-
gram.
The length of the character string associated with a string-variable can vary during the execution of a program from a length of zero
characters (signifying the null or empty string) to 18 characters.
Simple-numeric-variables and string-variables are declared implicitly through their appearance in the program.
A subscripted variable refers to the element in the one or two-dimensional array selected by the value(s) of the subscript(s). The value
of each subscript is rounded (see 4.16) to the nearest integer. Unless explicitly declared in a dimension-statement, subscripted
variables are implicitly declared by their first appearance in a program. In this case, the range of each subscript is from zero to ten
inclusive, unless the presence of an option-statement indicates that the range is from one to ten inclusive. Subscript expressions shall
have values within the appropriate range (see clause 19).
The same letter shall not be the name of both a simple variable and an array, nor the name of both a one-dimensional and a two-
dimensional array.
There is no relationship between a numeric-variable and a string-variable whose names agree except for the dollar-sign.
At the initiation of execution the values associated with all variables shall be implementation-defined.
8.5 Exceptions
An integer obtained as the value of a subsc:rrpt expression is not in the range of the explicit or implicit dimensioning bounds (fatal).
8.6 Remarks
Since initialization of variables is not specified, and hence may vary from implementation to implementation, programs that are in-
tended to be transportable should explicitly assign a value to each variable before any expression involving that variable is evaluated.
There are many commonly used alternatives for associating implementation-defined initial values with variables; it is recommended
that all variables are recognizably undefined in the sense that an exception will result from any attempt to access the values of any
variable before that variable is explicitly assigned a value.
8

---------------------- Page: 10 ----------------------
IS0 6373-1984 (E)
9 Expressions
9.1 General description
Expressions shall be either numeric-expressions or string-expressions.
Numeric-expressions may be constructed from variables, constants, and function references using the operations of addition,
substraction, multiplication, division, and involution (raising to a power).
String-expressions are composed of either a string-variable or a string-constant.
9.2 Syntax
The syntax shall be defined as follows:
1 ) expression = numeric-expression/string-expression
numeric-expression = sign ? term (sign term) +
term = factor (mult@lier factor) *
factor = primary (circumflex-accent primary) *
multiplier = asterisk/solidus
primary = numeric-variable/numeric-rep/numeric-function-ref/
(left-parenthesis numeric-expression right-parenthesis)
numeric-function-ref F numeric-function-name argument-list?
numeric-function-name = numeric-defined-function/numeric-supplied-function
argument-list = le ft-parenthesis argument right-parenthesis
argument = numeric-expression
string-expression = string-variable/string-constant
9.3 Examples
The following examples are taken from 9.2:
2) 3+x - Y-2
Ail) + Ai21 + Ai31
- X/Y
4) 2-i-x)
6) SQRiX-2 + Y-2)
9.4 Semantics
The formation and evaluation of numeric-expressions shall follow the normal algebraic rules. The symbols circumflex-accent, asterisk,
solidus, plus-sign, and minus-sign shall represent the operations *of involution, multiplication, division, addition, and substraction,
respectively. Unless parentheses dictate otherwise, involutions shall be performed first, then multiplications and divisions, and finally
additions and substractions. In the absence of parentheses, operations of the same precedence shall be associated to the left.
A-B-C shall be interpreted as (AWC, A^B"C as (A-B)"C, A/B/C as (A/B)/C arid -A-B as -iA-B).
If an underflow occurs in the evaluation of a numeric-expression, then the value generated by the operation which resulted in the
underflow shall be replaced by zero.
0-0 is defined as 1.
When the order of evaluation of an expression is not constrained by the use of parentheses, and if the mathematical use of operators
is associative, commutative, or both, then full use of these properties may be made in order to revise the order of evaluation of the
expression.
9

---------------------- Page: 11 ----------------------
IS0 6373-1984 (E)
In a function reference, the number of arguments supplied shall be equal to the number of parameters required by the definition of the
function.
A function reference is a notation for the invocation of a predefined algorithm, into which the argument value, if any, is substituted for
theparameter (see clauses 10 and 11) which is used in the function definition. All functions referenced in an expression shall either be
implementation-supplied or be defined in a de$-statement. The result of the evaluation of the function, achieved by the execution of
the defining algorithm, is a scalar numeric value which replaces the function reference in the expression.
The value of a string-expression is the value of the string-variable or the string-constant which constitutes that string-expression.
9.5 Exceptions
Evaluation of an expression results in a division by zero (nonfatal; the recommended recovery procedure is to supply machine infinity
it and continue).
with the sign of the numerator, report
Evaluation of an expression results in an overflow (nonfatal; the recommended recovery procedure is to supply machine infinity with
the algebraically correct sign, report it and continue).
Evaluation of the operation of involution results in a negative number being raised to a non-integral power (fatal).
Evaluation of the operation of involution results in zero being raised to a negative power (nonfatal; the recommended recovery pro-
cedure is to supply positive machine infinity, report it and continue).
9.6 Remarks
The accuracy with which the evaluation of an expression takes place will vary from implementation to implementation. While no
minimum accuracy is specified for the evaluation of numeric-expressions, it is recommended that implementations maintain at least
six significant decimal digits of precision.
The method of evaluation of the operation of involution may depend upon whether or not the exponent is an integer. If it is, then the
indicated number of multiplications may be performed; if it is not, then the operation may be evaluated using the LOG and EXP func-
...

Questions, Comments and Discussion

Ask us and Technical Secretary will try to provide an answer. You can facilitate discussion about the standard in here.