Archive: Problem with sections group hierarchy


Problem with sections group hierarchy
Hello to all,
I actually develop a Installer with NSIS and have a problem.... see subject.

Sample Code:
SectionGroup 'GRP_1' GRP_1
Section 'SEC_1_1' SEC_1_1
SectionEnd
SectionGroupEnd

SectionGroup 'GRP_2' GRP_2
Section 'SEC_2_1' SEC_2_1
SectionEnd
SectionGroupEnd

When the Installer starts it looks OK in this form:
[ ] GRP_1
....[ ] SEC_1_1
[ ] GRP_2
....[ ] SEC_2_1

When I read the sections text from a INI-File in .onInit and use the function SectionSetText, then the hierachy is not OK, it looks like:
[ ] GRP_1
....[ ] SEC_1_1
....[ ] GRP_2
........[ ] SEC_2_1

The grouping of the checkboxes is OK what means if I click on GRP_1 only SEC_1_1 is changed. With GRP_2 the same, SEC_2_1 is changed.

The INI-File content:
; section titles
[setup]
GRP_1=Group1
SEC_1_1=Sec_1_1
GRP_2=Group2
SEC_2_1=Sec_2_1

Can someone please give me a hint what I made wrong?
Thanks in advance
Joachim


can't think of anything... can you post a more complete example?

This is mine.. which works;


!include 'MUI.nsh'
!include 'LogicLib.nsh'
!include 'nsDialogs.nsh'

outfile 'customtest.exe'

Page Components

SectionGroup 'GRP_1' GRP_1
Section 'SEC_1_1' SEC_1_1
SectionEnd
SectionGroupEnd

SectionGroup 'GRP_2' GRP_2
Section 'SEC_2_1' SEC_2_1
SectionEnd
SectionGroupEnd

Function .onInit
ReadiniStr $0 "c:\temp\sectiontest.ini" "setup" "GRP_1"
SectionSetText ${GRP_1} "$0"
ReadiniStr $0 "c:\temp\sectiontest.ini" "setup" "SEC_1_1"
SectionSetText ${SEC_1_1} "$0"
ReadiniStr $0 "c:\temp\sectiontest.ini" "setup" "GRP_2"
SectionSetText ${GRP_2} "$0"
ReadiniStr $0 "c:\temp\sectiontest.ini" "setup" "SEC_2_1"
SectionSetText ${SEC_2_1} "$0"
FunctionEnd

Thank you for investigating. Yes, your examle is working.
I check more on my scipt and found a workaround but the error is not clear to me. I use a loop to iterate over all sections with the section index number. And the section 3 SectionGetText found '-'. But why? I insert the "IfErrors" instruction (see code) and now it works. But it is not clear to me why the section 3 has text like '-'.
Below the sections (with a lot of code for tests). I'm too new to NSIS ;-)

Thank you very much for your help
Joachim

My sections:


InstType "Default"
InstType "Default1"

!define SECTIONCOUNT 7 ; total - 1

Section ""
StrCpy $R0 "Hallo"
DetailPrint "--- $R0 Install Logfile ---"
Call GetWindowsVersion
Pop $R0
StrCpy $0 "Windows Version found: $R0"
DetailPrint $0
; DetailPrint $PLUGINSDIR
SectionEnd


#--- Group "default" installation
SectionGroup 'GRP_1' GRP_1
Section 'SEC_1_1' SEC_1_1
SectionIn 1
;File /r D:\_a\*.*
StrCpy $0 "putty.exe"
inetc::get /BANNER "Download in progress... ('$0')" \
"ftp://blabla@ftp.bla.net/$0" "$INSTDIR\$0"
Pop $0
DetailPrint $0
strCmp $0 "OK" dlok
MessageBox MB_OK|MB_ICONEXCLAMATION "ftp download Error, click OK to abort installation" /SD IDOK
Abort
dlok:
Call ReadComponentsText
DetailPrint "Sectionindex of ${GRP_1}"
DetailPrint "Sectionindex of ${SEC_1_1}"
SectionEnd
SectionGroupEnd

#--- Group custom installation
SectionGroup 'GRP_2' GRP_2
Section 'SEC_2_1' SEC_2_1
SectionIn 2
SectionGetText SEC_2_1 $R0
DetailPrint $R0
DetailPrint "Sectionindex of ${GRP_2}"
DetailPrint "Sectionindex of ${SEC_2_1}"
;;;;;;;;;;;;;;
SectionEnd

Section 'SEC_2_2' SEC_2_2
SectionIn 2
SectionGetText SEC_2_2 $R0
DetailPrint $R0
;;;;;;;;;;;;;;
SectionEnd

Section 'SEC_2_3' SEC_2_3
SectionIn 2
SectionGetText SEC_2_3 $R0
DetailPrint $R0
;ExecShell "open" "http://nsis.sf.net/"
SectionEnd
SectionGroupEnd

Section ""
;Create a Logfile from the installation
StrCpy $0 $INSTDIR\install.log
Push $0
Call DumpLog
SectionEnd

; FOLLOWING FUNCTION I CALLED IN .oninit
; It works only with the IfErrors instruction

Function ReadComponentsText
; start with section 1 as the section 0 is a "startup section" and is not visible
${For} $R1 1 ${SECTIONCOUNT}
SectionGetText $R1 $R2
DetailPrint "$R1, $R2"
ReadINIStr $R0 "$PLUGINSDIR\sections.ini" "setup" "$R2"
IfErrors xNext
DetailPrint "$R1, $R0"
SectionSetText $R1 $R0
xNext:
${Next}
FunctionEnd



A section with an empty string "" is treated as "-" by NSIS internally

If section_name is empty, omitted, or begins with a -, then it is a hidden section and the user will not have the option of disabling it.
Even if it returned an empty string as the text, you'd still get an error because you can't read an empty set from an INI file; so the IfErrors is proper to have there either way :)

Yes, that I know. But if you take a look to the sequence of the sections then you see, there is only a empty section at the beginning and one at the end.
That is the reason why the function to fill the section names starts with 1 and not with 0. OK one bug is there, the loop runs until the last empty section but it is not section 3.

Why he found such section with index 3? This is, what confuse me.

Joachim


ahhh okay...

That.. I do not know :) Seems to be one at the end of each sectiongroup, actually.


Hmmm.... may be. As I'm curious about that, I will investigate in the next time. Even I found alredy a solution....

Joachim