Old 16th February 2005, 00:02   #1
Marshall7a
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.
Marshall7a is offline   Reply With Quote
Old 16th February 2005, 03:20   #2
Anders
Moderator
 
Anders's Avatar
 
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
Anders is offline   Reply With Quote
Old 16th February 2005, 06:12   #3
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
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
kichik is offline   Reply With Quote
Old 16th February 2005, 09:11   #4
Marshall7a
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.
Marshall7a is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump