Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to calculate Lines of code

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
mahapatra

New User


Joined: 16 Aug 2006
Posts: 3

PostPosted: Wed Aug 16, 2006 4:23 pm    Post subject: How to calculate Lines of code
Reply with quote

Can any body tell me how to calculate the total lines of code in an application...I dont want the comments in the program...only the valid codes..
Back to top
View user's profile Send private message

vicky10001
Warnings : 1

Active User


Joined: 13 Jul 2005
Posts: 136

PostPosted: Wed Aug 16, 2006 4:48 pm    Post subject:
Reply with quote

Please Use below comments

Please Should use View mode onlY

1- x all "*" 7:
2- del x all;
3. num on/off
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Wed Aug 16, 2006 4:48 pm    Post subject:
Reply with quote

Try the following edit-macro:
Code:
/* REXX */                                                             
                                                                       
ADDRESS ISREDIT "MACRO PROCESS"                                         
ADDRESS ISPEXEC "CONTROL ERRORS RETURN"                                 
ADDRESS ISREDIT "(LASTL)  = LINENUM .ZLAST "                           
ADDRESS ISREDIT "FIND ALL '*' 7 7 "                                     
ADDRESS ISREDIT "(DUMMY,LINES) = FIND_COUNTS"                           
ADDRESS ISREDIT "RESET"                                                 
                                                                       
LASTL = STRIP(LASTL,"L","0")                                           
ZEDLMSG = COPIES('*',6) STRIP(COMMA(LASTL),'L','0'),                   
          'LINES,' LINES+0 'COMMENTED' COPIES('*',6)                   
ADDRESS ISPEXEC "SETMSG MSG(ISRZ000)"                                   
                                                                       
EXIT                                                                   
                                                                       
/* ------------------------------------------------------------------ */
   COMMA:                                                               
/* ------------------------------------------------------------------ */
                                                                       
ARG NUM                                                                 
IF NUM < 1000 THEN RETURN NUM                                           
                                                                       
REVNUM = REVERSE(NUM)                                                   
IF POS('.',REVNUM) <> 0 THEN                                           
   PARSE VAR REVNUM MANTISSA '.' REVNUM                                 
ELSE                                                                   
   MANTISSA = ''                                                       
DO WHILE START < LENGTH(REVNUM) - 4                                     
   START = LASTPOS(',',REVNUM) + 3                                     
   REVNUM = INSERT(',',REVNUM,START)                                   
END                                                                     
NUM = REVERSE(REVNUM)                                                   
IF MANTISSA <> '' THEN NUM = NUM || '.' || REVERSE(MANTISSA)           
                                                                       
RETURN NUM                                                             
                                                                       


O.
Back to top
View user's profile Send private message
mahapatra

New User


Joined: 16 Aug 2006
Posts: 3

PostPosted: Wed Aug 16, 2006 6:34 pm    Post subject:
Reply with quote

Thanks Vicky...I tried with 1st step and then deduct the no of comments line from Size and got the actual Lines of code including the Blank line....So Do u know any command to elliminate those blank lines from count...
Back to top
View user's profile Send private message
mahapatra

New User


Joined: 16 Aug 2006
Posts: 3

PostPosted: Wed Aug 16, 2006 6:37 pm    Post subject:
Reply with quote

Thanks Ofer...thanx for the MACRO...really a nice one to count....I appriciate ur effort..
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Wed Aug 16, 2006 6:46 pm    Post subject:
Reply with quote

To count blank lines, try the following edit-macro:

Code:

/*------------------------------- REXX -------------------------------
 * PROGRAM   : CBLK                                                   
 * FUNCTION  : Count blanks lines.                                     
 * AUTHOR    : OFER                                                   
 * DATE      : 13/03/03                                               
 * HOW TO USE: From within editor, type CBLK                           
 *------------------------------------------------------------------*/
                                                                       
ADDRESS ISREDIT "MACRO PROCESS"                                       
                                                                       
ADDRESS ISPEXEC "CONTROL ERRORS RETURN"                               
ADDRESS ISREDIT "(RECLEN) = LRECL"                                     
                                                                       
VAR = COPIES(' ',RECLEN)                                               
                                                                       
ADDRESS ISREDIT "FIND '"VAR"' 1 "RECLEN" ALL"                         
ADDRESS ISREDIT "(DUMMY,BLANKS) = FIND_COUNTS"                         
ADDRESS ISREDIT "RESET"                                               
                                                                       
SAY BLANKS + 0 'BLANK LINES'                                           
                                                                       
EXIT                                                                   
                                                                       


O.
Back to top
View user's profile Send private message
vicky10001
Warnings : 1

Active User


Joined: 13 Jul 2005
Posts: 136

PostPosted: Thu Aug 17, 2006 6:44 pm    Post subject:
Reply with quote

Q)Do u know any command to elliminate those blank lines from count...

Del X all;
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Thu Aug 17, 2006 6:51 pm    Post subject:
Reply with quote

In the same manner:
Code:
/****************************** REXX ******************************** */
/*                                                                    */
/* Name.......: DELBLANK                                              */
/*                                                                    */
/* Function...: Edit macro to delete blank lines in editor.           */
/*                                                                    */
/* Date.......: 13/03/2003.                                           */
/*                                                                    */
/* Author.....: OFER                                                  */
/*                                                                    */
/* Reqirements: ISPF                                                  */
/*                                                                    */
/* Description: Rtrieve the logical length of the data being edited,  */
/*              then delete all the lines that contain consecutive    */
/*              blank by this size.                                   */
/*              If no line deleted, a message shows.                  */
/*                                                                    */
/**********************************************************************/
                                                                       
ADDRESS ISREDIT "MACRO PROCESS"                                         
ADDRESS ISPEXEC "CONTROL ERRORS RETURN"                                 
ADDRESS ISREDIT "(RECLEN) = LRECL"                                     
                                                                       
LBLANK = COPIES(' ',RECLEN)                                             
                                                                       
ADDRESS ISREDIT "EXCLUDE '"LBLANK"' 1 "RECLEN" ALL"                     
IF RC = 4 THEN DO                                                       
  ZEDLMSG = 'No blank lines in data.'                                   
  ADDRESS ISPEXEC "SETMSG MSG(ISRZ000)"                                 
  EXIT                                                                 
END                                                                     
                                                                       
ADDRESS ISREDIT "DEL X ALL"                                             
                                                                       
EXIT 1                                                                 
                                                                       


O.
Back to top
View user's profile Send private message
vicky10001
Warnings : 1

Active User


Joined: 13 Jul 2005
Posts: 136

PostPosted: Thu Aug 17, 2006 7:24 pm    Post subject:
Reply with quote

Please Use command

1 step -x all ' ';
2 step - Del x all;

If you have any questions let me know
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Thu Aug 17, 2006 7:26 pm    Post subject:
Reply with quote

vicky10001 - You can't just exclude all lines with ' '. It will exclude every line... You have to delete only lines that contain all blanks...

O.
Back to top
View user's profile Send private message
vicky10001
Warnings : 1

Active User


Joined: 13 Jul 2005
Posts: 136

PostPosted: Thu Aug 17, 2006 8:06 pm    Post subject:
Reply with quote

Sorry .....Typed mistake


1 step - X all " Need to give maximum space ";

2 step -Del x all;

Ex :

X all " ";
Del x all;
Back to top
View user's profile Send private message
Sridevi_C

Active User


Joined: 22 Sep 2005
Posts: 104
Location: Concord, New Hampshire, USA.

PostPosted: Thu Aug 17, 2006 8:28 pm    Post subject: Re: How to calculate Lines of code
Reply with quote

Vicky,

It doesn't work as the command line is less than column 8 to 72 range of executable code :-(

Thanks.
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Thu Aug 17, 2006 9:31 pm    Post subject:
Reply with quote

True, and you can't expand the command line in ISPF editor.

O.
Back to top
View user's profile Send private message
baidyanath_biswas

New User


Joined: 04 Sep 2006
Posts: 11

PostPosted: Wed Sep 20, 2006 12:27 pm    Post subject: Where do u mention the file-name for which u r checking
Reply with quote

In the above macro,where do u mention the file name containing the program?
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Wed Sep 20, 2006 1:13 pm    Post subject:
Reply with quote

This is an Edit-Macro. You invoke it from within your editor while editing the program.

O.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Fri Sep 22, 2006 12:53 am    Post subject: Re: How to calculate Lines of code
Reply with quote

Try this:

X ALL
F P'?' ALL
X '*' 7 ALL
DELETE ALL X
RENUM

You can see the number of lines of code

CANCEL <=== be sure to do this


Dave
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Sep 23, 2006 9:11 pm    Post subject:
Reply with quote

For those that are prohibited/discouraged from using edit macros, you can try this variation on Vicky's suggestion:

Be sure to use VIEW or V not EDIT (E).

enter cmd line: x all;f all ' ' 7
enter cmd line: x all 7 'put as many spaces here as can fit the cmd line '
f all nx ' ' 7

The edit msg in the upper RH corner of the screen will tell you the # of lines found. This is the # of lines of code in the pgm, excluding code generated by copybooks.

You may pick up a few compiler directing stmts that technically aren't "code".

Oops, I didn't see David's entry till I edited this post. I kind of like this variation of his better than mine:

Use View.
x all;f all 7 72 p'^';x all 7 P'^';f all nx 7 ' '

The found cnt in the upper RH of the screen s/b the # of code lines.

The 7 72 above makes sure you don't pick up a blank line that has info in 1-6 or 73-80.
Back to top
View user's profile Send private message
PL1user

New User


Joined: 26 Nov 2008
Posts: 13
Location: UK

PostPosted: Thu Dec 04, 2008 2:49 am    Post subject:
Reply with quote

Hi,

Just came through this post...

Would it be possible to get the total lines of code for the programs in the entire program library.

E.G: If there are 10k programs in my library, would I be able to calculate the lines of code for the entire set in one go?

I am completely new to REXX but I now have a quick requirement to calculate the lines of code...and REXX should be the quickest and easiest way.

Any sort of help would be of great help.

Thanks.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 1 Fri Dec 02, 2016 9:47 am
No new posts What is the code in CLIST to enable t... jackzhang75 CLIST & REXX 1 Fri Dec 02, 2016 3:02 am
No new posts IDEAL - Code Retrieval yugendran CA Products 0 Fri Nov 25, 2016 3:27 pm
This topic is locked: you cannot edit posts or make replies. Need to code a Rexx PGM sundaram.naveen CLIST & REXX 18 Thu Oct 06, 2016 6:45 pm
No new posts Need Help in understanding what is th... mainakdalal PL/I & Assembler 9 Mon Oct 03, 2016 8:03 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us