Wednesday 18 November 2015

Top PLI Compiler Options for Debugging -Detailed Text of Usage


To simplify debugging and decrease compile time, set optimization to NOOPTIMIZE or OPTIMIZE(0).  

AGGREGATE:Specifies that a layout for arrays and major structures appears in the listing.

ESD: Includes the external symbol dictionary in the listing.

GONUMBER / GOSTMT: Tells the compiler to produce additional information specifying that line numbers from the source routine can be included in runtime messages and in the Language Environment dump.

INTERRUPT: Specifies that users can establish an ATTENTION ON-unit that gains control when an attention interrupt occurs.

LIST:Produces a listing of the assembler expansion of source code and global tables, literal pools, information about working storage, and size of routine’s working storage.

LMESSAGE:Tells the compiler to produce runtime messages in a long form. If the cause of a runtime malfunction is a programmer’s understanding of language semantics, specifying LMESSAGE: could better explain warnings or other information generated by the compiler.

MAP: Tells the compiler to produce tables showing how the variables are mapped in the static internal control section and in the stack frames, thus enabling static internal and automatic variables to be found in the Language Environment dump. If LIST is also specified, the MAP option also produces tables showing constants, control blocks, and INITIAL variable values.

OFFSET: Specifies that the compiler prints a table of statement or line numbers for each procedure with their offset addresses relative to the primary entry point of the procedure.

SOURCE:  Specifies that the compiler includes a listing of the source routine in the listing.

STORAGE: Includes a table of the main storage requirements for the object module in the listing.

TERMINAL: Specifies what parts of the compiler listing produced during compilation are directed to the terminal.

TEST: Specifies the level of testing capability that is generated as part of the object code. TEST also controls the location of test hooks and whether or not the symbol table is generated. Because the TEST option increases the size of the object code and can affect performance, limit the number and placement of hooks.

XREF and ATTRIBUTES: Creates a sorted cross-reference listing with attributes.

(Ref: IBM)

Thursday 15 October 2015

How 'POSITION' attribute works in PL/I

The Position attribute may be specified in overlay defining of BIT and CHAR string.

DCL LIST CHAR (40);

A_LIST   CHAR (10) DEFINED LIST;

This refers first ten 10 CHARs of LIST.

B_LIST   CHAR (20) DEFINED LIST POSITION (21);

This refers from 21 thru 40th CHARs of LIST.

C_LIST CHAR (10) DEFINED LIST POSITION (11);

This refers from 11 thru 20th CHARs of LIST.


Monday 12 October 2015

PLI Subroutines and top Interview Questions

In PL/I, a Subroutine is called by using CALL statement.

CALL Subrt(x,y,z);

  • Subroutines, which are separately compiles from the invoking procedure are called external procedures.
  • Each subroutine name should not be more than 8 chars.
  • Should not give STOP or EXIT statement in Subroutine. If we give it terminates total program execution. Actually this is main program's responsibility.

In the main program:
.
.
DECLARE Subrt entry;
CALL Subrt(x,y,z);
.
.
In the Subroutine:
.
Subrt: Proc(a,b,c)
.
.
.
END Subrt; 

Tuesday 16 June 2015

PLI Built-in Functions for Mainframe Programmers (1 of 5)

MAINFRAME+PLI+JOBS
ADDR -- Built-in function

Returns a pointer value identifying the location of x.

>>--ADDR(x)-------------------------------------------------------------><
  Example: P = ADDR(TABLE);

ALL -- Built-in function

Returns bit string (with length of longest element of array) resulting
from logical AND of all the elements of array x.

>>--ALL(x)--------------------------------------------------------------><
  Example: IF ALL(LIST) THEN CALL SUB;

AREA -- Attribute

Reserves storage (in bytes) for the area.  Default size is 1000 bytes.

>>--AREA----------------------------------------------------------------><
          +-(--*--)-------------------------------------¦
          +-(--expression-----------------------------)-+
                           +-REFER--(--variable--)-+
  Example: DECLARE MC AREA(4095);

ASSEMBLER (ASM) -- Option of OPTIONS Attribute

Specifies that entry point is in an assembler routine.

  Example: DECLARE ENTB ENTRY OPTIONS(ASM);

ATTENTION (ATTN) -- Condition

Occurs in conversational mode when programmer causes an attention interruption from the terminal or when
SIGNAL ATTENTION is executed.

>>--ATTENTION-----------------------------------------------------------><
  Example: ON ATTENTION CALL ATTPACK;


BACKWARDS -- Attribute

Causes the (implied) RECORD SEQUENTIAL INPUT tape file to be accessed in reverse order.

>>--BACKWARDS-----------------------------------------------------------><
  Example: DECLARE TAPE FILE INPUT BACKWARDS...;

BASED -- Attribute

Specifies that the actual area of storage is identified by locator values. A based variable can be used to refer
to variables of any storage class; it can also control its own storage by means of ALLOCATE and FREE
statements.

>>--BASED---------------------------------------------------------------><
           +-(--locator-reference--)-+
  Example: DECLARE REC CHAR(30) BASED(P);

Sunday 16 November 2014

PL/I - Select - When Coding

Use the SELECT statement when there are a large number of different conditions to test for. It's much easier to read than nested IF statements, and much safer to use. Too many nested IF statements get maintenance programmers in trouble, and are very difficult to understand and change. Never have the nesting be over one printed page in length. Too many WHEN…DO…ENDS make the code difficult to read:


[label:] SELECT(BOOZE);
WHEN('BEER') CALL USE_BIG_GLASS;
WHEN('GIN')DO; MARTINI = GIN||OLIVE; CALL STIR; END;
WHEN(BOURBON,RYE,NOT_TAXED) ITS_AMERICAN = YES;
WHEN(WINE) IF RED
THEN CALL SELECT_GLASS('RED');
ELSE CALL SELECT_GLASS('WHITE');
WHEN(WATER); /* IGNORE */
OTHERWISE DO; /*SOMETHING ELSE */ END;

END [label]; /* SELECT */
Using a label on a SELECT or a DO statement is a nice way to document the scope of the logic. This also helps the compiler report the location of missing END statements accurately.


A1: SELECT(SOME) WHEN… OTHERWISE… END A1; 

Friday 8 August 2014

PL/I - Programming Guide - Free Download

http://sriniforum.bestfreeforum.ca
SriniForum
BIT Attribute 

The BIT attribute specifies that the data item named in the DECLARE statement is represented as a bit
string consisting of a certain number of bits. The BIT attribute may appear in two forms:
BIT( length)
BIT(length) VARYING



[JOIN PL/I Forum to discuss your doubts]

Declaration of PL/I record:

DECLARE
1 PAYROLL-RECORD,
   3 MAN-NUMBER CHARACTER (6),
   3 NAME,
     27 LAST CHARACTER (15),
      27 FIRST CHARACTER (15),
     27 MIDDLE CHARACTER (10),
3 ADDRESS,
   12 STREET CHARACTER (20),
    12 CITY CHARACTER (15),
   12 ZONE CHARACTER (5),
   12 STATE CHARACTER (15),
3 DATE-HIRED,
  4 MONTH FIXED (2),
  4 DAY FIXED (2),
  4 YEAR,
    14 DECADE FIXED (1),
    14 YR FIXED (1),
3 RATE-OF-PAY FIXED (7,2);

http://bitsavers.trailing-edge.com/pdf/ibm/360/pli/SC20-1651-1_A_Guide_to_PL_I_for_Commercial_Programmers_Apr68.pdf