Rational Developer for System z
Enterprise PL/I for z/OS, Version 3.8, Language Reference Manual

Static storage and attribute

Variables declared with the STATIC attribute are allocated prior to running a program. They remain allocated until the program terminates. The program has no control over the allocation of static variables during execution.

Read syntax diagramSkip visual syntax diagram>>-STATIC------------------------------------------------------><
 

STATIC is the default for external variables, but internal variables can also be static. It is also the default for variables declared in a package, outside of any procedure. Static variables follow the normal scope rules for the validity of references to them. In the following example, the variable X is allocated for the life of the program, but it can be referenced only within procedure B or any block contained in B. The variable Y gets the STATIC attribute and is also allocated for the life of the program.

  Package: Package exports (*);
    dcl Y char(10);
 
    A: proc options(main);
      B: proc;
        declare X static internal;
      end B;
    end A;
 
    C: proc;
      Y = 'hello';
    end C;
 
  end Package;

If static variables are initialized using the INITIAL attribute, the initial values must be restricted expressions. Extent specifications must also be restricted expressions.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)