DocumentationEndless PL/I for OpenVMSReference Manual  ·  ESS-PFVRM-001

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

%activate-statement

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

allocate-statement

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

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 }
  { 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,...) }

delete-statement

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

%dictionary-statement

%DICTIONARY cdd-path;

%do-statement

  • %DO;

  • .

  • .

  • .

  • %END;

do-statement

DO[reference=expression]
  [TO expression [BY expression]]
  [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                 }
         { 'library-name(module-name)' }

%inform-statement

%INFORM preprocessor-expression;

leave-statement

LEAVE [label-reference];

%[no]list-statement

%[NO]LIST; %[NO]LIST_ALL; %[NO]LIST_DICTIONARY; %[NO]LIST_INCLUDE; %[NO]LIST_MACHINE; %[NO]LIST_SOURCE;

%null-statement

%;

null-statement

;

on-statement

ON condition-name,... [SNAP]  { on-unit }
                              { SYSTEM; }

open-statement

OPEN FILE(file-reference) [file-description-attribute ...]
         [,FILE(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,...) ];

%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] (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
{ 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 }

Entry Name Attributes

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

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

Non-Data Type Attributes

The following attributes can be applied to data declarations:

  • ALIGNED

  • DIMENSION

  • UNALIGNED

E.3. Expressions and Data Conversions

The following table lists the categories of operators, their symbols, and their meanings.

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, 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

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

The following table discusses the contexts in which PL/I performs data conversion.

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

⋮

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.
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.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

SubroutineFunction
DISPLAYReturns information about a file.
EXTENDAllocates additional disk blocks for a file.
FLUSHRequests the file system to write all buffers onto disk to preserve the current status of a file.
FREEUnlocks all the locked records in a file.
NEXT_VOLUMEBegins processing the next volume in a multivolume tape set.
RELEASEUnlocks a specified record in a file.
REWINDPositions a file at its beginning or at a specific record.
SPACEBLOCKPositions 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.