Perl Header: Send Text as RTF

Get help using and writing Nisus Writer Pro macros.
Post Reply
Posts: 32
Joined: 2003-07-22 01:31:29

Perl Header: Send Text as RTF

Post by rcgordon »

Can you pass on any references or guidance in terms of how the #Send Text as RTF header might be used as a means of manipulating attributed text within a Perl block. I'm wondering if I could build some commands around these to make up for the aspects of attribute-sensitive PowerFind Pro that are not working (as delineated in a bug report submitted on 7/17).

The manual makes an intriguing reference to it, but offers no details.

Official Nisus Person
Posts: 4785
Joined: 2002-07-11 17:14:10
Location: San Diego, CA

Post by martin »

Once you start passing text to Perl as RTF you're in for some real work on the Perl side. Basically your Perl code will need to parse/understand whatever RTF codes NWP uses to encode the formatting you're interested in. Sometimes it can be simple, like "\b" indicating some text is bold. Other times it's hard, like "\f3", where the 3 is an index into a font table that appeared earlier in the RTF.

You'll probably have to experiment and see if the task you want to accomplish is feasible. One tip: you can use the Encode RTF and Decode RTF macro commands to selectively encode/decode text.

An example macro that inspects the RTF used for the currently selected text:

Code: Select all

$text = Read Selection
$rtf = Encode RTF $text
Insert Text $rtf

Post Reply