[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
SUB...END SUB            Define Subprogram

 SUB globalname [(parmlist)] STATIC
 .
 .
 .
 [EXIT SUB]
 .
 .
 .
 END SUB

    Defines a subprogram.

  globalname    A variable name of 31 or fewer characters. globalname may
                not appear in any other SUB statement in the same program
                or in the user library.

    parmlist    One or more simple variables or arrays passed as
                parameters when the subprogram is CALLed. Names of array
                variables must be followed by an integer enclosed in
                parentheses; the integer specifies the number of
                dimensions in the array. Parameters are passed by
                reference.

      STATIC    Indicates that the subprogram is nonrecursive. QuickBASIC
                3.0 does not support recursive subprograms, so the STATIC
                attribute is mandatory.

    EXIT SUB    Provides optional exit from within a subprogram.

   -----------------------------------------------------------------------

      Notes:    Variables used within subprograms are local unless
                declared otherwise by means of a SHARED statement.
                Nevertheless, when a subprogram is exited and later
                reentered, the value of a local variable may have changed.
                To guarantee that a variable's value will not change
                between subprogram CALLs, declare the variable STATIC by
                means of a STATIC statement (not to be confused with the
                STATIC attribute of the SUB statement).

                You may not enter or exit a subprogram by means of GOSUB,
                GOTO, or RETURN.

See Also: CALL SHARED STATIC
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson