Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo Basic - <b>def fn define function</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
DEF FN                   Define Function

 1. DEF FNname[(parmlist)] = expression

 2. DEF FNname[(parmlist)]
    [LOCAL varlist]
    [STATIC varlist]
    [SHARED varlist]
    .
    . [statements]
    .
    [EXIT DEF]
    [FNname = expression]
    END DEF

    Defines a user function.

        name    A valid variable name, of the same type as expression.

    parmlist    One or more comma-delimited formal parameters for the
                function. Each must be a valid variable name. Parameters
                are passed by value.

  expression    An expression, of the same type as name, that defines the
                value returned by the function.

     varlist    A comma-delimited list of variables declared as LOCAL,
                STATIC, or SHARED.

       LOCAL    Declares one or more variables local to the function
                definition. Must appear before any executable statements
                within the function definition. Local variables may lose
                their value with each invocation of the function.

      STATIC    Declares one or more variables as static. Static variables
                are local to the function but retain their values between
                successive invocations.

      SHARED    Declares one or more variables as shared, or global. This
                is the default attribute for variables in a function
                definition.

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

      Notes:    For numeric functions, the precision specified by name
                determines the precision returned by the function.

                A function's definition need not appear ahead of its
                invocation, and program flow does not need to be directed
                through the function definition.

                You may not jump into or out of a function definition via
                GOTO, GOSUB, or RETURN. You may exit from a point other
                than END DEF by means of the optional EXIT DEF.

                Functions may not be defined from within other function
                definitions. Functions may invoke other functions,
                however.

See Also: EXIT LOCAL SHARED STATIC

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson