Appendix E
Language Summary
This appendix briefly describes PL/I statements, attributes, expressions, data conversions, built-in functions, pseudovariables, and built-in subroutines.
E.1. Statements
allocate-statement
{ ALLOCATE }
{ ALLOC }
allocate-item,...;allocate-item:
variable-reference[SET(locator-reference)][IN(area-reference)]
%assignment-statement
%target = expression;close-statement
CLOSE FILE(file-reference) [ENVIRONMENT(option,...)] [,FILE(file-reference) [ENVIRONMENT(option,...)]]...
%deactivate-statement
% { DEACTIVATE }
{ DEACT }
element,...;element:
{ identifier }
{ (identifier,...) }%declare-statement
% { DECLARE } element
{ DCL }
[ FIXED ] ,...;
[ CHARACTER ]
[ BIT ]element:
{ identifier }
{ (identifier,...) }declare-statement
{ DECLARE } [level] declaration [,[level] declaration,...];
{ DCL }declaration:
[level]declaration-item
declaration-item:
{ identifier }[(bound-pair,...)] [attribute...]
{ (declaration-item,...) }do-statement
DO[reference=expression] [TOexpression[BYexpression]] [REPEATexpression] [WHILE(expression)] [UNTIL(expression)];
entry-statement
entry-name: ENTRY [ (parameter,...) ] [ RECURSIVE ] [ NONRECURSIVE ] [ RETURNS (returns-descriptor) ];
get-statement
GET EDIT (input-target,...)(format-specification,...)
[ FILE(file-reference) ] [ {[SKIP[(expression)]] | [OPTIONS(option,...)]} ] [ STRING(expression) ] ;
GET LIST (input-target,...)
[ FILE(file-reference) ] [ {[SKIP[(expression)]] | [OPTIONS(option,...)]} ] [ STRING(expression) ] ;
GET [FILE(file-reference)] SKIP [(expression)];
%[no]list-statement
%[NO]LIST; %[NO]LIST_ALL; %[NO]LIST_DICTIONARY; %[NO]LIST_INCLUDE; %[NO]LIST_MACHINE; %[NO]LIST_SOURCE;
open-statement
OPEN FILE(file-reference) [file-description-attribute...] [,FILE(file-reference) [file-description-attribute...]]...
%procedure-statement
%label:{ PROCEDURE } [(parameter-identifier,...)][STATEMENT]
{ PROC }
RETURNS ( { CHARACTER } ); ⋮
{ FIXED }
{ BIT }
[%]RETURN (preprocessor-expression); ⋮
[%]END.procedure-statement
entry-name: { PROCEDURE } [ (parameter,...) ] { PROC } [ OPTIONS (option,...) ] [ RECURSIVE ] [ NONRECURSIVE ] [ RETURNS (value-descriptor) ];
put-statement
PUT EDIT (output-source,...) (format-specification,...)
[ FILE(file-reference) ] [ {[PAGE] | [LINE(expression)] | [SKIP[(expression)]] | [OPTIONS(option)]} ] [ STRING(reference) ] ;
PUT [FILE(file-reference)] LINE(expression);
PUT LIST (output-source,...)
[ FILE(file-reference) ] [ {[PAGE] | [LINE(expression)] | [SKIP[(expression)]] | [OPTIONS(option)]} ] [ STRING(reference) ] ;
PUT [ FILE(file-reference)] PAGE;
PUT [ FILE(file-reference)] SKIP [(expression)];
read-statement
READ FILE (file-reference) { INTO (variable-reference) } { SET (pointer-variable) } [ KEY (expression) ] [ KEYTO (variable-reference) ] [ OPTIONS (option,...) ];
rewrite-statement
REWRITE FILE (file-reference) [ FROM (variable-reference) [ KEY (expression) ]] [ OPTIONS (option,...) ];
select-statement
SELECT [(select-expression)]; [WHEN [ANY|ALL] (expression,...) [action];]... [{OTHERWISE|OTHER} [action];] END;
E.2. Attributes
Computational Data Type Attributes
The following attributes define arithmetic and string data:
CHARACTER [ (length) ] [ VARYING ] [ NONVARYING ] BIT [ (length) ] [ ALIGNED ] [ UNALIGNED ] { FLOAT } { BINARY } [ [PRECISION] (precision{ FIXED } { DECIMAL } [,scale-factor]) ] PICTURE 'picture'
These attributes can be specified for all elements of an array and for individual members of a structure.
Noncomputational Data Type Attributes
The following attributes apply to program data that is not used for computation:
AREA
CONDITION
ENTRY [VARIABLE]
FILE [VARIABLE]
LABEL [VARIABLE]
OFFSET
POINTER
Storage Class and Scope Attributes
The following attributes control the allocation and use of storage for a data variable and define the scope of the variable:
AUTOMATIC [INITIAL(
initial-element,...)]BASED [(pointer-reference)][INITIAL(
initial-element,...)]CONTROLLED [INITIAL(
initial-element,...)]DEFINED(
variable-reference) [POSITION(expression)]STATIC [READONLY] [INITIAL(
initial-element,...)]PARAMETER
INTERNAL
EXTERNAL [ GLOBALDEF [(
psect-name)] {VALUE | READONLY} ] [ GLOBALREF ]
Member Attributes
The following attributes can be applied to the major or minor members of a structure:
LIKE
MEMBER
REFER
STRUCTURE
TYPE
UNION
File Description Attributes
The following attributes can be applied to file constants and used in OPEN statements:
ENVIRONMENT(option,...)
{ RECORD [KEYED] } { STREAM } { INPUT } { OUTPUT [PRINT] } { UPDATE }{ DIRECT } { SEQUENTIAL }
E.3. Expressions and Data Conversions
The following table lists the categories of operators, their symbols, and their meanings.
Operators
| Category | Symbol | Operation |
|---|---|---|
|
Arithmetic operators |
+ - / * ** |
Addition or prefix plus Subtraction or prefix minus Division Multiplication Exponentiation |
|
Relational (or comparison) operators |
> < = ^> ^< ^= >= <= |
Greater than Less than Equal to Not greater than Not less than Not equal to Greater than or equal to Less than or equal to |
|
Bit-string (or logical) operators |
^ (prefix) & | &: |: ^ (infix) |
Logical NOT Logical AND Logical OR Logical AND THEN Logical OR ELSE Logical EXCLUSIVE OR |
|
Concatenation operator | || | String concatenation |
Note
For any of the operators, the tilde character (~) can be used instead of a circumflex (^), and an exclamation point (!) can be used instead of a vertical bar (|).
The following table gives the priority of PL/I operators. Low numbers indicate high priority. For example, the exponentiation operator (**) has the highest priority (1), so it is performed first, and the OR ELSE operator (|:) has the lowest priority (9), so it is performed last.
Precedence of Operators
| Operator | Priority | Left/Right Associative | Order of Evaluation |
|---|---|---|---|
| () | 0 | N/A | deepest first |
| ** | 1 | right | left to right |
| + (prefix) | 1 | N/A | N/A |
| - (prefix) | 1 | N/A | N/A |
| ^ (prefix) | 1 | N/A | N/A |
| * | 2 | left | left to right |
| / | 2 | left | left to right |
| + (infix) | 3 | left | left to right |
| - (infix) | 3 | left | left to right |
| || | 4 | left | left to right |
| > | 5 | left | left to right |
| < | 5 | left | left to right |
| ^> | 5 | left | left to right |
| ^< | 5 | left | left to right |
| = | 5 | left | left to right |
| ^= | 5 | left | left to right |
| <= | 5 | left | left to right |
| >= | 5 | left | left to right |
| & | 6 | left | left to right |
| | | 7 | left | left to right |
| ^ (infix) | 7 | left | left to right |
| &: | 8 | left | left to right across entire expression |
| |: | 9 | left | left to right across entire expression |
The following table discusses the contexts in which PL/I performs data conversion.
Contexts in Which PL/I Converts Data
| Context | Conversion Performed |
|---|---|
| target = expression; | In an assignment statement, the given expression is converted to the data type of the target. |
|
RETURNS (attribute...); ⋮ | In a RETURN statement, the specified value is converted to the data type specified by the RETURNS option on the PROCEDURE or ENTRY statement. |
| RETURN (value); | |
|
x + y x - y x * y x / y x**y x||y x & y x | y x&:y x|:y x ^ y x > y x < y x = y x^=y | In any expression, if operands do not have the required data type, they are converted to a common data type before the operation. For most operators, the data types of all operands must be identical. A warning message is issued in the case of a concatenation conversion. |
|
BINARY (expression) BIT (expression) CHARACTER (expression) DECIMAL (expression) FIXED (expression) FLOAT (expression) OFFSET (variable) POINTER (variable) | PL/I provides built-in functions that perform specific conversions. |
| PUT LIST (item,...); | Items in a PUT LIST statement are converted to character-string data. |
| GET LIST (item,...); | Character-string input data is converted to the data type of the target item. |
|
PAGESIZE (expression) LINESIZE (expression) SKIP (expression) LINE (expression) COLUMN (expression) format items A, B, E, F, and X TAB (expression) | Values specified for various options to PL/I statements must be converted to integer values. |
DO control-variable... | Values are converted to the attributes of the control variable. |
| parameter | Actual parameters are converted to the type of the formal parameter if necessary. |
| INITIAL attribute | Initial values are converted to the type of the variable being initialized. |
E.4. Pseudovariables
PL/I has the following pseudovariables:
INT
ONSOURCE
ONCHAR
PAGENO
POSINT
STRING
SUBSTR
UNSPEC
A pseudovariable can be used, in certain assignment contexts, in place of an ordinary variable reference. For example:
SUBSTR(S,2,1) = 'A';
This assigns the character 'A' to a 1-character substring of S, beginning at the second character of S.
A pseudovariable can be used wherever the following three conditions are true:
The syntax specifies a variable reference.
A value is explicitly assigned to the variable.
The context does not require the variable to be addressable.
Pseudovariables are used most often in the following locations:
The left side of an assignment statement
The input target of a GET statement
Note that a pseudovariable cannot be used in preprocessor statements or in an argument list. For example:
CALL P(SUBSTR(S,2,1));
Here, SUBSTR is interpreted as a built-in function reference, not as a pseudovariable. The actual argument passed to procedure P is a dummy argument containing the second character of string S.
E.5. Built-In Subroutines
The following table summarizes the file-handling built-in subroutines.
Summary of File-Handling Built-In Subroutines
| Subroutine | Function |
|---|---|
| DISPLAY | Returns information about a file. |
| EXTEND | Allocates additional disk blocks for a file. |
| FLUSH | Requests the file system to write all buffers onto disk to preserve the current status of a file. |
| FREE | Unlocks all the locked records in a file. |
| NEXT_VOLUME | Begins processing the next volume in a multivolume tape set. |
| RELEASE | Unlocks a specified record in a file. |
| REWIND | Positions a file at its beginning or at a specific record. |
| SPACEBLOCK | Positions a file forward or backward a specified number of blocks. |
PL/I also has the condition-handling subroutine RESIGNAL. This subroutine allows an ON-unit to pass on a condition signal and causes the condition to be resignaled for handling by a different ON-unit.