因此,鉴于此功能,我在GetRoot := ROOTPage.Values[0];
线。我希望它告诉我ROOTPage
没有定义?
const
DefaultRoot = 'C:\IAmGRoot';
Var
ROOTPage : TInputQueryWizardPage;
procedure SetupRoot;
begin
ROOTPage := CreateInputQueryPage(wpUserInfo,
ExpandConstant('{cm:RootTitle}'),
ExpandConstant('{cm:RootInstructions}'),
ExpandConstant('{cm:RootDescription}') + ' "' + DefaultRoot + '"'
);
ROOTPage.Add(ExpandConstant('{cm:SSRoot}') + ':', False);
ROOTPage.Values[0] := ExpandConstant('{DefaultRoot}');
// add SSROOT to path
end;
function GetRoot : string;
begin
GetRoot := ROOTPage.Values[0];
end;
我该如何解释这个错误。 Pascal 中的标识符是什么?
This page http://wiki.freepascal.org/Identifiers告诉我标识符是变量名。也许我需要扩展ROOTPage.Values[0]
在某种程度上,因为我从 Inno Setup 对象引用数组?
或者也许我需要以不同的方式返回值。我看见one page http://wiki.freepascal.org/Functions在 Pascal 上,您需要避免在无参数函数上分配函数值,以避免递归循环。这是否意味着我应该传递一个虚拟值?或者有不同的语法吗?该页面没有解释。
我暗自认为我真正的问题是我没有正确定义我的函数......但是好吧。至少可以编译这么多。这个问题可能会变成:如何处理 Pascal 中的无参数函数?
我不认为 Inno Setup 是问题的一部分,但我正在与 Inno Setup 合作,以防万一这很重要。
更新:
它似乎不是数组,因为这会出现相同的错误:
const
DefaultRoot = 'C:\IAmGRoot';
function GetRoot : string;
begin
GetRoot := DefaultRoot;
end;
更新:
这link http://www.functionx.com/objectpascal/Lesson11.htm已经说了函数名可以替换/应该用关键字替换Result
比如下面的代码。我实际上知道这一点,但 Inno Setup 编译器不会将其识别为有效语法。然后它告诉我我的函数是一个无效的原型。
function GetRoot : string;
begin
Result := DefaultRoot;
end;
更新:
如果我这样做,我会得到“Invalid Prototype for GetRoot”
function GetRoot : boolean;
begin
Result := False;
end;
@Martin Prikryl 的更新:
我在几个地方使用过它,但典型的用法是这样的:
[Files]
Source: "C:\ValidPath\Release\*"; DestDir: "{app}\bin"; Components: DefinedComponent
Source: "C:\ValidPath\Deployment\*"; DestDir: "{code:GetRoot}\"; Flags: ignoreversion recursesubdirs; Components: DefinedComponent