Number of lines of code in a program

895 pts.
Tags:
AS/400
RPG
hi, I've 50 programs to find the number of lines of code in it...

is there any smart way?

Thanks,

N.



Software/Hardware used:
as400

Answer Wiki

Thanks. We'll let you know when a new response is added.

You can paste it in Microsoft Word and use the word count tool or use an editor like visual studio or visual studio express which have line numbers.
=
A simple way is to just do DSPFD of the source file.
At the end, it will list each member with the number of records.

———————–
DSPFD on the source file – will show the number of rows in each member — some are comments, but this is a quick and dirty ..

——————–

The QUSRMBRD (Retrieve Member Description) API returns descriptive information about the member in a file. Parameter FMTNM2 specifies the format of the returned information. Format MBRD0200 is the first format option that returns the number of records and the number of deleted records in the file.

<pre>
D szMsgText S 255A
** Tells the APIs how long the buffers are that are being used.
D nBufLen S 10I 0
** The structure returned by the QusRMBRD API.
D szMbrd0100 DS INZ
D nBytesRtn 10I 0
D nBytesAval 10I 0
D szFileName 10A
D szLibName 10A
D szMbrName 10A
D szFileAttr 10A
D szSrcType 10A
D dtCrtDate 13A
D dtLstChg 13A
D szMbrText 50A
D bIsSource 1A
D RmtFile 1A
D LglPhyFile 1A
D ODPSharing 1A
D filler2 2A
D RecCount 10I 0
D DltRecCnt 10I 0
D DataSpaceSz 10I 0
D AccpthSz 10I 0
D NbrBasedOnMbr 10I 0

**—————————————————————-
** Input Parameters for the program.
**—————————————————————-
** Source file name
D szSrcFile S 10A
D szSrcLib S 10A
D szSrcMbr S 10A

**—————————————————————-
** Input Parameters to the QUSRMBRD API
**—————————————————————-
** Format to be returned
D szFmt S 8A Inz(‘MBRD0200′)
** Qualified source file and library name
D szQualName S 20A
** Whether or not to ignore overrides (0=Ignore, 1 = Apply)
D bOvr S 1A Inz(’0′)

**—————————————————————-
** Call this program with 3 parameters:
** Parm(QRPGLESRC myLibr ORDENTRY)
** srcfile srclib srcmbr
**—————————————————————-
C *ENTRY PLIST
C Parm szSrcFile
C Parm szSrcLib
C Parm szSrcMbr

**—————————————————————-
** Call QusRMBRD to retrieve the specified source member’s
**—————————————————————-
C Eval szQualName = szSrcFile + szSrcLib
C Eval nBufLen = %size(szMbrD0100)

**—————————————————————-
C Call(E) ‘QUSRMBRD’
C Parm szMbrD0100
C Parm nBufLen
C Parm szFmt
C Parm szQualName
C Parm szSrcMbr
C Parm bOvr

**—————————————————————-
** If RTFMBRD failed, we tell the FTP client that it failed.
**—————————————————————-
C if %Error
C Eval szMsgText = ‘RTVMBRD Failed’
C endif

C return
</pre>

—-
Another way

Give the command CMPPFM and take an F4

Give the Source Physical file name on both ‘New file’ and ‘Old file’ fields that are required by the command.

Use *ALL for keywords NEWMBR

Use *OMTRPGLECMT for keyword OPTION – in this case I am illustrating to avoid RPGLE code comments being counted along with LOC. You can select the appropriate keyword here if the source is different, for example *OMTCLCMT for omitting CL source statement comments. You can always leave this option blank if you wish to count commented lines as well

Select an desired output and press enter

However the command ends up with an error saying that there is no changes between new file and the old one, you will see a spool file created.

The three columns you see with same numbers are the lines of code in each source member. Just sum them up, you will get the total lines of code in the source physical file QRPGLESRC.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Nutangujar
    Context is a very good editor that has many features including showing line numbers.
    0 pointsBadges:
    report
  • Rajgoaj
    Give the command CMPPFM and take an F4 Give the Source Physical file name on both 'New file' and 'Old file' fields that are required by the command. Use *ALL for keywords NEWMBR Use *OMTRPGLECMT for keyword OPTION - in this case I am illustrating to avoid RPGLE code comments being counted along with LOC. You can select the appropriate keyword here if the source is different, for example *OMTCLCMT for omitting CL source statement comments. You can always leave this option blank if you wish to count commented lines as well Select an desired output and press enter However the command ends up with an error saying that there is no changes between new file and the old one, you will see a spool file created. The three columns you see with same numbers are the lines of code in each source member. Just sum them up, you will get the total lines of code in the source physical file QRPGLESRC.
    280 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following