English
Language : 

NSB8 Datasheet, PDF (39/158 Pages) List of Unclassifed Manufacturers – BASIC interpreter for Z80 family
ITALIAN TECHNOLOGY
grifo®
DEF
STATEMENT:
DEF <function name> (<parameter list>)=<expression>
DEF <function name> (<parameter list>)
ACTION:
The first form defines a single line user function, numeric or string. When evaluated, the single line
function returns the value of the expression on the right side of the equal sign. The type of the
expression must match the type of the function name, string or numeric
The second form begins the definition of a multi line user function. The function value in this case
is determined by the expression in the RETURN statement used in the body of the function definition
itself. The type of the expression in any RETURN statement in the function body must be of the same
type as the function name.
A user function name consists of the letter FN followed by a string or numeric variable name (such
as FNA$, FNQ7, etc.)
EXAMPLE:
Single line
70 DEF FNH(X,Y)=SQRT((X^2)+(Y^2)) \ REM Hypotenuse
45 DEF FNU$(L$)=CHR$(ASC(L$)-32) \ REM Low to upp case
Multi line
110 DEF FNQ(A,B,C)
589 DEF FNA7$(A$,A,M)
REMARKS:
The addition of the FN prefix distinguishes function names from variable names. FNA and variable
A are not the same, nor even necessarily related.
If a DEF statement is encountered during program execution, then execution will skip forwared to
the first statement after the definition. Function definitions may be located anywhere in the program
text. Function definitions occurs before program execution begins.
ERROR MESSAGE:
FUNCTION DEF ERROR
An (apparently) single line function was defined improperly, or an attempt was made to define
function within the definition of a multi line function.
SEE ALSO:
Section USER FUNCTION
Statement RETURN
Statement FNEND
NSB8
Rel. 5.10
Page 27