Any variable used within a procedure is completely distinct from a variable of the same name used outside the procedure or within a different procedure, as can be seen in the following example:
ICL> X=1 ICL> PROC FRED FRED> X=1.2345 FRED> =X FRED> END PROC ICL> FRED 1.234500 ICL> =X 1 ICL>
When you run the procedure FRED you get the value of the variable X within the procedure. Then, typing `=X' gives the value of X outside the procedure, which has remained unchanged during execution of the procedure. This feature has the consequence that you can use procedures freely without having to worry about any possible side effects on variables outside them.
The situation is exactly the same as that in Fortran where variables in a subroutine are local to the subroutine in which they are used. In Fortran, the COMMON statement is provided for use in cases where it is required to extend the scope of a variable over more than one routine. ICL does not have a COMMON facility, but does provide an alternative mechanism for accessing variables outside their scope using the command VARS and the function VARIABLE.
ADAM The Starlink Software Environment