Inno Setup 逗号错误

发布于 2024-12-09 01:43:39 字数 1025 浏览 0 评论 0原文

我在 [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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

狼性发作 2024-12-16 01:43:39

我认为你不能只在这样的代码中使用 Inno Setup 常量,你必须使用 ExpandConstant()

AppVersion := StrToInt(GetVersion(ExpandConstant('{#MyAppVersion}')), 0);

I think that you can't just have Inno Setup constants in code like this, you have to use ExpandConstant():

AppVersion := StrToInt(GetVersion(ExpandConstant('{#MyAppVersion}')), 0);
萌化 2024-12-16 01:43:39

你没有给我们足够的信息来给出明确的答案,但我认为情况如下。

您已经定义了一些名为 MyAppVersion 的常量,您可以让 ISPP(Inno Setup 预处理器)替换它。现在,您还没有告诉我们这个变量是什么类型,也没有告诉我们 GetVersion 的签名是什么(特别是,它期望什么类型的参数?)。然而,如果这些类型是字符串,那么你需要编写

StrToInt(GetVersion('{#MyAppVersion}'), 0);

才能获取,比如说,

StrToInt(GetVersion('Some string, this is!'), 0);

而不是

StrToInt(GetVersion(Some string, this is!), 0);

格式错误的(确实,到了让我看的眼睛疼的程度)。

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 of GetVersion is (in particular, what type of argument does it expect?). However, if these types are strings, you need to write

StrToInt(GetVersion('{#MyAppVersion}'), 0);

in order to obtain, say,

StrToInt(GetVersion('Some string, this is!'), 0);

instead of

StrToInt(GetVersion(Some string, this is!), 0);

which is malformed (indeed, to such an extent that it hurts my eyes to look at it).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文