Archive: SectionGroup and StrCmp


SectionGroup and StrCmp
I'm working on an installer that will install different files depending on the OS the installer is running on. With the "Examples" section I'm having a hard time figuring out a way to work.

With the paired down script below I get the compiler error "StrCmp not valid outside section or function" which is understandable (I guess) but I'm not sure how to work around it.

If "Examples" is selected, running under NT/2000/XP/2003, contents of "C" and "VB" are installed, if running on 9x/ME only a text file is installed. I'm looking for a better way to get the behavior I want. ANy ideas?

My Sections/SectionGroups goes as follows:

- Device
|
- DLLs
|
- Drivers
|
- Examples
|
- C
|
- VB

-- script example --

SectionGroup /e "DEVICE"

SetOverwrite try

Section "Dlls"
SetOutPath "$INSTDIR\Device\Dlls"
File "..\Foo1.dll"
File "..\Foo2.dll"
File "..\Foo3.dll"
SectionEnd

Section "Drivers"
SetOutPath "$INSTDIR\Device\Drivers"
File "..\Foo1.sys"
File "..\Foo2.sys"
File "..\Foo1.vxd"
SectionEnd

SectionGroup "Examples"

; "strOS" is either "9X" or "NT", this is done in .ioInit
StrCmp $strOS "9X" 0 NT_EXAMPLES

SetOutPath "$INSTDIR\Device\Example"
File "..\9x.Examples.txt"
Goto EXAMPLES_END

NT_EXAMPLES:

Section "C"
; examples for NT/2000/XP
SetOutPath "$INSTDIR\Device\Example\C\Bus"
File "..\example.c"
File "..\Device.h"
File "..\Device.lib"
SectionEnd

Section "VB6"
; examples for NT/2000/XP
SetOutPath "$INSTDIR\Device\Example\VB\Bus"
File "..\Example.FRM"
File "..\Example.VBP"
File "..\Example.VBW"
File "..\Readme.txt"
File "..\Device.BAS"
SectionEnd

EXAMPLES_END:

SectionGroupEnd ; End of Examples group
SectionGroupEnd ; End of Device group


You can convert SectionGroup "Examples" into simple Section.

Section "Examples"

; "strOS" is either "9X" or "NT", this is done in .ioInit
StrCmp $strOS "9X" 0 NT_EXAMPLES

SetOutPath "$INSTDIR\Device\Example"
File "..\9x.Examples.txt"
Goto EXAMPLES_END

NT_EXAMPLES:

; examples for NT/2000/XP
SetOutPath "$INSTDIR\Device\Example\C\Bus"
File "..\example.c"
File "..\Device.h"
File "..\Device.lib"

SetOutPath "$INSTDIR\Device\Example\VB\Bus"
File "..\Example.FRM"
File "..\Example.VBP"
File "..\Example.VBW"
File "..\Readme.txt"
File "..\Device.BAS"

EXAMPLES_END:

SectionEnd ; End of Examples section

I hate it when the answer is in front of me. Thanks glory_man. I like the idea of making it a Section, I don't know why I was stuck at SectionGroup. For my application it's not going to kill the user if both C and VB examples are installed.