2016-07-11 40 views
-3

我是一個新來的Delphi,並試圖編譯Inno Setup的Setup.e32文件,使用Inno Setup的源代碼和Delphi 10.1柏林。編譯錯誤:[dcc32錯誤] E2064左側不能分配

但問題是,當我嘗試編譯,我不斷收到錯誤[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; 

有什麼不對這些代碼?

當我創建​​並單擊compile.bat編譯非Unicode Inno Setup(現在我安裝了Delphi 7 .............),這就是發生了什麼。

This is what happened after following instructions...........

回答

3

此代碼是用於預Unicode版本的Delphi其中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柏林編譯Unicode Inno。

看起來你陷入了一片混亂的源文件。如果我是你,我會再次從Inno倉庫下載一個乾淨的下載文件。

  1. 刪除您現有的文件混雜。
  2. 從Inno存儲庫中獲取最新的源代碼。
  3. 按照自述文件的指示編譯Unicode版本的Inno。
+0

非常感謝您........經過艱苦的搜索後,我現在正在下載這個文件:CodeGearRADStudio2007_Dec2007.iso'。我可以使用這個RAD Studio 2007編譯這個文件嗎?我什至不能確定這個文件是什麼,因爲德爾福2007年現在已經結束了.....我只是下載來檢查。 :( – GTAVLover

+0

在我看來,像德爾福那樣老,這些模塊中的一些更好。 –

+0

或者我應該停止這個並下載它?這看起來像'德爾福2009年更新3'。鏈接:http://altd.embarcadero。com/download/Delphi_C++ Builder2009/Delphi_C++ Builder2009_ISO_June2009.iso我認爲這必須工作,因爲JR軟件說這是預期的編譯器。 – GTAVLover

2

自述明確規定,有創新科技的Unicode版本:

  • 安裝Borland的Delphi

    的Unicode Inno Setup的

    我們編譯所有的Inno Setup在Delphi 2009下的項目更新3

    較新的德爾福版本也應該工作但會導致顯着更大的文件。

    要使用的Delphi 2009 IDE的Windows 8.1下工作,你需要這兩樣東西,使其正常工作:

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

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

    。 ..

  • 建築物

    要構建所有文件,請運行build.bat並按照說明進行操作。

    要編譯Inno Setup運行compile-unicode.bat對於Unicode Inno Setup或compile.bat爲非Unicode Inno Setup並按照說明操作。

    ...

當使用德爾福2009年或更高版本(包括10.1柏林),請確保您編譯的Unicode版本英諾的,而不是一個安思版本。

話雖這麼說,代碼的麻煩線可以被重新寫入與德爾福的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); 

但是,如果您正在使用th,則這不應該是必需的e糾正開始的Unicode代碼版本的代碼。

+0

謝謝..........但是我從Github下載的uPSUtils.pas,uPSDebugger.pas,uPSRuntime.pas文件沒有附帶Inno Setup的源代碼。當我嘗試編譯'Setup .dproj'在Inno Setup源代碼中,Delphi表示形式'uPSUtils,uPSDebugger,uPSRuntime' not found ........所以我從PascalScript的源代碼中另外下載了這三種形式並添加到'Setup.dproj'中。這是問題嗎?我不知道他們是否是Unicode。 – GTAVLover

+0

@remy您提出的重新編寫修復了編譯器錯誤,但現在使用非ASCII數據在語義上破壞了這些函數。 –

+0

inno github項目鏈接到pascal腳本的Unicode端口,因此建議進行這樣的更改確實是一個非常糟糕的建議。 –