HTBasic Help
×
Menu
Index

FN

Executes a user-defined function.
 
 FN function-name[$] [(argument [,argument...] )]
 
Usage:
PRINT "New Value is";FNRate(Y)
Result$=FNCheck$(List$)
Pass=FNDecode(Code,(Express),@Line)
Rotate=FNTranslate(Comp(Trans1+Trans2),Table(*))
 
Example:           FN.BAS
 
Description:
A function subprogram is defined by DEF FN and called by referencing FNname. The supplied arguments, if any, may be used in the function's calculations. Upon completion it returns either a string or a numeric value depending on the type of the function name.
 
Calling a function subprogram changes the program context. Function subprograms may be called recursively. If there is more than one function with the same name the function with the lowest line number is called.
 
If an expression is defined and evaluated several times throughout a program, it is convenient to define it as a function and then specify the function name instead of the expression. A function can be used anywhere expressions are allowed.
 
Function subprograms can be included in expressions involved in keyboard calculations. For example, the return value of a function can be displayed by typing the function name and then pressing ENTER.
 
The arguments specified in the function reference must be of the same type as the parameters in the defining DEF FN. Variables passed by reference must exactly match the DEF FN parameters. Numeric values passed by value are changed to the type (REAL or INTEGER) of the parameter.
 
See Also: