/***********************REXX*******************************************/
/* FUNCTION : THIS PROGRAM FINDS AND LISTS THE NUMBER OF OCCURANCES */
/* OF THE WORD IN A GIVEN PDS OR A PS FILE */
/* WRITTEN BY GOPINATHAN BALASUBRAMANIAN ON 03/03/2003 */
/**********************************************************************/
o = 1
SAY "Enter the Dataset Name (e.g., REXX.EXEC) "
pull dataset
say "Enter the string to search "
parse pull string
PARSE upper VAR string UPPERST
x=outtrap(inprec.)
"free fiLE(infile)"
"free fiLE(outfile)"
"LISTDS" DATASET "MEMBERS"
"alloc da('scbgop.tsrch.result') fi(outfile) shr "
if rc \= 0 then
say "Output file not found "
else
nop
EXTRACT = 0
j = 1;
memlist. = " "
DO I=1 TO INPREC.0
IF INPREC.I = "--MEMBERS--"
THEN EXTRACT = 1;
ELSE
DO
IF INPREC.I = "READY" THEN
EXTRACT = 0
ELSE
NOP
END
IF EXTRACT = 1 & INPREC.I \= "--MEMBERS--"THEN
do
memlist.j = SUBSTR(INPREC.I,3,8)
j = j +1
end
ELSE
NOP
END;
if j = 1 & word(inprec.5,4) \= 'PS' then
do
disprec = "DATA SET" dataset "NOT IN CATALOG"
call prints
exit
end
else
nop
memlist.0 = j - 1
outrec. = " "
no = 0
disprec = "Result of the search operation for the word" string
call prints
if word(inprec.5, 4) = 'PO' then
do a = 1 to memlist.0
"alloc da("||dataset|| "("||strip(memlist.a,'t')||,
")) fi(infile) shr "
"execio * diskr infile (stem inrec. FINIS"
do b = 1 to inrec.0
parse upper var inrec.b upperrec
if (index(upperrec,upperst) \=0) then
do
ind=1
i=0
do while(index(upperrec,upperst,ind) \= 0 )
ind=index(upperrec,upperst,ind)
ind= ind + wordlength(string , 1)
no= no + 1
i=i+1
end
disprec = "Found in member" memlist.a " Line Number " b ,
"No of occurance:" i
call print
disprec = substr(inrec.b,1,79)
call prints
end
else
nop
end
inrec. = " "
"free fiLE(infile)"
end
else
do
"alloc da("||dataset ||") fi(infile) shr"
"execio * diskr infile (stem inrec. FINIS"
do b = 1 to inrec.0
parse upper var inrec.b upperrec
if (index(upperrec,upperst) \=0) then
do
ind=1
i=0
do while(index(upperrec,upperst,ind) \= 0 )
ind=index(upperrec,upperst,ind)
ind= ind + wordlength(string , 1)
no= no + 1
i=i+1
end
disprec = "Found in Line Number " b ,
"No of occurance:" i
call print
disprec = substr(inrec.b,1,79)
call prints
end
else
nop
end
inrec. = " "
"free fiLE(infile)"
end
if no > 0 then
if no > 1 then
do
disprec = no "occurances found"
call prints
end
else
do
disprec = no "occurance found"
call prints
end
else
do
disrec = "Sorry, its not found, Try again"
call prints
end
outrec.o=" "
outrec.0 = o-1
lines = o-1
"execio" lines " diskw outfile (stem outrec. FINIS"
"free fiLE(outfile)"
exit
print:
say disprec
outrec.o= disprec
o=o+1
return
prints:
say disprec
say " "
outrec.o= disprec
o=o+1
outrec.o= " "
o=o+1
return
/**********************************************************************/
/********************END OF THE REXX PRGRAM****************************/
/**********************************************************************/
Back to Index