You are on page 1of 14

PL/I

• • • • PL/I was developed as an IBM product in the mid 1960’s. PL/I is completely free form and has no reserved keywords. It precisely defines it's data types without regard for any hardware. PL/I is a block-oriented language, consisting of packages, begin blocks, and statements. This type of structure allows the programmer to produce highly-modular applications. • PL/I contains control stuctures. For example, SELECT...WHEN...OTHERWISE allow logical operations, and DO statements allow units to be executed unconditionally one time, forever, or while a condition is true or until a condition becomes true. • PL/I supports arrays, structures, unions, arrays of structures or unions, structures or unions of arrays, and combinations thereof. • PL/I provides four different storage classes: AUTOMATIC, STATIC, CONTROLLED, and BASED. Application objects' data type, representation, nature of use, etc... normally decides the type of storage class used for each.

INTRODUCTION TO PL/1 • PL/I is a structured language to develop systems and applications programs (both business and scientific). • Comment line(s) begins with /* and ends with */. Although comments may be embedded within a PL/I statements . . but it is recommended to keep the embedded comments minimum.

. the MAIN procedure statement consists of : Label • The statement ‘PROCEDURE OPTIONS (MAIN)’ • A semicolon to mark the end of the statement.INTRODUCTION TO PL/1 • There must be one and only one MAIN procedure to every program.

INTRODUCTION TO PL/1 The first PL/I statement in the program is the PROCEDURE statement : Max: PROC[EDURE] OPTIONS(MAIN). . A PL/I program is compiled by PL/I compiler and converted into the binary . OPTIONS(MAIN) : Compulsory for main programs and if not specified . Object program file for link editing . then the program is a subroutine. Max is the name of the program(label) and compulsory and marks the beginning of a program.

Better machine utilization. 4. Better integration of sets of programs covering several applications. 2. better intercept handling. greater use of channels .Advantages of PL/I Advantages of PL/I are : 1. Easier interchangeability of files 3. . more flexible storage assignment. Fewer programs to be written in a machine oriented language.

PL/I Restrictions The process of compiling a PL/I program and executing it in the computer’s memory takes place through JCL. Col # 1 for O. Col # 2 .S.72 for PL/I statements Col # 73 .80 ignored by complier .

0 -9 and 21 special characters. @ . #. extended characters: e. numeric digits (0-9) and underscore character.PL/I Language Components Character sets : 60 characters in total. An identifiers for data names . labels of PL/I statements and keywords. statement labels and internal procedure names may be from 1 to 30 alphabetic characters ( A – Z. Identifiers : Used to name data. procedures .Z . files . $ ) . $ . A .g # . . 2. !.@.

. the source program .Statement format LABEL : KEYWORD STATEMENT OPTIONS . A PL/I statement may be continued accros several lines. One line may contain several statements terminated by semi-colon.

PL/I constants A constant is a data item that does not have a name and whose value cannot change in a program. but only 2 or 3 types are used.  Decimal Fixed-point constants  Decimal Floating-point constants  Character string constants  Bit-string constants  Binary Fixed-Point and Binary Floating-Point constants . There are six types of constants .

Attributes: Mode: REAL/COMPLEX Scale: FIXED/FLOAT Base: DECIMAL/BINARY .Declarations DECLARE data-name attributes. OR DCL data-name attributes.

#. digits after decimal) .• DCL X FIXED BINARY.d) (width. • DCL Y FIXED DECIMAL. • The default values for base and scale depend on the first letter of the name of the variable.@ (Float Decimal) • First letter: I-N (Fixed Binary) • Precision attribute: (w. O-Z OR $. • First Letter: A-H.

2) Form: XXX. internal data • FLOAT BINARY: Scientific applications. counters. • FIXED DEC: business data • FIXED BINARY: Indices.• Precision: (5.XX • Precision: (8.xxx • The point is not actually stored but it would appear as shown if the number were printed.3) Form: xxxxx. measure .

Default specification • • • • Fixed decimal : (5.0) Fixed Binary: (15.0) Float Decimal: (6) Float Binary: (21) .

.BAL0) FIXED DECIMAL(8.Z) FLOAT BINARY. DCL (AMT.14159). DCL (X.Y.16).Initialization • DECLARE NAME TYPE INITIAL (VALUE) DECLARE RATE FIXED DECIMAL (5.2). DCL PI FLOAT BINARY INIT(3. DCL INACTIVE FIXED BINARY INIT(1111111B). DCL DOZEN FIXED BINARY INIT(12).2) INIT(.