Part 3 — PL/I Language Reference
3.1 Program Structure
3.1.1 PROCEDURE Statement
- Main procedure declaration
- Nested procedures
- OPTIONS(MAIN) entry point
3.1.2 PACKAGE Statement
- Package declaration for modular PL/I programs
3.1.3 ENTRY Statement
- Alternate entry points
- ENTRY data type for procedure references
3.1.4 BEGIN and END Blocks
- Block structure and scoping rules
3.2 Data Types and Declarations
3.2.1 DECLARE (DCL) Statement
Complete DECLARE syntax and attribute descriptions.
3.2.2 Arithmetic Data Types
| PL/I Declaration | Java Mapping | Description | See Also |
| FIXED BINARY(p) | Short / Integer / Long | Binary integers (2/4/8 bytes) | Runtime: 4.2.1 |
| FIXED DECIMAL(p,q) | BigDecimal | Packed decimal with precision | Runtime: 4.2.1 |
| FLOAT BINARY(p) | BigDecimal | Floating-point | Runtime: 4.2.2 |
| FLOAT DECIMAL(p) | BigDecimal | Floating-point (decimal base) | Runtime: 4.2.2 |
3.2.3 String Data Types
| PL/I Declaration | Java Mapping | Description | See Also |
| CHARACTER(n) | String / PLIString | Fixed-length character string | Runtime: 4.2.3 |
| CHARACTER(n) VARYING | String / PLIString | Variable-length string | Runtime: 4.2.3 |
| BIT(n) | BitN | Bit string | Runtime: 4.2.5 |
| BIT(1) | Boolean | Single-bit Boolean | Runtime: 4.2.5 |
3.2.4 PICTURE Data Type
- Character PICTURE specifications (A, X, 9, etc.)
- Numeric PICTURE specifications (9, Z, V, ., S, CR, DB, etc.)
- Currency symbols and formatting
- Date/time PICTURE support
- Java mapping:
Picture class
See also: Runtime Reference: 4.2.6 Picture Types
3.2.5 Structures (STRUCTURE)
- Level numbers for hierarchical records
- Nested structures
- LIKE attribute for structure cloning
- Java mapping: generated Java classes extending
Group
See also: Runtime Reference: 4.2.4 Structures (Group Classes)
3.2.6 Arrays
- Multi-dimensional array support
- Custom lower and upper bounds (default 1-based)
- HBOUND, LBOUND, DIM built-in functions
- Array slicing with
(*) notation - Java mapping:
Array<T> class
See also: Runtime Reference: 4.2.7 Arrays
3.2.7 Pointers and Locator Variables
| PL/I Declaration | Java Mapping | Description | See Also |
| POINTER | Pointer | Typed/untyped pointers | Runtime: 4.2.8 |
| AREA | Area | Memory allocation areas | Runtime: 4.2.9 |
| OFFSET | — | Offset within an area | — |
3.2.8 Other Data Types
| PL/I Declaration | Java Mapping | Description | See Also |
| FILE | IPLIFile | File handle | File I/O: 8.1 |
| ENTRY | Entry | Procedure reference | Runtime: 4.2.11 |
| CONDITION | Condition | Exception/condition handle | Conditions: 9.1 |
| LABEL | — | Statement label | — |
3.2.9 Data Attributes
- BASED attribute and based variables
- DEFINED attribute and overlay definitions
- CONTROLLED storage class
- AUTOMATIC storage class
- STATIC storage class
- EXTERNAL / INTERNAL scope
- INITIAL attribute and initialization
- REFER attribute for self-defining structures
- DIMACROSS for array-of-structure semantics
See also: Runtime Reference: 4.3 Storage Management for BASED, DEFINED, and CONTROLLED implementation
3.3 Expressions and Operators
3.3.1 Arithmetic Operators
+, -, *, /, ** (exponentiation)
3.3.2 Comparison Operators
=, ^= (or ¬=), <, >, <=, >=
3.3.3 Logical Operators
& (AND), | (OR), ^ or ¬ (NOT)
3.3.4 String Operators
|| (concatenation)
3.3.5 Type Conversion Rules
- Automatic numeric promotion for mixed arithmetic
- String to numeric conversion
- PICTURE type to BigDecimal conversion
- Pointer type conversion rules
3.4 Statements
3.4.1 Assignment Statement
- Simple assignment
- BY NAME assignment for structures
- SUBSTR pseudo-variable assignment
- Array assignment
3.4.2 Control Flow Statements
| Statement | Description |
| IF / THEN / ELSE | Conditional execution |
| SELECT / WHEN / OTHERWISE | Multi-way branching (switch) |
| DO / END | Simple block, WHILE loop, iterative loop, FOREVER |
| LEAVE | Exit a DO loop (with optional label) |
| ITERATE | Skip to next iteration (with optional label) |
| GOTO | Transfer control to a label |
3.4.3 Procedure Statements
| Statement | Description |
| CALL | Invoke a procedure |
| RETURN | Return from procedure (with optional value) |
| ENTRY | Alternate entry point definition |
3.4.4 Storage Management Statements
| Statement | Description | See Also |
| ALLOCATE | Allocate CONTROLLED or BASED storage | Runtime: 4.3 |
| FREE | Release allocated storage | Runtime: 4.3 |
3.4.5 I/O Statements
3.4.6 Condition Handling Statements
3.4.7 Other Statements
| Statement | Description |
| DISPLAY | Display output to the terminal |
| DELAY | Suspend execution for a duration |
| STOP | Terminate program execution |
| EXIT | Exit the program |
| RELEASE | Release a resource |
3.5 Built-in Functions
See also: Runtime Reference: 4.5 Built-in Functions for complete API documentation and implementation details
3.5.1 String Functions
| Function | Description |
| SUBSTR(s, pos, len) | Extract substring |
| LENGTH(s) | Get string length |
| INDEX(s, target) | Find substring position |
| VERIFY(s, chars) | Verify character membership |
| SEARCH(array, value) | Search array for value |
| SEARCHR(array, value) | Reverse search |
| TRANSLATE(s, to, from) | Character translation |
| TRIM(s) | Remove leading/trailing blanks |
| COPY(s, n) | Replicate string n times |
| REPEAT(s, n) | Repeat string |
| REVERSE(s) | Reverse a string |
| LOWERCASE(s) | Convert to lowercase |
| UPPERCASE(s) | Convert to uppercase |
| LOW(n) | Lowest character value |
| HIGH(n) | Highest character value |
| HEX(s) | Convert to hexadecimal representation |
| CHARACTER(x) | Convert to character string |
| STRING(s) | Concatenate structure elements |
3.5.2 Arithmetic Functions
| Function | Description |
| ABS(x) | Absolute value |
| ADD(x, y, p, q) | Addition with precision |
| CEIL(x) | Ceiling (round up) |
| FLOOR(x) | Floor (round down) |
| ROUND(x, n) | Round to n decimal places |
| TRUNC(x) | Truncate to integer |
| MOD(x, y) | Modulus |
| REM(x, y) | Remainder |
| SIGN(x) | Sign of number (-1, 0, +1) |
| MAX(x, y) | Maximum value |
| MIN(x, y) | Minimum value |
| MULTIPLY(x, y, p, q) | Multiplication with precision |
| DIVIDE(x, y, p, q) | Division with precision |
| PRECISION(x, p, q) | Set precision and scale |
3.5.3 Mathematical Functions
| Function | Description |
| SIN(x), COS(x), TAN(x) | Trigonometric functions |
| ASIN(x), ACOS(x), ATAN(x) | Inverse trigonometric |
| SINH(x), COSH(x), TANH(x) | Hyperbolic functions |
| LOG(x) | Natural logarithm |
| LOG2(x) | Base-2 logarithm |
| LOG10(x) | Base-10 logarithm |
| EXP(x) | e^x |
| SQRT(x) | Square root |
3.5.4 Array Functions
| Function | Description |
| DIM(array, n) | Get dimension size |
| HBOUND(array, n) | Get upper bound of dimension n |
| LBOUND(array, n) | Get lower bound of dimension n |
| ALL(array) | True if all elements are true |
| ANY(array) | True if any element is true |
| INLIST(value, list) | Check if value is in list |
| BETWEEN(x, low, high) | Check if x is in range [low, high] |
3.5.5 Conversion Functions
| Function | Description |
| DEC(x, p, q) | Convert to FIXED DECIMAL |
| DECIMAL(x, p, q) | Convert to FIXED DECIMAL |
| BINARY(x) | Convert to BINARY |
| FIXED(x, p, q) | Convert to FIXED |
| FLOAT(x) | Convert to FLOAT |
| UNSPEC(x) | Unspecified bit-string representation |
| REPATTERN(x, spec) | Repattern/convert data encoding |
| MEMCONVERT(tgt, src, ...) | Memory-level conversion (EBCDIC/ASCII) |
3.5.6 Storage and Pointer Functions
| Function | Description |
| ADDR(x) | Get address (pointer) of variable |
| NULL() | Null pointer value |
| SYSNULL() | System null pointer |
| SIZE(x) | Size of data item in bytes |
| STG(x) / STORAGE(x) | Storage occupied by variable |
| CSTG(x) | Current storage usage |
| ALLOCATION(x) | Allocation count of controlled variable |
| POINTERADD(p, n) | Add offset to pointer |
| POINTERDIFF(p1, p2) | Difference between two pointers |
| PTRADD(p, n) | Pointer addition (alias) |
3.5.7 Date/Time Functions
| Function | Description |
| DATE() | Current date |
| TIME() | Current time (HHmmss999) |
| DATETIME() | Current date/time timestamp |
| DAYS(date, pattern) | Convert date to Lillian day number |
| DAYSTODATE(n, pattern) | Convert Lillian day number to date string |
| SECS(time) | Convert time to seconds |
| SECSTODAYS(s) | Convert seconds to days |
3.5.8 Condition-Handling Functions
| Function | Description |
| ONCODE() | Condition code of current ON-unit |
| ONCHAR() | Character that caused CONVERSION condition |
| ONSOURCE() | Source string that caused CONVERSION condition |
| PLIRETV() | PL/I return value (last CALL return code) |
3.5.9 Miscellaneous Functions
| Function | Description |
| PROCNAME() | Name of current procedure |
| PACKAGENAME() | Name of current package |
| SOURCEFILE() | Name of source file |
| SOURCELINE() | Current source line number |
| PLIDUMP() | Dump diagnostic information |
| PLITDLI(args) | IMS DL/I call interface |