Kednos PL/I for UNIX

Reference Manual

April 1996

This manual defines Kednos PL/I for UNIX. It includes the keywords
and the semantic and syntax rules of PL/I programming language
statements, attributes, built-in functions, and other language elements.

 

 

 

Operating System and Version: Digital UNIX Version 3.2 or
higher

Software Version: Kednos PL/I for UNIX
Version 1.3



 

Kednos Corporation
Pebble Beach, California
Second Printing (Update), April 1996

Kednos Systems, Inc., makes no representations that the use of its products in the manner described in this publication will not infringe on existing or future patent rights, nor do the descriptions contained in this publication imply the granting of licenses to make, use, or sell equipment or software in accordance with the description.

Possession, use, or copying of the software described in this publication is authorized only pursuant to a valid written license from Kednos or an authorized sublicensor.

No responsibility is assumed for the use or reliability of software on equipment that is not listed as supported in the Product Description.

Restricted Rights: Use, duplication or disclosure by the U.S. Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013.

© Kednos Corporation, 1995, 1996, All Rights Reserved.

Kednos, Kednos PL/I, and Kednos VPO are trademarks of Kednos Corporation.

Alpha AXP, CDD, DEC,DEC 4000, DECwindows, Digital, OpenVMS AXP, ULTRIX, VAX, OpenVMS, VT102, VT220, VT240, VT320, VT330, VT340, and the DIGITAL logo are trademarks of Digital Equipment Corporation.

SAA and IBM are trademarks of International Business Machine Inc.

Stratus is a trademark of Stratus Computer Inc.

Kednos PL/I for UNIX includes the GNU readline and assembler software. See the Kednos PL/I for UNIX User's Manual for the entire text of the Free Software Foundation's GNU Copyleft.

Portions Copyright 1984-1990 FairCom Corporation. All Rights Reserved.

Kednos requests your critical evaluation to assist in preparing future documentation. Please send any comments to comments@Kednos.com or by physical mail to:

Kednos Corporation
1051 Rodeo Road
Pebble Beach, CA  93953

Preface xxiii

Intended Audience xxiii

Associated Documents xxiii

Conventions xxiv

Technical Assumptions xxv

Terminological Conventions xxv

Chapter 1 --

Program Structure and Content 1-1

Lexical Elements 1-1

Keywords 1-2

Punctuation 1-2

Identifiers 1-5

Comments 1-5

Statements 1-6

Statement Formats 1-7

Condition Prefixes (IBM Dialect Only) 1-7

Statement Labels 1-8

Simple Statements 1-8

Compound Statements 1-9

Preprocessor Statements 1-9

Summary of Statements by Function 1-9

Program Format 1-12

Blocks 1-13

Begin Blocks 1-15

Procedure Blocks 1-16

Containment 1-16

Block Activation 1-17

Relationship of Block Activations 1-17

Block Termination 1-20

Data and Variables 1-20

Preprocessor 1-21

Chapter 2 --

Declarations 2-1

DECLARE Statement 2-2

Simple Declarations 2-2

Declarations Outside Procedures 2-3

Multiple Simple Declarations 2-4

Factored Simple Declarations 2-4

Array Declarations 2-5

Structure Declarations 2-6

Attributes 2-7

ALIGNED Attribute 2-15

ANY Attribute 2-15

AREA Attribute 2-16

AUTOMATIC Attribute 2-17

BASED Attribute 2-17

BINARY Attribute 2-18

BIT Attribute 2-19

BUFFERED and UNBUFFERED Attributes (IBM Dialect Only) 2-20

BUILTIN Attribute 2-21

CHARACTER Attribute 2-22

CONDITION Attribute 2-23

CONTROLLED Attribute 2-23

DECIMAL Attribute 2-24

DEFINED Attribute 2-25

DIMENSION Attribute 2-26

DIRECT Attribute 2-27

ENTRY Attribute 2-28

ENVIRONMENT Attribute 2-30

EXTERNAL Attribute 2-33

FILE Attribute 2-34

FIXED Attribute 2-34

FLOAT Attribute 2-36

GLOBALDEF Attribute 2-36

GLOBALREF Attribute 2-37

INITIAL Attribute 2-37

INPUT Attribute 2-41

INTERNAL Attribute 2-42

KEYED Attribute 2-42

LABEL Attribute 2-43

LIKE Attribute 2-43

MEMBER Attribute 2-44

NONVARYING Attribute 2-44

OFFSET Attribute 2-44

OPTIONAL Attribute (Dec and Ansi Dialects Only) 2-45

OUTPUT Attribute 2-45

PARAMETER Attribute 2-46

PICTURE Attribute 2-46

POINTER Attribute 2-47

POSITION Attribute 2-47

PRECISION Attribute 2-48

PRINT Attribute 2-49

READONLY Attribute 2-49

RECORD Attribute 2-50

REFER Attribute 2-50

REFERENCE Attribute 2-50

RETURNS Attribute 2-51

SEQUENTIAL Attribute 2-52

STATIC Attribute 2-53

STREAM Attribute 2-53

STRUCTURE Attribute 2-54

TYPE Attribute 2-54

TRUNCATE Attribute 2-56

UNALIGNED Attribute 2-57

UNBUFFERED Attribute (IBM Dialect Only) 2-57

UNION Attribute 2-57

UPDATE Attribute 2-58

VALUE Attribute 2-59

VARIABLE Attribute 2-60

VARYING Attribute 2-60

Chapter 3 --

Data Types 3-1

Summary of Data Types 3-1

Declarations 3-2

Default Attributes 3-3

Attributes of Constants 3-4

Arithmetic Operands 3-5

Compatible Data Types 3-6

Arithmetic Data 3-8

Precision and Scale of Arithmetic Data Types 3-8

Fixed-Point Binary Data 3-9

Internal Representation of Fixed-Point Binary Data 3-10

Fixed-Point Decimal Data 3-11

Fixed-Point Decimal Constants 3-11

Fixed-Point Decimal Variables 3-12

Use in Expressions 3-12

Internal Representation of Fixed-Point Decimal Data 3-13

Floating-Point Data 3-13

Floating-Point Constants 3-14

Floating-Point Variables 3-14

Using Floating-Point Data in Expressions 3-15

Floating-Point Data Formats 3-15

IEEE S_floating Format 3-16

IEEE T_floating Format 3-17

Character Pictured Data 3-17

Character Picture Characters 3-18

Examples of Character Picture Variable Definitions 3-18

Numeric Pictured Data 3-19

Picture Characters 3-20

Picture Syntax 3-28

Examples 3-31

Assigning Values to Pictured Variables 3-32

Extracting Values from Pictured Data 3-33

Editing by Picture 3-34

The Internal Representation of Pictured Variables 3-34

Character String Data 3-36

Character String Constants 3-36

Replication of String Constants 3-37

Character-String Variables 3-37

Fixed-Length Character String Variables 3-38

Internal Representation of Fixed-Length Character Data 3-39

Varying-Length Character String Variables 3-39

Internal Representation of Varying Character Data 3-40

Alignment of Character Strings 3-40

Bit-String Data 3-40

Bit-String Constants 3-41

Replication Factor for Bit-String Constants 3-42

Bit-String Variables 3-43

Alignment of Bit-String Data 3-44

Internal Representation of Bit Data 3-45

Bit Strings and Integers 3-48

Pointer Data 3-49

Pointer Variables in Expressions 3-50

Internal Representation of Pointer Data 3-50

Offset Data 3-50

Label Data 3-51

Label Array Constants 3-52

Label Values 3-54

Label Variables 3-55

Internal Representation of Label Variables 3-56

Entry Data 3-57

Entry Constants 3-57

Entry Values 3-58

Entry Variables 3-58

Internal Representation of Entry Variables 3-59

File Data 3-60

File Constants 3-60

File Values 3-61

File Variables 3-61

Area Data 3-62

Area Variables in Expressions 3-63

Reading and Writing Areas 3-63

Internal Representation of Area Data 3-63

Condition Data 3-64

Chapter 4 --

Aggregates 4-1

Arrays 4-1

Array Declarations 4-1

References to Individual Elements 4-5

Initializing Arrays 4-6

Assigning Values to Array Variables 4-10

Order of Assignment and Output for Multidimensional Arrays 4-11

Using GET and PUT Statements with Array Variables 4-12

Passing Arrays as Arguments 4-12

Built-In Functions Providing Array Dimension Information 4-13

Structures 4-14

Structure Declarations and Attributes 4-14

Using The UNION Attribute On Structure Declarations 4-16

Initializing Structures 4-17

Using Structure Variables in Expressions 4-17

Passing Structure Variables as Arguments 4-18

Member Attributes 4-18

Using the TYPE Attribute 4-18

Using the LIKE Attribute 4-21

Using the REFER Option 4-23

Structure-Qualified References 4-27

Arrays of Structures 4-28

Arrays of Structures that Contain Arrays 4-29

Connected and Unconnected Arrays 4-30

Internal Representation of Aggregate Data 4-32

Chapter 5 --

Storage Classes 5-1

Automatic Variables 5-2

Static Variables 5-2

Internal Variables 5-3

External Variables 5-3

Based Variables 5-5

Data Types Used with Based Variables 5-6

Allocation in Areas 5-6

Referring to Based Variables 5-8

Based Variables and Dynamic Storage Allocation 5-10

Using the ADDR Built-in Function 5-13

Data-Type Matching for Based Variables 5-14

Matching by Overlay Defining 5-14

Matching by Left-to-Right Equivalence 5-15

Nonmatching Based Variable References 5-16

Examples of Based Variables 5-16

Controlled Variables 5-19

Using the ALLOCATION Built-In Function 5-20

Using the ADDR Built-In Function 5-21

Dynamically Allocated Variables 5-22

ALLOCATE Statement 5-22

FREE Statement 5-23

Other Mechanisms for Dynamic Storage Allocation 5-25

Defined Variables 5-25

String Overlay Defining 5-26

Rules for Overlay Defining 5-28

Storage Sharing 5-28

Chapter 6 --

Expressions and Data Type Conversions 6-1

Assignment Statement 6-1

Operators and Operands 6-4

Arithmetic Operators 6-5

Logical Operators 6-6

NOT 6-8

AND 6-8

OR 6-9

EXCLUSIVE OR 6-10

AND THEN 6-10

OR ELSE 6-11

Relational Operators 6-12

Arithmetic Comparisons 6-12

Bit-String Comparisons 6-13

Character-String Comparisons 6-13

Comparing Noncomputational Data 6-13

Concatenation Operator 6-14

Precedence of Operators and Expression Evaluation 6-15

Data Type Conversion of Operands and Expressions 6-17

Contexts in which PL/I Converts Data 6-18

Derived Data Types for Arithmetic Operations 6-21

Conversion of Operands in Nonarithmetic Operations 6-22

Built-In Conversion Functions 6-23

Implicit Conversion During Assignment 6-24

Assignment to Arithmetic Variables 6-25

Arithmetic to Arithmetic Conversions 6-25

Pictured to Arithmetic Conversions 6-27

Bit-String to Arithmetic Conversions 6-27

Character-String to Arithmetic Conversions 6-29

Assignments to Bit-String Variables 6-30

Arithmetic to Bit-String Assignments 6-30

Pictured to Bit-String Conversions 6-32

Character-String to Bit-String Conversions 6-33

Assignments to Character-String Variables 6-33

Arithmetic to Character-String Conversions 6-34

Pictured to Character-String Conversion 6-37

Bit-String to Character-String Conversion 6-37

Assignments to Pictured Variables 6-37

Conversions Between Offsets and Pointers 6-38

Chapter 7 --

Procedures 7-1

PROCEDURE Statement 7-2

Functions and Function References 7-4

ENTRY Statement 7-5

Specifying Entry Points 7-7

Multiple Entry Points 7-8

CALL Statement 7-9

Parameters and Arguments 7-10

Rules for Specifying Parameters 7-13

Argument Passing 7-15

Calling External and Internal Procedures 7-18

Terminating Procedures 7-20

Passing Arguments to Non-PL/I Procedures 7-22

Passing Arguments by Immediate Value 7-22

Passing Arguments by Reference 7-23

Chapter 8 --

Program Control 8-1

DO Groups and Statements 8-1

Simple DO 8-2

DO WHILE 8-3

DO UNTIL 8-4

DO REPEAT 8-6

Controlled DO 8-9

BEGIN Statement 8-13

END Statement 8-15

IF Statement 8-16

Nested IF Statements 8-17

SELECT Statement 8-18

The Two Forms of the SELECT Statement 8-19

OTHERWISE Clause 8-21

Nested SELECT Statements 8-21

GOTO Statement 8-22

LEAVE Statement 8-26

STOP Statement 8-28

Null Statement 8-29

Condition Handling 8-30

ON Statement 8-30

SIGNAL Statement 8-31

REVERT Statement 8-32

Summary of ON Conditions 8-34

ANYCONDITION Condition 8-37

AREA Condition 8-37

ATTENTION Condition (IBM Dialect Only) 8-37

CHECK Condition (IBM Dialect Only) 8-38

CONDITION Condition 8-39

CONVERSION Condition 8-39

ENDFILE Condition 8-42

ENDPAGE Condition 8-43

ERROR Condition 8-45

FINISH Condition 8-45

FIXEDOVERFLOW Condition 8-46

KEY Condition 8-47

NAME Condition (IBM Dialect Only) 8-49

OVERFLOW Condition 8-50

RECORD Condition (IBM Dialect Only) 8-50

SIZE Condition (IBM Dialect Only) 8-51

STRINGRANGE Condition 8-53

STRINGSIZE Condition (IBM Dialect Only) 8-55

SUBSCRIPTRANGE Condition 8-55

STORAGE Condition 8-56

TRANSMIT Condition (IBM Dialect Only) 8-56

UNDEFINEDFILE Condition 8-57

UNDERFLOW Condition 8-59

VAXCONDITION Condition 8-60

ZERODIVIDE Condition 8-60

Default PL/I ON-Unit 8-60

Using Condition Prefixes (IBM Dialect Only) 8-61

Scope of Condition Prefixes 8-61

Default Status of Conditions 8-62

Establishing ON-Units 8-63

Contents of an ON-Unit 8-64

Search Path for ON-Units 8-65

Completion of ON-Units 8-65

Chapter 9 --

Input and Output 9-1

Opening and Closing Files 9-1

File Declarations 9-2

File Variables 9-2

Opening a File 9-3

OPEN Statement Options 9-5

Effects of Opening a File 9-6

Establishing the File's Attributes 9-7

Determining the File Specification 9-8

Accessing an Existing File 9-9

Creating a File 9-9

File Positioning 9-10

File Description Attributes and Options 9-10

Closing a File 9-11

Stream I/O 9-12

Processing and Positioning of Stream Files 9-14

Input by the GET Statement 9-16

Syntax Summary of the GET Statement 9-16

GET EDIT 9-19

GET LIST 9