61
61
var
62
62
PSelRelease: TWizardPage;
63
63
PSelReleaseListBox: TNewCheckListBox;
64
+ i: Integer;
65
+ _int: Integer;
64
66
65
67
function SplitStringRec (Str: String; Delim: String; StrList: TStringList): TStringList;
66
68
var
@@ -85,62 +87,46 @@ begin
85
87
end ;
86
88
87
89
function SplitString (Str: String; Delim: String): TStringList;
88
- var
89
- StrList: TStringList;
90
90
begin
91
- StrList := TStringList.Create;
92
- Result := SplitStringRec(Str, Delim, StrList)
91
+ Result := SplitStringRec(Str, Delim, TStringList.Create);
93
92
end ;
94
93
95
94
function CSVToStringTable (Filename: String): TStringTable;
96
95
var
97
- Rows: TArrayOfString;
98
- NumReleases: Integer;
99
- i: Integer;
100
- Values: TStringList;
101
- ReturnArray: TStringTable;
96
+ Rows: TArrayOfString;
102
97
begin
103
- LoadStringsFromFile(Filename, Rows);
104
-
105
- NumReleases := GetArrayLength(Rows);
106
- SetArrayLength(ReturnArray, NumReleases);
98
+ LoadStringsFromFile(Filename, Rows);
99
+ SetArrayLength(Result, GetArrayLength(Rows));
107
100
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], ' ,' );
110
103
end ;
111
-
112
- Result := ReturnArray;
113
104
end ;
114
105
115
106
procedure PopulatePSelReleaseListBox (StringTable: TStringTable);
116
107
var
117
108
PrereleaseLabel: String;
118
- MatchesCompatMask: Boolean;
119
- VersionLabel: String;
120
- i: Integer;
121
109
begin
122
110
PSelReleaseListBox.Items.Clear;
123
111
124
112
for i := 0 to GetArrayLength(StringTable) - 1 do begin
125
113
if (StrToInt(StringTable[i][3 ]) = { #COMPAT_MASK} ) then begin
126
- VersionLabel := ' Version ' + StringTable[i][0 ];
127
114
if StringTable[i][2 ] = ' true' then begin
128
115
PrereleaseLabel := ' Prerelease' ;
129
- end else
116
+ end else begin
130
117
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]);
133
120
end ;
134
121
end ;
135
122
end ;
136
123
137
124
function GetSelectedReleaseValues (): TStrings;
138
- var
139
- i: Integer;
140
125
begin
141
126
for i := 0 to PSelReleaseListBox.Items.Count - 1 do begin
142
127
if PSelReleaseListBox.Checked[i] then begin
143
128
Result := TStrings(PSelReleaseListBox.ItemObject[i]);
129
+ break;
144
130
end ;
145
131
end ;
146
132
end ;
@@ -155,15 +141,18 @@ begin
155
141
Result := GetSelectedReleaseValues[1 ];
156
142
end ;
157
143
144
+ function ErlangIsInstalled : Boolean;
145
+ begin
146
+ Result := Exec(' erl.exe' , ' +V' , ' ' , SW_HIDE, ewWaitUntilTerminated, _int);
147
+ end ;
148
+
158
149
procedure CurPageChanged (CurPageID: Integer);
159
150
begin
160
151
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
162
153
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' )));
167
156
end ;
168
157
169
158
if CurPageID = wpReady then begin
@@ -172,50 +161,24 @@ begin
172
161
end ;
173
162
end ;
174
163
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
-
198
164
function PrepareToInstall (var NeedsRestart: Boolean): String;
199
- var
200
- ErrorMsg: String;
201
165
begin
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
211
170
Result := ' Erlang not installed.' ;
212
171
end ;
213
172
end ;
214
173
end ;
215
174
216
- procedure ExtractPrecompiled ();
217
- var
218
- ResultCode: Integer;
175
+ procedure InitializeWizard ();
219
176
begin
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;
221
184
end ;
0 commit comments