Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Counting lines in an ascii file
Message
From
18/03/2004 11:27:07
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00887345
Message ID:
00887540
Views:
10
Thanks - you should have gotten 9 stars. All three work just fine.

Gaylen

>>I have a ascii text file and need to know the number of lines. What is the best way to count the lines programtically. I know I can use type file to xxxx number and look at the number on the last line but I would like to do it programatically.
>>
>>Thanks
>>Gaylen
>
>There're a few ways to do that.
* #1
>CREATE CURSOR test (C(1))
>APPEND FROM (lcAsciiFileName) TYPE SDF
>lnRecCount = _TALLY
>USE IN temp
>
>* # 2 - would return 1 for empty file
>lnRecCount = 0
>lnFH = FOPEN(lcAsciiFileName)
>DO WHILE NOT FEOF(lnFH)
>  = FGET(lnFH, 8192)
>  lnRecCount = lnRecCount + 1
>ENDDO
>
>* # 3 for a file with 65,000 or less lines
>lnRecCount = ALINES(laTemp, FILETOSTR(lcAsciiFileName))
>RELEASE laTemp
>
Previous
Reply
Map
View

Click here to load this message in the networking platform