1

A HelpNDoc file allows you to provide a text value for the Description property. This field is used by search engines when crawling the HTML help.

I have added topics to my help over the years and some of these descriptions need updating. In my case I needed to replace all instances of Midweek Editor with Meeting Editor.

How can this be done since there is no built-in way to update the Description property in bulk.

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164

1 Answers1

1

This can be done by writing a script and using the HelpNDoc API. These scripts can be built and run with the Script Editor. The object we need to use is HndTopics.

The HndTopics object includes some useful methods:

  • GetTopicDescription
  • SetTopicDescription

These can be used in combination with the Pascal functions Pos / StringReplace.

var
  // Current topic ID
  aTopicId, aTopicDesc, aTopicDescNew: string;

begin
  try
    // Get first topic
    aTopicId := HndTopics.GetTopicFirst();
    // Loop through all topics
    while aTopicId <> '' do
    begin
        // Does this topic description include the phrase?
        aTopicDesc := HndTopics.GetTopicDescription(aTopicId);
        if (pos('Midweek Editor', aTopicDesc) <> 0) then
        begin
            aTopicDescNew := StringReplace(aTopicDesc, 'Midweek Editor', 'Meeting Editor', [rfReplaceAll]);
            HndTopics.SetTopicDescription(aTopicId, aTopicDescNew);
            
            Print('Old: ' + aTopicDesc);
            Print('New: ' + aTopicDescNew);
        end;
        
        // Get next topic
        aTopicId := HndTopics.GetTopicNext(aTopicId);
    end;
  finally
  end;
end.
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164