# LOC (Lines of code)

**URL:** <https://techcommunity.softwareag.com/t/loc-lines-of-code/59937>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-Utilities, Natural-on-Windows-Unix\
**Created:** [April 26, 2005, 5:51am UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937 "2005-04-26T05:51:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carlos\_Siqueira](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/carlos_siqueira/32/112_2.png) [@Carlos\_Siqueira](https://techcommunity.softwareag.com/u/Carlos_Siqueira)\
**Post date:** [April 26, 2005, 5:51am UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/1 "2005-04-26T05:51:59Z")

</div>

When I am asked to determine how many lines of code that I have for a giving application, I don’t have any utility that would help me.  
Under NATURAL 3.1.6, when I type LIST \* and press PF11, I can see how many lines each module has, but that is only good for that screen.

If I have 1000 modules, I have to keep pressing PF8 and PF11 and keep adding the numbers. If I try in batch, it does not work… ☹

Another approach is to use SYSTRANS UNLOAD and take a look on the number in the report, than I multiply by .75 and get an estimated number.

Any unknown utility available or option of the LIST command ?

Thanks

---

<div class="post-metadata">

**Author:** ![Jon\_Russell](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@Jon\_Russell](https://techcommunity.softwareag.com/u/Jon_Russell)\
**Post date:** [April 26, 2005, 5:35pm UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/2 "2005-04-26T17:35:12Z")

</div>

Carlos,  
If you have Natural Engineer this will give the number of lines information in the “Source Code summary” report.  
Regards  
Jon

---

<div class="post-metadata">

**Author:** ![Carlos\_Siqueira](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/carlos_siqueira/32/112_2.png) [@Carlos\_Siqueira](https://techcommunity.softwareag.com/u/Carlos_Siqueira)\
**Post date:** [April 27, 2005, 6:33am UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/3 "2005-04-27T06:33:46Z")

</div>

Thanks John.

I am aware of Natural Engineer, but we don’t have it and it does not look like we will have it soon.

I was hoping that Darmstad would have a solution similar to the PF11 on the LIST command.

Regards,

Carlos

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 27, 2005, 1:58pm UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/4 "2005-04-27T13:58:34Z")

</div>

For applications compiled with the Optimizer Compiler NOCSTAT may be an option, gives you statement counts for all NOCed objects, with the advantage of providing downloadable CSV or XML output.

---

<div class="post-metadata">

**Author:** ![Scott](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@Scott](https://techcommunity.softwareag.com/u/Scott)\
**Post date:** [April 28, 2005, 2:52am UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/5 "2005-04-28T02:52:47Z")

</div>

NOCSTAT will provide the total number of statements in an object, as well as the number that are noc-able, and also breakdowns by statement type. THe CSV output makes it quite easy to manipulate for totals in Excel. Natural Opt. does not have to be installed to use NOCSTAT. Also it reports statements not lines of code.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 28, 2005, 3:58am UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/6 "2005-04-28T03:58:11Z")

</div>

Right, I mis-formulated…

Should have been “for every compiled object”, of course.

“Statements”, in that context, does not include DEFINE DATAs, btw.

---

<div class="post-metadata">

**Author:** ![Carlos\_Siqueira](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/carlos_siqueira/32/112_2.png) [@Carlos\_Siqueira](https://techcommunity.softwareag.com/u/Carlos_Siqueira)\
**Post date:** [April 28, 2005, 6:45am UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/7 "2005-04-28T06:45:55Z")

</div>

Unfortunately, NOCSTAT does not fit the bill for what we need ☹

---

<div class="post-metadata">

**Author:** ![Scott](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@Scott](https://techcommunity.softwareag.com/u/Scott)\
**Post date:** [April 28, 2005, 7:19am UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/8 "2005-04-28T07:19:46Z")

</div>

Hmmm

I’m curious does NOCSTAT report significantly different numbers than LIST \* :?

---

<div class="post-metadata">

**Author:** ![Carlos\_Siqueira](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/carlos_siqueira/32/112_2.png) [@Carlos\_Siqueira](https://techcommunity.softwareag.com/u/Carlos_Siqueira)\
**Post date:** [April 28, 2005, 7:50am UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/9 "2005-04-28T07:50:41Z")

</div>

Sure, a lot! Just try it and you will see.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 28, 2005, 2:22pm UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/10 "2005-04-28T14:22:44Z")

</div>

NOCSTAT, as I mentioned, totally excludes the DEFINE DATA section.

I’d suggest using USR1032N to read the library directory, then read the objects via USR1057N and count the “lines of code”.

---

<div class="post-metadata">

**Author:** ![Steve3](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@Steve3](https://techcommunity.softwareag.com/u/Steve3)\
**Post date:** [April 29, 2005, 6:53pm UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/11 "2005-04-29T18:53:39Z")

</div>

I found it easier to do a NATUNLD of the source and write a program to read the flat file to count the lines of code.

---

<div class="post-metadata">

**Author:** ![Carlos\_Siqueira](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/carlos_siqueira/32/112_2.png) [@Carlos\_Siqueira](https://techcommunity.softwareag.com/u/Carlos_Siqueira)\
**Post date:** [April 30, 2005, 6:29am UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/12 "2005-04-30T06:29:11Z")

</div>

As I said on my first posting, we use SYSTRANS UNLOAD and than multiply the numbers from the output by .75 to get an estimate.

My company has over 650 applications and 80 of them are critical and written in ADABAS/NATURAL. We really need something simple and objective like LIST LOC \* or ALL or similar.

---

<div class="post-metadata">

**Author:** ![Steve3](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@Steve3](https://techcommunity.softwareag.com/u/Steve3)\
**Post date:** [May 2, 2005, 5:46pm UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/13 "2005-05-02T17:46:08Z")

</div>

Unless you want to submit a CE, then parsing either the NATUNLD or the FUSER file is the only way that I know of to get the information. By Reading the NATUNLD we create a report that can tell us by library, by object type how many lines of code that we have, we also have the option not to count comment lines. I don’t work for a large shop, but not counting comments, we do have over 30 million lines of code in our shop.

If you would like more information on how we do this, let me know, otherwise, I think the CE is your only option.

---

<div class="post-metadata">

**Author:** ![Carlos\_Siqueira](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/carlos_siqueira/32/112_2.png) [@Carlos\_Siqueira](https://techcommunity.softwareag.com/u/Carlos_Siqueira)\
**Post date:** [May 2, 2005, 8:01pm UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/14 "2005-05-02T20:01:31Z")

</div>

Sure, that would be good if you can send the info.  
30 millions ? Huuummm, we have to talk :lol:

---

<div class="post-metadata">

**Author:** ![Steve3](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@Steve3](https://techcommunity.softwareag.com/u/Steve3)\
**Post date:** [May 2, 2005, 10:01pm UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/15 "2005-05-02T22:01:49Z")

</div>

If you send me your email address, I will send you a systrans of the code, I tried to attach it here, but there is a 5k limit and the systrans file is 15k. the program is only about 160 line or less, not large by any means. I can be reach at [slboehm@uss.com](mailto:slboehm@uss.com)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [May 2, 2005, 10:09pm UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/16 "2005-05-02T22:09:47Z")

</div>

Maybe ZIPping it would reduce the size to less than 5k ?

---

<div class="post-metadata">

**Author:** ![Steve3](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@Steve3](https://techcommunity.softwareag.com/u/Steve3)\
**Post date:** [May 3, 2005, 3:41am UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/17 "2005-05-03T03:41:54Z")

</div>

Ok, I think zipping it may work, I used winzip to compress the file  
[slbcnt.zip](https://techcommunity.softwareag.com/uploads/short-url/wGVb8WiSSoFkkVSomTDYJHonuhi.zip) (2.1 KB)

---

<div class="post-metadata">

**Author:** ![Steve3](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@Steve3](https://techcommunity.softwareag.com/u/Steve3)\
**Post date:** [May 3, 2005, 3:42am UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/18 "2005-05-03T03:42:26Z")

</div>

Ok, I think zipping it may work, I used winzip to compress the file  
[slbcnt.zip](https://techcommunity.softwareag.com/uploads/short-url/wGVb8WiSSoFkkVSomTDYJHonuhi.zip) (2.1 KB)

---

<div class="post-metadata">

**Author:** ![Darrell](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@Darrell](https://techcommunity.softwareag.com/u/Darrell)\
**Post date:** [May 5, 2005, 10:43pm UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/19 "2005-05-05T22:43:39Z")

</div>

Carlos,

It sounds like you already have the LISTPROF modified in your SYSLIB or you wouldn’t be getting the LINES counted column. You normally only see the SIZE column (which is the number of bytes). If not, copy LISTPR-S from SYSLIB and modify it to make a SYSPROF in SYSLIB. Be careful of the square brackets, they need to be hex 41 for left, and hex 42 for right.

So, modify the LISTPROF a little more and have it keep the SORT dataset in a library where you can play with it. (Preferrably, do this by user-id, do not make it the default for everyone).

Then from the Natural command line, do a L P \* command, and at the bottom of the first screen type the SORT subcommand. It will generate a Natural member that contains all the info you need.

From there, you have a dozen ways to read the data and add the numbers. For example, batch LIST the member to a file, and have a Natural program READ WORK, add the column for lines and WRITE the totals as you like. Or, once it is listed to a file, DFSORT or SYNCSORT have commands that read files and add columns for you. You don’t even need to write a Natural program if you don’t want. All very simple stuff… only a few minutes of effort to build.

Hope that helps.

---

<div class="post-metadata">

**Author:** ![Carlos\_Siqueira](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/carlos_siqueira/32/112_2.png) [@Carlos\_Siqueira](https://techcommunity.softwareag.com/u/Carlos_Siqueira)\
**Post date:** [May 7, 2005, 10:13pm UTC](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937/20 "2005-05-07T22:13:28Z")

</div>

Huuum, I just got your reply Darrel. I will take a look on Monday.  
Are you still at same number at WSU ?

[Next page](https://techcommunity.softwareag.com/t/loc-lines-of-code/59937.md?page=2)
