[next] [previous] [contents]

  13.4.2 Invoking FUNCTION Subprograms
  The following example performs the same task as the SUB
  program; however, this example uses a FUNCTION subpro-
  gram that returns the value to the main program and the
  main program prints the result:
  
EXAMPLE: Click to display example.

  If you do not assign a value to the function name and you do
  not specify a return value on an EXIT FUNCTION or END
  FUNCTION statement, the function returns zero or the null
  string.

  Note that when writing FUNCTION subprograms, you must
  specify a data type for the function in both the main program
  EXTERNAL statement and the subprogram FUNCTION
  statement. This data type keyword specifies the data type
  of the value returned by the function subprogram. You
  should ensure that the data type specified in an EXTERNAL
  FUNCTION statement matches the data type specified in the
  FUNCTION statement.

  If you declare a FUNCTION subprogram with an
  EXTERNAL statement and use the CALL statement to
  invoke the function, it executes correctly but the function
  value is not available. Note that BASIC still performs pa-
  rameter validation when you invoke a function with the
  CALL statement.

  Note that you cannot use the CALL statement to invoke a
  string or packed decimal function.