HelpNDoc Pascal Script 是否支持结构?

Does HelpNDoc Pascal Script support structures?

我正在尝试创建一个结构:

MyTopic
    TopicID : String;
    HelpID : Integer;

我想创建一个包含这些结构的数组,以便对它们进行排序。

我试过使用 type / record 语法,但它失败了。

更新

我定义了这个 typeprocedure:

type
    TMyTopicRecord = record
        idTopic : String;
        idContextHelp : integer;
    End;

procedure GetSortedTopicIDs(aTopics : array of String; size : Integer);
var
    aMyTopicRecords : array of TMyTopicRecord;
    temp : TMyTopicRecord;
    iTopic, i, j : Integer;
begin
    // Init the array
    SetLength(aMyTopicRecords, size); 

    // Fill the array with the existing topid ids.
    // Get the context ids at the same time.
    for iTopic := 0 to size - 1 do
        aMyTopicRecords[iTopic].idTopic := aTopics[iTopic];
        aMyTopicRecords[iTopic].idContextHelp := HndTopics.GetTopicHelpContext(aTopics[iTopic]);

    // Sort the array on context id
    for i := size-1 DownTo 1 do
    for j := 2 to i do
        if (aMyTopicRecords[j-1].idContextHelp > aMyTopicRecords[j].idContextHelp) Then
        begin
            temp := aMyTopicRecords[j-1];
            aMyTopicRecords[j-1] := aMyTopicRecords[j];
            aMyTopicRecords[j] := temp;
        end;

    // Rebuild the original array of topic ids
    for iTopic := 0 to size - 1 do
        aTopics[iTopic] := aMyTopicRecords[iTopic].idTopic;
end;

该过程在 parent 函数的循环中被调用(代码被截断):

function GetKeywordsAsHtml(): string;
var
    aKeywordList: THndKeywordsInfoArray;
    aAssociatedTopics: array of string;
    nBlocLevel, nDif, nClose, nCurKeywordLevel, nCurKeywordChildrenCnt: Integer;
    nCurKeyword, nCurKeywordTopic: Integer;
    nCountAssociatedTopics: Integer;
    sCurrentKeyword, sKeywordLink, sKeywordRelated: string;
    sKeywordJsCaption: string;
begin
    Result := '<ul>';
    nBlocLevel := 0;
    try
        aKeywordList := HndKeywords.GetKeywordList(False);
        for nCurKeyword := 0 to length(aKeywordList) - 1 do
        begin
            sCurrentKeyword := aKeywordList[nCurKeyword].id;
            nCurKeywordLevel := HndKeywords.GetKeywordLevel(sCurrentKeyword);
            nCurKeywordChildrenCnt := HndKeywords.GetKeywordDirectChildrenCount(sCurrentKeyword);

            sKeywordLink := '#';
            sKeywordRelated := '[]';

            aAssociatedTopics := HndTopicsKeywords.GetTopicsAssociatedWithKeyword(sCurrentKeyword);
            nCountAssociatedTopics := Length(aAssociatedTopics);
            if nCountAssociatedTopics > 0 then
            begin
                GetSortedTopicIDs(aAssociatedTopics, nCountAssociatedTopics);
                // Code snipped
            end;
        end;
    finally
        Result := Result + '</ul>';
    end;
end;

HelpNDoc 内部编辑器中的脚本编译没有问题。但是当我去实际构建我的 HTML 文档时,我遇到了一个问题:

HelpNDoc API 有解释 here

我的代码有问题吗?

我决定换一种方式,使用更简单的技术:

procedure GetSortedTopicIDs(var aTopics : array of String; iNumTopics : Integer);
var
    iTopic : Integer;
    // List of output
    aList: TStringList;
begin
    // Init list
    aList := TStringList.Create;

    // Build a new array of "nnn x"
    //  - nnn is the help context id
    //  - x is the topid id

    // Note: I know that the context ID values are within the range 0 - 200
    for iTopic := 0 to iNumTopics - 1 do
        // We pad the context id with 0. We could increase the padding width to
        // make the script mre useful
        aList.Add(Format('%0.3d %s', [
            HndTopics.GetTopicHelpContext(aTopics[iTopic]),
            aTopics[iTopic]
        ]));

    // Now we sort the new array (which basically sorts it by context id)
    aList.Sort; 

    // Update original array
    for iTopic := 0 to iNumTopics - 1 do
        // We ignore the "nnn " part of the string to get just the topic id
        aTopics[iTopic] := copy(aList[iTopic],5, length(aList[iTopic])-4);

    // Tidy up      
    aList.Free;
end;

这会编译,我在它的末尾得到了主题 ID 的排序数组。所以 pop-up 帮助现在按我的需要列出了。