Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Counting lines in an ascii file
Message
 
 
To
17/03/2004 19:16:42
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00887345
Message ID:
00887347
Views:
9
This message has been marked as the solution to the initial question of the thread.
>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
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform