Removing CRLF from text

mfstuart mfstuart at cox.net
Wed Aug 6 20:17:35 EDT 2008


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
-- 
View this message in context: http://www.nabble.com/Removing-CRLF-from-text-tp18862004p18862004.html
Sent from the Revolution - User mailing list archive at Nabble.com.




More information about the use-livecode mailing list