【问题标题】:Inno Setup comma errorInno 设置逗号错误
【发布时间】:2011-10-06 16:39:15
【问题描述】:

我在 [Code] 中有 GetVersion 函数,它返回一个类似“1004”、“1003”等的字符串。

我创建了这个函数来检查最低版本号的注册表值并卸载它们。

这是代码的 sn-p,它为 StrtoInt 转换行提供错误点说明

Comma (,) expected

这里是sn-p:

function DoesOldVersionsExist(): Boolean;
var
  AppVersion: integer;
  mstr: string;
  VersionInstalled: cardinal;
begin
  AppVersion := StrToInt(GetVersion({#MyAppVersion}), 0);
...

在那一行之后,我简单地比较这些值并返回真或假。非常感谢。

这是错误消息的内容:

Line 55
Column 40.
Comma (,) expected

感谢迪安娜,但不幸的是,这是指向此的错误消息:

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;

【问题讨论】:

  • 你的右括号好像太多了。
  • 当您收到错误消息时,也请尝试发布它,因为它通常会提供有关问题所在的线索。
  • 很好,我改变了它仍然没有运气。我会编辑我的问题谢谢。
  • 与您的previous question 一样,您还没有告诉我们 MyAppVErsion 的定义是什么。这对这两个问题都至关重要,因为它在所有情况下都被完全按照原样使用。您需要确保它是“干净的”特殊字符并根据需要将其引用为代码/脚本中的文字。在我们知道那个值是什么之前,我们所做的只是猜测。
  • #define MyAppVersion GetFileVersion("Release\myFile.dll") 版本看起来像这样“1.0.0.3”

标签: inno-setup pascal


【解决方案1】:

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

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

【讨论】:

  • 这不是一个常数。它是 Inno Setup 预处理器 (ISPP) 认可的“魔术词”(可能不是官方术语)。
【解决方案2】:

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

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

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

为了获得,比如说,

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

而不是

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

这是畸形的(确实,看着它会伤害我的眼睛)。

【讨论】:

  • 刚刚添加了getversion功能。它返回一个字符串。
猜你喜欢
  • 1970-01-01
  • 2011-09-20
  • 1970-01-01
  • 2023-03-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多