-3

I an new to Delphi and tried to compile Inno Setup's Setup.e32 file using Inno Setup's Source Code with Delphi 10.1 Berlin.

But the problem is when I try to compile, I keeps getting Error [dcc32 Error] uPSUtils.pas(944): E2064 Left side cannot be assigned to.

I don't know how to resolve this and also read questions in this site which asked about that Error but even can't determine what is wrong in this code.

The Parts of the Code:

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;

What is wrong in these codes?

After I created compilesettings.bat and Clicked on compile.bat to Compile non Unicode Inno Setup (As now I installed Delphi 7.............) , this is what happened.

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

GTAVLover
  • 1,407
  • 3
  • 22
  • 41

2 Answers2

3

This code is written for a pre-Unicode version of Delphi where Char is an alias for the 8 bit AnsiChar. The cast to Byte reflects that. Since Delphi 2009 Char is aliased to the 16 bit WideChar.

Assuming that you are compiling the correct code (you are not - see below), the solution is to compile this code with the intended compiler. To determine what that is, read the documentation: https://github.com/jrsoftware/issrc/blob/master/README.md. My reading of this is that you should be able to compile the non-Unicode version of Inno with Delphi 7 or Delphi 2007.

Of course it may just be easier for you to compile the Unicode version. Again the instructions for doing so are very clearly laid out in the readme.


It transpires from comments that you are not compiling the intended versions of the PascalScript source. You say you downloaded some files with the same names. Don't do that. Use the source linked from the Inno repository. Use the compilers recommended there. Since you have Delphi 10.1 Berlin compile Unicode Inno.

It looks like you've got into quite a pickle with a confusion of source files. If I were you I would start again with a clean download from the Inno repository.

  1. Remove your existing mishmash of files.
  2. Fetch the latest source from the Inno repository.
  3. Compile the Unicode version of Inno following the instructions from the readme.
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Thank You Very Much........After hard searching I'm now downloading this file : `CodeGearRADStudio2007_Dec2007.iso`.Can I compile this using this RAD Studio 2007? I even can't determine what this file is as Delphi 2007 is now end of its life.....I just downloading to check. :( – GTAVLover Jul 11 '16 at 03:58
  • Looks to me like the older the Delphi the better for some of these modules. – David Heffernan Jul 11 '16 at 04:01
  • Or should I stop this and download this? This looks like `Delphi 2009 Update 3` . LINK : http://altd.embarcadero.com/download/Delphi_C++Builder2009/Delphi_C++Builder2009_ISO_June2009.iso I think this must work as JR Software says this as the intended compiler. – GTAVLover Jul 11 '16 at 04:05
  • Not for that component. That component wants a non Unicode compiler. Delphi 3 perhaps. Or Delphi 2. Later should also work. Older the better I guess. Not sure which component this is. Just that it clearly wants pre 2009. Why do you have two accounts here? – David Heffernan Jul 11 '16 at 04:08
  • Whose? In this site? No I haven't.This is the first one.Why? This is the `Setup.dproj` which is located in the Source Code of Inno Setup.But why this needs a non Unicode Compiler? isn't `uPSUtils` "u" means Unicode?I know nothing about "Unicode" and "non Unicode" so sorry if I wrong. – GTAVLover Jul 11 '16 at 04:11
  • 2
    Isn't this also you: http://stackoverflow.com/questions/38292468/cant-compile-compil32-dproj-using-delphi-10-1 the topic is just the same and the writing style matches, use of italic etc. Are you up voting the other accounts posts? If so you will likely get banned. – David Heffernan Jul 11 '16 at 04:15
  • Then what Version of Delphi should I download to compile this component and all other components in Inno Setup Compiler's Source Code? I need a Working Recommendation from you to do this. :) – GTAVLover Jul 11 '16 at 04:27
  • A pre Unicode version. The earlier the better. 2009 is Unicode. Everything earlier should work. If you want to contact that other user try ESP – David Heffernan Jul 11 '16 at 04:28
  • What is ESP? Don't tell words like `Everything Earlier`..........Please specify a version to use. I will use the version you tell to use because I don't like to fail again on compiling. – GTAVLover Jul 11 '16 at 04:33
  • You need to decide for yourself. I can't decide for you. The readme tells you what Jordan uses. Have you read it. Perhaps you might leave a comment at that other question. Maybe the other asker will share his experiences. I'm sure he'd love to help you also. – David Heffernan Jul 11 '16 at 04:36
  • Okay........Jordan Russell uses `Delphi 2009 with Update 3` as I read in the ReadMe. Am I wrong? – GTAVLover Jul 11 '16 at 04:37
  • Okay you mean non Unicode Version of Inno Setup.They may use `Delphi 2.01` Now am I right? According to Jordan Russell, should I have two versions of Delphi to compile Unicode versions and non Unicode versions? :( – GTAVLover Jul 11 '16 at 04:40
  • I think you need to slow down a little. Try to understand this a bit more. Jordan is using three different versions to compile non Unicode inno. But he says that it should work with any non Unicode Delphi. But he doesn't test all possible combinations. That's written in the readme but you keep skim reading it. Take your time. Learn. Understand. – David Heffernan Jul 11 '16 at 04:44
  • Thank You......Okay I will slow down............That's the last. Where can I find a download link for `Delphi 2 or 3`?They are now owned by `Embarcadero`. :( – GTAVLover Jul 11 '16 at 04:46
  • You won't find such old versions for download. I think D7 is as old as you can get from Emba. Having a licence for modern Delphi entitles you to some previous versions but I guess you know that. – David Heffernan Jul 11 '16 at 04:49
  • Sorry I wanted know will `Delphi 7` compile those units and components without Errors? – GTAVLover Jul 11 '16 at 04:51
  • There is an easy way to find out. – David Heffernan Jul 11 '16 at 04:53
  • Install Delphi 7 and compile – David Heffernan Jul 11 '16 at 05:00
  • @David......Thank You Very Much......I understood reading as a good mannar.....:) – GTAVLover Jul 11 '16 at 05:05
  • @RudyVelthuis JR does use D2009 with update 3 because he says so in the Inno readme – David Heffernan Jul 11 '16 at 10:47
  • Yes, but they come up with it when the matter is compiling without Unicode. – Rudy Velthuis Jul 11 '16 at 10:47
  • @RudyVelthuis I think that what has happened it that he/they are compiling with Unicode with Berlin, but have mixed in some PascalScript sources that target the ANSI compilers. The whole thing is a mess and quite frankly not helped by a suggestion to continue hacking around these bogus PascalScript sources. – David Heffernan Jul 11 '16 at 11:00
  • I'm also convinced that the other user in the other question is in fact the same person. Same project, same issues, same typing style, both with references to car based video games... – Jerry Dodge Jul 11 '16 at 22:03
  • @JerryDodge This is my Original Account. – GTAVLover Sep 30 '16 at 07:11
  • The rules of the site prohibit having multiple accounts. Ask the moderators to merge your accounts. – David Heffernan Sep 30 '16 at 07:12
2

The Readme specifically states that there is a Unicode version of 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.

    ...

When using Delphi 2009 or later (including 10.1 Berlin), make sure you are compiling a Unicode version of Inno, not an Ansi version.

That being said, the troublesome lines of code can be re-written to be compatible with Unicode versions of Delphi:

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);

However, this should not be necessary if you are using the correct Unicode-enabled version of the code to begin with.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Thank You..........But the file `uPSUtils.pas,uPSDebugger.pas,uPSRuntime.pas` whose I downloaded from Github is not came with Inno Setup's Source code.When I tried to compile `Setup.dproj` in Inno Setup Source Code, Delphi says form 'uPSUtils,uPSDebugger,uPSRuntime` not found........So I downloaded those three forms additionally from PascalScript's Source Code and added to the `Setup.dproj`. Is this the problem? I didn't know if they are Unicode or not. – GTAVLover Jul 11 '16 at 05:04
  • @remy Your proposed re-writes fix the compiler error but now leave those functions semantically broken with non ASCII data. – David Heffernan Jul 11 '16 at 05:13
  • The inno github project links to Unicode port of pascal script so it is really really bad advice to suggest making such changes. – David Heffernan Jul 11 '16 at 05:16
  • Inno has a `UniPs` folder that links to RemObjects' repository, so I assume that is the Unicode units being used. – Remy Lebeau Jul 11 '16 at 05:17
  • They would not have those casts. And in his comment asker says he has downloaded some other pascal script source. Asker is just thrashing around compiling lord knows what. He needs to step back and start again more slowly. It doesn't help that asker has no Delphi experience and so keeps taking the wrong decisions. – David Heffernan Jul 11 '16 at 05:20
  • @DavidHeffernan no, they don't break anything, and the original semantics are preserved. – Remy Lebeau Jul 11 '16 at 05:21
  • The original code assumed ASCII. I'd expect a Unicode version to handle more than ASCII. Wouldn't it be better to use Unicode pascal script? Or do you advise the asker to make those changes you added in your edit? Is that your recommendation? That asker downloads random files and hacks them until they compile. If that is your advice then it is exceedingly poor in my view. I believe you should better advise that asker compiles the correct source with the correct compiler. – David Heffernan Jul 11 '16 at 05:24
  • @DavidHeffernan of course use code that has already been written for Unicode. But regarding the code in question, handling case conversions in Unicode is complex, so it is not unreasonable to limit the conversions to ASCII letters. It depends on the context in which the code is being used. `ParseToken()` is only allowing ASCII tokens anyway. – Remy Lebeau Jul 11 '16 at 05:28
  • Which is why I think that final part of your answer is very bad. Asker has got in a mess by getting hold of the wrong source. Hacking that source won't lead anywhere. Getting the correct source is the way out. – David Heffernan Jul 11 '16 at 05:31
  • Regarding ParseToken I agree that it is limited to ASCII. Did you verify all other calls to FastUpperCase and FastLowerCase are compatible with these semantics. The asker isn't aware of any of these nuances and may just do those changes and think everything works. Then maybe there are failures down the line caused by this that will be a nightmare to track down. – David Heffernan Jul 11 '16 at 05:44
  • @DavidHeffernan no, I did not check the uses of the Fast functions. However, they do not convert non-ASCII letters even for Ansi strings, so semantics are preserved when moving to Unicode strings. – Remy Lebeau Jul 11 '16 at 05:52
  • But perhaps that was changed in the Unicode port (I doubt it was). Bearing in mind that asker now has an incompatible mix of Pascalscript source files. You still recommend that approach rather than using the intended source? – David Heffernan Jul 11 '16 at 05:58
  • @GTA you are compiling the wrong code. That can be discerned from the first comment to this answer. – David Heffernan Jul 11 '16 at 06:00
  • Thanks @DavidHeffernan I Like to discern :) – GTAVLover Jul 11 '16 at 06:05
  • 1
    FWIW, **in Delphi**, you can not add 32 to a `Char`, no matter if it is an `AnsiChar` or `WideChar`. You can do `Chr(Ord(C) + 32)` at best, but for Unicode that is not good enough anyway. – Rudy Velthuis Jul 11 '16 at 06:29
  • @RemyLebeau, "`compile.bat for Non Unicode Inno Setup and follow the instructions`"............When I click on `Compile.bat,` an Error occurs telling :`compilesettings.bat is missing or incomplete. It needs to be created with the following lines, adjusted for your system: DELPHIROOT=c:\delphi2 [Path to Delphi 2 (or later)] DELPHI3ROOT=c:\delphi3 [Path to Delphi 3 (or later)] DELPHI7ROOT=D:\Borland\delphi7 [Path to Delphi 7 (or later)]`..............What is this `compilesettings.bat`??? – GTAVLover Jul 11 '16 at 08:20
  • "What is this compilesettings.bat?" Seriously? What do you think it is? – MartynA Jul 11 '16 at 09:45
  • Why do you see a message telling you what to do and ignore it and give up. The message you pasted into that comment tells you exactly what to do. Why don't you follow instructions? Are you expecting that we will tell you any different? And if we give you instructions will you follow them or ignore them? – David Heffernan Jul 11 '16 at 09:55
  • Okay I created Batch File and now got this Error.........Now don't tell that I ignore the instructions............That Error Window is shown in my updated question............... – GTAVLover Jul 11 '16 at 12:24
  • Jordan's readme file is nonsense..............When I first clicked on `build.bat`, it says `Help was unexpected at this time.` :( – GTAVLover Jul 11 '16 at 13:04