Error: 未知名称,为什么我的脚本在HelpNDoc中无法构建?

huangapple go评论46阅读模式
英文:

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 = &#39;d:\topics.txt&#39;;

var
  // Current topic ID
  aTopicId: string;
  // List of output
  aList: TStringList;

begin
  // Init list
  aList := TStringList.Create;
  aList.Add(&#39;Topic Caption | Help ID | Help Context | Meta Description&#39;);
  try
    // Get first topic
    aTopicId := HndTopics.GetTopicFirst();
    // Loop through all topics
    while aTopicId &lt;&gt; &#39;&#39; do
    begin
      // Add the topic to the list
      aList.Add(Format(&#39;%s | %s | %d | %s&#39;, [
        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:

Error: 未知名称,为什么我的脚本在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.

huangapple
  • 本文由 发表于 2023年2月7日 05:04:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75366566.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定