How to get number of lines in sourse code?

iudenika

New Member
Using COMPILER is there any way to get the number of line in source file. I need to get this as a output. Is there any way revert back to me.

Thax
 
why do you want the compiler to return you lines in source file? Do you want to add all the include files within the source file? What are you planning to do?
 
Do you want a count of the lines in the source file? If so the compiler doesn't do that.

On the other hand if you are looking for output that has line numbers on it then maybe you want the LISTING or DEBUG-LIST options to the COMPILE statement. For instance:

Code:
/* lineNum.p
 *
 * produce line numbers in an output file with the COMPILE command
 */

{nothing.i}

compile "lineNum.p" listing    "lineNum.lis".
compile "lineNum.p" debug-list "lineNum.dbg".

return.

----

/* nothing.i
 */

/* really, there is nothing here! */

Then run lineNum.p and it will produce:

lineNum.dbg
Code:
        1   /* lineNum.p
        2    *
        3    * produce line numbers in an output file with the COMPILE command
        4    */
        5
        6
        7   /* nothing.i
        8    */
        9
       10   /* really, there is nothing here! */
       11
       12
       13
       14   compile "lineNum.p" listing    "lineNum.lis".
       15   compile "lineNum.p" debug-list "lineNum.dbg".
       16
       17   return.

lineNum.lis
Code:
./lineNum.p                           05/20/2010 13:23:47   PROGRESS(R) Page 1

{} Line Blk
-- ---- ---
      1     /* lineNum.p
      2      *
      3      * produce line numbers in an output file with the COMPILE command
      4      */
      5
      6     {nothing.i}
 1    1     /* nothing.i
 1    2      */
 1    3
 1    4     /* really, there is nothing here! */
 1    5
      6
      7
      8     compile "lineNum.p" listing    "lineNum.lis".
      9     compile "lineNum.p" debug-list "lineNum.dbg".
     10
     11     return.
^L./lineNum.p                           05/20/2010 13:23:47   PROGRESS(R) Page 2

     File Name       Line Blk. Type   Tran            Blk. Label
-------------------- ---- ----------- ---- --------------------------------
./lineNum.p             0 Procedure   No
 
Thax lot
TomBascom

vinod_home

I think debug-list option more use full for my requirement.

Actually my real requirement is, i have a 4GL legacy code base we need to get rough estimate for this code base. I just wanted to get no of line each and every program.
 
If the OS is UNIX then something like this is what you want:

Code:
find . -name "*.[ip]" -exec wc -l {} \; | awk '{lines += $1} END {print lines}'
 
Note that the total line count from the compile listings may be much larger than the total number of lines of source code since any given include file will be counted every place it is used. Conversely, if you make heavy use of preprocessor commands, there may be lines in the source file that don't show in the listings.

If you are on Unix and Tom's one liner doesn't do it for you, let me know and I will post a script with a number of options that you should be able to adapt to the purpose.
 
Back
Top