Section Dependency: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
No edit summary |
|||
(One intermediate revision by the same user not shown) | |||
Line 3: | Line 3: | ||
== Description == | == Description == | ||
Macro's that are inserted in a block by block basis to build a list of Sections that are dependent on another Section. By this we mean that 1 or more Sections must have 1 or more other Sections checked first. | Macro's that are inserted in a block by block basis to build a list of Sections that are dependent on another Section. By this we mean that 1 or more Sections must have 1 or more other Sections checked first. | ||
== Example == | == Example == | ||
This is a complete working example script which can be compiled | This is a complete working example script which can be compiled. | ||
<highlight-nsis> | This script defines Sec2 ("Section 2") as the component which must be selected to install the other two components Sec3 ("Section 3") and Sec4 ("Section 4"). | ||
Name SectionDependency | <highlight-nsis>Name SectionDependency | ||
OutFile SectionDependency.exe | OutFile SectionDependency.exe | ||
Var IndependentSectionState | |||
Page Components | Page Components | ||
!include Sections.nsh | |||
Section "Section 1" Sec1 | Section "Section 1" Sec1 | ||
Line 43: | Line 29: | ||
SectionEnd | SectionEnd | ||
Function . | Function .onInit | ||
# This is necessary otherwise Sec3 won't be selectable for the first time you click it. | |||
SectionGetFlags ${Sec2} $R0 | |||
IntOp $R0 $R0 & ${SF_SELECTED} | |||
StrCpy $IndependentSectionState $R0 | |||
FunctionEnd | FunctionEnd | ||
Function .onSelChange | |||
Push $R0 | |||
Push $R1 | |||
# Check if Sec2 was just selected then select Sec3 and Sec4. | |||
SectionGetFlags ${Sec2} $R0 | |||
IntOp $R0 $R0 & ${SF_SELECTED} | |||
StrCmp $R0 $IndependentSectionState +3 | |||
StrCpy $IndependentSectionState $R0 | |||
Goto UnselectDependentSections | |||
StrCpy $IndependentSectionState $R0 | |||
Goto CheckDependentSections | |||
# Select Sec2 if Sec3 or Sec4 was selected. | |||
SelectIndependentSection: | |||
SectionGetFlags ${Sec2} $R0 | |||
IntOp $R1 $R0 & ${SF_SELECTED} | |||
StrCmp $R1 ${SF_SELECTED} +3 | |||
IntOp $R0 $R0 | ${SF_SELECTED} | |||
SectionSetFlags ${Sec2} $R0 | |||
StrCpy $IndependentSectionState ${SF_SELECTED} | |||
Goto End | |||
# Were Sec3 or Sec4 just unselected? | |||
CheckDependentSections: | |||
SectionGetFlags ${ | SectionGetFlags ${Sec3} $R0 | ||
IntOp $ | IntOp $R0 $R0 & ${SF_SELECTED} | ||
StrCmp $ | StrCmp $R0 ${SF_SELECTED} SelectIndependentSection | ||
SectionGetFlags ${Sec4} $R0 | |||
IntOp $R0 $R0 & ${SF_SELECTED} | |||
StrCmp $R0 ${SF_SELECTED} SelectIndependentSection | |||
Goto End | Goto End | ||
# Unselect Sec3 and Sec4 if Sec2 was unselected. | |||
UnselectDependentSections: | |||
SectionGetFlags ${Sec3} $R0 | |||
IntOp $R1 $R0 & ${SF_SELECTED} | |||
StrCmp $R1 ${SF_SELECTED} 0 +3 | |||
IntOp $R0 $R0 ^ ${SF_SELECTED} | |||
SectionSetFlags ${Sec3} $R0 | |||
SectionGetFlags ${ | SectionGetFlags ${Sec4} $R0 | ||
IntOp $ | IntOp $R1 $R0 & ${SF_SELECTED} | ||
StrCmp $ | StrCmp $R1 ${SF_SELECTED} 0 +3 | ||
IntOp $ | IntOp $R0 $R0 ^ ${SF_SELECTED} | ||
SectionSetFlags ${ | SectionSetFlags ${Sec4} $R0 | ||
End: | End: | ||
Pop $R1 | |||
Pop $R0 | |||
FunctionEnd</highlight-nsis> | |||
</highlight-nsis> | |||
-Stu | -Stu | ||
[[Category:Section Management Functions]] | [[Category:Section Management Functions]] |
Latest revision as of 18:32, 10 January 2006
Author: Afrow UK (talk, contrib) |
Description
Macro's that are inserted in a block by block basis to build a list of Sections that are dependent on another Section. By this we mean that 1 or more Sections must have 1 or more other Sections checked first.
Example
This is a complete working example script which can be compiled. This script defines Sec2 ("Section 2") as the component which must be selected to install the other two components Sec3 ("Section 3") and Sec4 ("Section 4").
Name SectionDependency OutFile SectionDependency.exe Var IndependentSectionState Page Components !include Sections.nsh Section "Section 1" Sec1 SectionIn RO SectionEnd Section "Section 2" Sec2 SectionEnd Section /o "Section 3" Sec3 SectionEnd Section /o "Section 4" Sec4 SectionEnd Function .onInit # This is necessary otherwise Sec3 won't be selectable for the first time you click it. SectionGetFlags ${Sec2} $R0 IntOp $R0 $R0 & ${SF_SELECTED} StrCpy $IndependentSectionState $R0 FunctionEnd Function .onSelChange Push $R0 Push $R1 # Check if Sec2 was just selected then select Sec3 and Sec4. SectionGetFlags ${Sec2} $R0 IntOp $R0 $R0 & ${SF_SELECTED} StrCmp $R0 $IndependentSectionState +3 StrCpy $IndependentSectionState $R0 Goto UnselectDependentSections StrCpy $IndependentSectionState $R0 Goto CheckDependentSections # Select Sec2 if Sec3 or Sec4 was selected. SelectIndependentSection: SectionGetFlags ${Sec2} $R0 IntOp $R1 $R0 & ${SF_SELECTED} StrCmp $R1 ${SF_SELECTED} +3 IntOp $R0 $R0 | ${SF_SELECTED} SectionSetFlags ${Sec2} $R0 StrCpy $IndependentSectionState ${SF_SELECTED} Goto End # Were Sec3 or Sec4 just unselected? CheckDependentSections: SectionGetFlags ${Sec3} $R0 IntOp $R0 $R0 & ${SF_SELECTED} StrCmp $R0 ${SF_SELECTED} SelectIndependentSection SectionGetFlags ${Sec4} $R0 IntOp $R0 $R0 & ${SF_SELECTED} StrCmp $R0 ${SF_SELECTED} SelectIndependentSection Goto End # Unselect Sec3 and Sec4 if Sec2 was unselected. UnselectDependentSections: SectionGetFlags ${Sec3} $R0 IntOp $R1 $R0 & ${SF_SELECTED} StrCmp $R1 ${SF_SELECTED} 0 +3 IntOp $R0 $R0 ^ ${SF_SELECTED} SectionSetFlags ${Sec3} $R0 SectionGetFlags ${Sec4} $R0 IntOp $R1 $R0 & ${SF_SELECTED} StrCmp $R1 ${SF_SELECTED} 0 +3 IntOp $R0 $R0 ^ ${SF_SELECTED} SectionSetFlags ${Sec4} $R0 End: Pop $R1 Pop $R0 FunctionEnd
-Stu