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
Start Date
15-Oct-1997
Completion Date
30-Oct-2025
Ref Project

Relations

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

Frequently Asked Questions

ISO 6373:1984 is a standard published by the International Organization for Standardization (ISO). Its full title is "Data processing - Programming languages - Minimal BASIC". This standard covers: Data processing - Programming languages - Minimal BASIC

Data processing - Programming languages - Minimal BASIC

ISO 6373:1984 is classified under the following ICS (International Classification for Standards) categories: 35.060 - Languages used in information technology. The ICS classification helps identify the subject area and facilitates finding related standards.

ISO 6373:1984 has the following relationships with other standards: It is inter standard links to ISO 29863:2007. Understanding these relationships helps ensure you are using the most current and applicable version of the standard.

You can purchase ISO 6373:1984 directly from iTeh Standards. The document is available in PDF format and is delivered instantly after payment. Add the standard to your cart and complete the secure checkout process. iTeh Standards is an authorized distributor of ISO standards.

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
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
.........................................
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

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
- 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.
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.
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-
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
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.
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
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
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.
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.
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.
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-
tions (see clause 10).
It is recommended that implementations report underflow as an exception and continue.
0-0 is defined as 1 to allow commonly occurring formulas such as
P-R * (I-P)”(N-R),
which appears in the formula for binomial probabilities, to be evaluated properly when P and R are both equal to O.
10 Implementation-supplied functions
10.1 General description
Predefined algorithms are supplied by the implementation for the evaluation of commonly used numeric functions.
10.2 Syntax
The syntax shall be defined as fbllows:
î) numeric supplied-function = ABS/ATN/COS/EXP/ INT/LOG/RND/$GN/SIN/ SQR/TAN
10.3 Examples
None.
10.4 Semantics
The values of the implementation-supplied functions, as well as the number of arguments required for each function, are described in
table 1. In all cases, X stands for a numeric-expression.
IS0 6373-1984 (E)
Table 1 - Values of implementation-supplied functions
Function value
Function
ABSiX) The absolute value of X.
The arctangent of X in radians, i.e., the angle whose tangent is X. The range of the function is
ATN(X)
-(pi/2) < ATN(X) < (pi/2)
where pi is the ratio of the circumference of a circle to its diameter.
The cosine of X, where X is in radians.
COSIX)
The exponential of X, i.e., the value of the base of natural logarithms raised to the power X; if EXP(X) is
EXP(X)
less than machine infinitesimal, then its value shall be replaced by zero.
INTiX) The largest integer not greater than X; for example
INT(1.3) = 1 and INT(-1.3) = -2.
LOGiX) The natural logarithm of X; X shall be greater than zero.
The next pseudo-random number in an implementation-supplied sequence of pseudo-random numbers
RND
uniformly distributed in the range O < = RND < 1 (see also clause 21).
SGNiXI Thesignof X: -1 if X < 0;Oif X = O, and + 1 if X > O.
The sine of X, where X is in radians.
SINiX)
The non-negative square root of X; X shall be non-negative.
SQR(X)
The tangent of X, where X is in radians.
TANiX)
10.5 Exceptions
The value of the argument of the LOG functions is zero or negative (fatal).
The value of the argument of the SQR function is negative (fatal).
The magnitude of the value of the exponential or tangent function is larger than machine infinity (nonfatal; the recommended
recovery procedure is to supply machine infinity with the appropriate sign, report it and continue).
10.6 Remarks
The RND function in the absence of a randomize-statement (see clause 21) shall generate the same sequence of pseudo-random
numbers each time a program is run. This convention is chosen so that programs employing pseudo-random numbers can be ex-
ecuted several times with the same result.
It is recommended that, if the value of the exponential function is less than machine infinitesimal, implementations report this as an
underflow and continue.
This international Standard requires that overflow be reported only for the final values of numeric-supplied-functions; exceptions
which occur in the evaluation of these functions need not be reported, though implementations shall take appropriate actions in the
event of such exceptions to ensure the accuracy of the final values.
11 User-defined functions
11.1 General description
In addition to the implementation-supplied functions (see clause IO), BASIC allows the programmer to provide single-line definitions
for functions within a program.
The general syntactic form of statements for defining functions is
DEF FNx = expression
or
DEF FNx (parameter) = expression
where x is a single letter and a parameter is a simple numeric-variable.
IS0 6373-1984 (E)
11.2 Syntax
The syntax shall be defined as follows
1) def-statement = DE F numeric-de fined- function
parameter-list ? equals-sign numeric-expression
2) numeric-defined-function = FN leMer
3) parameter-list = left-parenthesis parameter right-parenthesis
simple-numeric- variable
4) parameter
11.3 Examples
The following examples are taken from 11 -2:
1) DEF FNFfX) = X"4 -1
DEF FNA(X) = AUX + B
DEF FNP = 3.14159
11.4 Semantics
A function definition specifies the means of evaluating a function in terms of the value of an expression involving the parameter, if
any, appearing in the parameter-list and possibly other variables or constants. If the function definition does not contain a parameter-
/&, then references to the function (i.e., numeric-function-refs in expressions involving the function), shall not contain argument-
lists. If a function definition does contain a parameter-list, then references to the function shall contain argument-lists, in which case
the expression in the argument-list is evaluated and its value assigned to the parameter in the parameter-list for the function definition.
The expression in the function definition is then evaluated, and this value is assigned as the value of the function.
The parameter appearing in the parameter-list of a function definition is local to that definition, i.e., it is distinct from any variable with
the same name outside of the function definition. Variables in the numeric-expression which do not appear in the parameter-list are
the variables of the same names outside the function definition.
A function definition shall occur in a lower numbered line than that of the first reference to the function. The expression in a def-
statement is not evaluated unless the defined function is referenced.
If the execution of a program reaches a line containing a def-statement, then it shall proceed to the next line with no other effect.
A function definition may refer to other defined functions, but not to the function being defined. Afunction shall be defined only once
in a program.
11.5 Exceptions
None.
11.6 Remarks
None.
12 Let statement
12.1 General description
A let-statement provides for the assignment of the value of an expression to a variable. The general syntactic form of the let-statement
shall be
LET variable = expression
IS0 6373-1984 (E)
12.2 Syntax
The syntax shall be defined as follows:
1 ) let-statement = numeric-let-statement/string-let-statement
2) numeric-let-statement = LET numeric-variable equals-sign numeric-expression
3) string-let-statement = LET string-variable equals-sign string-expression
12.3 Examples
The following examples are taken from 12.2:
2) LET P = 3.14159
LET A(X,3) = SIN(Y)*Y + 1
3) LET AS = "ABC"
LETAÇ = BS
12.4 Semantics
The expression is evaluated (see clause 9) and its value is assigned to the variable to the left of the equals-signs.
12.5 Exceptions
An assignment of a string-expression to a string-variable results in a string overflow (fatal).
12.6 Remarks
None.
13 Control statements
13.1 General description
Control statements allow for the interruption of the normal sequence of execution of statements by causing execution to continue at a
specified line, rather than at one with the next higher line-number.
The goto-statement
GO TO line-number
allows for an unconditional transfer
The if-then-statement
IF expl re1 exp2 THEN line-number
where "expl" and "exp2" are expressions and "rel" is a relational operator, allows for a conditional transfer.
The gosub-statement and return-statement
GOSUB line-number
RETURN
allow for subroutine calls.
The on-goto-statement
ON expression GO TO line-number, . . . , line-number
allows control to be transferred to a selected line.
IS0 6373-1984 (E)
The stop-statement
STOP
allows for program termination.
13.2 Syntax
The syntax shall be defined as follows:
1 ) goto-statement = GO space* T line-number
2) if-then-statement = IF relational-expression TH EN line-number
3) relational-expression = (numeric-expression relation numeric-expression)/
(string-expression equality-relation string-expression)
4) relation = equalit y-rela tion / /less- than-sign/grea ter- than-sign/no t-less/no t-grea ter
5) equality-relation = equals-sign/not-equals
6) not-less = greater-than-sign equals-sign
7) not-greater = less-than-sign equals-sign
8) not-equals = less-than-sign greater-than-sign
9) gosub-statement = GO space" SUB line-number
1 O) return-statement = RETURN
11 ) on-goto-statement = ON numeric-expression GO space*
TO line number (comma line-number) *
12) stop-statement = STOP
13.3 Examples
The following examples are taken from 13.2:
1) GOT0999
GOT0 999
2) IF X > Y + 83 THEN 200
IFAÇ < > BÇTHEN550
9) GOSUB1000
GOSUB 1000
11) ON L + 1 GO TO 300,400,500
12) STOP
13.4 Semantics
-\%in
A goto-statement indicates that execution of the program shall be continued at the line with the specified line-number.
If the value of the relational-expression in an if-then-statement is true, then execution of the program shall be continued from the line
with the specified line-number; if the value of the relational-expression is false, then execution shall be continued in sequence, i.e.
with the line following that containing the if-then-statement.
The relation "less than or equal to" shall be denoted by < = . Similarly, "greater than or equal to" shall be denoted by > = , while
"not equal to" shall be denoted by < > .
The relation of equality holds between two strings if and only if the two strings have the same length and contain identical sequences
of characters.
The execution of the gosub-statement and the return-statement can be described in terms of a stack of line-numbers (but may be im-
plemented in some other fashion). Prior to execution of the first gosub-statement by the program, this stack is empty. Each time a
gosub-statement is executed, the line-number of the gosub-statement is placed on top of the stack and execution of the program is
IS0 6373-1984 (E)
continued at the line specified in the gosub-statement. Each time a return-statement is executed, the line-number on top of the stack
is removed from the stack and execution of the program is continued at the line following the one with that line-number.
It is not necessary that equal numbers of gosub-statements and return-statements be executed before termination of the program.
The expression in an on-goto-statement shall be evaluated and rounded to obtain an integer, whose value is then used to select aline-
number from the list following the GOT0 (the line-numbers in the list are indexed from left to right, starting with 1). Execution of the
program shall continue at the line with the selected line-number.
All line-numbers in control-statements shall refer to lines in the program.
The stop-statement causes termination of the program.
13.5 Exceptions
An attempt is made to execute a return-statement without having executed a corresponding gosub-statement (fatal).
The integer obtained as the value of an expression in an on-goto-statement is less than one or greater than the number of line-
numbers in the list (fatal).
13.6 Remarks
None.
14 For and next statements
14.1 General description
The for-statement and next-statement provide for the construction of loops. The general syntactic form of the for-statement and
next-statement is
FOR v = initial-value TO limit STEP increment.
NEXT v
where "v" is a simple-numeric-variable and the initial-value, limit, and increment are numeric-expressions; the clause "STEP
increment" is optional.
14.2 Syntax
The syntax shall be defined as follows:
1) for-block = for-line for-body
for-body = block next-line
for-line = line-number for-statement end-of-line
3)
next-line = line-number next-statement end-of-line
4)
for-statement = FOR control-variable equals-sign initial-value
5)
TO limit (STEP increment)?
= simple-numeric- variable
6) control-variable
initial- value = numeric-expression
7)
81 limit = numeric-expression
= numeric-expression
91 increment
next-statement = NEXT control-variable
1 O1
IS0 6373-1984 (E)
14.4 Semantics
The for-statement and the next-statement are defined in conjunction with each other. The physical sequence of statements beginning
with a for-statement and continuing up to and including the first next-statement with the same control-variable is termed a for-block.
For-blocks may be physically nested, i.e., one may contain another, buth they shall not be interleaved, i.e., a for-block which contains
a for-statement or a next-statement shall contain the entire for-block begun or ended by that statement.
e
Furthermore, physically nested for-blocks shall not use the same control-variable.
In the absence of a STEP clause in a for-statement, the increment is assumed to be + 1.
The action of the for-statement and the next-statement is defined in terms of other statements, as follows:
FOR v = initial-value TO limit STEP increment
(block)
NEXT v
is equivalent to :
line 1 LET own 1 = limit
LET own 2 = increment
LET v = initial-value
line 1 IF (v-own 1) * SGN (own 2) > O THEN line 2
(block)
LET v = v + own 2
GOT0 line 1
line 2 REM continued in sequence
Here v is any simple-numeric-variable, own 1 and own 2 are variables associated with the particular for-blockand not accessible to the
programmer, and line 1 and line 2 are line-numbers associated with the particular for-blockand not accessible to the programmer. The
variables own 1 and own 2 are distinct from similar variables associated with other for-blocks.
A program shall not transfer control into a for-body by any statement other than a return-statement (see clause 13).
14.5 Exceptions
None.
14.6 Remarks
Where arithmetic is approximate (as with decimal fractions in a binary machine), the loop will be executed within the limits of machine
arithmetic. No presumptions about approximate achievement of the end test are made. It is noted that in most ordinary situations
where machine arithmetic is truncated (rather than rounded), such constructions as
FOR X = O TO 1 STEP 0.1
IS0 6373-1984 (E)
will work as the user expects, even though O. 1 is not representable exactly in a binary machine. If this is indeed the case, then the con-
struction
FOR X = 1 TO O STEP -0.1
will probably not work as expected.
As specified above, the value of the control-variable upon exit from a for-block via its next-statement is the first value not used; if the
exit is via a control statement, the control-variable retains the value it has when the control statement is executed.
1" and "own 2" associated with a for-block are assigned values only upon entry to the for-block through its for-
The variables "own
statement.
15 Print statement
15.1 General description
The print-statement is designed for the generation of tab
...

Questions, Comments and Discussion

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

Loading comments...