Archive: Convert string to variable, is it possible?


Convert string to variable, is it possible?
I need to access hidden optional section to set it's flag to selected.
Since section is hidden it does not have name only variable.

Problem is I will know name of section only at runtime. I can generate string with name of this section variable, but how I can access it?

For example I have 2 hidden sections:

Section /o "" Pool_Conf1
SetOutPath $INSTDIR\Pool
File /r "${SOURCE}\Pool\*.*"
SectionEnd

Section /o "" Pool_Conf2
SetOutPath $INSTDIR\Pool
File /r "${SOURCE}\Pool\*.*"
SectionEnd

;I am trying to select it in function called after my custom page

Function func
StrCpy $R1 "Pool_Conf1"
;Next line obviously does not work,
;but can I convert string value Pool_Config1 to variable ${Pool_Config1}
SectionSetFlags ${R1} ${SF_SELECTED}
;I want it to be the same as:
SectionSetFlags ${Pool_Config1} ${SF_SELECTED}

FunctionEnd


Only solution I found to generate function with custom mapping string to variable:

Function GetConfSection
Pop $0
StrCpy $1 0
StrCmp $0 "Pool_Conf1" 0 +2
StrCpy $1 ${Pool_Conf1}
StrCmp $0 "Pool_Conf2" 0 +2
StrCpy $1 ${Pool_Conf2}
Push $1
FunctionEnd

A bit of pain to do, but it works.
If there is no easy way to map it with some NSIS function I think that will do for me.


What is ${R1} ?
You need SectionSetText if you want the section visible in components page.

See here, might help you,

http://forums.winamp.com/showthread....hreadid=292160


I don't want it to be visible on component page, but I want to select this section later on one of my custom page. In custom page I let user to select string and from that string I know name of variable that holds number of my hidden section. Problem was to access value in that variable by just having string name.

I did it by creating map function, when by comparing string I return section number and can set flag on it.


I don't want it to be visible on component page, but I want to select this section later on one of my custom page.
I think you can use the "SectionSetFlags" command for that ;)

Section test test_section_id
SectionEnd

Function .onInit
# set section 'test' as selected and read-only
IntOp $0 ${SF_SELECTED} | ${SF_RO}
SectionSetFlags ${test_section_id} $0
FunctionEnd


Using a section name that begins with a "-" will hide it on the components page...

I know all that, but it was not that simple.
If section has text name you can loop over all section and get section name, compare to your string and set flag. BUT, not for hidden section. Even if you set text name with "-", section become hidden and SectionGetText return empty string, like you did not put any name at all. So there is really no difference use empty string "" or "-something" for hidden section.


I think a section should be accessed by using it's ID, not by using it's caption. At the moment your string contains the caption of the section. Can't you store section's ID instead? Like this:

Section "" test_section_id
...
# Do some super secret things in this hidden section
...
SectionEnd

Function myFunction
StrCpy $1 ${test_section_id}
...
# Save section id stored in $1
...
FunctionEnd

Function myFunction2
...
# Load section id into $1 again
...
IntOp $0 ${SF_SELECTED} | ${SF_RO}
SectionSetFlags $1 $0
FunctionEnd