문제 설명
HelpNDoc 파스칼 스크립트는 구조를 지원합니까? (Does HelpNDoc Pascal Script support structures?)
구조를 만들려고 합니다.
MyTopic
TopicID : String;
HelpID : Integer;
이 구조를 정렬할 수 있도록 배열을 만들고 싶었습니다.
이 유형을 사용해 보았습니다.
/ record
구문이지만 실패합니다.
Update
이 type
및 절차를 정의했습니다.
:
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 문서를 작성하려고 할 때 문제가 발생합니다.
(by Andrew Truckle、Andrew Truckle)