Archive: Detect selected options and build list?


Detect selected options and build list?
I'm trying to show the user what paths things will be installed in, before the actual installation takes place

1) Is there currently already a way to do this? If not,
2) How do I detect what options are selected? I can't read the components section out of the registry, since they haven't been written yet. Currently, I've got a custom page set up, and use the MUI_INSTALLOPTIONS_WRITE macro to modify a label field. But then I realized the list of paths/items needs to be dynamic, so the static list I set up wouldn't work.

How do I detect what the user (left) selected and then build the list? This is what I did (which is not valid) before I realized it needs to be dynamic:


!insertmacro MUI_INSTALLOPTIONS_WRITE "reviewdirs.ini" "Field 1" "State" "$INSTDIR\Cactid\r\n\
$INSTDIR\Cygwin\r\n\
$INSTDIR\MySQL\r\n\
$INSTDIR\Net-SNMP\r\n\
$INSTDIR\PHP\r\n\
$INSTDIR\RRDTool\r\n\
$INSTDIR\USR\r\n\
$IISDIR\Cacti"

I suppose you want to detect the selected components, right ?

There is a useful macro you can use. Have a look at the end of sections.nsh in $NSISDIR\include\. In the examples directory you will find one-section.nsi that show general usage.

Use this and append your paths to that string you will write into your INI file. For better understanding see this example from NSIS-Wiki:
http://nsis.sourceforge.net/Subsecti...ially_selected

For your future use of conditional logic (If, else, while, case) I would really recommend the usage of LogicLib.nsh. See Include-Dir as well. Good luck.

excerpt from file sections.nsh:
; Check if one or more bits in section's flags are set
; If they are, jump to JUMPIFSET
; If not, jump to JUMPIFNOTSET

!macro SectionFlagIsSet SECTION BITS JUMPIFSET JUMPIFNOTSET
Push $R0
SectionGetFlags "${SECTION}" $R0
IntOp $R0 $R0 & "${BITS}"
IntCmp $R0 "${BITS}" +3
Pop $R0
StrCmp "" "${JUMPIFNOTSET}" +3 "${JUMPIFNOTSET}"
Pop $R0
Goto "${JUMPIFSET}"
!macroend


Well I've got something set up, which properly displays what I want -- only if all sections are selected. If I de-select a section, either reveiewdirs.ini displays blank text or it displays all the options, which is not correct.

What am I doing wrong?


Function ReviewDirs
!insertmacro MUI_HEADER_TEXT "Review Installation Locations" "Review the folders in which to install Cacti"

StrCpy $R5 ""
!insertmacro SectionFlagIsSet Cacti ${SF_SELECTED} set1 nset1
set1: StrCpy $R5 "$IISDIR\Cacti\r\n"
nset1: !insertmacro SectionFlagIsSet Cactid ${SF_SELECTED} set2 nset2
set2: StrCpy $R5 "$R5$INSTDIR\Cactid\r\n"
nset2: !insertmacro SectionFlagIsSet Cygwin ${SF_SELECTED} set3 nset3
set3: StrCpy $R5 "$R5$INSTDIR\Cygwin\r\n"
nset3: !insertmacro SectionFlagIsSet MySQL ${SF_SELECTED} set4 nset4
set4: StrCpy $R5 "$R5$INSTDIR\MySQL\r\n"
nset4: !insertmacro SectionFlagIsSet Net-SNMP ${SF_SELECTED} set5 nset5
set5: StrCpy $R5 "$R5$INSTDIR\Net-SNMP\r\n"
nset5: !insertmacro SectionFlagIsSet PHP ${SF_SELECTED} set6 nset6
set6: StrCpy $R5 "$R5$INSTDIR\PHP\r\n"
nset6: !insertmacro SectionFlagIsSet RRDTool ${SF_SELECTED} set7 nset7
set7: StrCpy $R5 "$R5$INSTDIR\RRDTool\r\n"
nset7: !insertmacro SectionFlagIsSet USR ${SF_SELECTED} set8 nset8
set8: StrCpy $R5 "$R5$INSTDIR\USR\r\n"
nset8: !insertmacro SectionFlagIsSet GetIF ${SF_SELECTED} set9 nset9
set9: StrCpy $R5 "$R5$PROGRAMFILES\GetIF\r\n"
nset9: !insertmacro SectionFlagIsSet "MySQL Administrator" ${SF_SELECTED} set10 nset10
set10: StrCpy $R5 "$R5$PROGRAMFILES\MySQL\MySQL Administrator 1.1\r\n"
nset10:

!insertmacro MUI_INSTALLOPTIONS_WRITE "reviewdirs.ini" "Field 1" "State" "$R5"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "reviewdirs.ini"
FunctionEnd

Figured it out.. I wasn't using the actual section_index_output name. Instead I was using the section name.

The description and/or example for SectionFlagIsSet really should be more specific on what field it needs.