Pli PPT Extra

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 20

Debugging a Program

• Debugging a program is the process of


removing known errors from your program.
• For Example: When any Keyword missed
in the syntax the compiler will note these
errors for you, the errors must then be
corrected.
• PL/I offers a wide variety of debugging aids
such as:
– CHECK Statement
– ACRT(Attribute & Cross Reference Table)
– DCLDATA(PUTDATA)
• CHECK STATEMENT :
– CHECK is a program trace feature.
– A program trace is a printout of the computer results after
each PL/I statement is executed.
• Syntax :
• (CHECK):
• AVERAGE: PROCEDURE OPTIONS (MAIN);
• :
• :
• END AVERAGE;
• Example Program:--
• /* Program to compute grade Average from 5 exam marks */
• /******************************************************/
• /* Program Name : AVERAGE */
• /* Description : Calculate the average grade from 5 sub marks */
• /* Input : System Input */
• /* Output : Printer */
• /******************************************************/

• (CHECK):
• AVERAGE: PROCEDURE OPTIONS(MAIN);

• GET LIST(A,B,C,D,E);
• SUM = A + B + C + D + E ;
• AVERAGE_GRADE = SUM / 5 ;
• PUT LIST(‘AVERAGE GRADE IS’, ACERAGE_GRADE);
• END AVERAGE;
• Example 2: To trace the output of a limited number of program
variables, then these variables may be listed in parentheses following
the keyword CHECK :--

• (CHECK(A,B,SUM)):
• AVERAGE: PROCEDURE OPTIONS(MAIN);
• :
• :
• END AVERAGE
ACRT (ATTRIBUTE AND
CROSS-REFERENCE TABLE)
• When the program is compiled, the PL/I
compiler prints a source listing of the
program and if requested through the
PROCESS statement, other information that
is most useful using a tool called ACRT.
Example of a ATTRIBUTE AND CROSS REFERENCE TABLE :--

DCL IDENTIFIER ATTRIBUTE AND REFERENCES


No.
---------------------------------------------------------------------------------------------------------
-
2 DESCRIPTION AUTOMATIC UNALIGNED CHARACTER(20)
11,14,18
3 ECONOMICAL_ORDER_QUANTITY
AUTOMATIC ALIGNED DECIMAL FIXED(5,0)
11,14,19
4 MORE_RECORDS AUTOMATIC UNALIGNED INITIAL BIT(1)
1,9,12
5 NO AUTOMATIC UNALIGNED INITIAL BIT(1)
1,9
21 PRINT_HEADING ENTRY RETURNS(DECIMAL /* SINGLE */ FLOAT (6))
10
6 PRODUCT_NO AUTOMATIC UNALIGNED CHARACTER (8)
******** SYSIN EXTERNAL FILE
9, 11, 14
******** SYSPRINT EXTERNAL FILE PRINT
16, 18, 19, 22, 23, 24, 25
• DCL NO. COLUMN : In The DCL NO. Column, the number of the declare
statement is specified.
• IDENTIFIER Column : In this Column all programmer-defined identifiers are
listed in alphabetic order. You should be sure to scan this list to verify that
only those names you intended to use are present. Sometimes a data entry error
is made in which an intervening balnk is inserted in the middle of an identifier.
• For example :
– QUANTITY_ON_HAND
– might have been inadvertently keyed as
– QUANTITY_ ON_HAND
– This situation could cause the compiler to treat the intended identifier as two
separate identifiers: QUANTITY_ and ON_HAND. If so these can be listed in
ACRT.
DCL DATA(PUT DATA)
• This statement causes all variables known to the program at the point
of the PUT statement to be output in the form of assignment
statements.
• PUT DATA can be a powerful debugging tool. One of the most useful
places to use the PUT DATA statement is in the ERROR on-unit.
• When the ERROR condition is raised, your program is about to be
terminated. Before termination, it might be useful to capture the
contents of program variables so that you may better understand what
has gone wrong in your program.
• For Eg :
• ON ERROR
• PUT DATA;
VERSIONS OF PL/I
Variety of PL/I compilers are available.
1.PL/I-C :
• PL/C is a PL/I processor that was developed by a systems
programming group of the Department of Computer Science at
Cornell University (hence, the C in PL/C).
• The users of PL/C are primarily educational institutions where
PL/C characteristics are particularly advantageous for large
numbers of relatively short programs produced by typically
inexperienced programmers.
• PL/C provides diagnostic assistance and also attempts to repair
errors.
2.PL/I-D : It is an IBM compiler designed to run on IBM
computers using the Disk Operating System(DOS).
• PL/I-D is subset Language.
3.PL/I-F : It is an early version of PL/I. It does provide full language
capability not a subset as in PL/I-D. PL/I-F is no longer supported by
IBM.
4.PL/I-G : Digital Research PL/I is an implementation of PL/I
for micro-computers that use the 8080, 8086, 8088 or similar processor. It
is formally based on ANSI X3.74 PL/I General Purpose Subset(Subset G).
Subset G has the formal structure of the full PL/I language.
5.PL/I CHECKOUT COMPILER: The PL/I checkout compiler is used by
programmers during program development time because of the extensive
error checking and diagnostic facilities.
6. PL/I OPTIMIZERS :
– DOS PL/I & OS PL/I by IBM
– Fully Language Capability
– Run on IBM’s S/370
– Many Advanctages over PL/I - D & PL/I - F
– Advantages include
¢ Better Object Code Generation
¢ Improved Diagnostics
¢ Error Checking
Eamples of Declarations
• FIXED DECIMAL :
• DATA FORMAT NAME: Packed decimal
• TYPE OF DATA:Coded Arithmetic
• DEFAULT PRECISION: 5 Decimal Digits
• MAXIMUM PRECISION: 15 Decimal Digits
• Examples:
• DECLARE GROSS_SALES FIXED DEC(7);
• DECLARE BASE_COMM FIXED DEC(9,2) INIT(24.00);
• DECLARE NET_SALES FIXED DEC;
– /* NET_SALES IS FIXED DECIMAL(5) */
• DEC HOUR_1 FIXED DEC(3,1) INIT(42.6);
– /* HOUR_1 = 42.6 */
• DEC HOUR_2 FIXED DEC(5,2) INIT(42.6);
– /* HOUR_2 = 042.6 */
• DEC HOUR_3 FIXED DEC(1,1) INIT(42.6);
– /* HOUR_3 = .6 */
• DEC HOUR_4 FIXED DEC(3,2) INIT(42.6);
– /* HOUR_4 = 2.60 */
• DEC HOUR_5 FIXED DEC(7,4) INIT(42.6);
– /* HOUR_5 = 042.6000 */
• DEC HOUR_6 FIXED DEC(5,0) INIT(42.6);
– /* HOUR_6 = 00042. */
• NOTE: FIXED DECIMAL CAN BE USED AS
– FIXED, FIXED DECIMAL, OR DECIMAL FIXED


• FIXED BINARY :
• Data Format Name : fixed point
• Type of data : coded arithmetic
– Default Precision : 15 bits(equivalent to 32,767 in decimal)
– Maximum Precision : 31 bits(equivalent to 2,147,483,647 in decimal)
• Examples:
• DEC ECONOMICAL_ORDER_QUANTITY FIXED BIN(15);
• DEC MAXIMUM FIXED BIN(31) INIT(2147483647);
• DEC DELTA FIXED BIN(31,6);
• :
FLOAT DECIMAL

• Data Format Name : floating-point


• Type of Data : coded arithmetic
• Default precision : 6 decimal digits
• Maximum precision : 16 decimal digits
• Examples :
• DCL FORCE FLOAT DEC(6);
• DCL INTERVAL DEC(6);
• DCL VARIANCE FLOAT(6);
• DCL LIGHT_YEAR FLOAT DEC(16) INIT)6E+12);
• DCL MILE FLOAT DEC INIT(5280);
• FLOAT BINARY :
• Data Format Name : floating-point
• Type of data : coded arithmetic
• Default precision : 21 bits (1,048.576 in decimal)
• Maximum precision : 53 bits
• Examples :
• DCL A FLOAT BINARY;
• DCL B BINARY FLOAT;
• DCL C BINARY;
• DCL D BIN(21);
• DCL E FLOAT BIN;
• DCL F FLOAT BIN(21);
– /* A,B,C,D,E, AND F ARE EQUIVALENT */
• BIT :
• Data format name : bit(bits are stored from 1 to 8 bits per byte)
• Type of data : Logical
• Default length : none
• Maximum length : 8000 bits for constants
» 32767 bits for variables
• Examples :
• DCL ITEM BIT(9) INIT(‘111100001’ B);
• DCL PATTERN BIT(16) INIT((8)’10’B);
– /* PATTERN = ‘1010101010101010’B */
• DCL SYMPTOMS BIT(8) INIT(‘0011’B);
– /* SYMPTOMS = ‘00110000’B */
• CHARACTER :
• Data format name : character
• Type of data : alphanumeric
• Default length : none
• Maximum length : 1000 characters for constants
• 32767 characters for variables
• Examples :
• DCL DESCRIPTION CHAR(20);
• DCL TITLE CHAR(25) INIT(‘BOOK STATUS REPORT’);
• DCL PART_NUMBER CHAR(9);

You might also like