Archive: Section Name Is A Variable


Section Name Is A Variable
Hi this is simple, I am trying to insert a certain section depending on a dynamic variable as following:

StrCmp ${$R2} "3" bla bla2

$R2 is a valid section name at this point, of this I am sure, but it seems I'm not allowed to use ${$R2} so can you please tell how this sould be put ?


Sorry what I posted above is wrong. I mean something like this:

SectionGetFlags ${$R0} $R1
StrCmp $R1 "3" etc...


will anyone help me out please ?


If $R0 contains your section index (zero based) then
SectionGetFlags $R0 $R1 is all you want.
Just checking if you're aware that $R1 will be the section flags, so if for example you want to check if it is selected, you should do:

!include Sections.nsh
...
SectionGetFlags $R0 $R1
IntOp $R0 $R0 & ${SF_SELECTED}
StrCmp $R0 ${SF_SELECTED} ...

Or even easier, use the SectionFlagIsSet macro in Sections.nsh.

-Stu


hmm I've tried that and it still won't work for me... to explain a bit more to you, I'm trying to save components to registry. My sections' indexes are numeric and as following:

SectionGroup "name" 1
-- Section "name" 1-1
-- Section "name" 1-2
SectionGroupEnd
SectionGroup "name" 2
... and so on. The function I wrote is the following:

Function RememberComponents
Push $R0
Push $R1
Push $R2
Push $R3
StrCpy $R2 "1"
StrCpy $R3 "0"
LoopStart:
ClearErrors
IntOp $R3 $R3 + 1
StrCpy $R4 $R2-$R3
SectionGetFlags $R4 $R0
IfErrors NextGroup
WriteRegStr HKCU "Software\blah\${VER}" "$R2-$R3" "$R0"
Goto LoopStart

NextGroup:
IntOp $R2 $R2 + 1
StrCmp $R2 "3" FinishAll
StrCpy $R3 "0"
Goto LoopStart

FinishAll:
FunctionEnd


The result is not very pleasant actually... I'm getting all flags as "0" and the loop keeps going for 1-999999 and causes the installer to crash. So can you please help me with that bit.

by 1-999999 above I mean it keeps going till infinity


The first parameter of SectionGetFlags must be an integer value; the index of the section that you want to get the flags of starting from 0 (0 is the first Section/SectionGroup, 1 is the next and so on).
"$R2-$R3" is of course not an integer value.

See this page: http://nsis.sourceforge.net/wiki/Two..._one_installer
There's code on there that loops through some Sections and saves the Section flags to an INI file - similar to what you want to do.

-Stu


finally! that's all I needed to know... it works now.


thank you