qb45advr.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
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