Archive: SectionGetText with loop "for"


SectionGetText with loop "for"
Hi everybody,

I have a problem with the function SectionGetText and use in a for loop:

Here is a quick excerpt from my code:

I have several of the type section:


Sectiongroup "One"
Section "aaa" SEC01
....
SectionEnd

Section "bbb" SEC03
....
SectionEnd

Section "xxx" SEC02
....
SectionEnd
SectionGroupEnd

Section "ccc" SEC03
....
SectionEnd

Function .onInit
...

SectionGetText ${SEC01} $1; Retrieve the name of the section and stores it in $ 1
IfFileExists "C:\$1" 0 +2
!insertmacro UnselectSection ${SEC01}

SectionGetText ${SEC02} $1 ; Retrieve the name of the section and stores it in $ 1
IfFileExists "C:\$1" 0 +2
!insertmacro UnselectSection ${SEC02}
...
FunctionEnd


I wish to change the last part of the code in Function .onInit by this :


${For} $R1 1 4
StrCpy $0 "SEC0$R1" ; Create the ref section in variable $0 example SEC01 For $R1=1
SectionGetText $0 $1 ; Stores the name of the section in $1
IfFileExists "C:\$1" 0 +3
!insertmacro UnselectSection $0

${Next}


The problem is that : SectionGetText $0 $1 always returns the same name.
against $0 change corectly.


Note : the sections are not arranged in chronological order and some have no reference.
I just want to access of the section identified by "SEC01"


I thank in advance those who will help me to solve a problem.

First off, you can't use relative jumps over macros ("IfFileExists "C:\$1" 0 +3" because the macro could change, use ${If} ${Exists} ... )

Now to the actual code...

Section ID's are actually just numbers starting at 0, so all you really need is a for loop that starts at ${SEC01} (${SEC01} would be 0 in this case) and ends at whatever section you want to end at, ${SEC03} in this case


Thanks Anders,

I have modified my code by :


..
${For} $0 ${SEC01} ${SEC08}
SectionGetText $0 $1
IfFileExists "${VAR_TESTJTAG}\$1.ini" section_installed section_non_installed
section_non_installed:
goto next
section_installed:
!insertmacro UnselectSection $0
next:
${Next}


and now is ok.

Just two small question : for example :


${For} $0 1 20
...
IfErrors Fin
...
${Next}
Fin :


Thanks again for your help.