Skip to main content

Problem

How to get count of how many lines of code in project/workspace

Resolution

Visual COBOL or Enterprise Developer do not offer a built in feature for this but an alternative is to use listing files to generate the information, then use a script to read those.

Content of .bat file used:

@ECHO OFF
setlocal enabledelayedexpansion
     set /A counter=0
for /F "delims=" %%a in ('findstr /S /I /C:"Lines of Code" *.lst') do (
     set result=%%a
     set /A endresult = endresult+!result:~-5%!
     set /A counter +=1
)
     echo Source line counter results are:
     echo Listing (.lst) files processed: %counter%
     echo Total lines of code counted: %endresult%


-Complete sample: linecounter-sample.zip.

-First set affected projects as follows, in the project properties see example:

-Compile affected projects (to generate .lst listing files).

-Copy the .bat file into the root of the project/workspace to count code lines for and execute, like below:


-Execute the .bat file to get the count of lines:

Article: https://portal.microfocus.com/s/article/KM000002265?language=en_US 


#SupportTips/SupportTips/KnowledgeDocs
#SupportTips/KnowledgeDocs