Inno Setup 将数组中的字符串转换为布尔值
Inno Setup convert string in array to boolean
从 开始,我有一个二维(四列)数组 RemoteDetailsLines
,其中最后一列存储一个 1
或 0
,指示是否它是否处于活动状态。我想使用下面数组中的值创建一个 CheckListBox
,这对于创建和命名复选框非常有效,但我也希望在最后一列包含 1
的地方选中该框.在下面代码中出现的 RemoteDetailsLines[intIndex][3]
不起作用,即使我使用 StringChangeEx
循环并将 1
和 0
值转换为 True
和 False
,因为值是字符串。
因此,问题是如何将这些值转换为 AddCheckBox
函数所期望的 Boolean
?我什至不确定数组是否可以是字符串值以外的任何东西?
CheckListBox := TNewCheckListBox.Create(SelectRemotesPage);
with CheckListBox do
begin
Parent := SelectRemotesPage.Surface;
Left := ScaleX(0);
Top := ScaleY(50);
Width := ScaleX(250);
Height := ScaleY(153);
for intIndex := 0 to intNumberRemotes - 1 do
begin
AddCheckBox(RemoteDetailsLines[intIndex][1], RemoteDetailsLines[intIndex][2], 0, RemoteDetailsLines[intIndex][3], True, False, False, Nil);
end;
end;
对于这个简单的案例,使用就足够了:
AddCheckBox(..., (RemoteDetailsLines[intIndex][3] <> '0'), ...);
比较运算符<>
returnsBoolean
.
更稳健的解决方案是:
AddCheckBox(..., (StrToIntDef(RemoteDetailsLines[intIndex][3], 0) <> 0), ...);
将字符串转换为 Integer
并回退到 0
,然后将整数与 0
.
进行比较
从 RemoteDetailsLines
,其中最后一列存储一个 1
或 0
,指示是否它是否处于活动状态。我想使用下面数组中的值创建一个 CheckListBox
,这对于创建和命名复选框非常有效,但我也希望在最后一列包含 1
的地方选中该框.在下面代码中出现的 RemoteDetailsLines[intIndex][3]
不起作用,即使我使用 StringChangeEx
循环并将 1
和 0
值转换为 True
和 False
,因为值是字符串。
因此,问题是如何将这些值转换为 AddCheckBox
函数所期望的 Boolean
?我什至不确定数组是否可以是字符串值以外的任何东西?
CheckListBox := TNewCheckListBox.Create(SelectRemotesPage);
with CheckListBox do
begin
Parent := SelectRemotesPage.Surface;
Left := ScaleX(0);
Top := ScaleY(50);
Width := ScaleX(250);
Height := ScaleY(153);
for intIndex := 0 to intNumberRemotes - 1 do
begin
AddCheckBox(RemoteDetailsLines[intIndex][1], RemoteDetailsLines[intIndex][2], 0, RemoteDetailsLines[intIndex][3], True, False, False, Nil);
end;
end;
对于这个简单的案例,使用就足够了:
AddCheckBox(..., (RemoteDetailsLines[intIndex][3] <> '0'), ...);
比较运算符<>
returnsBoolean
.
更稳健的解决方案是:
AddCheckBox(..., (StrToIntDef(RemoteDetailsLines[intIndex][3], 0) <> 0), ...);
将字符串转换为 Integer
并回退到 0
,然后将整数与 0
.