Syntax::RTF(3pm)

πŸ“¦
version 2.5.0 Β· 2 versions
, in ubuntu jammy

πŸ’– Syntax::RTF(3pm) β€” the vibe πŸ’–

User Contributed Perl Documentation ✨ okay bestie, sit down, we're learning Embperl::Syntax::RTF today and honestly? it's giving word-processing-glamour πŸŽ€


🌸 NAME 🌸

Embperl::Syntax::RTF β€” it defines the syntax for RTF files, periodt πŸ’…


✨ SYNOPSIS ✨

(no cap, this section is literally empty in the original β€” the whole plot happens down in DESCRIPTION, keep scrolling 🫢)


πŸ¦‹ DESCRIPTION πŸ¦‹

So this is a class derived from Embperl::Syntax, and what it does is define the syntax for RTF files. RTF files can be read and written by various word processing programs β€” which is lowkey iconic, because it means you can create dynamic word-processing documents, or even let serial letters get processed thru Embperl. main character energy fr fr πŸ‘‘

Currently Embperl recognizes the fields DOCVARIABLE, MERGEFIELD and NEXT. Variable names get resolved as hash keys to $param[0] β€” so like, "foo.bar" refers to "$param[0]{foo}{bar}", and the @param array can be set via the "param" parameter of the "Execute" function. 🌈

"NEXT" moves to the next element of the @param array. And if the end of the document is reached, Embperl repeats the document until all elements of @param are processed. That's literally the whole trick β€” you can, for example, tie a database table to @param and generate a serial letter. slay πŸŽ€

⚠️ NOTE: Extending this syntax to support full Embperl support (like embedding Perl into an RTF file) is planned, but not implemented yet. So don't come for me, it's on the vision board πŸ’€

πŸ“ Example for generating a serial letter from a database πŸ“

okay here's the whole thing verbatim, don't touch a single character bestie:

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

Creates a new syntax class. This method should only be called inside a constructor of a derived class. Like, only from inside the family, iykyk πŸ™ˆ

πŸ’œ AddRTFCmd ($cmdname, $procinfo)

Adds a new RTF command with the name $cmdname, and uses processor info from $procinfo. See Embperl::Syntax for a definition of procinfo. ✨

πŸ’œ AddRTFCmdWithEnd ($cmdname, $endname, $procinfo)

Adds a new RTF command with the name $cmdname, and uses processor info from $procinfo. Additionally 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)

Adds a new RTF command with the name $cmdname, 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) β€” thank you for your service, legend 🫑


🌈 See Also 🌈

  • Embperl::Syntax β€” go read it bestie, it's the source of all the procinfo lore πŸ“š

and that's the whole page!! πŸ¦‹ no cap, you're now certified in RTF syntax. this came to you via perl v5.34.0, dated 2022-02-06, and it's the Syntax::RTF(3pm) manual page πŸ’– mwah, go make a serial letter, you got this β­πŸŽ€

πŸ“¦ where this page comes from