Archive: Using a variable with SelectSection?


Using a variable with SelectSection?
Is something like this possible:

Pop $R0 ; $R0 = asdf
!insertmacro SelectSection ${$R0} ; Selects section labeled asdf

I suppose the real question is, does the SelectSection macro require its argument at compile-time or run-time?

Thanks,
- DF


That will not work. ${asdf} is a compile time constant (!define asdf 0). Instead, set $R0 to the section index (the first section is 0):

!insertmacro SelectSection $R0

Stu


Thanks for info Afrow.

Unfortunately, this is going to get messy then. I was hoping it would work that way since I am using the SelectSection for a one-section type that is under a SectionGroup. I am populating $R0 from the command line arguments.

I guess the best that I can do is this:


StrCpy $1 ${drivernone}
Call GetParameters ;Get CLI arguments
Pop $R0 ; $R0 = Model from WMI
StrCmp $R0 "[model1]" 0 +2
!insertmacro SelectSection ${[model1]}
StrCmp $R0 "[model2]" 0 +2
!insertmacro SelectSection ${[model2]}
ect.

:(

I really cant make the section labels numeric unless I want to cross reference from the model in WMI to the respective section index.

- DF

Watch out for relative jumps over a macro. Macros often, and in this case, definitely, may be multiple lines of code, and a relative jump will not skip over the entire macro.

StrCmp $R0 "[model1]" 0 +2
!insertmacro SelectSection ${[model1]}

Good catch there demiller. I know that would have messed me up...