title: Skipping custom pages based on optional components in Inno Setup
body: <p>In a prior question I asked how to have three optional components, where the user could also specify the locations for each component separately (e.g. a code part and two HTML web applications). @Miral gave me a great answer which I have now implemented:<br />
  <a href="https://stackoverflow.com/questions/13728134/three-components-in-three-user-defined-locations">three components in three user defined locations</a></p>
  <p>I have a small esthetic issue remaining. I am always creating and asking the user for a <code>CreateInputDirPage</code>, in the wizard. The question comes after the <code>wpSelectComponents</code>.</p>
  <p>Question: How do I skip the page if the component was not selected. That is, how do I skip my custom page?</p>
  <p>I have a feeling it has to do with <code>ShouldSkipPage()</code>. But I have no idea what the <code>PageID</code> for my custom page is, and how to test to see what components were selected.</p>
  <blockquote>
  <p>function ShouldSkipPage(PageID: Integer): Boolean;</p>
  <p>The wizard calls this event function to determine whether or not a particular page (specified by PageID) should be shown at all. If you return True, the page will be skipped; if you return False, the page may be shown.</p>
  </blockquote>
  <p>My script is enclosed below:</p>
  <pre class="lang-pascal prettyprint-override"><code>[Components]
  Name: &quot;Watson&quot;; Description: &quot;Watson Component&quot;; Types: onlywatson full
  Name: &quot;Toby&quot;; Description: &quot;Toby Component&quot;; Types: onlytoby full
  Name: &quot;Sherlock&quot;; Description: &quot;Sherlock Component&quot;; Types: onlysherlock full
  
  [Code]
  var 
      TobyDirPage: TInputDirWizardPage;
      SherlockDirPage: TInputDirWizardPage;
  
  procedure InitializeWizard;
  begin
    TobyDirPage := CreateInputDirPage(wpSelectComponents,
      'Select Location for Toby Web Pages', 'Where should we store the sample Toby application files?',
      'The sample Toby stand-alone map application will be saved in the following folder.'#13#10#13#10 +
      'To continue, click Next. If you would like to select a different folder, click Browse.',
      False, 'New Folder');
    { Add item (with an empty caption) }
    TobyDirPage.Add('');
    { Set initial value (optional) }
    TobyDirPage.Values[0] := ExpandConstant('c:\wwwroot\Toby');
    
    SherlockDirPage := CreateInputDirPage(wpSelectComponents,
      'Select Location for Sherlock Web Pages', 'Where should we store the Sherlock Catalog Search Tool?',
      'Sherlock.html and it'#39 + 's associated files will be saved in the following folder.'#13#10#13#10 +
      'To continue, click Next. If you would like to select a different folder, click Browse.',
      False, 'New Folder');
    { Add item (with an empty caption) }
    SherlockDirPage.Add('');
    { Set initial value (optional) }
    SherlockDirPage.Values[0] := ExpandConstant('c:\wwwroot\Sherlock');
  end;
  
  function GetTobyDir(Param: String): String;
  begin
    { Return the selected TobyDir }
    Result := TobyDirPage.Values[0];
  end;
  
  function GetSherlockDir(Param: String): String;
  begin
    { Return the selected TobyDir }
    Result := SherlockDirPage.Values[0];
  end;
  </code></pre>