Compile Error : [dcc32 Error] E2064 Left side cannot be assigned to

Compile Error : [dcc32 Error] E2064 Left side cannot be assigned to

我是 Delphi 的新手,并尝试使用 Inno Setup 的源代码和 Delphi 10.1 Berlin 编译 Inno Setup 的 Setup.e32 文件。

但问题是当我尝试编译时,我不断收到错误 [dcc32 Error] uPSUtils.pas(944): E2064 Left side cannot be assigned to.

我不知道如何解决这个问题,也阅读了本网站中询问该错误的问题,但甚至无法确定此代码中的错误。

代码部分:

function FastUpperCase(const s: String): string;
{Fast uppercase}
var
  I: Integer;
  C: Char;
begin
  Result := S;
  I := Length(Result);
  while I > 0 do
  begin
    C := Result[I];
    if c in [#97..#122] then
      Dec (Byte(Result[I]), 32);  <<<Error E2064 HERE>>>
    Dec(I);
  end;
end;

function FastLowerCase(const s: String): string;
{Fast lowercase}
var
  I: Integer;
  C: Char;
begin
  Result := S;
  I := Length(Result);
  while I > 0 do
  begin
    C := Result[I];
    if C in [#65..#90] then
      Inc(Byte(Result[I]), 32);  <<<ERROR E2064 HERE>>>
    Dec(I);
  end;
end;

 function ParseToken(var CurrTokenPos, CurrTokenLen: Cardinal; var  CurrTokenId: TPSPasToken): TPSParserErrorKind;
  {Parse the token}
  var
    ct, ci: Cardinal;
    hs: Boolean;
    p: PChar;
  begin
    ParseToken := iNoError;
    ct := CurrTokenPos;
     case FText[ct] of
      #0:
         begin
          CurrTokenId := CSTI_EOF;
          CurrTokenLen := 0;
         end;
      'A'..'Z', 'a'..'z', '_':
         begin
           ci := ct + 1;
          while (FText[ci] in ['_', '0'..'9', 'a'..'z', 'A'..'Z']) do begin
            Inc(ci);
            end;
              CurrTokenLen := ci - ct;

           FLastUpToken := GetToken(CurrTokenPos, CurrtokenLen);
          p := pchar(FLastUpToken);
           while p^<>#0 do
          begin
            if p^ in [#97..#122] then
              Dec ((Byte(p^)), 32);  <<<ERROR E2064 HERE>>>
            inc(p);
          end;
          if not CheckReserved(FLastUpToken, CurrTokenId) then
          begin
            CurrTokenId := CSTI_Identifier;
          end;
        end;

这些代码有什么问题?

在我创建 compilesettings.bat 并点击 compile.bat 编译非 Unicode Inno Setup 之后(现在我安装了 Delphi 7...................... .),原来是这样。

此代码是为 Delphi 的前 Unicode 版本编写的,其中 Char 是 8 位 AnsiChar 的别名。 Byte 的转换反映了这一点。由于 Delphi 2009 Char 是 16 位 WideChar 的别名。

假设您正在编译正确的代码(您不是 - 见下文),解决方案是使用预期的编译器编译此代码。要确定那是什么,请阅读文档:https://github.com/jrsoftware/issrc/blob/master/README.md。我对此的解读是,您应该能够使用 Delphi 7 或 Delphi 2007.

编译非 Unicode 版本的 Inno

当然,编译Unicode版本可能更容易。同样,自述文件中非常清楚地列出了这样做的说明。


从评论中可以看出您没有编译预期版本的 PascalScript 源代码。你说你下载了一些同名文件。不要那样做。使用从 Inno 存储库链接的源。使用那里推荐的编译器。因为你有 Delphi 10.1 Berlin compile Unicode Inno。

看来您因源文件混乱而陷入困境。如果我是你,我会从 Inno 存储库中重新开始下载。

  1. 删除现有的文件大杂烩。
  2. 从 Inno 存储库获取最新源代码。
  3. 按照自述文件中的说明编译 Inno 的 Unicode 版本。

自述文件明确指出有一个 Unicode 版本的 Inno:

  • Install Borland Delphi

    Unicode Inno Setup:

    We compile all of Inno Setup's projects under Delphi 2009 with Update 3.

    Newer Delphi versions should also work but will lead to significantly larger files.

    To work with the Delphi 2009 IDE under Windows 8.1 you need these two things to make it work well:

    http://www.jrsoftware.org/files/Delphi_2007_2009_WOW64_Debugger_Fix.exe (md5sum: 545fc506c0614cf7a3339a7acb5217dc)

    http://www.jrsoftware.org/files/dzEditorLineEndsFix.exe (md5sum: c9598cf14452dd08987c5aec23d04f7d)

    ...

  • Building

    To build all files run build.bat and follow the instructions.

    To just compile Inno Setup run compile-unicode.bat for Unicode Inno Setup or compile.bat for Non Unicode Inno Setup and follow the instructions.

    ...

使用 Delphi 2009 或更高版本(包括 10.1 Berlin)时,请确保您编译的是 Unicode 版本的 Inno,而不是 Ansi 版本。

也就是说,麻烦的代码行可以重写以与 Delphi 的 Unicode 版本兼容:

if c in [#97..#122] then
  Result[I] := Char(Ord(c) - 32);
  // or: Dec(c, 32); Result[I] := c;

if C in [#65..#90] then
  Result[I] := Char(Ord(c) + 32);
  // or: Inc(c, 32); Result[I] := c;

if p^ in [#97..#122] then
  Dec(p^, 32);

但是,如果您一开始使用的是正确的支持 Unicode 的代码版本,则没有必要这样做。