home support FAQ resources services partners contact us contact us
 MySQL Tutorial Previous  Next  
 

The code in format_banquet_entry() that puts the parts of the name together in the proper order is something we'll need for the RTF version of the directory as well. So instead of duplicating that code in format_rtf_entry(), let's stuff it into a helper function:

sub format_name
{
my $entry_ref = shift;

my $name = $entry_ref->{first_name} . " " . $entry_ref->{last_name};
if (defined ($entry_ref->{suffix})) # there is a name suffix
{
# no comma for suffixes of I, II, III, etc.
$name .= "," unless $entry_ref->{suffix} =~ /^[IVX]+$/;
$name .= " " . $entry_ref->{suffix}
}
return ($name);
}

With format_name() in place, the implementation of the format_ banquet_entry() function that prints an entry becomes almost completely trivial:

sub format_banquet_entry
{
printf "%s\n", format_name ($_[0]);
}
Generating the Print-Format Directory

Generating the RTF version of the directory is a little more involved than generating the member list for the banquet program. For one thing, we need to print more information from each entry. For another, we need to put out some RTF control language with each entry to achieve the effects that we want and some control language at the beginning and end of the document. A minimal framework for an RTF document looks like the following:

The document begins and ends with curly braces '{' and '}'. RTF keywords begin with a backslash, and the first keyword of the document must be \rtfn, where n is the RTF specification version number the document corresponds to. Version 0 is fine for our purposes.

Within the document, we specify a font table to indicate the font to use for the entries. Font table information is listed in a group consisting of curly braces containing a leading \fonttbl keyword and some font information. The font table shown in the framework defines font number 0 to be in Times. (We only need one font, but you could use more if you wanted to be fancier.)

The next few directives set up the default formatting style: \plain selects plain format, \f0 selects font 0 (which we've defined as Times in the font table), and \fs24 sets the font size to 12 points (the number following \fs indicates the size in half-points). It's not necessary to set up margins because most word processors will supply reasonable defaults.

The framework is provided by the initialization and cleanup functions, which look like the following (note the double backslashes to get single backslashes in the output):
Previous  Next  
Link Partners: Asia florist, Flowers to India, Hong kong flowers, Site submit, Cheap web hosting, China florist, Japan florist