Count Lines of Code?

Is there any way that I can count the number of lines of code in Script libraries, agents etc.? Design synopsis does not provide the information.

Thanks

Subject: One method…

Copy and paste the code into Tex Pad or someother Text application and count the lines.

Subject: RE: Count Lines of Code???

Don’t copy and paste, but export the script to a text file. Then use some other program to count the lines.

Subject: RE: Count Lines of Code???

Thanks for the response. As suggested I am exporting the code to a text file as “agentcode.txt” and then trying to count the number of lines. It is working but it is also counting the blank lines. Below is the code snippet:—

fileNum% = Freefile

ctr = 0

counter = 0

Open “c:\temp\agentcode.txt” For Input As fileNum%

Do While Not Eof(fileNum%)

Line Input #fileNum%, text$

temp = Left$( text, 1)

If text = “” Then

counter = counter + 1 'counting the blank lines

Elseif temp = “'” Then

counter = counter + 1 ’ commented lines

Else

ctr = ctr + 1 'actual lines of code.

End If

Loop

Close fileNum%

Messagebox(ctr)


The line that checks for blanks is not picking up all the blank lines. I tried to debug and some blank lines are not coming back as TEXT/STRING but something different.

Don’t know how to get a handle on all blank lines.

Any help is apprreciated.

Thanks

Subject: RE: Count Lines of Code???

A variable named text$ always contains a “text/string” value. If the debugger seems to be saying something different, it’s because of a display problem in the debugger.

A blank line doesn’t necessarily contain no characters – it may contain tabs or spaces. Exported LotusScript code assuredly contains tabs on some of its blank lines. The tabs may also be what’s messing up the display in the debugger.

You must strip off any leading tabs and spaces before checking whether the line is blank or whether the first character is apostrophe. You might do that as follows:

While text$ Like "[ " & Chr$(9) & “]*”

text$ = mid$(text$, 2)

Wend

Or you could use Replace and Trim, but be careful because Replace is likely to crash the Notes client if you give it the wrong argument types. Save your work before you try a script with Replace.

Incidentally, I notice your code doesn’t account for %REM comments.

Subject: RE: Count Lines of Code???

Thanks Andre, it works after the changes.