Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Read the text file contents from bottom to top
Message
De
29/11/2003 12:06:47
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00854392
Message ID:
00854450
Vues:
16
>I want to read the text file contents from bottom to top line by line and simultaneously delete the line from bottom top line by line.

Ravi,

Assume lines are sepatared by CRLF, or only by CR or LF.
lcOldText = FileToStr('filename')
lnCR = RAT(CHR(13),lcOldText)
lnLF = RAT(CHR(10),lcOldText)
IF lnLF - lnCR = 1
  * LAst separator is a CRLF or only a LF in position 1
  lcLastLine = SUBSTR(lcOldText,lnLF+1)
  lcNewText = LEFT(lcOldText,lnCR-1)
ELSE
  * Last separator is a lone CR or LF
  lcLastLine = SUBSTR(lcOldText,MAX(lnCR,lnLF)+1)
  lcNewText = LEFT(lcOldText,MAX(lnCR,lnLF)-1))
ENDIF
StrToFile(lcNewText,'filename')
Alex
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform