turning carriage returns into text and back again

hey, long time no see.

anyway, i can’t figure out a way to turn text that includes returns into text without returns with the returns marked by some type of markup like “%return%”, and a way to reverse the process

for example

 hey, how are you doing?

hi, i am doing great!

would become

 hey, how are you doing?%return%%return%hi, i am doing great!

i tried using a search and replace subroutine, but that didn’t work out

any help would be much appreciated, thank you in advance (i figure if i say that now, you’ll look bad if you don’t help) :smiley:

set theInput to "hey, how are you doing?

hi, i am doing great!"

set theOutput to ""
set theReturn to ""

repeat with tmpIndex from 1 to (count paragraphs of theInput)
	set theOutput to (theOutput & theReturn & (paragraph tmpIndex of theInput))
	set theReturn to "%return%"
end repeat

return theOutput

You’re welcome in advance… :rolleyes:
j

The easiest thing to do is to use paragraphs and text item delimiters:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]