Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Editing txt file
Message
From
09/06/2009 11:40:18
 
 
To
09/06/2009 05:49:37
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2008
Miscellaneous
Thread ID:
01404651
Message ID:
01404711
Views:
33
Its excellent
Tnx
>Chaim,
>
>non elegant, but give it a try:
>
>lcEnd='^^^'
>lcFile  = 'yourfile'
>lcLines = STRTOFILE(lcFile)
>
>
>lnLines = ALINES(laLines,lcLines,18)
>lcLines = ''
>*test for several Filetypes
>DO CASE
> CASE lnLines=1
>*just a single line
> CASE 0h0D0A=RIGHT(laLines(1),2)
>  lcLineEnd = ''+0h0D0A
> CASE 0h0A0D=RIGHT(laLines(1),2)
>  lcLineEnd = ''+0h0A0D
> CASE 0h0D=RIGHT(laLines(1),1)
>  lcLineEnd = ''+0h0D
> CASE 0h0A=RIGHT(laLines(1),1)
>  lcLineEnd = ''+0h0A
>ENDCASE
>FOR lnLine = 1 TO lnLines-1
> DO CASE
>  CASE laLines(lnLine)==lcLineEnd
>*empty line
>   lcLines = lcLines+laLines(lnLine)
>  CASE lcEnd+lcLineEnd$laLines(lnLine)
>*endchar exists
>   lcLines = lcLines+laLines(lnLine)
>  OTHERWISE
>*non empty line without lcEnd
>   lcLines = lcLines+STRTRAN(laLines(lnLine),lcLineEnd,lcEnd+lcLineEnd)
> ENDCASE
>ENDFOR
>
>*last line
>DO CASE
> CASE laLines(lnLines)==""
>*empty line
>*nothing to do
> CASE RAT(laLines(lnLine),LEN(lcEnd))==lcEnd
>*endchar exists
>  lcLines = lcLines+laLines(lnLine)
> OTHERWISE
>*non empty line without lcEnd
>  lcLines = lcLines+laLines(lnLine)+lcEnd
>ENDCASE
>STRTOFILE(lcLines,lcFile)
>
>
>Agnes
>>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
Thank you
Chaim
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform