2525 Ref: TObject;
2626 end ;
2727
28+ // Given an Elixir release type, return its string representation
2829function ReleaseTypeToString (ReleaseType: TElixirReleaseType): String;
2930begin
3031 Result := ' Unknown' ;
4041 Result := ' Incompatible' ;
4142end ;
4243
44+ // Given a filename to an elixir.csv file, return an array of Elixir releases corresponding to
45+ // the data in the csv file.
4346function CSVToElixirReleases (Filename: String): array of TElixirRelease;
4447var
4548 Rows: TArrayOfString;
4851 LatestPrerelease: Boolean;
4952 LatestRelease: Boolean;
5053begin
54+ // Initialize as one-way flags
5155 LatestPrerelease := True;
5256 LatestRelease := True;
5357
58+ // Read the file at Filename and store the lines in Rows
5459 LoadStringsFromFile(Filename, Rows);
60+ // Match length of return array to number of rows
5561 SetArrayLength(Result, GetArrayLength(Rows));
5662
5763 for i := 0 to GetArrayLength(Result) - 1 do begin
64+ // Separate values at commas
5865 RowValues := SplitString(Rows[i], ' ,' );
5966
6067 with Result[i] do begin
68+ // Store first and second values as the Version and URL respectively
6169 Version := RowValues[0 ];
6270 URL := RowValues[1 ];
6371
6472 if StrToInt(RowValues[3 ]) = { #COMPAT_MASK} then begin
73+ // Release has a compatibility mask matching this installer
6574 if RowValues[2 ] = ' prerelease' then begin
75+ // Release is designated as a prerelease
6676 if LatestPrerelease then begin
77+ // This is the first prerelease found, so it's the latest prerelease
6778 ReleaseType := rtLatestPrerelease;
6879 LatestPrerelease := False;
6980 end else begin
81+ // This is not the latest prerelease
7082 ReleaseType := rtPrerelease;
7183 end ;
7284 end else begin
7385 if LatestRelease then begin
86+ // This is the first release found, so it's the latest prerelease
7487 ReleaseType := rtLatestRelease;
7588 LatestRelease := False;
7689 end else begin
90+ // This is not the latest release
7791 ReleaseType := rtRelease;
7892 end ;
7993 end ;
8094 end else begin
95+ // Release can't be installed by this installer
8196 ReleaseType := rtIncompatible;
8297 end ;
8398
99+ // Assign this Elixir release a new reference object
84100 if Ref = nil then
85101 Ref := TObject.Create();
86102 end ;
87103 end ;
88104end ;
89105
106+ // Given an array of Elixir release and a list box, populate the list box with radio buttons
107+ // which describe and point to the releases in the Elixir release array
90108procedure ElixirReleasesToListBox (Releases: array of TElixirRelease; ListBox: TNewCheckListBox);
91109var
92110 i: Integer;
@@ -95,12 +113,12 @@ begin
95113 for i := 0 to GetArrayLength(Releases) - 1 do begin
96114 with Releases[i] do begin
97115 ListBox.AddRadioButton(
98- ' Elixir version ' + Version,
99- ReleaseTypeToString(ReleaseType),
100- 0 ,
101- (ReleaseType = rtLatestRelease),
102- (ReleaseType <> rtIncompatible),
103- Ref
116+ ' Elixir version ' + Version, // Label next to radio button
117+ ReleaseTypeToString(ReleaseType), // Label right-justified in list box
118+ 0 , // All choices on the same level
119+ (ReleaseType = rtLatestRelease), // Radio button selected by default if it's the latest release
120+ (ReleaseType <> rtIncompatible), // Incompatible releases can't be selected
121+ Ref // Pointer to release's reference object
104122 );
105123 end
106124 end ;
0 commit comments