• Aucun résultat trouvé

IBM System/360

N/A
N/A
Protected

Academic year: 2022

Partager "IBM System/360 "

Copied!
379
0
0

Texte intégral

(1)

Systems Refelaence Library

IBM System/360

PL/I ReferencI3 Manual

This publication provides the rules for writing PL/I programs that are to be com- piled using the! PL/I (F) Compiler under the IBM System/360 Operating System.

File No. S360-29 Form C28-8201-1

OS

(2)

Second Edition (March 1968)

This edition, C28-8201-1, obsoletes the previous edition, C28-8201-0.

Chapters 14 and 15 are completely new and should be reviewed in their entirety: other changes are indicated by a vertical line to the left of the changed text, while changes to illustrations are indicated by the symbol • to the left of the caption.

Specifications contained herein are subject to change from time to time.

Any such change will be reported in subsequent revisions or Technical Newsletters.

This publication was prepared for production using an IBM update the text and to control the page and line impressions for photo-offset printing were obtained from Printer using a special print chain.

computer to format. Page an IBM 1403

A form is provided at the back of this publication for reader's comments. If the form has been removed, comments may be addressed to IBM United Kingdom Laboratories Ltd., Programming Publications, Hursley Park, Winchester, Hampshire, England.

C International Business Machines Corporation 1967, 1968

(3)

PREFACE

This publication is planned for use as a reference book by the PL/I programmer. It is not intended to be a tutorial publica- tion, but is designed for the reader who already has a knowledge of the language and who requires a source of reference materi- al.

It is divided into two parts.

contains discussions of concepts language. Part II contains dE~tailed

and syntactic descriptions.

Part I of the

rules

Al though implementation :Lnformation is included, the book is not a complete des- cription of any implementation environment.

In general, i t contains infOll::mation needed in writing a program; i t does not contain all of the information required to ~~cute a program.

The following features, discussed in this publication., are impl'emented in the fourth version of the F Compiler but are not implemented in the third v'ersion:

• Based storage facilities:

The BASED, POINTER, AREA, and OFFSET attributes;

The ADDRf NULL. NULLO, and EMPTY built- in functions;

The AREA condition;

Area-to-area assignment;

and The LOCATE statement;

locator-to-Iocator

The IN option on the ALLOCATE and FREE statements;

The SET option on the RE~J), LOCATE" and ALLOCATE statements;

The REFER option in a l~sed structure declaration;

The pointer qualification symbol.

• Multitasking facilities:

The TASK, EVENT, and PRIORITY options on the CALL statement;

The EVENT option on the DISPLAY state- ment with the REPLY option;

The TASK option in the OPTIONS list;

The TASK attribute;

Explicit declaration of event varia- bles;

The use of event arrays in the WAIT statement, and the use of an expression specifying the number of events to be waited for;

The STATUS and PRIORITY built-in func- tions and pseudo-variables;

The EXCLUSIVE file attribute;

The UNLOCK statement;

The NOLOCK option on the READ state- ment.

• Data interchange: the COBOL option in the ENVIRONMENT attribute •

• Carriage control: the CTLASA and CTL360 options in the ENVIRONMENT attribute.

• The STRINGRANGE condition.

• Omission of the data list from a data- directed PUT statement.

• Use of the LINESIZE option for any stream output file; use of the SKIP option and the COLUMN and SKIP format items, in GET statements for stream input files.

• Use of VARYING strings in the INTO and FROM options of record-oriented input/output statements.

• Omission of the KEY option from the DELETE statement (to allow deletion from SEQUENTIAL UPDATE files for INDEXED data sets).

REQUISITE PUBLICATION

For information necessary to compile, linkage edit, and execute a program, the reader should be familiar with the following publication:

IBM System/360 Operating system, PL/I (F) Programmer's Guide, Form C28-6594

(4)

~ECOM~ENDED PUBLICATIONS

']~he following publications contain other information that might be valuable to the PL/I programmer or to a programmer ~ho is learning PL/:

~ PL/I Primer, Form C28-6808

A Guide to PL/I for Commercial Proqram-

~ers; Form C20-1651

A Guide to PL/I for FORTRAN Users" Form C20-1637

(5)

CONTENTS

CHAPTER 1: BASIC CHARACTERISTICS OF PL/I • • •

Machine Independence Program Structure. • ,Mul tiprogramming • •

Data Types and Data Description. • Default Assumptions.

Storage Allocation • Expressions. • • Data Collections Input and Output

Compile-Time Operations. • Interrupt Activities • • • CHAPTER 2: PROGRAM ELEMENTS • • Character Sets • • •

60-Character Set.

48-Character set.

Using the Character Set Identifiers • • • The Use of Blanks. • Comments...

Basic Program Structure.

Simple and compound Sta-tement,s.

Statement Prefixes • • • • • Groups and Blocks • • •

CHAPTER 3: DATA ELEMENTS • • Data Types • • • • •

Problem Data • • • • • Arithmetic Data •

Decimal Fixed-Point Data sterling Fixed-Point Data. • Binary Fixed-Point Data. • • Decimal Floating-Point Data. . Binary Floating-Point Data Complex Arithmetic Data.

Numeric Character Data String Data • • • •

Character-String Data.

Bit-String Data. • • • • • Program Control Data

Label Data. • • • • • • Event Data • •

Task Data • • • • Locator Data.

• 19 19

• 19 19

• 19

• • 20

• 20

• 20

• 21

• 21

• • 21

• • 22

• 23

• 23

• 23

• 23

• 24

• 25

• 25

• 25

• 26

• 26

• 26

• 27

• 28

• 28

• 28

• 28

• 29

• 30

• 30 31

• 31

• 32

• 32

• 33

• 34

• 35

• 35

• 35

• 36

• 36

• 36

CONTENTS

Area Data . • • •

Data Organization. • • • • •

Arrays. • • • • • • • • Expressions as Subscripts.

Cross Sections of Arrays Structures. • • •

Qualified Names • • • • Arrays of Structures.

• 37

• 37 37

• 38

• 39 39

• 40

• 40 other Attributes • • • • • 41 The DEFINED Attribute. • 41 The LIKE Attribute • • • • • • • • 42 The ALIGNED and PACKED

Attributes. • • • • '. • • • • • • 42 The INITIAL Attribute. • • • 42 CHAPTER 4: EXPRESSIONS. • 44

Use of Expressions • 44

Data Conversion in Operational

Expressions • • • • . • • • • • • 45 Problem Data Conversion • • • • • • • 45 Bit-String to Character-String • • 45 Character-String to Bit-String • • 45 Character-String to Arithmetic • • 45 Arithmetic to Character-String • • 45 Bit-String to Arithmetic • • 46 Arithmetic to Bit-String • • 46 Arithmetic Mode Conversion • • 46 Arithmetic Base and Scale

• 46 Conversion. • • • • •

Locator Data Conversion • Offset to Pointer.

Pointer to Offset. •

• • • • • • 46

• • • • • • 46

Conversion by Assignment Expression Operations • •

Arithmetic Operations

• 46

• 46

• 46

• 46 Data Conversion in Arithmetic

Operations. • • • • • . • • • • • 47 Results of Arithmetic Operations • 47 Bit-String Operations • • • • • 49 Comp?rison Operations • • • • • 50 Concatenation Operations. • • • 51 Combinations of Operations.. • 51 Priority of Operators. • • • 52 Array Expressions • • • • • • • •

Prefix Operators and Arrays • • • . Infix Operators and Arrays • •

Array and Element Operations Array and Array Operations • Array and Structure Operations . Data Conversion in Array

Expressions • • •

structure Expressions. • • • • • • Prefix operators and Structures • Infix Operators and Structures.

4 53

• 53 53

• 53

• 54

• 54

• 54

• 54 55

• 55

(6)

structure and Element Operations . 55 Structure and structure

Operations. • • • • • • • • • 55 structure Assignment BY NAME • • • 55 Operands of Expressions. • • • • • 56 Function Reference Operands • • • 56 concepts of Data Conversion. • • • 57 Target A'ttributes for Type Conversion. • 58

Bit to Character and Character to

Bit. • • • • • • • • • • 58 Arithmetic to String. • • • • • • • • 58 string to Arithmetic. • • • • • . • • 58

Target Attributes for Arithmetic Expression Operands • • • • • 59 Precision and Length of

Expression Operand Targets. • 59 Precision for Arithmetic

Conversions • • • • • • • • . 60 Lengths of Character-String

Targets • • • • • • • . • • • 61 Lengths of Bit-String Targets. • • 61 Conversion of the Value of an

Expression. • • • • • 61 Conversion Operations. • • 61 The CONVERSION, SIZE, FIXEDOVERFLOW,

and OVERFLOW Conditions • • • • • • • • 62 CHAPTER 5: STATEMENT CLASSIFICATION. • • 64 64

• 64 Classes of Statements. • • • •

Descriptive Statements. •

The DECLARE statement. • • 64 Other Descriptive Statements

Input/Output Statements • • • • RECORD I/O Transfer Statements • STREAM I/O Transfer Statements • Input/Output Control Statements.

The DISPLAY Statement. • • • • Data Movement and Computational

Statements • • • • • • • • The Assignment Statement • The STRING Option. • • Control Statements. • • •

The GO TO Statement.

The IF Statement • • • • • • • • The DO Statement • •

Noniterative DO Statements • The CALL, RETURN, and END

statements. • • • • • • • • The STOP and EXIT Statements

• 64

• 65

• 65

• 65

• 66 66

• 66

• 66

• 67

• 67

• 67

• 68

• 68

• 69

• 69

• 70

• 70 Exception Control Statements. •

The ON Statement • • • • • • 70 The REVERT Statement • • • •

The SIGNAL Statement • • • • • Program Structure Statements. •

The PROCEDURE Statement.

The ENTRY Statement. • The BEGIN Statement. • • The DO Statement • • • • •

• 70 71

· 71

• 71

• 71

• 72 72 The ALLOCATE and FREE Statements • 72 CHAPTER 6: BLOCKS, FLOW OF CONTROL,

AND STORAGE ALLOCATION. • • • • • • • • 73

Blocks • • _ • • • • . • • • • • • 73

Procedure Blocks. • 73

Begin Blocks. • • • • • • . • 73 Internal and External Blocks. . • 74

Use of the END Statement with Nested Blocks and DO-GrOups

(Multiple Closure) • • • • • • • • 74 Activation and Termination of Blocks • • 75 Activation. • • • . • • • 75 Termination • . • • • • • 77 Begin Block Termination. • • • 77 Procedure Termination. • • • • • • 77 Program Termination. • • • • • • • 78 Storage Allocation. • • . • 78 Static Storage • • • • • 79

Automatic Storage. • 79

Controlled storage • • 79 Based storage. • • • • • • • • 80 Reactivation of an Active Procedure

(Recursion) • • • • • • • • • • • • • • 80 Effect of Recursion on Storage

Classes • • • • • • 81 Prologues and Epilogues.

Prologues.

Epilogues. • • • •

• 81

• 81

• 81 CHAPTER 7: RECOGNITION OF NAMES • . . 83 Explicit Declaration • • • • • • • • 83 Scope of an Explicit Declaration. • • 84 contextual Declaration • • • • • • • • • 84 Scope of a Contextual Declaration • • 85 Implicit Declaration • • • 85 Examples of Declarations . 85 Application of Default Attributes. • 86 The INTERNAL and EXTERNAL Attributes • • 87 Multiple Declarations and Ambiguous

References. • • • • • • • 88 CHAPTER 8: INPUT AND OUTPUT. • 89 Types of Data Transmission • • 89 Files. • • • • • • • • • • 90 File Attributes • • • • • • • • • 90 The FILE Attribute • • • • • • 90 Alternative and Additive

Attributes. • • • • • • • • • • • 90 Alternative Attributes • • 91 The STREAM and RECORD Attributes • 91 The INPUT, OUTPUT, and UPDATE

Attributes. • • • • • • The SEQUENTIAL and DIRECT

Attributes. • • • • • • The BUFFERED and UNBUFFERED

Attributes. '. • • • •

Additive Attributes • • • • • • . The PRINT Attribute. • • • • • ., The BACKWARDS Attribute. • • • .'

• 91

• 91

• 91

• 92

• 92

• 92

(7)

The KEYED Attribute. • • • • The EXCLUSIVE Attribute. • • The ENVIRONMENT Attribute. • Opening and Closing Files •

92

• 92

• 92

• 92

• 93

• 93 The OPEN Statement • •

Implicit Opening • • • • • Merging of Attributes.

Associating Data Sets with The CLOSE Statement. • • •

• 93 Files • 94

• • 96 Layout of STREAM Files • • •

Page Layout For Print Files • • Standard Files. • • • • • • • • • Environmental Considerations for Data

Sets. • • • • • • • •

Device Independence of Input and Output Statements. • • . • • •

The ENVIRONMENT Attribute. • Record Format. • • •

Data Set Positioning • Buffer Allocation. • •

• 96

• 96 97

• 97

• 98

· 98

• 98

• 99

• 99

• 99 Data Set Organization.

Carriage control • • • • • Data Interchange • • • • • •

• .104 .105 Data Transmission. • • •

stream-Oriented Transmission • • List-Directed Transmission • Data-Directed Transmission • Edit-Directed Transmission • Data Specifications for Stream

Transmission • • • • • • • • • Data Lists • • • • • • • • • Repetitive Specification • Transmission of Data-List

Elements. • • • • • • • • • List-Directed Data Specification. •

List-Directed Data in the Stream List-Directed Input Format • • • List-Directed Output Format. • • Data-Directed Data Specification. • Data-Directed Data in the Stream Data-Directed Input Format • • • Data-Directed output Format. • • Length of Data-Directed Output

.105 .105 .106 .106 .106 .106 .106

• 107 .108 .109 .109 .109 .109 .110 .110

• 111 .111 Fields • • • • • • • • • • • • • . 112 Edit-Directed Data Specification • • • 112 Format Lists • • • • • • • • • • • 114 Stream-Oriented Data Transmission

Statements • • • • • • • .117 Record-Oriented Transmission. • .117

Record-Oriented Data Transmission

Statements • • • • • • • • • .118 Options of Record-Oriented

Transmission Statements. .118 Record-Oriented Transmission

Statement Formats • • • • • .121 Summary of Record-Oriented

Transmission. • • .123

Examples of Declarations for RECORD

Files. • • • • • • • • • • • • 124 CHAPTER 9: EDITING AND STRING

HANDLING • • • • 125

Editing by Assignment • • • • • • • • • • 125 Altering,the Length of String Data • • 125 Other Forms of Assignment • • • _ • • 126 Input and Output Operations • • 126 The STRING Option in GET and PUT

Statements. • • • • • • • • .126 The Picture Spe9ification • • • • • • 127

Character-String Picture

Specifications • • • • • • • • • 127 Numeric Character Picture

Specifications • • • • • • • • • 128 Values of Numeric Character

Variables. • • • • • • • • .128 Editing Numeric Character Data • • 129 Using Numeric Character Data • • • 130 Bit-String Handling • • • • • • .131 Character-String and Bit-String

Built-In Functions • • • • • • .132 CHAPTER 10: SUBROUTINES AND FUNCTIONS • • 134 Arguments and Parameters .134

Subroutines. • • .135

Functions. • • • • • • .136 Attributes of Returned Values • • • 137 Built-In Functions • • • • • • • • 138 Relationship of Arguments and

Parameters. • • . . . • .140

, ,flO

Dummy Arguments • • • • • • • • • • The ENTRY Attribute • • • • • .140

• • • 141 .143 .143 Entry Names as Arguments • •

Allocation of Parameters. • •

Parameter Bounds and Lengths • • Simple Parameter Bounds and

Lengths • • • • • • • • • • • • • 143 Controlled Parameter Bounds and

Lengths • • • • • • • • • • .143 Argument and Parameter Types. • .144 Generic Names and References . • • .145 CHAPTER 11: EXCEPTIONAL CONDITION

HANDLING AND PROGRAM CHECKOUT • • • • • 147 Enabled Conditions and Established

Action. • • • • • • • • • • • • • 147 Condition Prefixes • • • • • • • • 147 Scope of the Condition Prefix • • • 147 The ON Statement • • • • .148 The Null On-Unit. • • .148 Scope of the ON Statement. • .149 The REVERT Statement. • • • .149 The SIGNAL Statement • • • • • • • 149 The CONDITION Condition. • • .149 The CHECK Condition. • • • .150 The SUBSCRIPTRANGE Condition • • • 150 The STRINGRANGE Condition. • .150 Condition Built-In Functions and

Condition Codes • • • • • • • • • 150 Example of Use of ON-Conditions • • .151 CHAPTER 12: COMPILE-TIME FACILITIES • • • 154 Introduction • • • • • • .154

(8)

Preprocessor Input and Output • • • • • • 154 Preprocessor Scan • • • • • • • • • • 154 Rescanning and Replacement. .155 Preprocessor Variables •

Preprocessor Expressions • Preprocessor Procedures.

Invocation of Preprocessor Procedures • • , • • • • • • • Arguments and Parameters for

Preprocessor Functions • • • • Returned Value • • • • • • • • Use of the SUBSTR Built-In

F'unction.

The Preprocessor DO-Group.

Inclusion Of External Text •

.156 .157 .157 .157 .158

• .159

• .160 .160 .160 Preprocessor Statements. • • • • • • 161 CHAPTER 13: EFFICIENT PERFORMANCE .163 Efficient Performance and Data

Conversion. • • • • • • • • • .163 Adjustable Bounds and String Lengths • • 163 VARYING String Lengths • .163 Blocks and Groups. • • • .163 The PACKED and ALIGNED Attributes. .163 The Use of the PICTURE Attribute • • • • 164 CHAPTER 14: BASED STORAGE AND LIST

PROCESSING. • .165

Introduction • • .165

Based Variables and Pointer Variables. .166 Pointer Qualification. • .166 Rules and Restrictions. • .166

Pointer Defining .167

Self-Defining Data. • • • • • • .167 The REFER Option. • .167 Pointer Setting, Based Storage

Allocation, and Input/Output. • Read with Set • • • • • • • •

I~oca te with and without Set • • Allocate with and without Set.

Pointer Assignment. • • • • • • The ADDR Built-in Function • rrhe NULL Built-in Function • Freeing Based Storage. •

Th~ Free Statement.

Implicit Freeing.

Areas and Offsets.. • • • •

.168 .168 .168 .169 .169 .169

• .• .170 .170 .170 .• .170 Area Variables. • • • • • • •

.171

• • 171 .171 .172

• • • 172 Rules and Restrictions • •

Offset Variables. • • • • Rules and Restrictions •

Allocation within an Area • • • • . setting Offset Values • • • • • • .

The NULLO Built-in Function.

Area Assignment and Input/output. . The EMPTY Built-in Function.

The AREA ON-Condition.

Input and Output • • • • • • Area and Offset Defining • • • •

• 172 .172 .173 .173 .173 .173 .174 .174 communication between Procedures. .174 Arguments and Parameters • • • • • • • 174 Pointer to Pointer. • .174 Offset to Pointer. • • • • • • 175

Offset to Offset. .175

Pointer to Offset. • • • • • • 175 Area to Area. • • .175 Returns from Entry Points • • • • • • 175 Locator Returns. • • • • • • .. . .175 Area Returns • • • • • • • • • • • 176 Variable Length Parameter Lists • • • 176 Examples of List Processing Technique • • 177 CHAPTER 15: MULTITASKING .180 Introduction • • • • • • 180 Creation of Tasks • • • • .181

The Call Statement. • The TASK Option. • The EVENT Option •

• • • • . .181

• • • • • • • .181 The PRIORITY Option. •

Priority of Tasks • • •

• • • • • .182

• • • • • .182 .182 Coordination and Synchronization of

Tasks. • • • • • • • • • • • • .183 Sharing Data between Tasks. • .183 Sharing Files between Tasks. .184 The EXCLUSIVE Attribute. • .184

The Wait Statement. .185

Testing and Setting Event Variables. .185 The Delay Statement • • • • • • • • • 186

Termination of Tasks .186

Programming Example. .187

CHAPTER 16: A PL/ I PROGRAM .• .191 SECTION A: SYNTAX NOTATION. • • 197 SECTION B: CHARACTER SETS WITH EBCDIC

AND CARD-PUNCH CODES. • • • • • • • 199 6 O-Char acter Set. • • • • • .199 48-Character Set. • • • • • • • • 200 SECTION C: KEYWORDS AND KEYWORD

ABBREVIATIONS • • • • • • • • • • • • • 201 SECTION D: PICTURE SPECIFICATION

CHARACTERS. • • • • • • • • • • • • 205 Picture Characters for

Character-String Data

Picture Characters For Numeric

'. • • • .205 Character Data. • • • • • • • • 206 Digit and Decimal-Point Specifiers • • 207

(9)

Zero Suppression Characters • • • • • 207 Insertion Characters. • • • • • .209 Signs And Currency Symbol. • • .210 Credit, Debit, And overpunched

Signs. • • • • • • • • • • • .212 .213 .214 .214 Exponent Specifiers •

Scaling Factor. • • • • • • • • sterling Pictures • • • • • •

SECTION E: EDIT-DIRECTED FORMA.T ITEMS .216 Data Format Items.

. ·

.216

Control Format Items

. . . ·

.216

Spacing Format Item.

· · · · .

.217

Remote Format Item

. · · · ·

.217

Use of Format Items.

· · · ·

.217

ALPHABETIC LIST OF FORMAT ITEMS • • The A Format Item. • • • •

.217 .217 .217 The B Format Item. • •

The C Format Item. • • • • The COLUMN Format Item • • The E Format Item. •

The F Format Item. • • • • • The LINE Format Item •

The P Format Item. • . • • • The PAGE Format Item •

The R Format Item. • The SKIP Format Item • The X Format Item. •

SECTION F: PROBLEM DATA CONVERSION

Arithmet~c Conversion • . • • • . Floating-Point Conversion.

Mode Conversion. • • • • • • Precision Conversion • • • Base Conversion. • • • • • coded Arithmetic to Numeric

character • • • • • • • • • Numeric Character to CodE~d

• .218 .218 .219 .220 .221 .221 .221 .221

• .222 .222 .223

• .223 .223 .223

• .224

• .224 .224 Arithmetic. • • • • • .224 Data Type Conversion. • • .224 Character-String to Aritt~etic • • 224 Arithmetic to Character-String • • 225 Character-String to Bit-String • • 227 Bit-String to Character-String • • 227 Arithmetic to Bit-String • • • • • 227 Bit-String to Arithmetic • • • • • 227 Table of Ceiling Values • • • • • • . 230 Tables for Results of Arithmetic

Operations • • • • • • • • • • .230 SECTION G: BUILT-IN FUNCTIONS l\ND

PSEUDO-VARIABLES • • • • ~ . • • • .233 Computational Built-In Functions. .234 String Handling Built-in Functions • • 234 BIT string Built-in Function • • • 234 BOOL String Built-in Function • • • 234 CHAR String Built-in Function • • • 235 HIGH String Built-in Function • • • 235 INDEX String Built-in Function • • 235 LENGTH String Built-in Function • • 236 LOW String Built-in Funct:ion • • .236

REPEAT String Built-in Function • • 236 SUBSTR String Built-in Function • • 237 UNSPEC String Built-in Function • • 237 Arithmetic Built-In Functions • • • • 238 ABS Arithmetic Built-in Function .238 ADD Arithmetic Built-in Function .239 BINARY Arithmetic Built-in

Function. • • • • • • • • • .239 CEIL Arithmetic Built-in

Function. • • • • • .239 COMPLEX Arithmetic Built-in

Function. • • • • • • • • • .239 CONJG Arithmetic Built-in

Function. • • • • • • • • .239 DECIMAL Arithmetic Built-in

Function. • • • • • • • • • .240 DIVIDE Arithmetic Built-in

Function4 • • • • • • • • .240 FIXED Arithmetic Built-in

Function. • • • • • • • • • .240 FLOAT Arithmetic Built-in

Function. • • • • • • • • • .240 FLOOR Arithmetic Built-in

Function. • • • • • • • .240 IMAG Arithmetic Built-in

Function. • • • • • • • • .241 MAX Arithmetic Built-in Function .241 MIN Arithmetic Built-in Function .241 MOD Arithmetic Built-in Function .241 MULTIPLY Arithmetic Built-in

Function • • _ • • • • • • • • • • 242 PRECISION Arithmetic Built-in

Function. • • • • • • • .242 REAL Arithmetic Built-in

Function. • • • • • • • .242 ROUND Arithmetic Built-in

Function. • • • • • • • • .242 SIGN Arithmetic Built-in

Function. • • • • • • • • .243 TRUNC Arithmetic Built-in

Function. • • • • • • • • • .243 Mathematical Built-in Functions • • • 243

ATAN Mathematical Built-in

Function. • • • • • • • • • .243 ATAND Mathematical Built-in

Function • • • • • • • • • • • • • 244 ATANH Mathematical Built-in

Function. • • • • • • • • • .244 COS Mathematical Built-in

Function. • • • • • • • • • .244 COSD Mathematical Built-in

Function • • _ • • • • • • • .244 COSH r1athematical Buil t- in

Function. • • • • • • • • .245 ERF Mathematical Built-in

Function • • _ • • • • • • • .245 ERFC Mathematical Built-in

Function. • • • • • • • • • .245 EXP Mathematical Built-in

Function. • • • • • • • • • .245 LOG Mathematical Built-in

Function. • • • • • • • • .245 LOG10 Mathematical Built-in

Function. • • • • • • • • .245 LOG2 Mathematical Built-in

Function. • _ • • • • • • • .245 SIN Mathematical Built-in

Function. • _ • • • • • • .246

(10)

SIND Mathematical Built-in

Func,tion. • • • • • • • • .246 SINH Mathematical Built-in

Function. • • • • • • • • • .246 SQRT Mathematical Built-in

Function. • • • • • • • • • TAN Mathematical Built-in

Function. • • • • • • • • TAND Mathematical Built-in

Functions • • • • • • • • • TANH Mathemat~cal Built-in

Function. • • • • • • • Summary of Mathematical

Functions • • • . ' . • • • Array Manipulation Built-in

Functions. • • • • • • •

ALL Array Manipulation Function.

ANY Array Manipulation Function.

DLM Array Manipulation 'Function.

HBOUND Array Manipulation Function. • • • • • • • • • LBOUND Array Manipulation

Function. • • • • • • • • • POLY Array Manipulation Function PROD Array Manipulation Function SUM Array Manipulation Function.

.246 .246 .246 . 246 .247 .247 .248 .249 .249 .249 .249 .249 .250 .250 condition Built-in Functions • • • • _ .250

DATAFIELD Condition Built-in

Function. • • • • • • • • .250 ONCHAR Condition Built-in

Function. • • • • • • • • • .250 ONCODE Condition Built-in

Fu~ction. • • • • • • • • • .251 ONCOUNT Condition Built-In

Function. • • • • • • • • .251 ONFILE Condition Built-in

Function. • • • • • • • .251 ONKEY Condition BUilt-in

Function. • • • • • • • • .251 ONLOC Condition Built-in

Function. • • • • .251 ONSOURCE Condition Built-in

Function. • • • •

Based Storage Built-in Functions • ADDR Based storage Built-in

Function. • • • • • • • • • EMPTY Based Storage Built-in

Function. • • • • • • • • • NULL Based Storage Built-in

F u n c t i o n . . . NULLO Based Storage Built-in

Function. • • • • • • • •

• .252 .252 .252 .252 .252 .252 Multitasking Built-in Functions. • .253

COMPLETION Multitasking Built-in Ftmction • • • • • • • • • • • • • 253 PRIORITY Multitasking Built-in

Function. • • • • • • • • • .253 STATUS Multitasking Built-in

Ftmction. • • • • • • • • .253 Miscellaneous Built-In Functions • •

ALI.OCATION Built-in Function COUNT Built-in Function.

DATE Built-in Function • • tINENO Built-in Function •

• .253 .253 .254 .254

• .254

TIME Built-in Function Pseudo-Variables • • • • • •

COMPLETION Pseudo-variable • COMPLEX Pseudo-variable.

IMAG Pseudo-variable • • • • ONCHAR Pseudo-variable • ONSOURCE Pseudo-variable PRIORITY Pseudo-variable • • REAL Pseudo-variable •

STATUS Pseudo-variable SUBSTR Pseudo-variable • UNSPEC Pseudo-variable • SECTION H: ON-CONDITIONS • Introduction • • • • • •

Condition Codes <ON-Codes) Multiple Interrupts • • section Organization • •

.254 .254 .255 .255 .255 .255 .255 .255

• .256

• .256 .256 .256 .257 .257

• .258 .259 .260 Computational conditions .260

The AREA Condition .260

The CONVERSION Condition. • .261 The FIXEDOVERFLOW Condition • • • • 261 The OVERFLOW Condition. • • .261 The SIZE Condition. • • .262 The UNDERFLOW Condition. .262 The ZERODIVIDE Condition .262 Input/Output Conditions. • •

The ENDFILE Condition.

The ENDPAGE Condition.

The KEY Condition. • • The NAME Condition • • The RECORD Condition.

The TRANSMIT Condition The UNDEFINEDFILE Condition.

.262

• • • 262 .263 .263 .264

• .264 .264 .265 Program-Checkout Conditions • • _ • • • • 265 The CHECK Condition • • • • • • • • 265 The SUBSCRIPTRANGE Condition • • • 267 The STRINGRANGE Condition. • .267 system Action Conditions • •

The ERROR Condition. • The FINISH Condition.

Programmer-Named Condition • The CONDITION Condition.

SECTION I: ATTRIBUTES • • • • Specification of Attributes.

Factoring of Attributes • Data Attributes. •

Problem Data. •

Program Control Data.

Entry Name Attributes. • File Description Attributes.

Scope Attributes

Storage Class Attributes • •

.268 .268 .268 .268 .268 .269 .269 .269 .269 .269 .270 .270 .270

• .270 .271

(11)

Alphabetic List of Attributes. '. • • .. .271 ABNORMAL and NORMALo • • • • • • • 271 ALIGNED and PACKED (Array and

Structure Attributes) • •

AREA (Program Control Dat:a .271 Attribute) • • • • 0 • • • • • • • 272 AUTOMATIC, STATIC, CONTROLLED

and BASED (Storage Class

Attributes) • • • • • • • • • • • 272 BACKWARDS (File Descripti.on

Attribute) • • • • • • • • • • • • 273 BASED (Storage Class Atti.bute) • • 273 BINARY and DECIMAL (Arithmetic

Data Attributes) • • • • • BIT and CHARA.CTER (Stringr

Attributes) • • • • • • • • BUFFERED and UNBUFFERED (File

Description Attributes) • • BUILTIN (Entry Attribute) • • CHARACTER (String Attribute) COMPLEX and REAL (Arithmetic

Data Attributes) • • • • • • CONTROLLED (Storage Class.

Attribute). • • • • • • • DECIMAL (Arithmetic Data

.273 .274 .274 .275 .275 .275 '. .275 Attribute). • • • • • • .275 DEFINED (Data Attribute) .275 Dimension (Array Attribute) • • • • 278 DIRECT and SEQUENTIAL (File

Description Attributes) • • ENTRY Attribute. • • • • • • ENVIRONMENT (File Description

Attribute). • • • '. • • • • EVENT (Program Control Data

Attribute) • • • • • • • • • EXCLUSIVE (File Description

Attribute). • • • • • • • • EXTERNAL and INTERNAL (Scope

Attributes) • • • • • • FILE (File Description

.279 .279 .280 .281 .283 .283 Attribute) • • • • • • • • • • • • 283 FIXED and FLOAT (Arithmetic Data

Attributes) • • • • • • • • • • • 284 FLOAT (Arithmetic Data

Attribute) • • • • • • • • • • • • 284 GENERIC (Entry Name Attribute) • • 284 INITIAL (Data Attribute) • • • • • 285 INPUT, OUTPUT, and UPDATE (File

Description Attributes) • • INTERNAL (Scope Attribute) IRREDUCIBLE and REDUCIBLE.

KEYED (File Description Attribute). • • • • • • • • LABEL (Program Control Data

.287 .287 .287 .287 Attribute). • • • • • • • • .287 Length (String Attribute) • • • • • 288 LIKE (structure Attribute) • .288 NORMAL • • • • • .. • • • • • .289 OFFSET and POINTER (Program

Control Data Attributes) • • OUTPUT (File Description

Attribute). • • • • • • • '.

PACKED (Array and Structure Attribute) ,. • • • • • • PICTURE (Data~Attribute) . . . POINTER (Program Control lData

.289 .289 .289

• 290 Attribute). • • • • • • • • .292 POSI'I'ION (Data Attribute). • • • .292

Precision (Arithmetic Data

Attribute). .. • • • • • .292 PRINT (File Description

Attribute). • .. • • • • • .293 REAL (Arithmetic Data Attribute) .293 RECORD and STREAM (File

Description Attributes) . . . 293 REDUCIBLE. • • • • • • • • • '. • .294 RETURNS (Entry Name Attribute) • • 294 SEQUENTIAL (File Description

Attribute) . . . 294 SETS and USES • • • • • • • • • • • 294 STATIC (Storage Class Attribute) .295 STREAM (File Description

Attribute). • • • • • • .. • .295 TASK (Program Control Data

Attribute). • • • • • • .. • .295 UNBUFFERED (File Description

Attribute). • • • • • • • .295 UPDATE (File Description

Attribute) • • • • • • • • • • • • 295 USES . . . 295 VARYING (String Attribute) • • • .2.95 SECTION J: STATEMENTS.. • • • • ..296

The ALLOCATE Statement. • .296 The Assignment Statement. • .298 The BEGIN Statement. • • .302 The CALL Statement . 0 • .302 The CLOSE Statement. • • .303 The DECLARE Statement. .303 The DELAY Stat'ement. • .304 The DELETE Statement. • • .304 The DISPLAY Statement. • • • 305 The DO Statement • • • • • • • • • 305 The END Statement • • • • • • • • • 308 The ENTRY Statement. '. • '. • ,. • .308 The EXIT Stateroent.. .309 The FORMAT Statement. • .309 The FREE Statement . . . 309 The GET Statement. • • • • • '. • .310 The GO TO Statement . . . 311 The IF Statement • • • • • • • • • 312 The LOCATE Statement. .312 The Null' Statement • • • • • • • • 313 The ON Statement '. • • • .313 The OPEN Statement. • .314 The PROCEDURE Statement. .315 The PUT Statement . . . 316 The READ Statement. • .318 The RETURN Statement • • • ,.320 The REVERT Statement. .320 The REWRITE Statement. • .. '. • • .321 The SIGNAL Statement '. • • • '. • .322 The STOP Statement. • .322 The UNLOCK Statement.. • '. • .. • .322 The WAIT statement • • • • • • • • 323 The WRITE Statement . . . 324 Preprocessor Statements. •

The %ACTIVATE Statement. • • The % Assignment Statement The %DEACTIVATE Statement.

The %DECLARE Statement The %00 Statement. • • The %END Statement • • The %GO TO Statement The %IF Statement. • •

.325 .325

• ,.325 .326

• .326

• .. 327 .327

• .327 .328

(12)

The %INCLUDE Statement. .328 The % Null Statement • • • .329 The %PROCEDURE Statement. .329 The Preprocessor RETURN

Statement. • • • • .330 SECTION K:

INDEX. • •

DEFINITIONS OF TERMS • .331 .339

(13)

Figure 7-1. Scopes of Data

Declarations. • .. • • • • • • • • • • • 86 Figure 7-2. Scopes of Entry and Label

Declarations However, i t could appear in a CALL statement in E, since the CALL statement itself would provide a contextual declaration of A, which would then result in the SCOp4~ of A

being all of A and all of E . . . 86 Figure 8-1. General Format for

Repetitive SpecificationsD • • • • • • • 108 Figure 8-2. Example of Data-Directed

Transmission (Both Input and Output) • • 113 Figure 11-1. A Program Checkout

Routine. • • • • • • • • • • • • .152 Figure 14-1. Example of

Two-Directional Chain • • . • • • .177 Figure 15-1. Synchronous and

Asynchronous Operation. • • • • • .180 Figure 15-2. Flow Diagram for

Programming Example of Multitasking • • 190 Figure D-l. Pictured Character·-String

Examples. • • • • • • • • • • • .206 Figure D-2oo Pictured Numeric

Character Examples. • • • • • .207 Figure D-3. Examples of Zero

Suppression • • • • .. • .. .. • .208

FIGURES

Figure D-4. Examples of Insertion

Characters. • • . • • • • • • • . .210 Figure D-5. Examples of Drifting

Picture Characters. • • • • • • • • • .211 Figure D-6. Examples of CR, DB, T, I,

and R Picture Characters. • • • • .. 213 Figure D-7. Examples of Floating-Point

Picture specifications . . . 213 Figure D-8. Examples of Scaling Factor

Picture Characters . . . 214 Figure D-9. Examples of Sterling

Picture Specifications • • • • • • • • • 215 Figure F-l. Examples of Conversion

from Fixed-Point to Character-String • • 226 Figure F-2. Examples of Conversion

From Arithmetic to Bit-String. • .228 Figure G-l. Mathematical Built-In

Functions . . . 247 Figure I-i. Permissible Items for

Overlay Defining. • .. .. • • • ..277 Figure J-l. General Formats of the

Assignment Statement. • • • • .299 Figure J-2. General Format of the DO

Statement • • • • • • • • • • • .306 Figure J-3. General Format of the

%DECLARE Statement. • • • .. • • .326

(14)

TABLES

Table 2-1. Some Functions of Special Characters. • • • • • •

Table 4-1. Target Types for Expression Operands • •

Table 4-2. Precision for Arithmetic Conversion. • • ~

Table 4-3. Lengths of Character-String Targets • • • • • • • • • • • • • Table 4-4. Lengths of Bit-String

• 24

• 58

• 60 61 Targets • • • • • • • • • • 61 Table 4-5. Circumstances that Can

Cause Conversion. • • • • • • • • • 62 Table 15-1. Effect of Operations on

EXCLUSIVE Files • • • : .. • • • .184 TableF-l. Data Type of Result of

Bit-String Operation. • • • • • .228 Table F-2. Data Type of Result of

Concatenation Operation .228

Table F-3a. Data Type of Result of

Comparison Operation. • • • • • • .228 Table F-3b. Data Type of Intermediate

Operands of Comparison Operation • • • • 229

Table F-4. Data Type of Result of

Arithmetic Operation • • • • • • • • • • 229 Table F-5. Precision for Arithmetic

Conversions. • . • • • • • • • . .229 Table F-6. Lengths of Converted

Character Strings (Arithmetic To

Character-String) • • • • • • • • .230 Table F-7. Lengths of Converted Bit

Strings (Arithmetic to Bit-String) • . • 230 Table F-8. Ceiling Values • • • • • • • 230 Table F-9. Attributes of Result in

Addition and Subtraction Operations • • 230 Table F-9. Attributes of Result in

Addition and Subtraction Operations • • 231 Table F-l0. Attributes of Result in

Multiplication Operations • • • . • • • 231 Table F-ll. Attributes of Result in

Division Operations • • • • • • • • • • 232 Table F-12. Attributes of Result in

Exponentiation Operations • • .. . '. . .232

(15)

PL/I is a programming lang'uage designed to cover as wide a range of programming applications as possible. A basic belief underlying the design of PL/I is that programmers have common problems, regard- less of the different. applications with which they may be concerned.

The language also is designed to reduce the cost of programming, including the cost of training programmers, the cost of debug- ging, and, in particular, the cost of program maintenance.

Training programmers to use a particular language can often be expensive, particu- larly if each programmer mus1:. be taught the entire language, even if he need use only a part of it. One of the prime features in the design of PL/I is modularity: in gener- al, a programmer need know only as much of the language as he requirE~s to solve his problems.

Another factor that contributes to pro'"

gramming cost is that a proqram frequently must be rewritten, sometimes because the system under which-it is uS4ed has changed, sometimes because the program is to be run on a new machine. I't is not uncommon to find that rewriting a program costs as much as writing it in the first place.

Two basic characteristics of PL/I are intended to reduce the need to rewrite complete programs if either the machine environment or the application environment changes. These characteristics are the block structure used in the language and its machine independence. '

A PL/I program is composed of blocks of statements called procedure blocks (or procedures) and begin blocks, each of which defines a region of the, program. A single program may consist of one procedure or of several procedures and begin blocks. Eith- er a procedure block or a begin block can contain other blocks; a begin block must be contained in a procedure block. Each external procedure, that is~ a procedure that is not contained in another procedure, is compiled separately. The same external procedure might be used in a number of different programs. Consequently, a neces-

sary change made in that one block effec- tively makes the change in all programs that use it.

INTRODUCTION

PL/I is much less machine dependent than most commonly used programming languages.

In the interest of efficiency" however, certain features are provided that allow machine dependence for those cases in which complete independence would be too costly.

The variety of features provided by PL/I, as well as the simplicity of the concepts underlying them, demonstrate the versatility of the language, its universal- ity. and the ease with which different subsets can be defined to meet the needs of different users.

USE OF THIS PUBLICATION

This publication is designed as a ref- erence ,book for the PL/I prog~ammer,. Its two-part format allows a presentation of the material in such a way that references can be found quickly, in as much or as little detail as the user needs.

Part I, "concepts of PL/I,," is composed of discussions a.nd examples that explain the different features of the language : and their interrelationships. To reduce the need for cross references ann to allow each chapter to stand alone as a complete ref- erence to its subject, some information is repeated from one chapter to another. Part I can~ nevertheless, be read Sequentially in its entirety.

Part II, "Rules and Syntactic Descrip- tions," provides, a quick reference to specific information. It includes less information about interrelationships, but it is organized so that a particular ques- tion can be answerej quickly. Part II is organized purely from a reference point of view: it is not intended for sequential reading ..

For example, a programmer would read Chapter 5 in Part I, "Statement Classifica- tion," for information about the interac- tions of different statements in a program;

but he would look in section J of Part II,

"statements," to find all the rules for the use of a specific statement, its effect, options allowed, and the format in which i t is written.

In the same manner, he would read Chap- ter 4 in Part I, "Expressions," for a discussion of the concepts of data conver- sion, but he would use section F of Part II, "Problem Data Conversion," to determine the exact results of a particular type of conversion.

15

(16)

An explanation of the syntax language used in this publication to describe ele- ments of PL/I is contained in Part II, Section A, "Syntax Notation."

IMPLEMENTATION CONSIDERATIONS

This,publication reflects features of Ithe fourth version of the F Compiler. No attempt is made to provide complete implem- entatio:p information; this publication is designed for use in conjunction with IBM

Syste~/360 Operating System: PL/I (F) PrQg!:.?mmer's Guide. Form C28-6594. Discus- sion of implementation is limited to those feature$ that are required for a full explanation of the language. For example"

references to certain parameters of the Data D$fini tion (DD) job control language

statement are essential to of record-oriented input organization.

an explanat~ion

anj output file Implementation features identified by the phrase "for System/360 implementa- tions ••• " apply to all implementations for IBM System/360 computers. Features iden- tified by the phrase. "for the F Compiler ••. " apply specifically to the IBM F Compiler under the IBM System/360 Operat- ing System.

A separate publication, IBM System/360:

PL/I Subset Reference Manual, Form C28-8202. provides the same type of implem- entation information as i t applies to the D Compiler used under the IBM System/360 Disk and Tape Operating Systems.

(17)

PART I

(18)
(19)

The modulari ty of PI,II" the ease with which subsets can be defined to. meet dif- ferent needs. becomes apparent when one examines the different features of the language. Such modularity is one of the most important characteristics of PL/I, •.

This chapter contains brief discussions of most of the basic features t,o provide an overall description of ' the language. Each is treated in more detail in subsequent chapters,. An annotated example in Chapter 14" "A PL/I Program,," illustrates the use of many of these features.

MACHINE INDEPENDENCE

No language can be comple:tely machine independent, but PL/I is much less machine dependent than most commonly used program- ming languages. The methods used to achieve this show in the form of restric- tions in ,the language. The most obvious example is that data with different charac- teristics cannot in general share the same storage; to equate a floating-point number with a certain number of alphabetic charac- ters would be to make assumptions about the representation of these data items which would not be true for all machines.

It is recognized that the price entailed by machine independence may sometimes be too high. In the interest of efficiency#

certain features such as the, UNSPEC built.:- in function and record-oriented datjl transmission, do permit a degree of mach~n~

depEmdence ..

PROGRAM STRUCTURE

A PL/I program consists of one or more blocks of statements called procedures. A procedure may be thought of as a subrou- tine. Procedures may invoke other proce- dures, and these procedures or subroutines may either be compiled separately, or may be nested within the calling procedure and compiled with it. Each procedure may con- tain declarations that define names and control allocation of storage.

The rules defining t.he Ulse of proce- dures, communication between procedures,

CHAPTER 1: BASIC CHARACTERISTICS OF PL/I

the meaning of names, and allocation of storage are fundamental to the proper understanding of PL/I at any level but the most elementary. These rules give the programmer considerable control over the degree of interaction between subroutines.

They permit flexible communication and storage allocation" at the same time allow- ing the definition of names and allocation of storage for private use within a proce- dure.

By giving the programmer freedom to determine the degree to which a subroutine is self-contained. PL/I makes i t possible to write procedures which can freely be used in other environments, while still allowing interaction in procedures where interaction is desirable.

MULTIPROGRAMMING

By means of the PL/I multitasking facil- ities, the programmer can specify that an invoked procedure is to be executed concur- rently with the invoking procedure, thus making use of the multiprogramming capabil- ities of the system. In this way~ the central processing unit can be occupied with one part of the program while the input/output channels are occupied with other parts of the program; this can reduce the overall amount of waiting time during execution.

Concurrent execution of different parts of a program does not imply that the program cannot be coordinated. The pro- grammer can specify that execution of a ,procedure will be suspended at a specified point until some point in another procedure has been reached, or until an input/output operation has been completed.

DATA TYPES AND DATA DESCRIPTION

The characteristic of PL/I that most contributes to the range of applications for which i t can be used is the variety of data types that can be represented and manipulated. PL/I deals with arithmetic data, string data (bit and character), and program control data, such as labels.

Arithmetic data may be represented in a variety of ways; i t can be binary or Cha,pter 1: Basic Characteristics of PL/I 19

(20)

decimal, fixed-point or floating-point, real or complex, and its precision may be specified.

PL/I provides features to perform arith- metic operat-ions, operations for compari- sons, logical manipulation of bit strings, and operations and functions for assem~

bling" scanning, and subdividing character strings.

The: compiler must be able to determine, for every name used in a program, the complete set of attributes associated with that name. The programmer may specify these attributes explicitly by means of a DECLARE statement, the compiler may deter- mine all or some of the attributes by context, or the attributes may be assumed by default.

DEFAUDT ASSUMPTIONS

An important feature of PL/I is its default philosophy. If all the attributes associated with a name, or all the options permit,ted in a statement, are not specified by the programmer, attributes or options may be assigned by the compiler. This defaul:t action has two main consequences.

Firs-t, it reduces the amount of declaration and other program writing required; second, i t makes i t possible to teach and use subsets of the language for which the programmer need not know all possible alternatives. or even that alternatives exis-t.

Since defaults are based on assumptions about thE~ intent of the programmer, errors or omissions may be overlooked. and incor- rect attributes may be assigned by default.

To reduce the chance of this, the F Compil- er optionally provides an attribute list- ing, which can be used to check the names in the program and the attributes associat- ed with them.

~TORAGE ALLOCATION

PL/I goes beyond most other languages in the flexibility of storage allocation that i t provides. Dynamic storage allocation is comparatively difficult for an assembly language programmer to handle for himself;

yet it is automatically provided in PL/I.

There are four different storage classes:

AUTOMATIC, STATIC, CONTROLLED, and BASED.

In general, the default storage class in PL/I is AUTOMATIC. This class of storage

is allocated whenever the block in which the variables are declared is activated.

At that time the bounds of arrays and the lengths of \strings are calculated. AUTO- MATIC storage is freed and is availablE:! for re-use whenever control leaves the block in which the storage is allocated.

Storage also may be declared STATIC., in which case i t is allocated when the program is loaded; i t may be declared CONTRO]~LED,

in which case it is explicitly controlled by the programmer with ALLOCATE and FREE statements, independent of the invocation

I

of blocks; or i t may be declared Bl~SED,

which gives the programmer an even higher degree of control.

The existence of several storage classes enables the programmer to determine for himself the speed, storage space, or pro- gramming economy that he needs for each application. The cost of a particular facility will depend upon the implementa- tion, but i t will usually be true that the more dynamic the storage allocation., the greater the overhead in execution time.

EXPRESSIONS

Calculations in PL/I are specified by expressions. An expression has a meaning in PL/I that is similar to that of elemen- tary algebra. For example:

A + B

*

C

This specifies multiplication of the value of B by the value of C and adding the value of A to the result. PL/I places few restrictions on the kinds of data that: can be used in an expression. For example, it is conceivable, though unlikely, that A could be a floating-point number, B a fixed-point number, and C a character string.

When such mixed expressions are speci- fied, the operands will be converted so that the operation can be evaluated mean- ingfully. Note, however, that the rules for conversion must be considered careful- ly; converted data may not have the same value as the ori'ginal. And, of course, any conversion requires additional compiler- generated coding, which increases execution time,.

The results of the evaluation of expressions are assigned to variables by means of the assignment statement." An example of an assignment statement is:

x = A + B

*

C;

(21)

This means: evaluate the expression on the right and store the result in X. If the attributes of X differ from th~e attributes of the result of the expression, conversion will again be performed.

DATA COLLECTIONS

PL/I permits the programmer many ways of describing and operating on collections of

data~ or data aggregates. Arrays are col- lections of data elements, all of the same type, collected into lists or tables of one or more dimensions. Structures are hierar- chical collections of data, not necessarily all of the same type. Each l~evel of the hierarchy may contain other structures of deeper levels. The deepest levels of the hierarchy represent elementa:ry data items or arrays.

An element of an array may be a struc- ture; similarly, any level of a structure may be an array. Operations can be speci- fied for arrays, structures" or parts of arrays or structures. For example:

A

=

B + C;

In this assignment statement~ A, B, and C could be arrays or structures.

INPUT AND OUTPUT

Facilities for input and output allow the user to choose between factors such as simplicity., machine independence, and effi- ciency. There are two broad classes of input/output in PL/I: stream-oriented and record-oriented.

Stream-oriented input/output is almost completely machine independent. On input, data items are selected onle by one from what is assumed to be a continuous stream of characters that are conver-ted to inter- nal form and assigned to variables speci- fied in a list. Similarly, on output, data i terns are converted one by on~e to external character form and are added to a concep- tually continuous stream of characters.

Within the class of stream input/output, the programmer can choose different levels of control over the way data items are edited and selected from or added to the stream.

For printing, the output stream may be considered to be divided into lines and pages. An output stream file may be

declared to be a print file with a speci- fied line size and page size. The program- mer has facilities to detect the end of a page and to specify the beginning of a line or a page. These facilities may be used in subroutines that can be developed into a report generating system suitable for a particular installation or application.

Record-oriented input/output is machine dependent. It deals with collections of data, called records, and transmits these a record at a time without any data conver- sion; the external representation is an exact copy of the internal representation.

Because the aggregate is treated as a whole, and because no conversion is per- formed, this form of input/output is poten- tially more efficient than stream-oriented input/output, although the actual efficien- cy of each class will, of course, depend on the implementation.

stream-oriented input and output usually sacrifices effic~ency for ease of handling.

Each data item is transmitted separately and is examined to determine if data con- version is required. Record-oriented input and output, on the other hand. provides faster transmission by transmitting data as entire records, without conversion.

COMPILE-TIME OPERATIONS

Most programming is concerned only with operations upon data.. PL/I permits a compile-time level of operation, in which preprocessor statements specify operations upon the text of the source program itself.

The simplest, and perhaps the commonest preprocessor statement is %INCLUDE (in gen- eral, preprocessor statements are preceded by a percent sign). This statement causes text to be inserted into the program, replacing the %INCLUDE statement itself. A typical use could be to copy declarations from an installation's standard set of definitions into the program.

Another function p:ovided by compile- time facilities 1S the selective compilation of program text. For example, i t might specify the inclusion or deletion of debugging statements.

Since a simple but powerful part of the PL/I language is available for compile-time activity, the generation, or replacement and deletion, of text can become roore elaborate, and more subtle transformations can be performed. Such transformations might then be considered to be installation-defined extensions to the lan- guage.

Chapter 1: Basic Characteristics of PL/I 21

(22)

INTERRUPT ACTIVITIES

Modern computing systems provide facili- ties for interrupting the execution of a program whenever an exceptional condition arises. Further, they allow the program to deal with the exceptional condition and to return to the point at which the interrupt occurred.

PL/I provides facilities for detecting a variety of exceptional conditions. It allows the programmer to specify. by means of a condition prefix., whether ce:rtain interrupts will or will not occur if the condition should arise,. And, by use of an ON statement, he can specify the action to be taken when an interrupt does occur.

Références

Documents relatifs

Les silicates artificiels, dont certains sont d'une importance industrielle primordiale, sont pour la plupart cristallisés, à l'exception des verres ; leurs structures rentrent

In Step 2 of the clipping algorithm, for all the curve segments obtained by general closest point pair clipping, except for their starting points and ending points, the

Data-aided schemes are more suitable for applications re- quiring fast and reliable synchronization. A popular algorithm to perform timing synchronization and frequency offset

Nev- ertheless, specific conservation practices—agroforestry sys- tems and application of biochar in soil—can boost sequestration of organic C and, in addition, increase

Talking about monetary consequences associated with eCall not only involves the costs of installing eCall devices into vehicles but also the effects of reducing congestion,

CPMCGLM: an R package for p-value adjustment when looking for an optimal transformation of a single explanatory variable in generalized linear models.. Benoit Liquet,

To determine whether Cx43 is directly involved in trophoblast fusion, we used an antisense strategy in primary cultures of human villous cytotrophoblasts

33-FRANSOIS SULGER : LES GESTES VERTE ,EDITION SAND,PARIE,SANS ANNE... 36- I-GASMAN ,J-F ALLILAIRE : PSYCHATRIE DE L’ENFANT