2
votes

Following on from Inno Setup create array from comma delimited strings stored in an array, I have a two dimensional (four column) array RemoteDetailsLines, in which the last column stores a 1 or 0 indicating whether it is active or not. I want to create a CheckListBox using the values from the array as below, which works fine for creating and naming the checkboxes, but I also want to have the box appear checked where the last column contains a 1. Using RemoteDetailsLines[intIndex][3] where it appears in the code below does not work, even if I use StringChangeEx to loop through and convert the 1 and 0 values to True and False, as the values are strings.

Therefore, the question is how can these values be converted to a Boolean that the AddCheckBox function is expecting? I am not even sure if arrays can be anything other than string values?

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

1 Answers

2
votes

For this simple case it's enough to use:

AddCheckBox(..., (RemoteDetailsLines[intIndex][3] <> '0'), ...);

The comparison operator <> returns Boolean.


A more robust solution is:

AddCheckBox(..., (StrToIntDef(RemoteDetailsLines[intIndex][3], 0) <> 0), ...);

Convert the string to an Integer with a fallback to 0 and then compare the integer to 0.