Appendix E
Language Summary
This appendix briefly describes Endless PL/I for POSIX Systems statements, attributes, statement format, expressions, data conversions, built-in functions, pseudovariables, and built-in subroutines.
{ ALLOCATE } allocate-item, ... ;
{ ALLOC }allocate-item:
variable-reference[SET(locator-reference)] [IN(area-reference)]
%assignment-statement
%target = expression;CLOSE FILE(file-reference) [ENVIRONMENT(option, ...)] [,FILE(file-reference) [ENVIRONMENT(option, ...)]] ... ;
%{ DEACTIVATE } element, ...;
{ DEACT }element:
{ identifier }
{ (identifier, ...) }%{ DECLARE } element [ FIXED ]... ;
{ DCL } [ CHARACTER ]
[ BIT ]element:
{ identifier }
{ (identifier, ...) }{ DECLARE } [level] declaration [,[level] declaration, ...];
{ DCL }declaration:
{ identifier } [(bound-pair)] [attribute ...]
{ (identifier, ...) }[reference=expression] [TOexpression[BYexpression]] DO [REPEATexpression] [WHILE(expression)] [UNTIL(expression)];
entry-name: ENTRY [(parameter, ...)] [ RECURSIVE ] [ NONRECURSIVE ] [RETURNS(returns-descriptor)]
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)] ;
LOCATEbased-variableFILE (file-reference) [ SET (pointer-reference) ] [ KEYFROM (expression) ];
OPEN FILE(file-reference) [file-description-attribute...] (file-reference) [file-description-attribute...]] ...;
%label { PROCEDURE } [(parameter-identifier, ...)] [STATEMENT]
{ PROC }
RETURNS( { CHARACTER } ); ...
{ FIXED }
{ BIT }
[%]RETURN (preprocessor-expression);
...
[%]END;entry-name: { PROCEDURE } [(parameter, ...)] { PROC } [OPTIONS(option, ...)] [ RECURSIVE ] [ NONRECURSIVE ] [RETURNS(value-descriptor)] ;
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 FILE (file-reference){ INTO(variable-reference) }
{ SET(pointer-variable) }
[ KEY(expression) ]
[ KEYTO(variable-reference) ]
[OPTIONS(option, ...)]
[IGNORE (expression)] ;REWRITE FILE (file-reference) [ FROM (variable-reference) [ KEY (expression) ]] [ OPTIONS (option, ...) ];
SELECT [(select-expression)]; [WHEN [ANY | ALL] (case-expression, ...) [action] ; ] ... [(OTHERWISE | OTHER) [action] ; ] END;
The following attributes define arithmetic and string data:
CHARACTER[(length)] [ VARYING ] [ NONVARYING ] BIT[(length)] [ ALIGNED ] [ UNALIGNED ] { FLOAT }{ BINARY }[[PRECISION](precision[,scale-factor])] { FIXED }{ DECIMAL } PICTURE 'picture'
These attributes can be specified for all elements of an array and for individual members of a structure.
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 ]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 is valid on OPEN in the dec and ansi dialects only):
ENVIRONMENT(option, ...)
{ RECORD[KEYED] }{ INPUT }
{ STREAM }{ OUTPUT[PRINT] }
{ UPDATE }
{ DIRECT }
{ SEQUENTIAL }E.3. Statement Format
The general format of a PL/I statement consists of an optional condition prefix (ibmdialect only), an optional statement label, the body of the statement, and the required semicolon terminator. The format of a statement is:
[ (condition-prefix[ ,condition-prefix] ... ) : ] [label: ]statement-body;
Table E.1, “Operators” lists the categories of operators, their symbols, and their meanings.
Note
For any of the operators, you can use the tilde character (~) instead of a circumflex (^), and you can use an exclamation point (!) instead of a vertical bar (|).
Table E.2, “Precedence of Operators” gives the priority of PL/I operators. Low numbers indicate high priority. For example, the exponentiation operator (**) has the highest priority (1), so PL/I performs it first, and the OR ELSE operator (|:) has the lowest priority (9), so PL/I performs it last.
| 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 |
Table E.3, “Contexts in Which PL/I Converts Data” discusses the contexts in which PL/I performs data conversion.
| Context | Conversion Performed |
|---|---|
| target = expression; | In an assignment statement, the given expression is converted to the data type of the target. |
|
RETURNS (attribute ...); ⋮ RETURN (value); | In a RETURN statement, the specified value is converted to the data type specified by the RETURNS option on the PROCEDURE or ENTRY statement. |
| 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.5. Pseudovariables
PL/I has the following pseudovariables:
INT (dec and ansi dialects only)
ONSOURCE
ONCHAR
PAGENO (dec and ansi dialects only)
POSINT (dec and ansi dialects only)
STRING
SUBSTR
UNSPEC
Pseudovariables 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.
Pseudovariables 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
Pseudovariables 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.6. Built-In Subroutines
Table 11.2, “Summary of PL/I Built-In Subroutines” summarizes the built-in subroutines.
| Category | Routine Reference | Action | Dialect |
|---|---|---|---|
| Condition-handling | RESIGNAL() | Allows more processing of a signal. | dec,ansi |
| File-control | FLUSH(f) | Forces flushing of all buffers for file f. | dec,ansi |
| REWIND(f) | Resets file f to the beginning. | dec,ansi | |
| Sorting | PLIRETC | Sets the PL/I return code, which the Sort program examines in input and output routines and the PLIRETV built-in function returns. | ibm |
| PLISRTA | An entry point of the Sort program, which sorts records with the system's sort
command. | ibm | |
| PLISRTB | An entry point of the Sort program, which sorts records with the system's sort
command. | ibm | |
| PLISRTC | An entry point of the Sort program, which sorts records with the system's sort
command. | ibm | |
| PLISRTD | An entry point of the Sort program, which sorts records with the system's sort
command. | ibm |