View previous topic :: View next topic
|
Author |
Message |
mahapatra
New User
Joined: 16 Aug 2006 Posts: 3
|
|
|
|
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 |
|
|
vicky10001 Warnings : 1 Active User
Joined: 13 Jul 2005 Posts: 136
|
|
|
|
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 |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
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 |
|
|
mahapatra
New User
Joined: 16 Aug 2006 Posts: 3
|
|
|
|
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 |
|
|
mahapatra
New User
Joined: 16 Aug 2006 Posts: 3
|
|
|
|
Thanks Ofer...thanx for the MACRO...really a nice one to count....I appriciate ur effort.. |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
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 |
|
|
vicky10001 Warnings : 1 Active User
Joined: 13 Jul 2005 Posts: 136
|
|
|
|
Q)Do u know any command to elliminate those blank lines from count...
Del X all; |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
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 |
|
|
vicky10001 Warnings : 1 Active User
Joined: 13 Jul 2005 Posts: 136
|
|
|
|
Please Use command
1 step -x all ' ';
2 step - Del x all;
If you have any questions let me know |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
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 |
|
|
vicky10001 Warnings : 1 Active User
Joined: 13 Jul 2005 Posts: 136
|
|
|
|
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 |
|
|
Sridevi_C
Active User
Joined: 22 Sep 2005 Posts: 104 Location: Concord, New Hampshire, USA.
|
|
|
|
Vicky,
It doesn't work as the command line is less than column 8 to 72 range of executable code :-(
Thanks. |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
True, and you can't expand the command line in ISPF editor.
O. |
|
Back to top |
|
|
baidyanath_biswas
New User
Joined: 04 Sep 2006 Posts: 11
|
|
|
|
In the above macro,where do u mention the file name containing the program? |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
This is an Edit-Macro. You invoke it from within your editor while editing the program.
O. |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
PL1user
New User
Joined: 26 Nov 2008 Posts: 13 Location: UK
|
|
|
|
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 |
|
|
|