Using declarative statements

Declarative statements enable you to provide definitions for the STL Translator that are in effect for all the statements in a program following the declarations.

The four types of declarative statements enable you to define the following STL elements:
  • Variable types and classes
  • Constant names
  • User tables
  • Allocation of save areas, counters, and switches to variables.
You must code declarative statements outside procedures; they cannot be located between MSGTXT and ENDTXT statements. Declarative statements that you code at the beginning of a program are in effect for the entire program. Those coded between procedures in a program are only in effect for the procedures that follow.

It does not matter whether you code all declarative statements at the beginning of a program or intersperse them between the procedures that make up a program. However, you cannot use a variable or constant name defined on a declarative statement before its declaration in the source data set. For this reason, you may find it helpful to place all declarative statements preceding the first procedure in your program.

The example in Figure 1 shows how declarative statements and procedures are coded in an STL program.
Figure 1. Placement of declarative statements in an STL program
 These declarations       ┌───── declarative statement
 will be in effect for    │      .
 the entire program. ─────┤      .
                          │      .
                          └─────  
                                 proc1: msgtxt
                                 .
                                 .
                                 .
                                 endtxt
 These declarations       ┌───── declarative statement
 will be in effect only   │      .
 for those procedures ────┤      .
 that follow--not for     │      .
 proc1.                   └─────  
                                 proc2: msgtxt
                                 .
                                 .
                                 .
                                 endtxt
                                 proc3: msgtxt
                                 .
                                 .
                                 .
Note: Variable declarations for one program do not apply to another program. For example, if you had four programs in your input data set, a variable defined in program 1 would not be usable by program 2. Each program has its own set of variables.

The following sections explain the four types of declarative statements.