Page 1 of 1

Wanted: merge some rtf fields to one rtf file

Posted: Mon May 15, 2017 5:07 pm
by pderks
Hi,

among other scripts I tried:

Code: Select all

put 3444 into ii
put "/Users/pd/Desktop/TEST.rtf" into TestPath
put "¶" into Sep
put the rtfText of fld "A" of cd ii of this stack & Sep ¬
  & the rtfText of fld "B" of cd ii of this stack & Sep ¬
  & the rtfText of fld "C" of cd ii of this stack & Sep ¬
  into URL ("file:" & TestPath)
and failed.

I reckon, one of you has already developed an elegant solution.

Regards,

Peter

Re: Wanted: merge some rtf fields to one rtf file

Posted: Mon May 15, 2017 6:22 pm
by dunbarx
Hmm.

I get no errors when I try this with a document created in textEdit in a non-RTF format, like "Word" or "odt". I modified slightly to make it easier:

Code: Select all

on mouseUp
   answer file "DD" --to make sure format is sound
   put it into testpath
     put random(999) into url ("file:" & testPath)
end mouseUp
But when I try this with a document created with textEdit in "RTF" format, no errors are thrown, but the document cannot be opened. Same thing with:

Code: Select all

   
   open file testPath for text write
   write random(999) to file testPath
   close file testPath
Someone will know why.

Craig Newman

Re: Wanted: merge some rtf fields to one rtf file

Posted: Mon May 15, 2017 8:10 pm
by SparkOut
try binfile? (it *shouldn't* need it, I think but some vague inkling is trying to stir my memory about something)

Re: Wanted: merge some rtf fields to one rtf file

Posted: Mon May 15, 2017 8:17 pm
by FourthWorld
I wonder if the problem may be that RTF contains a header, and perhaps having multiple headers within the file invalidates it.

You could use another format like htmlText to aggregate the fields into another, or into the templateField, before exporting.