6161var
6262 PSelRelease: TWizardPage;
6363 PSelReleaseListBox: TNewCheckListBox;
64+ i: Integer;
65+ _int: Integer;
6466
6567function SplitStringRec (Str: String; Delim: String; StrList: TStringList): TStringList;
6668var
@@ -85,62 +87,46 @@ begin
8587end ;
8688
8789function SplitString (Str: String; Delim: String): TStringList;
88- var
89- StrList: TStringList;
9090begin
91- StrList := TStringList.Create;
92- Result := SplitStringRec(Str, Delim, StrList)
91+ Result := SplitStringRec(Str, Delim, TStringList.Create);
9392end ;
9493
9594function CSVToStringTable (Filename: String): TStringTable;
9695var
97- Rows: TArrayOfString;
98- NumReleases: Integer;
99- i: Integer;
100- Values: TStringList;
101- ReturnArray: TStringTable;
96+ Rows: TArrayOfString;
10297begin
103- LoadStringsFromFile(Filename, Rows);
104-
105- NumReleases := GetArrayLength(Rows);
106- SetArrayLength(ReturnArray, NumReleases);
98+ LoadStringsFromFile(Filename, Rows);
99+ SetArrayLength(Result, GetArrayLength(Rows));
107100
108- for i := 0 to NumReleases - 1 do begin
109- ReturnArray [i] := SplitString(Rows[i], ' ,' );
101+ for i := 0 to GetArrayLength(Result) - 1 do begin
102+ Result [i] := SplitString(Rows[i], ' ,' );
110103 end ;
111-
112- Result := ReturnArray;
113104end ;
114105
115106procedure PopulatePSelReleaseListBox (StringTable: TStringTable);
116107var
117108 PrereleaseLabel: String;
118- MatchesCompatMask: Boolean;
119- VersionLabel: String;
120- i: Integer;
121109begin
122110 PSelReleaseListBox.Items.Clear;
123111
124112 for i := 0 to GetArrayLength(StringTable) - 1 do begin
125113 if (StrToInt(StringTable[i][3 ]) = { #COMPAT_MASK} ) then begin
126- VersionLabel := ' Version ' + StringTable[i][0 ];
127114 if StringTable[i][2 ] = ' true' then begin
128115 PrereleaseLabel := ' Prerelease' ;
129- end else
116+ end else begin
130117 PrereleaseLabel := ' Release' ;
131-
132- PSelReleaseListBox.AddRadioButton(VersionLabel , PrereleaseLabel, 0 , False, True, StringTable[i]);
118+ end ;
119+ PSelReleaseListBox.AddRadioButton(' Version ' + StringTable[i][ 0 ] , PrereleaseLabel, 0 , False, True, StringTable[i]);
133120 end ;
134121 end ;
135122end ;
136123
137124function GetSelectedReleaseValues (): TStrings;
138- var
139- i: Integer;
140125begin
141126 for i := 0 to PSelReleaseListBox.Items.Count - 1 do begin
142127 if PSelReleaseListBox.Checked[i] then begin
143128 Result := TStrings(PSelReleaseListBox.ItemObject[i]);
129+ break;
144130 end ;
145131 end ;
146132end ;
@@ -155,15 +141,18 @@ begin
155141 Result := GetSelectedReleaseValues[1 ];
156142end ;
157143
144+ function ErlangIsInstalled : Boolean;
145+ begin
146+ Result := Exec(' erl.exe' , ' +V' , ' ' , SW_HIDE, ewWaitUntilTerminated, _int);
147+ end ;
148+
158149procedure CurPageChanged (CurPageID: Integer);
159150begin
160151 if CurPageID = PSelRelease.ID then begin
161- if not FileExists(ExpandConstant(' {tmp}\releases.csv' )) then
152+ if not FileExists(ExpandConstant(' {tmp}\releases.csv' )) then begin
162153 idpDownloadFile(' http://elixir-lang.org/releases.csv' , ExpandConstant(' {tmp}\releases.csv' ));
163-
164- PopulatePSelReleaseListBox(
165- CSVToStringTable(
166- ExpandConstant(' {tmp}\releases.csv' )));
154+ end ;
155+ PopulatePSelReleaseListBox(CSVToStringTable(ExpandConstant(' {tmp}\releases.csv' )));
167156 end ;
168157
169158 if CurPageID = wpReady then begin
@@ -172,50 +161,24 @@ begin
172161 end ;
173162end ;
174163
175- procedure CreatePages ();
176- begin
177- PSelRelease := CreateCustomPage(wpWelcome, ' Select Elixir release' , ' Setup will download and install the Elixir release you select.' );
178-
179- PSelReleaseListBox := TNewCheckListBox.Create(PSelRelease);
180- PSelReleaseListBox.Width := PSelRelease.SurfaceWidth;
181- PSelReleaseListBox.Height := PSelRelease.SurfaceHeight - 10 ;
182- PSelReleaseListBox.Parent := PSelRelease.Surface;
183- end ;
184-
185- function ErlangIsInstalled : Boolean;
186- var
187- ResultCode: Integer;
188- begin
189- Result := Exec(' erl.exe' , ' +V' , ' ' , SW_HIDE, ewWaitUntilTerminated, ResultCode)
190- end ;
191-
192- procedure InitializeWizard ();
193- begin
194- idpSetOption(' DetailsButton' , ' 0' );
195- CreatePages;
196- end ;
197-
198164function PrepareToInstall (var NeedsRestart: Boolean): String;
199- var
200- ErrorMsg: String;
201165begin
202- if ErlangIsInstalled then begin
203- Result := ' ' ;
204- end else begin
205- ErrorMsg := ' Warning: Erlang does not seem to be installed.' + #13 #10 #13 #10 +
206- ' In order for Elixir to run, you will need to install Erlang from http://www.erlang.org/ and then add it to your Path environment variable.' + #13 #10 #13 #10 +
207- ' Proceed anyway?' ;
208- if MsgBox(ErrorMsg, mbConfirmation, MB_YESNO or MB_DEFBUTTON2) = IDYES then begin
209- Result := ' ' ;
210- end else begin
166+ if not ErlangIsInstalled then begin
167+ if MsgBox(' Warning: Erlang does not seem to be installed.' + #13 #10 #13 #10 +
168+ ' In order for Elixir to run, you will need to install Erlang from http://www.erlang.org/ and then add it to your Path environment variable.' + #13 #10 #13 #10 +
169+ ' Proceed anyway?' , mbConfirmation, MB_YESNO or MB_DEFBUTTON2) = IDNO then begin
211170 Result := ' Erlang not installed.' ;
212171 end ;
213172 end ;
214173end ;
215174
216- procedure ExtractPrecompiled ();
217- var
218- ResultCode: Integer;
175+ procedure InitializeWizard ();
219176begin
220- Exec(' powershell.exe' , ExpandConstant(' -File {tmp}\extract-zip.ps1 {tmp}\Precompiled.zip {tmp}\Precompiled' ), ' ' , SW_HIDE, ewWaitUntilTerminated, ResultCode);
177+ idpSetOption(' DetailsButton' , ' 0' );
178+
179+ PSelRelease := CreateCustomPage(wpWelcome, ' Select Elixir release' , ' Setup will download and install the Elixir release you select.' );
180+ PSelReleaseListBox := TNewCheckListBox.Create(PSelRelease);
181+ PSelReleaseListBox.Width := PSelRelease.SurfaceWidth;
182+ PSelReleaseListBox.Height := PSelRelease.SurfaceHeight - 10 ;
183+ PSelReleaseListBox.Parent := PSelRelease.Surface;
221184end ;
0 commit comments