|
|
|
|
#1 |
|
Junior Member
Join Date: Oct 2004
Location: UK
Posts: 33
|
Get Current Section Index
In my program, an active 'currently-being-installed' section needs to know it's own section index number.
For example: Section "Component X" GetCurrentSectionIndex $R1 WriteINIStr "$INSTDIR\install.ini" CHOICES1 Component $R1 SectionEnd What would I use in place of "GetCurrentSectionIndex"? I know it doesn't change at runtime but when I have just under 900 sections that need this info, it would save me a lot of time if I didn't have to enter the number in the script manually. I've never been very sure about what is right. I'm not even sure that there is such a thing as right. Or wrong. Just places to stand. |
|
|
|
|
|
#2 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
|
Section "Component X" SEC_COMPONENTX
WriteINIStr "$INSTDIR\install.ini" CHOICES1 Component ${SEC_COMPONENTX} SectionEnd IntOp $PostCount $PostCount + 1 |
|
|
|
|
|
#3 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,343
|
You could join the section deceleration and the WriteINIStr in a macro so you wouldn't have to maintain both lines. But the easier solution is looping through all the sections and write a value if a section is enabled. Since the indexes start with 0 and end with the last section's index, it shouldn't be hard if you know what the last section is. If you don't, you can add a dummy section or wait for SectionGetFlags to raise the error flag. SectionGetFlags raises the error flag when the section index is out of range.
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Oct 2004
Location: UK
Posts: 33
|
Many thanks.
In the end I realised that only one section in the group will ever be checked. I know the start number and end number so I just looped through all the setions to find the one that was checked. I've never been very sure about what is right. I'm not even sure that there is such a thing as right. Or wrong. Just places to stand. |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|