Wanted: merge some rtf fields to one rtf file

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
pderks
Posts: 58
Joined: Sat May 14, 2011 4:25 pm

Wanted: merge some rtf fields to one rtf file

Post by pderks » Mon May 15, 2017 5:07 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10350
Joined: Wed May 06, 2009 2:28 pm

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

Post by dunbarx » Mon May 15, 2017 6:22 pm

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

SparkOut
Posts: 2949
Joined: Sun Sep 23, 2007 4:58 pm

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

Post by SparkOut » Mon May 15, 2017 8:10 pm

try binfile? (it *shouldn't* need it, I think but some vague inkling is trying to stir my memory about something)

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10057
Joined: Sat Apr 08, 2006 7:05 am
Contact:

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

Post by FourthWorld » Mon May 15, 2017 8:17 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply