Name test
OutFile test.exe

ComponentText "please choose components"

!define SF_SELECTED   1
!define SF_SUBSEC     2
!define SF_SUBSECEND  4
!define SF_BOLD       8
!define SF_RO         16
!define SF_EXPAND     32

!define SECTION_OFF   0xFFFFFFFE

Section !Required
	SectionIn RO
SectionEnd

Section "section0" s0
SectionEnd

Section "section1" s1
SectionEnd

Section "test" test
SectionEnd


Function .onSelChange

   push $5
   push $6

   statusS0: 
      SectionGetFlags ${s0} $0
      IntOp $0 $0 & ${SF_SELECTED}
	   IntCmp $0 ${SF_SELECTED} compareS0sel compareS0unsel compareS0unsel
         
         compareS0sel:
            StrCpy $5 "1"
            StrCmp $5 $R0 statusS1 chgR0
            
         compareS0unsel:
            StrCpy $5 "0"
            StrCmp $5 $R0 statusS1 chgS1

         chgS1:
            SectionGetFlags ${s1} $6
            IntOp $6 $6 & ${SECTION_OFF}
            SectionSetFlags ${s1} $6
            StrCpy $R1 "0"
            goto chgR0
            

         chgR0:
            StrCpy $R0 $5
            goto end
         


   statusS1:
      SectionGetFlags ${s1} $1
      IntOp $1 $1 & ${SF_SELECTED}
	   IntCmp $1 ${SF_SELECTED} compareS1sel compareS1unsel compareS1unsel

         compareS1sel:
            StrCpy $5 "1"
            StrCmp $5 $R1 end chgS0
            
         compareS1unsel:
            StrCpy $5 "0"
            StrCmp $5 $R1 end chgR1

         chgS0:
            SectionGetFlags ${s0} $6
            IntOp $6 $6 | ${SF_SELECTED}
            SectionSetFlags ${s0} $6
            StrCpy $R0 "1"
            goto chgR1
   
         chgR1:
            StrCpy $R1 $5
            goto end

   end:

   pop $5
   pop $6

FunctionEnd
