Archive: How do you Enumerate Sections in a subsection???


How do you Enumerate Sections in a subsection???
This portion of code works

SubSection /E "Supporting Files" SPF
Section "Internet Explorer 6.0 With SP1" IE6
...
SectionEnd
Section "Microsoft .Net Framework" DOTNET
...
SectionEnd
SubSectionEnd

if not ie6 then
SectionSetText ${ie6} ""
endif
if not DotNet then
SectionSetText ${DOTNET} ""
endif

This is what I would like to achieve

if ${SPF}.Count = 0 then
SectionSetText ${SPF} ""
endif

Any suggestions would be appreciated
:)


StrCmp ${SPF} 0 If0 NotIf0
If0:
...
NotIf0:
...

-Stu


Tried it and thought it work at first, but other code changed that.

Sorry but it does not work I f ahve tried the following variations

StrCmp ${SPF} 0 Disable CheckComplete
Disable:
SectionSetText ${SPF} ""
Goto CheckComplete
CheckComplete:

StrCmp ${SPF} "0" Disable CheckComplete
Disable:
SectionSetText ${SPF} ""
Goto CheckComplete
CheckComplete:

IntCmp ${SPF} 0 Disable CheckComplete
Disable:
SectionSetText ${SPF} ""
Goto CheckComplete
CheckComplete:


;)


My most humble apologies.

There was code that was executing that intefered and caused the
routine not to be called.

:hang:

This product Rocks


I agree with you very much!

Check this out:
http://dynamic.gamespy.com/~dday/ib3...t=ST;f=2;t=983

Check the source too ;)

-Stu


Are you sure that code works? It seemed that you wanted to tell how many sections that are in the subsection "Supporting Files" are selected. Your code checks if the id number of the subsection is zero or not.

To check if a section is selected or not you should use this code:

!include Sections.nsh

SectionGetFlags ${sectionid} $0
IntOp $0 $0 & ${SF_SELECTED}
StrCmp $0 ${SF_SELECTED} selected not_selected

If you wish to enumerate use something like this:

StrCpy $0 ${SPF}
StrCpy $3 0
loop:
IntOp $0 $0 + 1
SectionGetFlags $1 $0
IntOp $2 $1 & ${SF_SUBSECEND}
StrCmp $2 ${SF_SUBSECEND} done
IntOp $2 $1 & ${SF_SELECTED}
StrCmp $2 ${SF_SELECTED} loop
IntOp $3 $3 + 1
Goto loop
done:
DetailPrint '$3 sections selected under "Supporting Files"'


StrCmp ${SPF} 0 Disable CheckComplete

does work for the implementation that I wanted.
The prolem was when there was no sub items defined I still had the parent tree node. So if there where no child nodes I did not want to display the parent node.

The code that you have supplied will go into my code library as I will be needing it in the near future.

Thanks.


Do you mind explaining a little more please? ${SPF} is a constant number that holds the id of the subsection "Supporting Files". Why do you compare it with 0?


The problem is as follows :

SubSection /E "Supporting Files" SPF
Section "ABC" ABC
EndSection

Section "DEF" DEF
EndSection

Section "GHI" GHI
EndSection
EndSubSection

Later on in the script we get the following

SectionSetText ${ABC} ""
SectionSetText ${DEF} ""
SectionSetText ${GHI} ""

But now we have "Supporting Files" and no sub nodes.
The idea is if ${SPF} = 0 nodes then
SectionSetText ${SPF} = ""
so that it does not display "Supporting files" as an option, but if
there is one or
more subsections then I want to display "Supporting files".

this "StrCmp ${SPF} 0 Disable CheckComplete" appears to change if
the ${SPF} has nodes defined beneath it.

In Short it seems to work.


But SPF is just a constant which contains the id of the subsection which is its serial id. If it is the first [sub]section created it will be numbered 0, second - 1, etc. Your comparison is meaningless. SPF will only be 0 if it's the first section created, not if there are nodes beneath it and will never change on runtime.


I have tried your code, but the code runs into a continuous loop and I cannot seem to figure out why.


Isn't it way easier to create something like this:

If Not IE6 And Not DOTNET Then
SectionSetText ${SPF} ""
EndIf


That is what I ultimately would like to do but the Subsections are my variables. Does NSIS support If ... Endif. Have not come across it in my documentation.


Yep, it does support conditional operations. In NSIS code it would be something like:

;$R0 = "1" if IE is installed
;$R1 = "1" if DOTNET is installed

StrCmp $R0 "1" done
StrCmp $R1 "1" done

SectionSetText ${SPF} ""

done:


This one has been tested and should work:

StrCpy $0 ${SPF}
StrCpy $3 0
loop:
IntOp $0 $0 + 1
SectionGetFlags $0 $1
IfErrors done
IntOp $2 $1 & ${SF_SUBSECEND}
StrCmp $2 ${SF_SUBSECEND} done
IntOp $2 $1 & ${SF_SELECTED}
StrCmp $2 ${SF_SELECTED} 0 loop
IntOp $3 $3 + 1
Goto loop
done:
DetailPrint '$3 sections selected under "Supporting Files"'