Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Code to count number of lines in a PDS

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
Akash Sharma

New User


Joined: 13 Jan 2009
Posts: 36
Location: India

PostPosted: Fri Apr 17, 2009 4:18 pm    Post subject: Code to count number of lines in a PDS
Reply with quote

Hi All,

Is it possible to write a code in REXX or CLIST which would could perform following operation:

1. Input: PDS Name

2. Functionality: Compute number of lines of code for each member in that PDS.

3. Output: A report in following format.

Code:

PDS: DEV.BAT.SOURCE
PROGRAM NAME                   LOC
PROG1                                 000456
PROG2                                 001173
PROG1                                 008702
Back to top
View user's profile Send private message

superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4650
Location: Raleigh, NC, USA

PostPosted: Fri Apr 17, 2009 4:21 pm    Post subject: Reply to: Code to count number of lines in a PDS
Reply with quote

Yes, of course. It'll have to be up to you to determine what constitutes a "line of code" and how to count it.
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4650
Location: Raleigh, NC, USA

PostPosted: Fri Apr 17, 2009 4:22 pm    Post subject: Reply to: Code to count number of lines in a PDS
Reply with quote

Search for "LOC" to find other similar topics.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Fri Apr 17, 2009 4:33 pm    Post subject:
Reply with quote

yes, suggest you read some of the documentation provided by this link:

http://www-01.ibm.com/software/awdtools/ispf/library/

and look for rexx documentation at:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/library

as well as search this forum for similarly titled exercises.

or if you are only looking for someone to provide you code in order to avoid learning something:

http://www.lbdsoftware.com/ispftools.html

http://home.roadrunner.com/~mvsrexx/REXX/

or

or mainipulate the data presented by a pds index listing
Back to top
View user's profile Send private message
Akash Sharma

New User


Joined: 13 Jan 2009
Posts: 36
Location: India

PostPosted: Fri Apr 17, 2009 4:53 pm    Post subject: Reply to: Code to count number of lines in a PDS
Reply with quote

HI Dick,

Thanks a lot for the effort and time u have put in replying to the query.
Well, a beginner just expects that some pro could give him a clue whether it is possible or not. I have looked into previous posts for LOC and then posted a new one.
Thanks anyway. Help is much appreciated.
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2086
Location: Silicon Valley

PostPosted: Fri Apr 17, 2009 9:34 pm    Post subject: Reply to: Code to count number of lines in a PDS
Reply with quote

Quote:
a beginner just expects that some pro could give him a clue whether it is possible or not.


If you want lines of text, it is fairly easy. Search the ISPF manuals for the LMMLIST service.

Lines of code is not well defined. For example, some lines might be continued to another line. Is it counted as one line of code or two? Are comments considered lines of code?
Back to top
View user's profile Send private message
Akash Sharma

New User


Joined: 13 Jan 2009
Posts: 36
Location: India

PostPosted: Mon Apr 20, 2009 10:17 am    Post subject: Reply to: Code to count number of lines in a PDS
Reply with quote

Hi Pedro,

Quote:

Is it counted as one line of code or two? Are comments considered lines of code?


Yes, Comments are considered in LOC and continuation of a command in second line also considered as 2 lines.
Its just counting no. of lines in a program blindly.

Thanks for the help.
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2086
Location: Silicon Valley

PostPosted: Tue Apr 21, 2009 5:26 am    Post subject: Reply to: Code to count number of lines in a PDS
Reply with quote

LMMLIST relies on the ISPF statistics being turned on. Sometimes they are not.
Back to top
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Fri May 15, 2009 1:46 pm    Post subject:
Reply with quote

Akash,

Though belated I think I have solution for your problem, let me know if this solves your problem

/*REXX*/
/*ARG DSN */
DSN='XXXX.YYYY.ZZZZ'
DSN0='AAAA.BBBB.CCCC'
ADDRESS TSO "ALLOC DA('"DSN0"') DD(OUTDD) MOD REUSE"
"EXECIO 0 DISKW OUTDD (OPEN" /* OPEN INDD */
X = OUTTRAP('VAR.')
"LISTDS '"DSN"' MEMBERS"
G = 0
/*SAY 'THE NUMBER OF LINES TRAPPED IS' VAR.0 */
DO I = 7 TO VAR.0
MEM=DSN || '(' || STRIP(VAR.I) || ')'
DSE=SYSDSN("'"MEM"'")
IF DSE <> 'OK' THEN
"FREE DD(INDD)"
ADDRESS TSO "ALLOC DA('"MEM"') DD(INDD) SHR REUSE"
EOFFLAG = 2 /* RETURN CODE TO INDICATE END-OF-FILE */
RETURN_CODE = 0 /* INITIALIZE RETURN CODE */
IN_CTR = 0 /* INITIALIZE # OF LINES READ */
"EXECIO 0 DISKR INDD (OPEN" /* OPEN INDD */
DO WHILE (RETURN_CODE ¬ = EOFFLAG) /* LOOP WHILE NOT END-OF-FILE */
'EXECIO 1 DISKR INDD' /* READ 1 LINE TO THE DATA STACK */
RETURN_CODE = RC /* SAVE EXECIO RC */
IF RETURN_CODE = 0 THEN /* GET A LINE OK? */
DO /* YES */
IN_CTR = IN_CTR + 1 /* INCREMENT INPUT LINE CTR */
PARSE PULL LINE.1 /* PULL LINE JUST READ FROM STACK*/
END
END
SAY IN_CTR
G = G + 1
REPORT.G = MEM || ''LINES OF CODE'' IN_CTR
"EXECIO 0 DISKR INDD (FINIS" /* CLOSE THE INPUT FILE, INDD */
"FREE FI(INDD)"
END
X = OUTTRAP('OFF')
DO M = 1 TO G
END
'EXECIO 'G 'DISKW OUTDD(FINIS STEM 'REPORT.
"FREE FI(OUTDD)"
EXIT
END
Back to top
View user's profile Send private message
Akash Sharma

New User


Joined: 13 Jan 2009
Posts: 36
Location: India

PostPosted: Fri May 15, 2009 2:04 pm    Post subject: Reply to: Code to count number of lines in a PDS
Reply with quote

Prasad,

Thanks a lot for the code.
In the meantime i was too working on it.
The below code which i wrote is working too... icon_smile.gif
I have also written an ISPF Panel from where im taking the PDS name as input...performing some validations on it.

Code:

X = OUTTRAP(LISTMEM.,"*")
"LISTDS '"DASN"' MEM "    /* DASN--> PDS NAME

DO CNT = 7 TO LISTMEM.0                                     
   MCNT = MCNT + 1                                         
   MEM = STRIP(LISTMEM.CNT)                                 
   LOC.MCNT = MEM                                           
   PDS=DASN'('MEM')'                                       
   "ALLOC DA('"PDS"') F(INDD4) SHR REUSE"                   
   "EXECIO * DISKR INDD4 (STEM MEMLOC. FINIS"               
   FINVAR.MCNT = DASN || '    ' || MEM || '    ' || MEMLOC.0
   MLOC = MLOC + MEMLOC.0                                   
END


Here MLOC gives a total count count of LOCs in the PDS...
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts Speed-up/reduce CPU use of code prino PL/I & Assembler 0 Tue Sep 26, 2017 12:05 am
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us