112112procedure CurStepChanged (CurStep: TSetupStep);
113113begin
114114 if CurStep = ssPostInstall then begin
115+ // The other sections ([Files], [Run]) have been processed
115116 if IsTaskSelected(' erlang\newpath' ) or IsTaskSelected(' existingpath' ) then
117+ // An Erlang Path-related task was selected, so it is performed here
116118 AppendPath(GetLatestErlangPath + ' \bin' );
117119 end ;
118120end ;
@@ -122,25 +124,37 @@ var
122124 ListBoxesToCheck: array [0 ..1 ] of TNewCheckListBox;
123125begin
124126 if CurPageID = wpPreparing then begin
127+ // We're on the page after the "Ready To Install" page but before [Files] and [Run] are processed
128+
125129 with GlobalErlangData do begin
126130 if IsTaskSelected(' erlang\32' ) then
131+ // 32-bit OTP needs to be downloaded before it's installed
127132 idpAddFile(URL32, Tmp(Exe32));
128133 if IsTaskSelected(' erlang\64' ) then
134+ // 64-bit OTP needs to be downloaded before it's installed
129135 idpAddFile(URL64, Tmp(Exe64));
130136 end ;
131-
137+
138+ // Look in these two listboxes for the selected release to install
132139 ListBoxesToCheck[0 ] := GlobalPageSelInstallType.CheckListBox;
133140 ListBoxesToCheck[1 ] := GlobalPageSelRelease.CheckListBox;
134-
141+
142+ // Store the selected release for use during the installation process
135143 CacheSelectedRelease := FindSelectedRelease(ListBoxesToCheck, GlobalElixirReleases);
144+
145+ // Download the Precompiled.zip archive for the selected release
136146 idpAddFile(CacheSelectedRelease.URL, Tmp(' Precompiled.zip' ));
147+
148+ // Put the downloader page directly after this page
137149 idpDownloadAfter(wpPreparing);
138150 end ;
139151end ;
140152
141153function ShouldSkipPage (PageID: Integer): Boolean;
142154begin
143155 if PageID = GlobalPageSelRelease.ID then begin
156+ // We should skip the page for selecting an Elixir release if the install type selection page
157+ // has some Elixir release set (such as the latest stable release)
144158 Result := not (GlobalPageSelInstallType.CheckListBox.ItemObject[GlobalPageSelInstallType.SelectedValueIndex] = nil );
145159 end else begin
146160 Result := False;
@@ -149,51 +163,62 @@ end;
149163
150164procedure InitializeWizard ();
151165begin
166+ // Define the installation type page
152167 GlobalPageSelInstallType := CreateInputOptionPage(
153168 wpWelcome,
154169 ' Select Elixir installation type' ,
155170 ' Select which installation type you want to perform, then click Next.' ,
156171 ' I want to:' ,
157- True, False
172+ True, False // (Use Radio Buttons), (Don't put them in a scrollable list box)
158173 );
159-
174+
175+ // Define the custom release selection page
160176 GlobalPageSelRelease := CreateInputOptionPage(
161177 GlobalPageSelInstallType.ID,
162178 ' Select Elixir release' ,
163179 ' Setup will download and install the Elixir release you select.' ,
164180 ' All releases available to install are listed below, from newest to oldest.' ,
165- True, True
181+ True, True // (Use Radio Buttons), (Put them in a scrollable list box)
166182 );
167-
183+
184+ // Create an array of TElixirRelease records from elixir.csv and store them in a global variable
168185 GlobalElixirReleases := CSVToElixirReleases(GlobalElixirCSVFilePath);
186+
187+ // Use the global Elixir release array to populate the custom Elixir release list box
169188 ElixirReleasesToListBox(GlobalElixirReleases, GlobalPageSelRelease.CheckListBox);
170-
189+
190+ // Find the latest release and put it as a selection on the installation type page
171191 with FindFirstReleaseOfType(GlobalElixirReleases, rtLatestRelease) do begin
172192 GlobalPageSelInstallType.CheckListBox.AddRadioButton(
173193 ' Install the latest stable release (v' + Version + ' )' ,
174194 ' ' , 0 , True, True, Ref
175195 );
176196 end ;
197+ // Create a selection which will allow the custom Elixir release page to show up next
177198 GlobalPageSelInstallType.CheckListBox.AddRadioButton(
178199 ' Select another release to install' ,
179200 ' ' , 0 , False, True, nil
180201 );
181-
202+
203+ // Create an TErlangData from erlang.csv record and store it in a global variable
182204 GlobalErlangData := CSVToErlangData(GlobalErlangCSVFilePath);
183205end ;
184206
185207function InitializeSetup (): Boolean;
186208begin
187209 Result := True;
188-
210+
211+ // Store the paths to elixir.csv, erlang.csv in global variables
189212 GlobalElixirCSVFilePath := Tmp(GetURLFilePart(' {#ELIXIR_CSV_URL}' ));
190213 GlobalErlangCSVFilePath := Tmp(GetURLFilePart(' {#ERLANG_CSV_URL}' ));
191214
215+ // Download elixir.csv; show an error message and exit the installer if downloading fails
192216 if not idpDownloadFile(' {#ELIXIR_CSV_URL}' , GlobalElixirCSVFilePath) then begin
193217 MsgBox(' Error: Downloading {#ELIXIR_CSV_URL} failed. Setup cannot continue.' , mbInformation, MB_OK);
194218 Result := False;
195219 exit;
196220 end ;
221+ // Download erlang.csv; show an error message and exit the installer if downloading fails
197222 if not idpDownloadFile(' {#ERLANG_CSV_URL}' , GlobalErlangCSVFilePath) then begin
198223 MsgBox(' Error: Downloading {#ERLANG_CSV_URL} failed. Setup cannot continue.' , mbInformation, MB_OK);
199224 Result := False;
@@ -202,8 +227,11 @@ begin
202227end ;
203228
204229function CheckToInstallErlang : Boolean; begin
230+ // Erlang should be installed if there's no Erlang path in the registry
205231 Result := (GetLatestErlangPath = ' ' ); end ;
206232function CheckToAddExistingErlangPath : Boolean; begin
233+ // We shouldn't add an existing Erlang path if it's already in Path or it isn't installed at all
207234 Result := not (CheckToInstallErlang or ErlangInPath); end ;
208-
235+
236+ // Scripted constants expand here
209237{ #StrInspectAllFuncs}
0 commit comments