Natural Program - Line of code Information

How to get the total line of code from a NATURAL PROGRAM? Can we get it through PREDICT? If so,can some one explain the procedure?
Are there any utiliites available?

Thanks,
Arun

It depends on what you count a “line of code”, e.g. do you want to

  • exclude comments ?
  • count “lines” or “statements” (what about multiple statements on one line ?)

The easiest way is to issue a

L *
L P *

etc. , then press PF11 to shift right and this will give you a “count of lines”.

I am not getting the LOC after hitting PF11. I need LOC with commented lines.

Which Natural version are we talking about ?

When I issue a L P USR* in SYSEXT (Natural v4.2), for example, I see, after hitting PF11


14:46:01               ***** NATURAL LIST COMMAND *****              2012-04-23
User XYZ                 - LIST Objects in a Library -         Library SYSEXT  
                                                                               
Cmd  Name     Source Type Size   Lines SM Vers.  User ID  Save Date  Save Time 
---  -------- ----------- ------ ----- -- ------ -------- ---------- --------- 
__   USRTEST  Program       5616   181 S  4.2.04 CNDTSO   2008-01-02 22:04:21  
__   USRTEST2 Program       5496   181 S  4.2.04 CNDTSO   2008-01-03 17:47:13  
__   USRTINA  Program       5620   181 S  4.2.04 CNDTSO   2008-01-02 21:49:29  
__   USR0010P Program       1071    34 S  4.2.01 NAT421   2006-03-06 16:07:37  

The “Lines” column indicates the number of source lines.

Even We are using 4.2 however I am not getting,Are there any other ways?

Hi Arun,

I see what you mean. We have Natural 4.2.7, and the PF11 screen for me looks like this:

09:43:21 	              	***** NATURAL LIST COMMAND ***** 	             	2012-04-23
User 	VSTA003  	           	- LIST Objects in a Library - 	        	Library 	SYSEXT  
                                                                               
Cmd  	Name 	    	Source Type 	Size 	  	      	SM Vers.  User ID  	Save Date  	Save Time 
---  	-------- 	----------- 	------ ----- -- ------ -------- ---------- --------- 
__ 	  	USR0010P 	Program     	  1071 	      	S  	4.2.01 	NAT421   	2006-03-06 	16:07:37 	 
__ 	  	USR0011P 	Program     	  1108 	      	S  	4.2.01 	NAT421   	2006-03-06 	16:07:37 	 
__ 	  	USR0020P 	Program     	  3175 	      	S  	4.2.01 	NAT421   	2006-03-06 	16:07:37 	 
__ 	  	USR0040P 	Program     	   535 	      	S  	4.2.01 	NAT421   	2006-03-06 	16:07:37 	 
__ 	  	USR0050P 	Program     	  2402 	      	S  	4.2.01 	NAT421   	2006-03-06 	16:07:37 	 
__ 	  	USR0060P 	Program     	  2958 	      	S  	4.2.01 	NAT421   	2006-03-06 	16:07:37 	 

If you are looking for lines in just one object, you can bring it into the editor:

> 	                                      	> 	+ 	Program     	USR0010P  	Lib 	SYSEXT   
Top  	  	....+....1....+....2....+....3....+....4....+....5....+.Mode Structured.
  	0010 	/* This program serves as example how to design a user-defined          
  	0020 	/* program to call 'USR0010N'                                           
  	0030 	/***********************************************************************
  	0040 	DEFINE DATA                                                             
  	0050 	LOCAL                                                                   
  	0060 	 1 USR0010L                                                             
  	0070 	   2 OUTPUTS                                                            
  	0080 	     3 FILENAME       (A12/1:50)                                        
  	0090 	     3 DBID           (P03/1:50)                                        
  	0100 	     3 FNR            (P03/1:50)                                        
  	0110 	     3 DBNAME         (A07/1:50)                                        
  	0120 	     3 AMOUNT         (P04)                                             
  	0130 	 1 IX                 (I01)                                             
  	0140 	END-DEFINE                                                              
  	0150 	/**********************                                                 
  	0160 	CALLNAT 'USR0010N'  USR0010L                                            
  	0170 	/*                                                                      
  	0180 	IF AMOUNT = 0                                                           
  	0190 	  WRITE '*** INFORMATION NOT AVAILABLE ***' (I)                         
  	0200 	ELSE                                                                    
       	....+..Current Source Size: 1071 Char. Free: 304642 ..+... 	S 	34   	L 	1   

The number 34 on the bottom right indicates lines of source code.

Interesting, I’m in a NAT427 non-NSC environment, this may make a difference.

Can you please try if USR4216P gives you the line numbers (it does for me), in the last column here

Number returned ...          10 End of List .......                        
USRTEST  S   Program     S 4.2.04 CNDTSO   2008-01-02 22:04:21   5616   181
                                                                                                                                                      
USRTEST2 S   Program     S 4.2.04 CNDTSO   2008-01-03 17:47:13   5496   181                                                                           
                                                                           
USRTINA  S   Program     S 4.2.04 CNDTSO   2008-01-02 21:49:29   5620   181                                                                           
                                                                           
USR0010P S   Program     S 4.2.01 NAT421   2006-03-06 16:07:37   1071    34

Arun and Brian, on the command line of the “LIST Objects in a Library” screen, enter the COUNTsource subcommand. I think this will give you the Lines column that Wolfgang sees.

I don’t have to, Ralph, I see them right away …

USR4216P does provide this line count as Wolfgang suggested. It’s odd that L P * and PF11 behaves differently.

Page 	     1 	                                                 	12-04-23  10:12:28
                                                                               
Number returned ... 	         10 	End of List ....... 	                           
USR0010P 	S/C 	Program 	    	S 	4.2.01 	NAT421 	  	2006-03-06 	16:07:37 	  1071 	   34 	   
             	Program 	    	S 	4.2.01 	NAT421 	  	2006-02-24 	15:32:01 	  3564 	  1744 	  
             	IBM01140 	                                                         
USR0011P 	S/C 	Program 	    	S 	4.2.01 	NAT421 	  	2006-03-06 	16:07:37 	  1108 	   32 	   
             	Program 	    	S 	4.2.01 	NAT421 	  	2006-02-24 	15:32:01 	  3416 	   664 	  
             	IBM01140 	                                                         
USR0020P 	S/C 	Program 	    	S 	4.2.01 	NAT421 	  	2006-03-06 	16:07:37 	  3175 	   87 	   
             	Program 	    	S 	4.2.01 	NAT421 	  	2006-02-24 	15:32:02 	  5340 	  2592 	  
             	IBM01140 	                                                         
USR0040P 	S/C 	Program 	    	S 	4.2.01 	NAT421 	  	2006-03-06 	16:07:37 	   535 	   17 	   
             	Program 	    	S 	4.2.01 	NAT421 	  	2006-02-24 	15:32:02 	  2852 	   592 	  
             	IBM01140 	                                                         
USR0050P 	S/C 	Program 	    	S 	4.2.01 	NAT421 	  	2006-03-06 	16:07:37 	  2402 	   71 	   
             	Program 	    	S 	4.2.01 	NAT421 	  	2006-02-24 	15:32:02 	  4880 	  1120 	  
             	IBM01140 	                                                         
USR0060P 	S/C 	Program 	    	S 	4.2.01 	NAT421 	  	2006-03-06 	16:07:37 	  2958 	   91 	   
             	Program 	    	S 	4.2.01 	NAT421 	  	2006-02-24 	15:32:02 	  4400 	   832 	  
             	IBM01140 	                                                         
USR0080P 	S/C 	Program 	    	S 	4.2.03 	NAT424 	  	2007-11-05 	21:02:30 	  2843 	   79 	   
             	Program 	    	S 	4.2.02 	NAT423 	  	2006-12-14 	17:44:26 	  5292 	   968 	  
VVVV 	                                                                          

Line count is all the way on the right column.

It looks to me like Wolfgang’s COUNTSOURCE setting is ON and Arun and Brian are set to OFF. Wolfgang, you will see what they see by entering subcommand COUNT OFF.

For GPs the rightmost column shows the DATSIZE, so make sure to filter sources only :wink:

Right, looks like the relevant parameter in LISTPROF has been changed from the default of N to Y in this environment…

Thanks Everyone.USR4216P worked for me.
I am creating seperate Batch program to get the LOC in dataset.I am trying to call the inetrface USR4216N,however my module failed due to subprogram is not founr. Even I copied my module to SYSTEM libray and its not working,

Please advice how to get rid off this error.

Thanks,
Arun

Did you copy it to SYSTEM/FNAT or SYSTEM/FUSER ?

While it shouldn’t matter you should only copy to SYSTEM/FUSER, and then it
should be found as SYSTEM is automatically added to the STEPLIB chain.

If it still does not work (it definitely should) I can only assume a typo in your
calling program, i.e. you misspelled the subprogram name etc.

USR4216N it has only object code,I could not able to see the SOURCE code.Cab you please tell how to place USR4216N in system fuser?
If I execute from SYSEXT it is working fine.

Use SYSPROF to find the dbid/file number for FUSER

Use SYSMAIN to copy USR4216N from SYSEXT/FNAT to SYSTEM/FUSER

Thanks.I will try that.

Hi

I can get Lines of code by PF11 key in online with L P * and giving countsource ON in command
.
When trying to get same results in Batch via below code, am able see results of 1st screen and last screen, but not 2nd screen with PF11(total 4 screen results)

//CMSYNIN DD *
LOGON SYSTEM
L P *
FIN
//*

What to be included to get all results.

In batch PF keys can be simulated with %K (for example, %K11 for PF11), but they are not accepted by all Natural commands and displays.

If you have the latest Natural version, 8.2.6, you can try

LIST P * SET COUNT-SOURCE-LINES=Y