qb45advr.hlp (
Topic list)
DEF FN Functions
◄Modules and Procedures► ◄DEF FN Functions► ◄Contents► ◄Index►
──────────────────────────────────────────────────────────────────────────────
DEF FN Functions
DEF FN functions are always part of a program's module-level code. For this
reason, their use is more limited than that of SUBs or FUNCTIONs. Like
FUNCTION procedures, DEF FN functions return single values and are used
like BASIC built-in functions:
' Function to find log base 10 of a number using
' BASIC's built-in natural logarithm function.
DEF FNLog10 (X)
FNLog10 = LOG(X) / LOG(10.0)
END DEF
INPUT "Enter a number: ",Num
PRINT "10 ^ Log10(";Num;") is" 10.0 ^ FNLog10(Num)
END
DEF FN function arguments are passed by value. The name of a DEF FN function
always begins with FN. In addition, DEF FN functions
■ must be defined before they are used
■ cannot be called from outside the module in which they are defined.
■ cannot be used recursively