IBM 5100 Basic Reference Manual page 69

Hide thumbs Also See for 5100:
Table of Contents

Advertisement

(
(
(
(
(
RETURN [arith-exp]
where:
arith-exp is an arithmetic expression that specifies the value of the user-defined
function to the referencing function.
FNEND [comment]
The FNEND statement is nonexecutable and simply indicates the end of a multiline
function. The value of the function is specified in an arithmetic expression in a
RETURN statement. The comment is optional.
When a reference to a user-defined function is encountered during program execution,
the value of each parameter in the expression is used to initialize the corresponding
variable. The optional variables must be arithmetic and must match the number
specified in the function reference.
If
the expression is present, the function is defined
on the one line and its value is the value of that expression. This is a single line func-
tion.
If
the expression is not specified, the DEF statement is the start of a multiline
function. In this case, the FNEND statement indicates the end of the function and
the value of the function is specified in an arithmetic expression in a RETURN
statement.
Notes About DEF
• A function can be defined anywhere in a BASIC program, either before or after
it is referenced.
• A function of a given name can be defined only once in a given program.
• A function cannot contain references to itself or to other functions that refer to
it in their definitions.
• The expression in the RETURN statement is required for multiline functions
(see
GOSUB and RETURN).
• A function reference to a user-defined function can appear anywhere in a BASIC
expression that a constant, variable, subscripted array element reference, or system
function reference can appear.
• The arithmetic variables have a special meaning in the DEF statement. Conse-
quently, it is possible to have a variable with the same name as a simple arith-
metic variable used elsewhere in the program. Each is recognized as being unique,
and no conflict of names or values results from this duplicate usage.
• The maximum number of user-defined functions in a program is 29, and the max-
imum number of nested function references varies according to the complexity
of the referencing statement.
• User-defined functions that are referred to during an input or output operation
cannot themselves perform any input or output.
65

Advertisement

Table of Contents
loading

Table of Contents