The Scope of Variables
Variable names must be unique in their scope. The EQUEL/Fortran preprocessor understands scoping of variables if your program adheres to the following rules:
• To declare a scope for a program or subprogram, use the ## signal on the program, subroutine or function statement line and also on the line where the matching end statement appears. EQUEL considers the scope of variables declared in such a program or subprogram to be exactly that program unit. The variables can be local variables, common variables or subprogram dummy arguments (formal parameters).
• Be aware that without scoping information, the preprocessor considers the
declare and
declare forms statements to signal the closing of the previous scope and the opening of a new one. In other words, if your program has
not used the ## signal on a
program,
subroutine or
function statement, a
declare statement begins a new scope. For a discussion of the EQUEL/Fortran
declare statement, see
The Declare and Declare Forms Statements.
The following program fragments illustrate the scope of variables in an EQUEL/Fortran program:
## program emp
## declare
C The following two declarations will be visible to the
C preprocessor until the end of program 'emp'.
## integer empid
## real empsal
## real raise
C EQUEL statements using 'empid', 'empsal' and 'raise'
call prcemp (empid)
call prcsal (empsal, raise)
## end
## subroutine prcemp (empid)
## declare
C 'empid' must be redeclared to EQUEL because of new
C scope
## integer empid
C EQUEL statements using 'empid'
## end
## subroutine prcsal (esal, raise)
## declare
C Declare only those formal parameters to EQUEL that
C will be used in EQUEL statements.
## real esal
C EQUEL statements using 'esal'
## end
Last modified date: 04/03/2024