DocumentationEndless PL/I for POSIX SystemsReference Manual  ·  ESS-PFURM-001

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.

E.1. Statements

%activate-statement

%{ ACTIVATE } element [ RESCAN   ]... ;
 { ACT      }         [ NORESCAN ]

allocate-statement

{ ALLOCATE } allocate-item, ... ;
{ ALLOC    }

allocate-item:

variable-reference [SET(locator-reference)] [IN(area-reference)]

%assignment-statement

%target = expression;

assignment-statement

target, ... = expression;

begin-statement

BEGIN;

call-statement

CALL entry-name [(argument, ...)];

close-statement

CLOSE FILE(file-reference) [ENVIRONMENT(option, ...)]
       [,FILE(file-reference) [ENVIRONMENT(option, ...)]] ... ;

%deactivate-statement

%{ DEACTIVATE } element, ...;
 { DEACT      }

element:

{ identifier         }
{ (identifier, ...)  }

%declare-statement

%{ DECLARE } element [ FIXED     ]... ;
 { DCL     }         [ CHARACTER ]
                     [ BIT       ]

element:

{ identifier        }
{ (identifier, ...) }

declare-statement

{ DECLARE } [level] declaration [,[level] declaration, ...];
{ DCL     }

declaration:

{ identifier        } [(bound-pair)] [attribute ...]
{ (identifier, ...) }

delete-statement

DELETE FILE(file-reference) [KEY (expression)] [OPTIONS(option, ...)]

%do-statement

%DO;
⋮
%END;

do-statement

   [reference = expression]
   [TO expression [BY expression]]
DO [REPEAT expression]
   [WHILE(expression)]
   [UNTIL(expression)];

%end-statement

%END;

end-statement

END [label-reference];

entry-statement

entry-name: ENTRY [(parameter, ...)]
            [ RECURSIVE    ]
            [ NONRECURSIVE ]
            [RETURNS(returns-descriptor)]

%error-statement

%ERROR preprocessor-expression;

%fatal-statement

%FATAL preprocessor-expression;

format-statement

label:

FORMAT (format-specification, ...);

free-statement

FREE variable-reference [IN area-reference], ...;

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)] ;

%goto-statement

%GOTO label-reference;

goto-statement

{ GOTO  } label-reference;
{ GO TO }

%if-statement

%IF test-expression %THEN action [%ELSE action];

if-statement

IF test-expression THEN action [ELSE action];

%include-statement

%INCLUDE { 'file-spec'                    };
         { module-name                    }
         { 'directory-name (module-name)' }

%inform-statement

%INFORM preprocessor-expression;

leave-statement

LEAVE [label-reference];

locate-statement (ibm dialect only)

LOCATE based-variable FILE (file-reference)
       [ SET (pointer-reference) ]
       [ KEYFROM (expression) ];

%null-statement

%;

null-statement

;

on-statement

ON condition-name { on-unit }
                  { SYSTEM  }

open-statement

OPEN FILE(file-reference) [file-description-attribute ...]
       (file-reference) [file-description- attribute ...]] ...;

%page-statement

%PAGE;

%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, ...)]
[IGNORE (expression)] ;

%replace-statement

%REPLACE identifier BY constant-value;

%return-statement

[%]RETURN (preprocessor-expression);

return-statement

RETURN [ (return-value) ];

revert-statement

REVERT condition-name, ...;

rewrite-statement

REWRITE FILE (file-reference)
       [ FROM (variable-reference) [ KEY (expression) ]]
       [ OPTIONS (option, ...) ];

%sbttl-statement

%SBTTL preprocessor-expression

select-statement

SELECT [(select-expression)];
       [WHEN [ANY | ALL] (case-expression, ...) [action] ; ] ...
       [(OTHERWISE | OTHER) [action] ; ]
END;

signal-statement

SIGNAL condition-name;

stop-statement

STOP;

%title-statement

%TITLE preprocessor-expression

%warn-statement

%WARN preprocessor-expression;

write-statement

WRITE FILE(file-reference) FROM (variable-reference)
       [ KEYFROM (expression) ]
       [ OPTIONS (option, ...) ]; 

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[,scale-factor])]
{ FIXED }{ DECIMAL }
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 is valid on OPEN in the dec and ansi dialects only):

ENVIRONMENT(option, ...)
{ RECORD[KEYED] }{ INPUT         }
{ STREAM        }{ OUTPUT[PRINT] }
                 { UPDATE        }
{ DIRECT     }
{ SEQUENTIAL }

Entry Name Attributes

The following attributes can be applied to identifiers of entry points:

ENTRY[VARIABLE] [ OPTIONS [ (VARIABLE) ] ]
                [         [ (C)        ] ]
        [RETURNS(returns-descriptor)]
        [BUILTIN]

Non-Data Type Attributes

The following attributes can be applied to data declarations:

ALIGNED
DIMENSION
UNALIGNED

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;

E.4. Expressions and Data Conversions

Table E.1, “Operators” lists the categories of operators, their symbols, and their meanings.

Table E.1. Operators
CategorySymbolOperation
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, 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.

Table E.2. Precedence of Operators
OperatorPriorityLeft/Right AssociativeOrder of Evaluation
()0N/Adeepest first
**1rightleft to right
+ (prefix)1N/AN/A
- (prefix)1N/AN/A
^ (prefix)1N/AN/A
*2leftleft to right
/2leftleft to right
+ (infix)3leftleft to right
- (infix)3leftleft to right
||4leftleft to right
>5leftleft to right
<5leftleft to right
^>5leftleft to right
^<5leftleft to right
=5leftleft to right
^=5leftleft to right
<=5leftleft to right
>=5leftleft to right
&6leftleft to right
|7leftleft to right
^ (infix)7leftleft to right
&:8leftleft to right across entire expression
|:9leftleft 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.

Table E.3. Contexts in Which PL/I Converts Data
ContextConversion Performed
target = expression;In an assignment statement, the given expression is converted to the data type of the target.

entry-name

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^=yIn 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.
parameterActual parameters are converted to the type of the formal parameter if necessary.
INITIAL attributeInitial 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.

Table E.4. Summary of PL/I Built-In Subroutines
CategoryRoutine ReferenceActionDialect
Condition-handlingRESIGNAL()Allows more processing of a signal.dec,ansi
File-controlFLUSH(f)Forces flushing of all buffers for file f.dec,ansi
REWIND(f)Resets file f to the beginning.dec,ansi
SortingPLIRETCSets the PL/I return code, which the Sort program examines in input and output routines and the PLIRETV built-in function returns.ibm
PLISRTAAn entry point of the Sort program, which sorts records with the system's sort command.ibm
PLISRTBAn entry point of the Sort program, which sorts records with the system's sort command.ibm
PLISRTCAn entry point of the Sort program, which sorts records with the system's sort command.ibm
PLISRTDAn entry point of the Sort program, which sorts records with the system's sort command.ibm