Escolar Documentos
Profissional Documentos
Cultura Documentos
DAY 5
% Statements
Statements that direct the operation of the compiler, begin with a percent
(%) symbol. These statements must not have label or condition prefixes,
and cannot be a "unit" of a compound statement.
The % statements allow you to control the source program listing and to
include external strings in the source program. These control statements,
%INCLUDE, %PRINT, %NOPRINT, %PAGE, and %SKIP
>>__%INCLUDE__member________ _________;_______________><
|_dataset__(__member__)_|
Dataset specifies the ddname used in the FILEDEF command for the VM
library, or in the ddname of the appropriate DD statement for MVS. The
default ddname is SYSLIB. The ddname must refer to a partitioned data set.
Dataset is optional.
Member specifies the name of the library member to be incorporated in VM
or the name of the data set member to be incorporated in MVS.
% INCLUDE PAYRL;
Directs the compiler to resume printing the source and in-source listings.
>>__%PRINT__;_____________________________________><
%PRINT is in effect at the onset of both the in-source and the source
listings, provided that the relevant compile-time options are specified.
The %PRINT statement must be on a line with no other statements. It must
not appear within another statement.
>>__%NOPRINT__;_______________________________________><
>>__%PAGE__;_________________________________________><
This statement controls both the in-source and the source listing.
For paging to take place, the %PAGE statement must be on a line with no
other statements. When paging takes place, %PAGE does not appear in the
formatted listing
|_(__n__)_|
Storage Classes
Data names represent locations in main storage where the data items are
recorded.
When a locations in the main storage has been associated with a data name,
storage is said to be allocated.
The time at which storage is to be allocated depends on the storage class of the
data.
Storage Classes
AUTOMATIC
AUTO
CALL B;
You use static storage when the variable is local to the procedure and the
value it contains must be saved between successive invocations.
Variables declared with the STATIC attribute are allocated prior to running a
program.
They remain allocated until the program terminates (STATIC storage in
fetched procedures is an exception).
The program has no control on the allocation of static variables during
execution.
Based Variable
Pointer
DCL P1 POINTER;
DCL A(10,2) CHAR(10) BASED (P1);
DCL P POINTER;
P=ADDR(A);
It is possible for more than one variable to be based on the same pointer.
READ READ
WRITE WRITE
READ – Record is moved from the dataset to the buffer and from the buffer to
the program (the record specified in the INTO).
WRITE – Record is moved from the program (the record specified in FROM) to
the buffer and from the buffer to the dataset.
The locate mode allows the programmer to process the data directly from
the buffer without moving it to the program.
Here the data transmission statement identifies the location of the storage
allocated to a record in the buffer.
Locate mode requires the files to be declared as BUFFERED
SEQUENTIAL.
A:PROC;
DCL X CONTROLLED;
CALL B;
.
.
.
B:PROC;
ALLOCATE X;
.
.
END B;
END A;
Controlled attribute stores the allocations in a stack with the most recent
one at the top.
DO; END;
A = ALLOCATION(Y);
LISTS
DCL 1 CRICKET,
2 NAME CHAR(20),
2 NEXT_PTR POINTER;
The elements in the list do not have be contiguous in the main storage.
This helps in more efficient use of the main storage.
The main storage need only be allocated for those items that are currently in
the list and subsequently freed when specific items need no longer remain
in the list.
New items can be added and existing items can be deleted in a linear list
without resorting the list – you simple change the pointers.
A circular list is a linear list in which the last element contains the address
for the first element in the list rather than the end-of-list indicator (null value).
A bidirectional list contains two points per element. One pointer points to
the preceding element in the list and the other to the succeeding element.
Useful in applications that need processing in forward and backward
directions.
BORDER TENDULKAR
VENGSARKAR
BOON
*
*
*
*
The advantage of creating this type of list structure is that the items entered
into the binary tree did not have to be sorted.
Search time to locate an item is reduced.
Each element is in a list is allocated storage by a PL/I program at the time storage is needed for
that item.
One method for allocating storage is a based structure and associated pointer variable.
Declare
DCL 1 CRICKET BASED(P),
2
Allocate Storage
ALLOCATE CRICKET
Declare
DCL 1 CRICKET BASED,
2
Allocate Storage
ALLOCATE CRICKET SET P
If the pointer variable has not been declared with the based variable, then
the ALLOCATE statement must indicate the name of the pointer to be set.
However CRICKET must always be referenced by a locator qualifier.
P -> CRICKET
If P was set by the above ALLOCATE statement (2), the reference is to the
current generation of CRICKET
Miscellaneous Topics
INTERNAL specifies that the name can be known only in the declaring
block. Any other explicit declaration of that name refers to a new object with
a different, non-overlapping scope.
A name with the EXTERNAL attribute can be declared more than once,
either in different external procedures or within blocks contained in external
procedures. All declarations of the same name with the EXTERNAL
attribute refer to the same data. The scope of each declaration of the name
(with the EXTERNAL attribute) includes the scopes of all the declarations of
that name (with EXTERNAL) within the program.