Removing CRLF from text
Martin Baxter
mb.userev at harbourhosting.co.uk
Thu Aug 7 03:32:20 EDT 2008
How about this?
put "C:/temp/some.ini" into tFilename
put URL ("binfile:" & tFilename) into tData
put "+" & crlf into tmatchstring
replace tmatchstring with space in tData
If you read as binfile: it should stop the engine automatically
translating crlf to lf on import.
Martin Baxter
mfstuart wrote:
> Hi,
>
> RunRev: 2.90
> OS: WinXP
>
> I have a situation where a software application's ini file has the plus (+)
> char and CRLF at the end of a line, when the line passes 80 characters. The
> balance of the ini entry is placed on the next line. Each ini entry could be
> very long and possibly go to 3 lines.
> Why they did this I don't know, really.
>
> But what I need to do is remove the + and CRLF so that each ini entry is
> complete in itself, on one line.
>
> ini file currently contains:
> dfgsdfg sdfgsd fgsdfgsdf gsdfg +
> sdfgadfs dgdghs dfdfgg fghf+
> dfgh dfgh
>
> Result I'd like after running the script:
> dfgsdfg sdfgsd fgsdfgsdf gsdfg sdfgadfs dgdghs dfdfgg fghf dfgh dfgh
>
> I've used this script, and variations of it, to remove these characters: +
> CRLF.
> It removes the + char, but still leaves each ini entry split into multiple
> lines.
>
> I've also searched the archives for a solution, nothing is working.
>
> Any ideas?
>
>
> My script:
> ####
> on mouseUp
> --clear current fields on card
> --these fields are so that I can see the results from the script.
> put empty into fld "Orig"
> put empty into fld "Changed"
>
> --fetch the file
> put "C:/temp/some.ini" into tFilename
> put URL ("file:" & tFilename) into tData
> put tData into fld "Orig"
>
> repeat for each line L in tData
> --grab the line
> put L into tLine
>
> --If the line contains +, then it will also contain CR and LF,
> --so only work on a line with +.
> if (tLine contains "+") then
> --find + and delete it
> put offSet("+",tLine) into tPos
> delete char tPos to tPos in tLine
>
> --find CR and delete it
> put offSet(CR,tLine) into tPos
> delete char tPos to tPos in tLine
>
> --find LF and delete it
> put offSet(LF,tLine) into tPos
> delete char tPos to tPos in tLine
>
> --put the line into a container so that I can see the results
> put tLine & cr after theLines
> else -- just put the line into a container
> put tLine & cr after theLines
> end if
> end repeat
>
> put theLines into fld "Changed"
> end mouseUp
> ####
>
> Regards,
> Mark Stuart
--
I am Not a Number, I am a free NaN
More information about the use-livecode
mailing list