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.
SUBROUTINE
◄Up► ◄Contents► ◄Index► ◄Back►
─────SUBROUTINE─────────────────────────────────────────────────────────────
Action
Identifies a program unit as a subroutine, gives it a name, and
identifies its formal arguments.
Syntax
SUBROUTINE subr [ [sattrs] ] [([ formal [ [attrs] ]
[,formal [ [attrs] ] ]...])]
Parameter Description
subr The global, external name of the subroutine. The
name cannot appear in AUTOMATIC, COMMON, DATA,
EQUIVALENCE, INTRINSIC, LOADDS, SAVE, or type
statements.
[sattrs] A list of attributes for the subroutine,
separated by commas. Valid attributes are:
ALIAS, C, FAR, NEAR, PASCAL, VARYING.
formal A formal-argument name. Separate multiple
arguments with commas. A formal argument may
also be an alternate return label (*).
[attrs] A list of attributes for the formal argument,
separated by commas. Valid attributes are: FAR,
HUGE, NEAR, REFERENCE, VALUE.
Remarks
A subroutine can contain any statement except BLOCK DATA, FUNCTION,
INTERFACE TO, PROGRAM, or SUBROUTINE.
Within the calling program, <subr> is global, and may not be used
for any other variable or subprogram.
Formal-argument names cannot appear in AUTOMATIC, COMMON, DATA,
EQUIVALENCE, INTRINSIC, or SAVE statements.
In a CALL statement, the actual arguments passed to the
subroutine must agree with the corresponding formal arguments in
the SUBROUTINE statement in order, in number (except when the C
and VARYING attributes are specified), and in type.
FORTRAN does not support recursive subroutine calls; the results
are unpredictable.
See Also: ◄CALL►
Example
SUBROUTINE GetNum (num, unit)
INTEGER num, unit
10 READ (unit, '(I10)', ERR = 10) num
END
-♦-