Search code examples
arraysinno-setuppascalscript

How can I get the length of a static array?


If I have a static array of labels:

Labels: array [0..6] of TLabel;

How can I get the number of labels in a procedure?

Also if anyone could tell me more about the kind of Pascal Inno Setup is using, or if there's some manual for it. I can't do High() on the array, for example.


Solution

  • Inno Setup Unicode version:

    In Unicode versions of Inno Setup you can use the Low, High and even Length functions like known from Delphi. So maybe it's time to move to the Unicode version to write a code like this:

    function InitializeSetup(): Boolean;
    var
      Labels: array [0..6] of TLabel;
    begin
      MsgBox(
        'Array length: ' + IntToStr(Length(Labels)) + #13#10 +
        'Array low bound: ' + IntToStr(Low(Labels)) + #13#10 +
        'Array high bound: ' + IntToStr(High(Labels)),
        mbInformation, MB_OK);
    end;
    

    Inno Setup ANSI version:

    There is no way to get length or bounds of a static array in ANSI versions of the InnoSetup. There are no Low nor High functions and the Length function is applicable only for string, the GetArrayLength only for dynamic arrays. Just another static array Inno Setup nitpick.

    Source:
    http://www.mirality.co.nz