NO

Author Topic: Line Counter Add-IN  (Read 38548 times)

Offline John Z

  • Member
  • *
  • Posts: 860
Line Counter Add-IN
« on: May 17, 2021, 04:00:50 PM »
Here is version 1.7.6.1 of an Add-In for PellesC (of course).
This Add-In is a Line counter. I saw a forum member ask for one.
The Add-In will be a menu item under the main menu 'Source.' It
will show as "Line Counts +".

It will do more than just line counting. You can get the line number for each user procedure.  You can also get list of all user procedures called from within each user procedure.  BTW the user procedure determination is independent and not using the treeview information from the project window.

John Z

Update 6/24 - The attachment here is the latest version 1.7.5 to make it easy  :)
Update 7/6/2023 - The attachment here is the Pelles C V12.002 build to version 1.7.6
Update 8/14/2023 - The attachment here is the Pelles C V12.002 build to version 1.7.6.1
Update 11/01/2023 - The attachment on page 6 is the Pelles C V12.002 build to version 1.7.7
« Last Edit: August 26, 2024, 10:50:42 PM by John Z »

Grincheux

  • Guest
Re: Line Counter Add-IN
« Reply #1 on: May 17, 2021, 07:24:20 PM »
I have loaded your addin but I can't see any line. :-[

Offline John Z

  • Member
  • *
  • Posts: 860
Re: Line Counter Add-IN
« Reply #2 on: May 17, 2021, 08:00:57 PM »
perhaps a step wise instruction
1) Close PellesC
2) Copy the dll into the "Bin" folder subfolder "Addins64"
3) Open PellesC
4) Click 'Tools'
5) Click 'Customize'
6) Click 'Add-Ins' tab
7) Check box next to "PellesC Line Counte Add-In"  (I see typo)
8) Click OK

Steps 1-8 only need to be done the first time

9) Open a PellesC project file
10) Select a source .C file
11) Click Menu 'Source'
12) Click 'Line Counts'   - Should be there ;) like attached screen shot

13) See results in Output tab

John Z

Grincheux

  • Guest
Re: Line Counter Add-IN
« Reply #3 on: May 17, 2021, 08:14:32 PM »
Quote
File name:C:\Users\51966\OneDrive\Documents\Pelles C Projects\Essai\Start.asm
startLine:90, endLine:93
Total Lines: 4
 Empty Lines: 1
 Code Lines: 3


With my current ASM Project

Grincheux

  • Guest
Re: Line Counter Add-IN
« Reply #4 on: May 17, 2021, 08:17:17 PM »
Tested on CFE project


Quote
File name:C:\Users\51966\OneDrive\Documents\Pelles C Projects\Cfe\Cfe.c
startLine:0, endLine:5946
Total Lines: 5946
 Empty Lines: 1076
 Lone {: 350
 Lone {: 348
 Comment Lines: 8
 Continuations: 139
 Code Lines: 4025

Offline John Z

  • Member
  • *
  • Posts: 860
Re: Line Counter Add-IN
« Reply #5 on: May 17, 2021, 09:11:54 PM »
Great! I know it’s not detecting asm comment lines …. might be worth adding. I’ll look at your attachment.  Was targeting C code originally.

Thanks for trying it.


John Z

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Line Counter Add-IN
« Reply #6 on: May 17, 2021, 10:57:00 PM »
File name:C:\Program Files\PellesC\Files\LCounter\Line_Count.c
startLine:0, endLine:371
Total Lines: 371
 Empty Lines: 44
 Lone {: 15
 Lone {: 26
 Comment Lines: 103
 Continuations: 1
 Code Lines: 182
 

Shouldn't be: "Total Lines: 372" ?  ???
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline John Z

  • Member
  • *
  • Posts: 860
Re: Line Counter Add-IN
« Reply #7 on: May 18, 2021, 12:12:32 AM »
Thanks Frankie,

Well... there are actually 371 lines when I use the cursor in the file. The discrepancy, if any, might be in saying the start is line 0. PellesC edit window shows that to be line 1.  I'll double check though when I fix the typos, one of which was the second output { line which should have been lone } (close bracket).

The TrimTail code had these lines for the full page:
Code: [Select]
iFirstLine = 0;
iLastLine = AddIn_GetSourceLineCount(hwndDoc) - 1;

So it appears to get line 1 you start with line 0, and the last line which is the required PellesC closing CRLF is not included.

The sum of the processed lines also adds up to the 371.

I'll look further though :)

Thanks for the inputs,

John Z

Grincheux

  • Guest
Re: Line Counter Add-IN
« Reply #8 on: May 18, 2021, 06:01:54 AM »
In C you search for '{' and '}', in asm search for 'PROC' and 'ENDP'.

Offline John Z

  • Member
  • *
  • Posts: 860
Re: Line Counter Add-IN
« Reply #9 on: May 18, 2021, 02:28:35 PM »
Version 0.2
Fixed text typos, fixed line start when processing entire source file, fixed line end when processing a selected block of source code.  Added some error reporting, added a count and warning of long lines > 4095 characters when found.

Haven't looked at processing asm specifically yet....

John Z
« Last Edit: May 22, 2021, 01:45:43 PM by John Z »

Grincheux

  • Guest
Re: Line Counter Add-IN
« Reply #10 on: May 18, 2021, 03:00:44 PM »
It was version 1.0 before and now 0.2!
For the asm I will wait, perhaps one day >:( >:( >:(

Offline John Z

  • Member
  • *
  • Posts: 860
Re: Line Counter Add-IN
« Reply #11 on: May 18, 2021, 03:40:49 PM »
 :)
it was version 0.1 before …. shouldn't version 1.0 be the first 'official' release?   ;D

I think asm line count needs different groupings, like .data, .code, comments, label lines, etc so will need to check extension and change processing based on the file type.


Cheers,

John Z



Offline John Z

  • Member
  • *
  • Posts: 860
Re: Line Counter Add-IN
« Reply #12 on: May 19, 2021, 03:04:27 PM »
Version 0.3 for testing
This version adds in ASM specific line binning when the file extension is .asm

Question:  Should it clear the output window before showing results?

Example Output:
File name:C:\Program Files\PellesC\Files\Essai\Start.asm
startLine:1, endLine:118
Total Lines: 118
 Empty Lines: 27
 Data : 4
 Labels  : 5
 Comment Lines: 22
 Code Lines: 60


I'll post the code soon.  I think it is almost done, I know it is not and probably never will be a high use add-in but it was a good one for me to gain experience on.

John Z
« Last Edit: May 22, 2021, 01:45:59 PM by John Z »

Grincheux

  • Guest
Re: Line Counter Add-IN
« Reply #13 on: May 19, 2021, 03:21:30 PM »
Quote
Question:  Should it clear the output window before showing results?


YES

I have installed the add-in but I don't see annythig for a '.c' file and a '.asm' file.
I made a wrong thing but which one?
« Last Edit: May 19, 2021, 03:49:39 PM by Grincheux »

Offline John Z

  • Member
  • *
  • Posts: 860
Re: Line Counter Add-IN
« Reply #14 on: May 19, 2021, 03:34:13 PM »
Quote
Question:  Should it clear the output window before showing results?
Quote
YES
Thanks I'll add the clear.
Quote
I have installed the add-in but I don't see anything for a '.c' file and a '.asm' file.
I made a wrong thing but which one?

The determination of .asm or .c (where really is anything but .asm) is within the code by looking at the file extension.  The user does not select C or ASM directly.

Looks like your post was hit with the Notepad++ bug but I was able to read it by using quote :)

Thanks,

John Z