>Hi
>
>I have txt file with many lines ,each one is single lines, Sometimes The last line is empty.
>
>I want to add '^^^' (for example) in the end of each line.
>So the code job is:
>To scan each line and if the line not empty and the end of the line it's not ^^^, to add ^^^.
>
>Help Please
>
>Tnx
How about:
#DEFINE LF CHR(13)+CHR(10)
CLEAR
lcTail="^^^"
?" First crete a tst file"
TEXT TO lcText NOSHOW TEXTMERGE
line 1
line 2
line 3
line 4
NEXT line is empty
line 7
NEXT line is emptyagain
ENDTEXT
lcFileName="ThisIsPetersTestFile.txt"
IF NOT FILE(FULLPATH(lcfileName))
STRTOFILE(lcText, lcfileName)
ENDIF
?lcText
?"-------------------------------------------------------"
?"now work on it"
lcTextOut=[]
lcTextIn=FILETOSTR(FULLPATH(lcfileName))
lnNumLines= ALINES(laText,lcTextIn)
FOR I =1 TO lnNumLines
DO CASE
CASE empty(laText[m.I]) && empty line
lcTextOut = lcTextOut + laText[m.I] +LF
CASE lcTail$laText[m.I] && already has tail
lcTextOut = lcTextOut + laText[m.I]+LF
OTHERWISE
lcTextOut = lcTextOut + laText[m.I]+lcTail+LF
ENDCASE
ENDFOR
?lcTextOut
?"-------------------------------------------------------"
Peter Cortiel