Archive: Referencing Section index beofre it's declared


Referencing Section index beofre it's declared
I have a problem similar to the below, where I have a sectiongroup with three sections in it, and if at least one of those sections is selected, I want to first install some files required by all sections. So I have something like the below, but it does not compile because the hidden section is referencing the symbol ${Sec_ThisGroup} which is not yet defined. Any ideas on how I can work around this? I'm going to be encountering this in several places.


Section "-Hidden common"
Section RO
${If} ${SectionIsSelected} ${Sec_ThisGroup}
${OrIf} ${SectionIsPartiallySelected} ${Sec_ThisGroup}
;Install common files
${EndIf}
SectionEnd

SectionGroup "this group" Sec_ThisGroup
Section "Blah 1"

SectionEnd
Section "Blah 2"

SectionEnd
Section "Blah 3"

SectionEnd
SectionGroupEnd



Instead of using the If SectionIsSelected, a less elegant alternative is that I place code in the onSelChange or components page leave callback, that enables and disables the hidden common section, but I'd need that also in the oninit in case the installer is run silently. I figured it would be much easier to maintain if I just had a hidden section before the other section, because it will be run regardless of whether it's silent or not. As I add more logic to handle certain silent install scenarios, my code is getting pretty tangled and more difficult to handle.

Maybe there should be a mandatory waiting period before posting :) I thought I was at a dead end but right after I posted I reallized I could declare a function after the section declarations, but call the function from the first section, and basically nest all the logic within that function, then the section index will be declared when the compiler reaches the function, but the code at runtime will be run from the first section.