Archive: Problem to have two directories in one installer ?


Problem to have two directories in one installer ?
Hi,

I'm trying to have in my installer two directories; one for my application and another for my data base.
I have already posted but nobody answered me.
I have read in the archive this : http://nsis.sourceforge.net/archive/...php?pageid=553

That is not exactly what i want and i have adapted it:

Here is my code that you can test; for the instructions in the sections, i just display messages:

#begin of my code
!include "Sections.nsh"

Name Test
OutFile test.exe

Page components

Var ECITIZ_DIR
PageEx directory
DirText "Ceci installera l'Application"
DirVar $ECITIZ_DIR
PageCallbacks DirectoryAppliPre "" ""
PageExEnd

Var POSTGRES_DIR
PageEx directory
DirText "Ceci installera la Base de Données PostgreSQL \ dans le dossier suivant; pour l'installer dans un autre \ dossier,cliquez parcourir et choisissez un autre dossier. \ Cliquez suivant pour continuer." "Installation de \
la Base de Données PostgreSQL"
DirVar $POSTGRES_DIR
PageCallbacks DirectoryBDPre "" ""
PageExEnd

Page instfiles

!macro SiCocheAlorsVaA TMPVAR SECTION GOTO
SectionGetFlags ${SECTION} ${TMPVAR}
IntOp ${TMPVAR} ${TMPVAR} & ${SF_SELECTED}
IntCmp ${TMPVAR} 1 ${GOTO} +1
!macroend

Function DirectoryAppliPre
Push $1
StrCpy $ECITIZ_DIR "c:\ecitiz"
!insertmacro SiCocheAlorsVaA $1 eCitiz afficherPageAppli
!insertmacro SiCocheAlorsVaA $1 examples afficherPageAppli
Pop $1
Abort

afficherPageAppli:

FunctionEnd

Function DirectoryBDPre
Push $1
StrCpy $ECITIZ_DIR "c:\postgres"
!insertmacro SiCocheAlorsVaA $1 bdd afficherPageDB

Abort

afficherPageDB:
Pop $1
FunctionEnd

SubSection "e-Citiz"
;sous-section d'installation du studio
Section "!e-Citiz Studio" eCitiz
SetOutPath $INSTDIR
MessageBox MB_OK "eCitiz"
SectionEnd

;Sous-section d'installation du bouquet
Section /o "!Exemples de Téléprocédures" examples
SetOutPath $INSTDIR
MessageBox MB_OK "examples"
SectionEnd

Section "!Raccourcis" short
MessageBox MB_OK "short"
SectionEnd

SubSectionEnd


SubSection "Base de données"
# Sous-section d'installation de posgreSQL
Section "!PostgreSQL" bdd
MessageBox MB_OK "bdd"
SectionEnd
SubSectionEnd

SubSection "Adobe Acrobat Reader"
# Sous-section d'installation de Acrobat Reader
Section /o "!Adobe Acrobat Reader" adobe
MessageBox MB_OK "adobe"
SectionEnd
SubSectionEnd

#end of my code

a°)What i would like do:
1°)if and only if i select sections with index "eCitiz" or "examples", it displays the page to select the directory for the Application; in all other cases it must not display this page to select the directory for my Application.
2°)if and only if i select sections with index "bdd", it displays the page to select the directory for my Data Base; in all other cases it must not display this page to select the directory for my Data Base.

b°)How it works now :
1°)if i select sections with index "eCitiz" or "examples",and i clik to next it start executing instructions in sections "eCitiz" or "examples", without displaying the page to select the directory for the Application.
2°)if i select sections with index "bdd",and i clik to next it start executing instructions in sections "bdd" , without displaying the page to select the directory for the Data Base.

3°)if i select the three sections with index "eCitiz", "examples",and "short",and i clik to next it displays first the page to select the directory for the Application, and after the page to select the directory for the Data Base even if i don't select the section "bdd"

4°)if i select the four sections with index "eCitiz", "examples","short",and "bdd",and i clik to next it displays first the page to select the directory for the Application, and after the page to select the directory for the Data Base ;before executing instructions in the sections (here all is rigth).

I think it is about the two functions "DirectoryAppliPre" and "DirectoryDBPre" or the macro "SiCocheAlorsVaA" ?
Is there a bug in NSIS ?
All seem to be logic in my code !!!
Can somebody tell me what is wrong ?

Thanks to have a look to my question !!


Sould be:
!insertmacro SiCocheAlorsVaA $1 ${eCitiz} afficherPageAppli
!insertmacro SiCocheAlorsVaA $1 ${examples} afficherPageAppli

Currently you're passing "eCitiz" and "examples" as two strings of characters when you want to be passing the values of the defines.

Edit: And you really shouldn't post numerous topics for the same problem. It makes the moderators unhappy.

-Stu


Or, you could just use ${${SECTION}} inside your macro.

-Stu


Originally posted by Afrow UK
Or, you could just use ${${SECTION}} inside your macro.

-Stu
Yes, use ${${SECTION}}.
Remove DirectoryAppliPre, DirectoryBDPre functions after sections declaration.
Instead
StrCpy $ECITIZ_DIR "c:\postgres"
in DirectoryBDPre function use
StrCpy $POSTGRES_DIR "c:\postgres"
.
And I think in sections use SetOutPath $POSTGRES_DIR or SetOutPath $ECITIZ_DIR.

Thanks you very very much for your answers.
All is working right now !