FN
Invoke User-Defined Function
This numeric or string function invokes a user defined function created by the DEF FN directive and is valid only within the program that contains the DEF FN directive.
Syntax
Section titled “Syntax”FNx (value-list)
FNx$ (value-list)x- is the function name. In Thoroughbred Basic release levels before 8.1B2, the function name must be a single, uppercase alphabetic character. Starting with release level 8.1B2, the function name must begin with an uppercase letter, can be up to 32 characters long, and can contain any combination of uppercase letters (A-Z), numbers (0-9), and the underscore character.
value-list- is a list of variables or expressions to be used as arguments in resolving the numeric- or string-expression values.
Remarks
Section titled “Remarks”The values in the value-list of this function and in the variable-list of the DEF FN directive may have different variable names, but must be in corresponding positions in both lists. The first variable in the FN function value-list sends its value to the first variable in the DEF FN directive variable-list, etc. For example:
FN Function Value-List- DEF FN Directive Variable List
(M, N$)- (A, B$)
In this case, M is sent to A and N$ is sent to B$. The variables A and B$ are changed by execution of the FN function. If the value-list of the FN function does not correspond in type and number with the DEF FN directive, an ERR=20 results.
Examples
Section titled “Examples”LET Y=FNA (X)If X=3 and DEF FNA (Z)=Z*2/0.5, assigns Y the value 12. Z and X contain the value 3.
FNP (X$,Y)If X$=“A”, Y=32, and DEF FNP (P$,Q) = DEC (P$) + Q, returns the value 97 with P$ and X$ = “A”, Y and Q = 32.
See also
Section titled “See also”DEF FN directive
From the Thoroughbred Basic Language Reference, Volume II: F–Q, version 8.9.1. Open this page in the PDF