“colon (':') expected” compiler error on character range in case statement in Inno Setup Pascal script

前端 未结 1 1010
予麋鹿
予麋鹿 2020-12-20 00:58

I\'m getting a \"colon (:) expected\" syntax error on this code (Line 14; Column 10) and I\'m at a loss. This code runs in Inno Setup compiler, it is Delphi-like, but I don\

相关标签:
1条回答
  • 2020-12-20 01:50

    The Ansi version of Inno Setup does not seem to support ranges in case statement.

    So you have to enumerate the set:

    case C of
      '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': B := ...;
      ...
    end;
    

    In what case it's probably better to use if:

    if (C >= '0') and (C <= '9') then
    

    Though even better, use the Unicode version of Inno Setup. It's 21st century, you should not develop non-Unicode applications anymore. See Upgrading from Ansi to Unicode version of Inno Setup (any disadvantages). And Inno Setup 6 has Unicode version only anyway.


    You better use the CryptStringToBinary Windows API function for the hex to binary conversion anyway. See my answer to your other question Writing binary file in Inno Setup.


    Note that there are lot of other problems with your code.

    • You are subtracting char from integer.
    • The Inno Setup does not have a two argument overload of Inc.
    • TStream.WriteBuffer takes string, not byte.
    0 讨论(0)
提交回复
热议问题