Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Editing txt file
Message
From
09/06/2009 12:09:49
 
 
To
09/06/2009 06:08:47
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:
01404714
Views:
34
this was just a jump start. Feel free to write your own better code :-)

>>How about:
>
>Peter,
>
>I would not use the $ operator since ^^^ may already be in the line at any place
>
>Better use right(..., len(m.lcTail)) == m.lcTail)) 
>
>
>
>>#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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform