1

Tasks can be set to display dependent on the component selected by simply listing Components: a b c etc and can be set to not be checked by default by specifying Flags: unchecked. However, there doesn't appear to be a way run a conditional check using Code to have a task checked if only one specific component is selected and remaining unchecked for all others.

Name: "SystemInfo"; Description: "Audit System Information"; GroupDescription: "Additional Setup Options"; Flags: unchecked; Components: Client Standalone Server

Here I want to have the SystemInfo task display as a selectable option if the Client, Standalone or Server components are selected, but if the Server component is selected I want this option to be checked by default rather than unchecked. Basically, is there a way to do a Check: IsComponentServerSelected in Code and remove the Flag: unchecked if true? Maybe there is another approach to this that I have overlooked?

Robert Wigley
  • 1,917
  • 22
  • 42

1 Answers1

1

I'm not entirely happy with this solution, but at least it does seem to work. It's possible to do this by creating two similar [Task] entries and displaying either the checked or unchecked one dependent on the components selected, like so:

Name: "SystemInfo"; Description: "Audit System Information"; GroupDescription: "Additional Setup Options"; Flags: unchecked; Components: Client
Name: "SystemInfoServer"; Description: "Audit System Information"; GroupDescription: "Additional Setup Options"; Components: Server Standalone

and then in [Code] referencing both tasks, rather than just the one:

      if IsTaskSelected('SystemInfo') or IsTaskSelected('SystemInfoServer') then
    begin;
      AuditSystemInfo;
    end;

I am still interested to hear if there is a better solution that would allow just one task to exist and to dynamically change the Flag status dependent on the components selected. Note, I did try using a Flag: {code: GetAuditFlag}, but this did not work, I assume because it was being called too early i.e. before Setup had initialised.

Robert Wigley
  • 1,917
  • 22
  • 42
  • You cannot use `{code...}` constants for `Flags`, but you can make two entries and let create only one of them by using `Check` (something [`like this`](http://stackoverflow.com/a/14415103/960757)). – TLama Mar 11 '15 at 16:00
  • @TLama Thanks, but I think that's what I have already done, but using the `Components` entries, isn't it? Or is doing it via a `Check` constraint slightly different? It's funny, because I was originally using a `Check` constraint, before realising it wasn't needed and could be done using the `Components` entry. Could you clarify if there is a difference? – Robert Wigley Mar 11 '15 at 16:34
  • I've checked deeper for a direct solution, but there is no one at this time. The way you've posted seems to be the best. What I suggested would work too, but would require writing an extra `Check` function. Listing only components is far better. – TLama Mar 12 '15 at 16:30
  • @TLama Thanks for confirming. – Robert Wigley Mar 12 '15 at 16:38