forlang.hlp (Table of Contents; Topic list)
FUNCTION (External)
                                             Up Contents Index Back
─────FUNCTION (External)────────────────────────────────────────────────────
 
     Action
 
     Identifies a program unit as a function, and supplies its name, data
     type, and optional formal parameters.
 
     Syntax
 
     [type] FUNCTION func [ [fattrs] ]
     ([ formal [ [attrs] ] ] [, formal [ [attrs] ] ] ...)
 
     Parameter          Description
 
     type               Data type of the value returned by the function.
 
                        If omitted, the applicable IMPLICIT statements
                        determine the function's type. If there are no
                        IMPLICIT statements, the function's type is
                        established by FORTRAN's default typing.
 
                        If <type> is specified, the function name cannot
                        appear in a type statement.
 
     func               The name of the function. The same name cannot
                        appear in AUTOMATIC, COMMON, DATA, EQUIVALENCE,
                        INTRINSIC, NAMELIST, or SAVE statements.
 
     [fattrs]           A list of attributes for the function, separated
                        by commas. Valid attributes are: ALIAS, C, FAR,
                        NEAR, PASCAL, VARYING.
 
     formal             A formal-argument name. If more than one is
                        specified, they must be separated by commas.
 
     [attrs]            A list of attributes for the formal argument,
                        separated by commas. Valid attributes are: FAR,
                        HUGE, NEAR, REFERENCE, VALUE.
 
     Remarks
 
     A function begins with a FUNCTION statement and ends with the
     next END statement.
 
     A function can contain any statement except a BLOCK DATA,
     FUNCTION, INTERFACE TO, PROGRAM, or SUBROUTINE statement.
 
     The length specifier for the function type may follow the
     function name.
 
     Within the calling program, <func> is global, and may not be used
     for any other variable or subprogram.
 
     FORTRAN does not support recursive function calls.
 
     Example
 
     C     GetNo is a function that reads a number from unit i
           i = 2
        10 IF (GetNo(i) .EQ. 0.0) GOTO 10
           END
     C
           FUNCTION GetNo (nounit)
           READ (nounit, '(F10.5)') r
           GetNo = r
           END
                                    -♦-