[comp.sys.mac.hypercard] Export to RTF files

gourdol@imag.imag.fr (Arnaud Gourdol) (02/12/91)

I would like to know if anybody knows about an XCMD (or a very nice script)
that could export styled text contained in an HyperCard stack to something that
Microsoft Word 4.0 could read, presumably some RTF file. I'd be to heaven if it
could manage style sheets, but it's not a requirement. It would be great too if
it could automatically index words in a given style. BTW it would be really
great if HC could provide some user definable styles like bold, italic, group,
but that would have no display change, just to know that an active text belongs
to a given category or another. Coding it with actual text styles, font and
size is painful.

If there is nothing that can do the Word export, I'd like to know if there is a
way to get style runs in text fields: I want to know that from char 1 to char 9
its the same style, then from char 10 to char 14...
The only thing I see is looking the style of one character at a time and to
compare with style of previous character. I doubt that this would be very fast,
but maybe there is a cleverer algorithm. Another approach could be to write a
nice XCMD that would direclty look into the teHandle. Any suggestion?

Arnaud.

mandel@vax.anes.tulane.edu (Jeff E Mandel MD MS) (02/14/91)

In article <17984@imag.imag.fr> gourdol@imag.imag.fr (Arnaud Gourdol) writes:
>I would like to know if anybody knows about an XCMD (or a very nice script)
>that could export styled text contained in an HyperCard stack to something
that
>Microsoft Word 4.0 could read, presumably some RTF file. I'd be to heaven if
it
>could manage style sheets, but it's not a requirement. It would be great too
if
>it could automatically index words in a given style. BTW it would be really
>great if HC could provide some user definable styles like bold, italic, group,
>but that would have no display change, just to know that an active text
belongs
>to a given category or another. Coding it with actual text styles, font and
>size is painful.
>
>If there is nothing that can do the Word export, I'd like to know if there is
a
>way to get style runs in text fields: I want to know that from char 1 to char
9
>its the same style, then from char 10 to char 14...
>The only thing I see is looking the style of one character at a time and to
>compare with style of previous character. I doubt that this would be very
fast,
>but maybe there is a cleverer algorithm. Another approach could be to write a
>nice XCMD that would direclty look into the teHandle. Any suggestion?
>
>Arnaud.
>
I have worked with this, and it is relatively easy (heh-heh). My application
creates a form consisting of tables separated by normal paragraphs with
postscript (I never do anything simply). RTF is a fairly simple-minded
language, basically, there is a long prologue that defines your styles, the
fonts you use, etc., then a series of instructions that encode departures from
the norm. The easiest thing to do is to generate a Word document that contains
everything you want to do (please don't tell me that is everything), save it as
RTF, then go in and carve up that file and paste it into fields of a HyperCard
stack.

Thus, in field roomDivide1:
\plain \s224\qj \b\v\f20\fs20 .para.\par 
gsave wp$box .98 setgray fill grestore\par 
\pard\plain \s6\qj \b\f20\fs20 

In roomDivide2:
{\plain \f20\fs16 \par }

In script:
		global roomLongNames
  put NewFileName ("Name of the export file?",thePrompt) into RTFile
  open file RTFile
		[useful stuff]
	 repeat with roomNum = 1 to the number of lines in caseList
    write cd fld "roomDivide1" to file RTFile
    write line roomNum of roomLongNames to file RTFile
    write cd fld "roomDivide2" to file RTFile
				[other useful stuff]
		end repeat
		[still more useful stuff]

 The only thing to be aware of is that RTF expects commands to be separated
from data by spaces or carraige returns, and lines cannot get too long (I
believe 256 characters is the limit).

Hope this helps,

Jeff E Mandel MD MS
Asst Professor of Anesthesiology
Tulane University School of Medicine
New Orleans, LA

ec1k+@andrew.cmu.edu (Edward P. Costello) (02/14/91)

There's also a stack which has an xcmd (xfcn?) which does this
called "RTF Maker".  I thought it was at sumex, but I found a copy
at rascal.ics.utexas.edu:/mac/hypercard/RTFMaker_stack_[bin | intro]

From the _intro file:
>From: bri@garnet.Berkeley.EDU (Brian Reilly)
>Newsgroups: comp.binaries.mac
>Subject: RTF Maker Stack
>Date: 28 Apr 90 07:01:31 GMT
>Organization: University of California, Berkeley
>[RTF Maker Stack]
>
>The following is RTF Maker, a HyperCard stack by Bill Engels which
>generates RTF (rich text format) files from HyperCard that can be read
>by Microsoft Word.


I think there's also a doc explaining the specs for RTF at sumex, but
again I couldn't find it.

-ed costello