NAME
Embperl::Syntax::RTF - define syntax for RTF files
SYNOPSIS
DESCRIPTION
Class derived from Embperl::Syntax to define the syntax for RTF files. RTF files can be read and written by various word processing programs. This allows you to create dynamic wordprocessing documents or let process serial letters thru Embperl.
Currently Embperl regocnices the fields DOCVARIABLE
, MERGEFIELD
and NEXT
. Variablenames are resolved as hash keys to $param[0] e.g. foo.bar
referes to $param[0]{foo}{bar}
, the @param
Array can by set via the param
parameter of the Execute
function. NEXT
moves to the next element of the @param array. If the end of the document is reached, Embperl repeats the document until all element of @param are processed. This can for example be use to tie a database table to @param and generate a serial letter.
NOTE: Extenting this syntax to support full Embperl support (like embedding Perl into RTF file is planned, but not implemented yet)
Example for generating a serial letter from a database
use DBIx::Recordset ;
use Embperl ;
*set = DBIx::Recordset -> Search({'!DataSource' => $db, '!Table' => 'address', '!WriteMode' => 0}) ;
die DBIx::Recordset -> LastError if (DBIx::Recordset -> LastError) ;
Embperl::Execute ({'inputfile' => 'address.rtf', param => \@set, syntax => 'RTF'}) ;
# if your database table contains fields 'name' and 'street' you can now simply insert a
# fields call 'name' and 'street' in your RTF file and Embperl will repeat the document
# until all records are outputed
Methods
Embperl::Syntax::RTF defines the following methods:
Embperl::Syntax::RTF -> new / $self -> new
Create a new syntax class. This method should only be called inside a constructor of a derived class.
AddRTFCmd ($cmdname, $procinfo)
Add a new RTF command with name $cmdname
and use processor info from $procinfo
. See Embperl::Syntax for a definition of procinfo.
AddRTFCmdWithEnd ($cmdname, $endname, $procinfo)
Add a new RTF command with name $cmdname
and use processor info from $procinfo
. Addtionaly specify that a matching $endname
RTF command must be found to end the block, that is started by this RTF command. See Embperl::Syntax for a definition of procinfo.
AddRTFCmdBlock ($cmdname, $endname, $procinfostart, $procinfoend)
Add a new RTF command with name $cmdname
and and a second RTF command $endname
which ends the block that is started by $cmdname
. Use processor info from $procinfo
. See Embperl::Syntax for a definition of procinfo.
Author
G. Richter (richter at embperl dot org)
See Also
Embperl::Syntax