Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Changing field names in templates

edited June 2002 in General
As our package is evolving, we are now getting to the stage of needing to
redesign parts of the database...

Within our application, we have the ability to create new fields as
required, copy old data to new columns then delete the obsolete columns.
It's nice to have this flexibility but the only glitch is when it comes to
RB templates...

We supply some as standard but users invariably create their own. Obviously
if we change some of the field names in the database, their templates are no
longer going to work ...

A while ago, the templates used to be in ASCII format and thus would have
made it posssible for us to scan all the templates in a particular directory
and change the field names as necessary.

The templates no longer appear to be stored in ASCII format.

How should we go about modifying the templates automatically?

Comments

  • edited June 2002
    One option is to load the templates and iterate through all the objects and
    change the field names. For example:

    for liBands := 0 to ppReport.BandCount - 1 do
    for liObjects := 0 to ppReport.Bands[liBands].ObjectCount - 1 do
    begin

    lObject := ppReport.Bands[liBands].Objects[liObject];

    if (lObject is TppSubreport) then
    ... recursively process subreport
    else if (lObject is TppDBText) or (lObject is TppDBMemo) or (lObject is
    TppDBRichText) or etc... then
    ... reassign the field is necessary.
    end

    You can also load the templates in binary and save them back into ascii. For
    example:

    ppReport.Template.FileName := 'myTemplate.rtm';
    ppReport.Template.Format := ftBinary;
    ppReport.Template.LoadFromFile;
    ppReport.Template.Format := ftASCII;
    ppReport.Templaet.SaveToFile;

    Then you can proceed to scan through the files and change the field names.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

This discussion has been closed.