keeping tabstops intact when exporting an rtf?

Malte Brill revolution at derbrill.de
Thu Feb 6 20:06:28 EST 2014


Thanks for your replies guys!

@Richmond: You may be right. it looks like a PITA, but RTF seems to be the only formatted option that is somewhat portable to other apps...
@Richard: I guess an enhancment request is a good idea
@Bernd: My Problem was (/is) to keep the tabs aligned across lines / paragraphs. 

One of the major Problem seems to be that liveCode creates a paragraph for each line, while this is not necessariely needed. I am still reading into the rtf specs (boy, that is confusing).

I managed to get something working cross applications and cross OS, that fits my purpose.

I came up with this:

on mouseUp
   local tHeader
   local tBody
   put "Short"&TAB&"Test" into fld "theRTFText" 
   put  cr&"Longer"&TAB&"Test" after fld "theRTFText"
   put cr&"very very long"&TAB&"Test" after fld "theRTFText"
   set the textStyle of word 1 of line 2 of fld "theRTFText" to "bold"
   set the textColor of word 1 of fld "theRTFText" to "red"
   put line 1 to 2 of the rtfText of fld "theRTFText" into tHeader
   put line 3 to -1 of the rtfText of fld "theRTFText" into tBody
   put cr after tHeader
   put "\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0"  after tHeader
-- papersetup
   put cr after tHeader
   replace "\pard" with "\pard\tx2647\pardirnatural" in tBody
-- add more tx for more TABSTOPS
   replace "\'09" with "\tab " in tBody -- Word!
   put "\par" before char -1 of tBody
   -- somehow missing in rtfText. Wordpad on Win complains if this is not there
   ask file "Save RTF file..."
   put tHeader & tBody into URL ("binfile:"&it)
end mouseUp

All the best,

Malte



More information about the use-livecode mailing list