Archive: Is it unloading the files or what?


Is it unloading the files or what?
I found this code on the internet and have been trying to get it to work:

## Sections Group 1
SectionGroup /e "Program #1" PROG1
Section "Main" SEC1
##All the files in Group 1 will be installed to the same location, $INSTDIR
SetOutPath "$INSTDIR"
## Main files to install here

messagebox mb_ok sec1

SectionEnd

Section "Other" SEC2
## Other files to install here

messagebox mb_ok sec2

SectionEnd

SectionGroupEnd

## Sections Group 2
SectionGroup /e "Program #2" PROG2

Section "Main" SEC3
##All the files in Group 2 will be installed to the same location, $INSTDIR
SetOutPath "$INSTDIR"
## Main files to install here

messagebox mb_ok sec3

SectionEnd

Section "Other" SEC4
## Other files to install here

messagebox mb_ok sec4

SectionEnd

SectionGroupEnd

##===========================================================================
## Settings
##===========================================================================

!define PROG1_InstDir "C:\PROG1"
!define PROG1_StartIndex ${PROG1}
!define PROG1_EndIndex ${SEC2}

!define PROG2_InstDir "C:\PROG2"
!define PROG2_StartIndex ${PROG2}
!define PROG2_EndIndex ${SEC4}

##===========================================================================
## Please don't modify below here unless you're a NSIS 'wiz-kid'
##===========================================================================

## Create $PLUGINSDIR
Function .onInit
InitPluginsDir
FunctionEnd

## If user goes back to this page from 1st Directory page
## we need to put the sections back to how they were before
Var IfBack
Function SelectFilesCheck
StrCmp $IfBack 1 0 NoCheck
Call ResetFiles
NoCheck:
FunctionEnd

## Also if no sections are selected, warn the user!
Function ComponentsLeave
Push $R0
Push $R1

Call IsPROG1Selected
Pop $R0
Call IsPROG2Selected
Pop $R1
StrCmp $R0 1 End
StrCmp $R1 1 End
Pop $R1
Pop $R0
MessageBox MB_OK|MB_ICONEXCLAMATION "$(NoSectionsSelected)"
Abort

End:
Pop $R1
Pop $R0
FunctionEnd

Function IsPROG1Selected
Push $R0
Push $R1

StrCpy $R0 ${PROG1_StartIndex} # Group 1 start

Loop:
IntOp $R0 $R0 + 1
SectionGetFlags $R0 $R1 # Get section flags
IntOp $R1 $R1 & ${SF_SELECTED}
StrCmp $R1 ${SF_SELECTED} 0 +3 # If section is selected, done
StrCpy $R0 1
Goto Done
StrCmp $R0 ${PROG1_EndIndex} 0 Loop

Done:
Pop $R1
Exch $R0
FunctionEnd

Function IsPROG2Selected
Push $R0
Push $R1

StrCpy $R0 ${PROG2_StartIndex} # Group 2 start

Loop:
IntOp $R0 $R0 + 1
SectionGetFlags $R0 $R1 # Get section flags
IntOp $R1 $R1 & ${SF_SELECTED}
StrCmp $R1 ${SF_SELECTED} 0 +3 # If section is selected, done
StrCpy $R0 1
Goto Done
StrCmp $R0 ${PROG2_EndIndex} 0 Loop

Done:
Pop $R1
Exch $R0
FunctionEnd

## Here we are selecting first sections to install
## by unselecting all the others!
Function SelectFilesA

# If user clicks Back now, we will know to reselect Group 2's sections for
# Components page
StrCpy $IfBack 1

# We need to save the state of the Group 2 Sections
# for the next InstFiles page
Push $R0
Push $R1

StrCpy $R0 ${PROG2_StartIndex} # Group 2 start

Loop:
IntOp $R0 $R0 + 1
SectionGetFlags $R0 $R1 # Get section flags
WriteINIStr "$PLUGINSDIR\sections.ini" Sections $R0 $R1 # Save state
!insertmacro UnselectSection $R0 # Then unselect it
StrCmp $R0 ${PROG2_EndIndex} 0 Loop

# Don't install prog 1?
Call IsPROG1Selected
Pop $R0
StrCmp $R0 1 +4
Pop $R1
Pop $R0
Abort

# Set current $INSTDIR to PROG1_InstDir define
StrCpy $INSTDIR "${PROG1_InstDir}"

Pop $R1
Pop $R0
FunctionEnd

## Here we need to unselect all Group 1 sections
## and then re-select those in Group 2 (that the user had selected on
## Components page)
Function SelectFilesB
Push $R0
Push $R1

StrCpy $R0 ${PROG1_StartIndex} # Group 1 start

Loop:
IntOp $R0 $R0 + 1
!insertmacro UnselectSection $R0 # Unselect it
StrCmp $R0 ${PROG1_EndIndex} 0 Loop

Call ResetFiles

# Don't install prog 2?
Call IsPROG2Selected
Pop $R0
StrCmp $R0 1 +4
Pop $R1
Pop $R0
Abort

# Set current $INSTDIR to PROG2_InstDir define
StrCpy $INSTDIR "${PROG2_InstDir}"

Pop $R1
Pop $R0
FunctionEnd

## This will set all sections to how they were on the components page
## originally
Function ResetFiles
Push $R0
Push $R1

StrCpy $R0 ${PROG2_StartIndex} # Group 2 start

Loop:
IntOp $R0 $R0 + 1
ReadINIStr "$R1" "$PLUGINSDIR\sections.ini" Sections $R0 # Get sec flags
SectionSetFlags $R0 $R1 # Re-set flags for this sec
StrCmp $R0 ${PROG2_EndIndex} 0 Loop

Pop $R1
Pop $R0
FunctionEnd

## Here we are deleting the temp INI file at the end of installation
Function DeleteSectionsINI
Delete "$PLUGINSDIR\Sections.ini"
FlushINI "$PLUGINSDIR\Sections.ini"
FunctionEnd

Whenever I add more than two sections to sectiongroup 2 and don't select group 1 in the setup itself, it does not jump to sectiongroup 2 without displaying some sort of status bar. It looks like it's installing the components of sectiongroup 1. How do I get rid of this step?

Cheers

Rich


How do we get rid of reading such a huge posts?


Anything smart to say or just moaning?

Originally posted by pospec
How do we get rid of reading such a huge posts?