Enterprise PL/I For Z/OS Language Reference

Transcription

Enterprise PL/I for z/OSPL/I for AIXEnterprise PL/I for z/OSIBMLanguage ReferenceVersion 5 Release 1SC27-8940-00

Enterprise PL/I for z/OSPL/I for AIXEnterprise PL/I for z/OSIBMLanguage ReferenceVersion 5 Release 1SC27-8940-00

NoteBefore using this information and the product it supports, be sure to read the general information under “Notices” on page673.First Edition (August 2017)This edition applies to Enterprise PL/I for z/OS, Version 5 Release 1 (5655-PL5), IBM PL/I for AIX, Version 3Release 1 (5724-H45), and Rational Developer for System z PL/I for Windows, Version 9.1, and to any subsequentreleases of any of these products until otherwise indicated in new editions or technical newsletters. Make sure youare using the correct edition for the level of the product.Order publications through your IBM representative or the IBM branch office serving your locality. Publications arenot stocked at the address below.A form for readers' comments is provided at the back of this publication. If the form has been removed, addressyour comments to:IBM Corporation, Department H150/090555 Bailey Ave.San Jose, CA, 95141-1099United States of AmericaWhen you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in anyway it believes appropriate without incurring any obligation to you. Copyright IBM Corporation 1999, 2017.US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contractwith IBM Corp.

ContentsTables . . . . . . . . . . . . . . . xiiiFigures . . . . . . . . . . . . . . xvAbout this book . . . . . . . . . . xviiNotation conventions used in this book . . . . xviiSemantics . . . . . . . . . . . . . . . xixIndustry standards used . . . . . . . . . . xxSummary of changes . . . . . . . . . . . xxEnhancements in this release . . . . . . . xxEnhancements from V4R5 . . . . . . . . xxivEnhancements from V4R4 . . . . . . . . xxivEnhancements from V4R3 . . . . . . . . xxvEnhancements from V4R2 . . . . . . . . xxviEnhancements from V4R1 . . . . . . . . xxviEnhancements from V3R9 . . . . . . . . xxviEnhancements from V3R8. . . . . . . . xxviiEnhancements from V3R7 . . . . . . . xxviiiEnhancements from V3R6 . . . . . . . xxviiiEnhancements from V3R5 . . . . . . . . xxixEnhancements from V3R4 . . . . . . . . xxixEnhancements from V3R3 . . . . . . . . xxixEnhancements from V3R2 . . . . . . . . xxixEnhancements from V3R1 . . . . . . . . xxxHow to send your comments . . . . . . . . xxxiAccessibility . . . . . . . . . . . . . xxxiiChapter 1. Program elements . . . . . 1Single-byte character set . . .Decimal digits . . . . . .Binary digits . . . . . .Hexadecimal digits . . . .Special characters . . . . .Composite symbols . . . .Case sensitivity . . . . .Statement elements for SBCS .Statements . . . . . . . .Simple statements . . . .Compound statements. . .Groups . . . . . . . . .Double-byte character set . . .DBCS identifiers . . . . .Statement elements for DBCSDBCS continuation rules . . 1. 3. 3. 3. 3. 4. 5. 5. 8. 10. 10. 11. 11. 12. 13. 13Chapter 2. Data elements . . . . . . . 15Data items. . . . . .Variables . . . . .Constants . . . . .Using quotation marksPunctuating constants .Data types and attributes .Data attributes . . .Nondata attributes . . Copyright IBM Corp. 1999, 2017.1515161616171818Computational data types and attributesCoded arithmetic data and attributes .String data and attributes. . . . .Program-control data types and attributesLabel data and LABEL attribute . .Format data and FORMAT attribute .VARIABLE attribute . . . . . .22223046474849Chapter 3. Expressions and references 51Order of evaluation. . . .Targets . . . . . . . .Variables . . . . . .Pseudovariables . . . .Intermediate results . .Operational expressions . .Handle operations . . .Pointer operations . . .Arithmetic operations . .Bit operations. . . . .Comparison operations .Concatenation operations .Combinations of operationsPriority of operators . .Array expressions . . . .Prefix operators and arraysInfix operators and arraysStructure expressions . . .Restricted expressions . . .53545454545555565765676970707272737474Chapter 4. Data conversion . . . . . . 77Built-in functions for computational data conversionConverting string lengths. . . . . . . . . .Converting arithmetic precision. . . . . . . .Converting mode . . . . . . . . . . . .Converting other data attributes . . . . . . .Source-to-target rules . . . . . . . . . . .Examples . . . . . . . . . . . . . . .Example: DECIMAL FIXED converted toBINARY FIXED with fractions . . . . . . .Example: Arithmetic converted to bit string . .Example: Arithmetic converted to character. . .Example: A conversion error. . . . . . . .7879798080818989899090Chapter 5. Program organization . . . 91Programs . . . . . . . . . . . . . . . 91Program structure . . . . . . . . . . . 91Program activation . . . . . . . . . . . 92Program termination . . . . . . . . . . 93Blocks . . . . . . . . . . . . . . . . 93Block activation . . . . . . . . . . . . 93Block termination . . . . . . . . . . . 94Packages . . . . . . . . . . . . . . . 94Procedures . . . . . . . . . . . . . . 97PROCEDURE statement . . . . . . . . . 98ENTRY statement . . . . . . . . . . . 100iii

Parameter attribute . . . . . . . .Procedure activation . . . . . . . .Procedure termination . . . . . . .Recursive procedures . . . . . . . .Dynamic loading of an external procedureSubroutines . . . . . . . . . . . .Example 1 . . . . . . . . . . .Example 2 . . . . . . . . . . .Built-in subroutines . . . . . . . . .Functions . . . . . . . . . . . . .Examples . . . . . . . . . . . .Built-in functions . . . . . . . . .Passing arguments to procedures . . . . .Using BYVALUE and BYADDR . . . .Using INONLY, INOUT and OUTONLY .Dummy arguments . . . . . . . .Passing arguments to the MAIN procedureBegin-blocks . . . . . . . . . . . .BEGIN statement . . . . . . . . .Begin-block activation . . . . . . .Begin-block termination . . . . . . .Entry data . . . . . . . . . . . .Entry constants . . . . . . . . . .Entry variables . . . . . . . . . .ENTRY attribute . . . . . . . . .OPTIONAL attribute . . . . . . . .LIST attribute . . . . . . . . . .LIMITED attribute. . . . . . . . .Generic entries . . . . . . . . . .GENERIC attribute . . . . . . . .Entry invocation or entry value . . . . .CALL statement . . . . . . . . . .RETURN statement . . . . . . . . .Return from a subroutine . . . . . .Return from a function . . . . . . .OPTIONS option and attribute . . . . .RETURNS option and attribute . . . . 134134135144Chapter 6. Type definitions . . . . . 147User-defined types (aliases). . . . . . . . .DEFINE ALIAS statement . . . . . . . .Defining ordinals . . . . . . . . . . . .DEFINE ORDINAL statement . . . . . . .Defining typed structures and unions . . . . .HANDLE attribute . . . . . . . . . .Declaring typed variables . . . . . . . . .TYPE attribute . . . . . . . . . . . .ORDINAL attribute . . . . . . . . . .Typed structure qualification . . . . . . . .Using the period operator (.) . . . . . . .Combinations of arrays and typed structures orunions. . . . . . . . . . . . . . .Using handles . . . . . . . . . . . .Using ordinals . . . . . . . . . . . . .Type functions . . . . . . . . . . . . ter 7. Data declarations . . . . . 161Explicit declaration . .DECLARE statement .Factoring attributes .iv.Enterprise PL/I for z/OS Language Reference. 161. 162. 163Implicit declaration . . . . . . . . . .Scope of declarations . . . . . . . . . .INTERNAL and EXTERNAL attributes . . .RESERVED attribute . . . . . . . . . .FORCE attribute . . . . . . . . . . .SUPPRESS attribute . . . . . . . . . .Data alignment . . . . . . . . . . . .ALIGNED and UNALIGNED attributes . .Defaults for attributes . . . . . . . . .Language-specified defaults . . . . . .DEFAULT statement . . . . . . . . .Restoring language-specified defaults . . .Arrays. . . . . . . . . . . . . . .DIMENSION attribute . . . . . . . .DIMACROSS attribute . . . . . . . .Examples of arrays . . . . . . . . .Subscripts . . . . . . . . . . . .Cross sections of arrays . . . . . . . .Structures and unions . . . . . . . . .Structures . . . . . . . . . . . .Unions . . . . . . . . . . . . .Structure and union qualification . . . . .Assignments to UNIONs . . . . . . .LIKE attribute . . . . . . . . . . .INDFOR attribute . . . . . . . . . .NOINIT attribute . . . . . . . . . .NULLINIT attribute . . . . . . . . .XML-related attributes . . . . . . . .JSON-related attributes . . . . . . . .Aggregate combinations and mapping . . . .Combinations of arrays, structures, and unionsCross sections of arrays of structures or unionsStructure and union operations . . . . .Structure and union mapping . . . . . 88190190190191193194195197198198198199200200201. 201. 201Chapter 8. Statements and directives213ALLOCATE statement . . . . . . . . . .ASSERT statement. . . . . . . . . . . .Assignment and compound assignment statementsAssignment statements . . . . . . . . .Assignment statements that use the BYDIMACROSS option . . . . . . . . . .Compound assignment statements . . . . .Target variables . . . . . . . . . . .How assignments are performed . . . . . .Multiple assignments . . . . . . . . . .Examples . . . . . . . . . . . . . .ATTACH statement . . . . . . . . . . .BEGIN statement . . . . . . . . . . . .CALL statement . . . . . . . . . . . .CANCEL THREAD statement . . . . . . . .CLOSE statement . . . . . . . . . . . .DECLARE statement . . . . . . . . . . .DEFINE ALIAS statement . . . . . . . . .DEFINE ORDINAL statement . . . . . . . .DEFINE STRUCTURE statement . . . . . . .DEFAULT statement . . . . . . . . . . .DELAY statement . . . . . . . . . . . .DELETE statement . . . . . . . . . . .DETACH statement . . . . . . . . . . .DISPLAY statement . . . . . . . . . . 26226226226227227227228

DO statement . . . . . . . . .Type 1. . . . . . . . . . .Types 2 and 3 . . . . . . . .Type 4. . . . . . . . . . .Examples of basic repetitions . . .Example of DO with WHILE, UNTILExample of DO with UPTHRU andDOWNTHRU . . . . . . . .Example of REPEAT . . . . . .END statement . . . . . . . . .ENTRY statement . . . . . . . .EXIT statement . . . . . . . . .FETCH statement . . . . . . . .FLUSH statement . . . . . . . .FORMAT statement . . . . . . .FREE statement . . . . . . . .GET statement . . . . . . . . .GO TO statement . . . . . . . .IF statement . . . . . . . . . .Examples . . . . . . . . . .Short-circuit evaluation . . . . .%INCLUDE directive. . . . . . .ITERATE statement . . . . . . .LEAVE statement . . . . . . . .%LINE directive . . . . . . . .LOCATE statement . . . . . . .%NOPRINT directive. . . . . . .%NOTE directive . . . . . . . .null statement . . . . . . . . .ON statement . . . . . . . . .OPEN statement . . . . . . . .OTHERWISE statement . . . . . .PACKAGE statement . . . . . . .%PAGE directive . . . . . . . .%POP directive. . . . . . . . .%PRINT directive . . . . . . . .PROCEDURE statement . . . . . .%PROCESS directive . . . . . . .*PROCESS directive . . . . . . .%PUSH directive . . . . . . . .PUT statement . . . . . . . . .READ statement . . . . . . . .REINIT statement . . . . . . . .RELEASE statement . . . . . . .RESIGNAL statement. . . . . . .RETURN statement . . . . . . .REVERT statement . . . . . . .REWRITE statement . . . . . . .SELECT statement. . . . . . . .SIGNAL statement . . . . . . .%SKIP directive . . . . . . . .STOP statement . . . . . . . .WAIT statement . . . . . . . .WHEN statement . . . . . . . .WRITE statement . . . . . . . .%XINCLUDE statement . . . . . .XPROCEDURE statement . . . . 56256256256257257257Chapter 9. Storage control . . . . . . 259Storage classes, allocation, and deallocation .Static storage and attribute . . . . . . . 259. 260Automatic storage and attribute . . . . . .Controlled storage and attribute . . . . . .ALLOCATE statement for controlled variablesFREE statement for controlled variables . .Multiple generations of controlled variables .Asterisk notation . . . . . . . . . .Adjustable extents . . . . . . . . . .Built-in functions for controlled variables . .Based storage and attribute. . . . . . . .Extent specifications in BASED declarations .BASED VARYING string . . . . . . .Storage allocation for BASED variable . . .Locator variables . . . . . . . . . .DEFINED and UNION attributes . . . . .INITIAL attribute . . . . . . . . . .Locator data . . . . . . . . . . . .POINTER variable and attribute . . . . .Built-in functions for based variables . . .ALLOCATE statement for based variables . .FREE statement for based variables . . . .REFER option (self-defining data) . . . .Area data and attribute . . . . . . . . .Offset data and attribute . . . . . . .LOCATES attribute . . . . . . . . .Built-in functions for area variables . . . .Area assignment . . . . . . . . . .Input/output of areas . . . . . . . .List processing . . . . . . . . . . . .ASSIGNABLE and NONASSIGNABLE attributesNORMAL and ABNORMAL at

A form for eaders' comments is r ovided at the back of this publication. If the form has been pr emoved, r address your comments to: IBM Corporation, Department H150/090 555 Bailey Ave. San Jose, CA, 95141-1099 United States of America When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in any way it believes appropriate without incurring .