如何获得静态数组的长度?

时间:2022-02-21 21:13:53

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.

另外,如果有人能告诉我更多关于Pascal Inno安装使用的类型,或者是否有一些手册。例如,我不能对数组执行High()。

1 个解决方案

#1


5  

InnoSetup ANSI version:

InnoSetup ANSI版本:

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 InnoSetup nitpick.

在InnoSetup的ANSI版本中,无法获得静态数组的长度或边界。没有高低函数,长度函数只适用于字符串,GetArrayLength函数只适用于动态数组。只是另一个静态数组InnoSetup nitpick。

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

来源:http://www.mirality.co.nz

InnoSetup Unicode version:

InnoSetup Unicode版本:

In Unicode versions of InnoSetup 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:

在InnoSetup的Unicode版本中,可以使用从Delphi获得的低、高、甚至长度的函数。因此,也许是时候转向Unicode版本,编写这样的代码了:

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;

#1


5  

InnoSetup ANSI version:

InnoSetup ANSI版本:

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 InnoSetup nitpick.

在InnoSetup的ANSI版本中,无法获得静态数组的长度或边界。没有高低函数,长度函数只适用于字符串,GetArrayLength函数只适用于动态数组。只是另一个静态数组InnoSetup nitpick。

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

来源:http://www.mirality.co.nz

InnoSetup Unicode version:

InnoSetup Unicode版本:

In Unicode versions of InnoSetup 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:

在InnoSetup的Unicode版本中,可以使用从Delphi获得的低、高、甚至长度的函数。因此,也许是时候转向Unicode版本,编写这样的代码了:

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;