Anyone able to fix the below? do shell script refuses to write the file to disk. I think its not handling the double quote marks incorrectly.
Thanks in advance.
--TEMP
set centredetails to {"centrename",
"forename surname",
"addressline1",
"addressline2",
"addressline3",
"addressline4",
"addressline5",
"post code",
"02389239349",
"
email@hidden"}
set fullname to words of item 2 of centredetails
if (count of items in fullname) is greater than 2 then
set middlename to item 2 of fullname
set surname to item 3 of fullname
else
if (count of items in fullname) is 2 then
set surname to item 2 of fullname
else
set surname to ""
end if
end if
set forename to item 1 of fullname
set outputstring to "|S0233|,|Customer|,||,||,|" & forename & "|,|" & surname & "|,|" & surname & "|,|" & item 9 of centredetails & "|,||,|" & item 10 of centredetails & "|,||,||,|Centre Leader|,||,|1|,||,||,|Their Website|,||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,|" & item 1 of centredetails & "|,|" & item 1 of centredetails & "|,|" & item 2 of centredetails & "|,|" & item 3 of centredetails & "|,|" & item 4 of centredetails & "|,|" & item 5 of centredetails & "|,|" & item 6 of centredetails & "|,|" & item 7 of centredetails & "|,||GB||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,||,"
set outputstring to my findAndReplace("|", quote, outputstring)
do shell script "/bin/echo " & quoted form of outputstring & " & >> ~/desktop/test.txt"
outputstring
on findAndReplace(tofind, toreplace, theString)
set ditd to text item delimiters
set text item delimiters to tofind
set textItems to text items of theString
set text item delimiters to toreplace
if (class of theString is string) then
set res to textItems as string
else -- if (class of TheString is Unicode text) then
set res to textItems as Unicode text
end if
set text item delimiters to ditd
return res
end findAndReplace