qbasic.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.
FUNCTION Statement
  Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
Defines a FUNCTION procedure.
 
FUNCTION name [(parameterlist)] [STATIC]
    [statementblock]
  name = expression
    [statementblock]
END FUNCTION
 
    ■ name             The name of the function and the data type it returns,
                       specified by a data-type suffix (%, &, !, #, or $).
    ■ parameterlist    One or more variables that specify parameters to be
                       passed to the function when it is called:
 
                       variable[( )] [AS type] [, variable[( )] [AS type]]...
 
                       variable    A Basic variable name.
                       type        The data type of the variable (INTEGER,
                                   LONG, SINGLE, DOUBLE, STRING, or a
                                   user-defined data type).
 
    ■ STATIC           Specifies that the values of the function's local
                       variables are saved between function calls.
    ■ expression       The return value of the function.
 
    ■ When you call the function, you can specify that an argument's value
      will not be changed by the function by enclosing the argument in
      parentheses.
 
 
Example:
    The program REMLINE.BAS illustrates calling FUNCTION procedures. To view
    or run this program, load REMLINE.BAS using the Open command from the
    File menu.
 
See Also    DECLARE    DEF FN    EXIT    SHARED, STATIC    SUB