The use of the cataloged procedure IBMZC to compile a simple PL/I program and place the object module in a new library named EXLIB is shown in Figure 20. The DD statement that defines the new library and names the object module overrides the DD statement SYSLIN in the cataloged procedure. (The PL/I program is a function procedure that, given two values in the form of the character string produced by the TIME built-in function, returns the difference in milliseconds.)
The use of the cataloged procedure IBMZCL to compile and link-edit a PL/I program and place the load module in the existing library HPU8.CCLM is shown in Figure 21.
//OPT10#1 JOB
//TR EXEC IBMZC
//PLI.SYSLIN DD UNIT=SYSDA,DSNAME=HPU8.EXLIB(ELAPSE),
// SPACE=(TRK,(1,,1)),DISP=(NEW,CATLG)
//PLI.SYSIN DD *
ELAPSE: PROC(TIME1,TIME2);
DCL (TIME1,TIME2) CHAR(9),
H1 PIC '99' DEF TIME1,
M1 PIC '99' DEF TIME1 POS(3),
MS1 PIC '99999' DEF TIME1 POS(5),
H2 PIC '99' DEF TIME2,
M2 PIC '99' DEF TIME2 POS(3),
MS2 PIC '99999' DEF TIME2 POS(5),
ETIME FIXED DEC(7);
IF H2<H1 THEN H2=H2+24;
ETIME=((H2*60+M2)*60000+MS2)-((H1*60+M1)*60000+MS1);
RETURN(ETIME);
END ELAPSE;
/* //OPT10#2 JOB
//TRLE EXEC IBMZCL
//PLI.SYSIN DD *
MNAME: PROC OPTIONS(MAIN);
.
.
.
program
.
.
.
END MNAME;
/*
//LKED.SYSLMOD DD DSNAME=HPU8.CCLM(DIRLIST),DISP=OLDTo use a PL/I program to add or delete one or more records within a member of a library, you must rewrite the entire member in another part of the library. This is rarely an economic proposition, since the space originally occupied by the member cannot be used again. You must use two files in your PL/I program, but both can be associated with the same DD statement. The program shown in Figure 23 updates the member created by the program in Figure 22. It copies all the records of the original member except those that contain only blanks.
//OPT10#3 JOB
//TREX EXEC IBMZCBG
//PLI.SYSIN DD *
NMEM: PROC OPTIONS(MAIN);
DCL IN FILE RECORD SEQUENTIAL INPUT,
OUT FILE RECORD SEQUENTIAL OUTPUT,
P POINTER,
IOFIELD CHAR(80) BASED(P),
EOF BIT(1) INIT('0'B);
OPEN FILE(IN),FILE (OUT);
ON ENDFILE(IN) EOF='1'B;
READ FILE(IN) SET(P);
DO WHILE (¬EOF);
PUT FILE(SYSPRINT) SKIP EDIT (IOFIELD) (A);
WRITE FILE(OUT) FROM(IOFIELD);
READ FILE(IN) SET(P);
END;
CLOSE FILE(IN),FILE(OUT);
END NMEM;
/*
//GO.OUT DD UNIT=SYSDA,DSNAME=HPU8.ALIB(NMEM),
// DISP=(NEW,CATLG),SPACE=(TRK,(1,1,1)),
// DCB=(RECFM=FB,BLKSIZE=3600,LRECL=80)
//GO.IN DD *
MEM: PROC OPTIONS(MAIN);
/* this is an incomplete dummy library member */ //OPT10#4 JOB
//TREX EXEC IBMZCBG
//PLI.SYSIN DD *
UPDTM: PROC OPTIONS(MAIN);
DCL (OLD,NEW) FILE RECORD SEQUENTIAL,
EOF BIT(1) INIT('0'B),
DATA CHAR(80);
ON ENDFILE(OLD) EOF = '1'B;
OPEN FILE(OLD) INPUT,FILE(NEW) OUTPUT TITLE('OLD');
READ FILE(OLD) INTO(DATA);
DO WHILE (¬EOF);
PUT FILE(SYSPRINT) SKIP EDIT (DATA) (A);
IF DATA=' ' THEN ;
ELSE WRITE FILE(NEW) FROM(DATA);
READ FILE(OLD) INTO(DATA);
END;
CLOSE FILE(OLD),FILE(NEW);
END UPDTM;
/*
//GO.OLD DD DSNAME=HPU8.ALIB(NMEM),DISP=(OLD,KEEP)