英文:
Why is my script not building in HelpNDoc? Error: Unknown name
问题
我正在尝试编写一个脚本:
const
// 定义输出文件
OUTPUT_FILE = 'd:\topics.txt';
var
// 当前主题ID
aTopicId: string;
// 输出列表
aList: TStringList;
begin
// 初始化列表
aList := TStringList.Create;
aList.Add('主题标题 | 帮助ID | 帮助上下文 | 元描述');
try
// 获取第一个主题
aTopicId := HndTopics.GetTopicFirst();
// 遍历所有主题
while aTopicId <> '' do
begin
// 将主题添加到列表中
aList.Add(Format('%s | %s | %d | %s', [
HndTopics.GetTopicCaption(aTopicId),
HndTopics.GetTopicHelpId(aTopicId),
HndTopics.GetTopicHelpContext(aTopicId),
HndTopics.GetTopicDescription(aTopicId)
]));
// 获取下一个主题
aTopicId := HndTopics.GetTopicNext(aTopicId);
end;
// 创建文件
aList.SaveToFile(OUTPUT_FILE);
finally
aList.Free;
end;
end.
在HelpNDoc中构建时,为什么会显示错误消息:
[Error] script(9, 3): 未知名称 "aList";
英文:
I am trying to write a script:
const
// Define the output file
OUTPUT_FILE = 'd:\topics.txt';
var
// Current topic ID
aTopicId: string;
// List of output
aList: TStringList;
begin
// Init list
aList := TStringList.Create;
aList.Add('Topic Caption | Help ID | Help Context | Meta Description');
try
// Get first topic
aTopicId := HndTopics.GetTopicFirst();
// Loop through all topics
while aTopicId <> '' do
begin
// Add the topic to the list
aList.Add(Format('%s | %s | %d | %s', [
HndTopics.GetTopicCaption(aTopicId),
HndTopics.GetTopicHelpId(aTopicId),
HndTopics.GetTopicHelpContext(aTopicId),
HndTopics.GetTopicDescription(aTopicId)
]));
// Get next topic
aTopicId := HndTopics.GetTopicNext(aTopicId);
end;
// Create the file
aList.SaveToFile(OUTPUT_FILE);
finally
aList.Free;
end;
end.
When I build it in HelpNDoc:
Why is it saying:
> [Error] script(9, 3): Unknown name "aList"
答案1
得分: 0
Starting with HelpNDoc 7, you need to add the var
keyword each time you change the type: Migrating scripts from V6 to V7.
So my variable declaration section needed to be changed to something like:
var
// Current topic ID
aTopicId: string;
var
// List of output
aList: TStringList;
This is a limitation of HelpNDoc's scripting engine.
英文:
The authors of HelpNDoc provided some clarification about this issue. Starting with HelpNDoc 7, you need to add the var
keyword each time you change the type: Migrating scripts from V6 to V7.
So my variable declaration section needed to be changed to something like:
var
// Current topic ID
aTopicId: string;
var
// List of output
aList: TStringList;
This is a limitation of HelpNDoc's scripting engine.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论