Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Low level file functions -counting lines of code in prop
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00099818
Message ID:
00099847
Views:
26
>Hello:
>I'm writing a program to count the lines of code in my programs.
>I need to be able the count the lines of code without including the comments and blank spaces. Any ideas on how to do this? THis is the code that I'm using that returns the total number of lines including comments.
>gnfilehandle = fopen("mainlib.prg")
>nsize = fseek(gnfilehandle,0,2)
>if nsize <= 0
>wait window "this file is empty!" nowait
>else
>=fseek(gnfilehandle, 0)
>lctext = fread(gnfilehandle, nsize)
>lnlines = occurs(chr(13), lctext)
>? lnlines
>endif
>
>This works and returns total number of lines. Any suggestions would be greatly appreciated.

Sheena,

You've already gotten a good start here from Jim and Ed. I hate to throw this monkey wrench in but if you have lines ending with a semi-colon, they're technically not separate lines. This includes comments. For example:
lcstring = "Some info " +;
  " Some more info"
Is only one line of code. So you'll also need to check for this.

hth,
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform