Inno Setup 逗号错误
我在 [Code] 中有 GetVersion 函数,它返回一个类似“1004”、“1003”等的字符串。
我创建这个函数是为了检查最低版本号的注册表值并卸载它们。
这是它向 StrtoInt 转换行提供错误点的代码片段,说明
Comma (,) expected
以下是片段:
function DoesOldVersionsExist(): Boolean;
var
AppVersion: integer;
mstr: string;
VersionInstalled: cardinal;
begin
AppVersion := StrToInt(GetVersion({#MyAppVersion}), 0);
...
在该行之后,我简单地比较值并返回 true 或 false。非常感谢。
这就是错误消息的内容:
Line 55
Column 40.
Comma (,) expected
谢谢 Deanna,但不幸的是,这是指向此的错误消息:
AppVersion := StrToInt(GetVersion({#MyAppVersion}), 0);
^
这是 GetVersion 函数:
function GetVersion(AppVersion: String): String;
var
Version: String;
CharIndex: integer;
c: char;
begin
for CharIndex := 1 to Length(AppVersion) do begin
c := AppVersion[CharIndex];
if (c <> '.') then
Version := Version + c;
end;
Result := Version;
end;
I have GetVersion function in [Code] that returns a string like this "1004", "1003", etc.
I created this function to check the registry value for lowest version numbers and uninstall them.
Here is a snippet of the code it is giving error point to StrtoInt conversion line stating
Comma (,) expected
Here is the snippet:
function DoesOldVersionsExist(): Boolean;
var
AppVersion: integer;
mstr: string;
VersionInstalled: cardinal;
begin
AppVersion := StrToInt(GetVersion({#MyAppVersion}), 0);
...
after that line I'm simple comparing the values and return true or false. Much Appreciated.
This is what error message says:
Line 55
Column 40.
Comma (,) expected
Thanks Deanna but unfortunately that is the error message pointing to this :
AppVersion := StrToInt(GetVersion({#MyAppVersion}), 0);
^
Here is the GetVersion function:
function GetVersion(AppVersion: String): String;
var
Version: String;
CharIndex: integer;
c: char;
begin
for CharIndex := 1 to Length(AppVersion) do begin
c := AppVersion[CharIndex];
if (c <> '.') then
Version := Version + c;
end;
Result := Version;
end;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你不能只在这样的代码中使用 Inno Setup 常量,你必须使用
ExpandConstant()
:I think that you can't just have Inno Setup constants in code like this, you have to use
ExpandConstant()
:你没有给我们足够的信息来给出明确的答案,但我认为情况如下。
您已经定义了一些名为
MyAppVersion
的常量,您可以让 ISPP(Inno Setup 预处理器)替换它。现在,您还没有告诉我们这个变量是什么类型,也没有告诉我们GetVersion
的签名是什么(特别是,它期望什么类型的参数?)。然而,如果这些类型是字符串,那么你需要编写才能获取,比如说,
而不是
格式错误的(确实,到了让我看的眼睛疼的程度)。
You have not given us enough information to give a definite answer, but I think that the situation is as follows.
You have defined some constant called
MyAppVersion
which you let the ISPP (the Inno Setup pre-processor) substitute. Now, you have not told us what type this variable is, and you have not told us what the signature ofGetVersion
is (in particular, what type of argument does it expect?). However, if these types are strings, you need to writein order to obtain, say,
instead of
which is malformed (indeed, to such an extent that it hurts my eyes to look at it).