473,385 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Counting Commented lines in code

In Pl/SQL scripts, The comments are multi lined starting from /* and ending with */.
How can we count the commented lines if there are hundred scripts to be scanned.
a grep command will give only the first and last line.
Mar 28 '08 #1
6 2391
amitpatel66
2,367 Expert 2GB
In Pl/SQL scripts, The comments are multi lined starting from /* and ending with */.
How can we count the commented lines if there are hundred scripts to be scanned.
a grep command will give only the first and last line.
Are you looking at counting total number of commented lines from a file?
Mar 28 '08 #2
yes, i am looking at counting total no of lines in a code which are commented but not from a single file...it has to be done for abt 100 PL/SQL codes....
Mar 28 '08 #3
amitpatel66
2,367 Expert 2GB
yes, i am looking at counting total no of lines in a code which are commented but not from a single file...it has to be done for abt 100 PL/SQL codes....
Try this:

1. Have a counter = 0
2. Loop through the file, read line by line and grep for /* or *\. Say /* is in 6th Line. Then here counter = 6. Assign this calue to another variable say start_of_line = 6
3. Then cotinue fetching and checking for /* or *\. If you find *\ in 10th line. Now counter = 10, now result=result + (counter - start_of_line));
So result = 0 + (10-6) => 4;
4. Continue for another set of lines in the loop and keep adding to the result. Finally when you reach END OF FILE, you will have the total number of lines in the PLSQL CODE.

Try implementing this logic and let us know in case of any issues.
Mar 28 '08 #4
amitpatel66
2,367 Expert 2GB
yes, i am looking at counting total no of lines in a code which are commented but not from a single file...it has to be done for abt 100 PL/SQL codes....
If you want only the sum of total count from all the files as such, then i suggest you to concatenate all the files in to a single one and then loop through a single file. If you want the count file wise, then you need to loop through the files individually.
Mar 28 '08 #5
Yes, this is an option but using 'sed' to count the commented lines gives quite good results :)
Mar 28 '08 #6
amitpatel66
2,367 Expert 2GB
Yes, this is an option but using 'sed' to count the commented lines gives quite good results :)
Thats Good!! I dont have a unix box here else I would have tried and checked it out!!
Mar 28 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: Alex Vinokur | last post by:
Is there any tool to count C-program lines except comments? Thanks, ===================================== Alex Vinokur mailto:alexvn@connect.to http://mathforum.org/library/view/10978.html...
7
by: sathyashrayan | last post by:
Group, Following function will check weather a bit is set in the given variouble x. int bit_count(long x) { int n = 0; /* ** The loop will execute once for each bit of x set,
1
by: j | last post by:
Hi, I've been trying to do line/character counts on documents that are being uploaded. As well as the "counting" I also have to remove certain sections from the file. So, firstly I was working...
5
by: andy.lee23 | last post by:
hi im having trouble counting lines in a text file, i have the following code int node1, node2, i; char name; float value; ifstream fin; fin.open(OpenDialog1->FileName.c_str()); i=1;
10
by: cj | last post by:
I'm writing a TCP/IP server app that will have many simultaneous connections. The main thread listens for new connections and starts a thread to handle each requested connection. These are short...
16
by: sophie_newbie | last post by:
I have a list a little something like this: StringA StringC StringB StringA StringC StringD StringA ....
14
by: Dan | last post by:
Is this discouraged?: for line in open(filename): <do something with line> That is, should I do this instead?: fileptr = open(filename) for line in fileptr: <do something with line>
7
by: peraklo | last post by:
Hello, there is another problem i am facing. i have a text file which is about 15000 lines big. i have to cut the last 27 lines from that file and create a new text file that contans those 27...
2
by: aparajita | last post by:
In C scripts, The comments are multi lined starting from /* and ending with */. How can we count the commented lines if there are hundred scripts to be scanned. a grep command will give only the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.