man Embperl::Syntax::RTF () - Embperl::Syntax::RTF

NAME

Embperl::Syntax::RTF

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 programms. This allows you to create dynamic wordprocessing documents or let process serial letters thru Embperl.

Currently Embperl regocnices the fields CWDOCVARIABLE, CWMERGEFIELD and CWNEXT. Variablenames are resolved as hash keys to CW$param[0] e.g. CWfoo.bar referes to CW$param[0]{foo}{bar}, the CW@param Array can by set via the CWparam parameter of the CWExecute function. CWNEXT moves to the next element of the CW@param array. If the end of the document is reached, Embperl repeats the document until all element of CW@param are processed. This can for example be use to tie a database table to CW@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: Create a new syntax class. This method should only be called inside a constructor of a derived class. Add a new RTF command with name CW$cmdname and use processor info from CW$procinfo. See Embperl::Syntax for a definition of procinfo. Add a new RTF command with name CW$cmdname and use processor info from CW$procinfo. Addtionaly specify that a matching CW$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. Add a new RTF command with name CW$cmdname and and a second RTF command CW$endname which ends the block that is started by CW$cmdname. Use processor info from CW$procinfo. See Embperl::Syntax for a definition of procinfo.

Author

G. Richter (richter@dev.ecos.de)

See Also

Embperl::Syntax