dex ash
dex ash

Reputation: 21

HelpNDoc script - method GetTagsAssociatedWithTopic

Method GetTagsAssociatedWithTopic Unknown

I'm fairly new to HelpNDoc (working on an old version - 5).

From an existing script ( ExportHelpIdsandContexts.hnd.pas , provided with the installation ) I'm trying to get a list of the tags linked with each topic.

I thought HndTags.GetTagsAssociatedWithTopic(aTopicId) would get me through my task but if I try to build I get an error :

identifient non déclaré GetTagsAssociatedWithTopic .

I was hoping to get a file with (Topic Caption | Help ID | Help Context | Tags)

aList.Add(Format('%s | %s | %d | %s', [
        HndTopics.GetTopicCaption(aTopicId),
        HndTopics.GetTopicHelpId(aTopicId),
        HndTopics.GetTopicHelpContext(aTopicId),
        HndTags.GetTagsAssociatedWithTopic(aTopicId)
      ]));

got me the error described in the previous section.

I was thinking about the returned type of the function and tried to find a way to cast the returned TStringList into a String, but couldn't do it.


Add on Thanks for your answer. I dug up a little more still have a problem with TSTringDynArray.

If i dont define it, the error is "unknown type". Thanks to FreePascal i found out how it is supposed to be defined.

But of i define it, i get an erreur "Record required" for the following line

aTags:=HndTopicsTags.GetTagsAssociatedWithTopic(aTopicId);

So, i think i should have not "re"defined the TStringDynArray but i can't find out why it's not recognised by itself.

Upvotes: 1

Views: 59

Answers (2)

dex ash
dex ash

Reputation: 21

So, I finally managed to get the script to work.

  1. I needed to redefine
type 
    TStringDynArray = array of String;
  1. Stop mixing arrays and lists function
for i:= low(aTags) to high(aTags) do
begin
    aTagsString:= aTagsString + ' | ' + aTags[i];
end;

Upvotes: 1

jonjbar
jonjbar

Reputation: 4066

This code seems to have multiple problems:

  1. According to HelpNDoc's API documentation, the GetTagsAssociatedWithTopic method is part of the HndTopicsTags object. So HndTags.GetTagsAssociatedWithTopic is wrong and should be replaced with HndTopicsTags.GetTagsAssociatedWithTopic

  2. HndTopicsTags.GetTagsAssociatedWithTopic returns a TStringDynArray which is an array of string. It can't be used in the Format method using the %s placeholder. Instead, you should use a loop (for, while or repeat) to iterate over its items.

Upvotes: 2

Related Questions