Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Counting lines in an ascii file
Message
 
 
À
17/03/2004 19:16:42
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00887345
Message ID:
00887347
Vues:
11
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--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform