- NSIS Discussion
- Dependency components , directory?
Archive: Dependency components , directory?
hawkmaster
23rd April 2010 13:51 UTC
Dependency components , directory?
Hello,
I have two Page Directories. One path is for program files and the second is for data files.
In the moment the second directory choose dialog is shown always.
But I want to show it only if in components dialog the checkbox "Data" is selected.
How can you do this dependency?
!insertmacro MUI_PAGE_COMPONENTS
# First directory page for program files.
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
#!insertmacro MUI_PAGE_INSTFILES
##########################################################
# Second directory page for data files.
var INSTDIR2
!define MUI_DIRECTORYPAGE_TEXT_TOP "PLEASE SELECT HERE THE DIRECTORY FOR DATA "
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Data Files"
!define MUI_DIRECTORYPAGE_VARIABLE $INSTDIR2
!define MUI_PAGE_CUSTOMFUNCTION_PRE DirectoryPre
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
.....
Section "DATA"
SetOutPath "$INSTDIR2\Data"
SetOverwrite try
File /r "Datas\*.*"
SectionEnd
Thanks a lot for any help
hawk
jpderuiter
23rd April 2010 14:03 UTC
Call Abort in a pre-function callback to skip that page.
See http://nsis.sourceforge.net/Docs/Chapter4.html#4.5.3
hawkmaster
26th April 2010 09:47 UTC
hmm, sorry if I ask again.
As I understand a pre-function callback can only be done with Pages?
But I have no Page.
This will not work,
!insertmacro MUI_PAGE_DIRECTORY skipDirectories "" ""
!insertmacro MUI_PAGE_INSTFILES
Function skipDirectorie
Abort
FunctionEnd
MSG
26th April 2010 10:15 UTC
You will find the information you need in the Modern UI readme:
http://nsis.sourceforge.net/Docs/Mod...02/Readme.html
hawkmaster
26th April 2010 11:17 UTC
Hi MSG
thank you for help.
Ok, I read again and found this:
http://nsis.sourceforge.net/Skipping_Pages
So I have modified my script:
--------------------------------------------------
!include logiclib.nsh # dont know if this is neccessary?
!include sections.nsh # dont know if this is neccessary?
# Second directory page for data files.
var INSTDIR2
!define MUI_DIRECTORYPAGE_TEXT_TOP "PLEASE SELECT HERE THE DIRECTORY FOR DATA "
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "IData Directory"
!define MUI_DIRECTORYPAGE_VARIABLE $INSTDIR2
!define MUI_PAGE_CUSTOMFUNCTION_PRE dirPre
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
Function dirPre
${Unless} ${SectionIsSelected} ${SECTIONDIRECTORIES}
Abort
${EndUnless}
StrCpy $INSTDIR2 "$PROGRAMFILES\Data"
FunctionEnd
Section "Directories" SECTIONDIRECTORIES
SetOutPath "$INSTDIR2\Directories"
SetOverwrite try
File /r "Directories\*.*"
SectionEnd
##############################
The problem is that the second directories page is always show, also if section "Directories" is selected or not.
Any idea?
thanks a lot
regards
hawk
jpderuiter
26th April 2010 12:05 UTC
Not sure what your problem is, the following (complete) script is working fine here:
OutFile testsetup.exe
>!include logiclib.nsh
>!include sections.nsh
>!include MUI2.nsh
>!insertmacro MUI_PAGE_COMPONENTS
>!insertmacro MUI_PAGE_DIRECTORY
># Second directory page for data files.
>var INSTDIR2
>!define MUI_DIRECTORYPAGE_TEXT_TOP "PLEASE SELECT HERE THE DIRECTORY FOR DATA "
>!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "IData Directory"
>!define MUI_DIRECTORYPAGE_VARIABLE $INSTDIR2
>!define MUI_PAGE_CUSTOMFUNCTION_PRE dirPre
>!insertmacro MUI_PAGE_DIRECTORY
>!insertmacro MUI_PAGE_INSTFILES
>Function dirPre
>${Unless} ${SectionIsSelected} ${SECTIONDIRECTORIES}
>Abort
>${EndUnless}
>StrCpy $INSTDIR2 "$PROGRAMFILES\Data"
>FunctionEnd
Section"Directories" SECTIONDIRECTORIES
SetOutPath "$INSTDIR2\Directories"
>SetOverwrite try
>File /r "Directories\*.*"
>SectionEnd
>
hawkmaster
26th April 2010 12:20 UTC
Hi,
thanks a lot for your help.
I have found my problem.
First I had the function "DirectoryPre" before the Section "Directories" and the compiler says a warning that the constant "SECTIONDIRECTORIES" not be found.
Now I put the function after the section and it works fine :-)
-----------------------------
Section "Directories" SECTIONDIRECTORIES
SetOutPath "$INSTDIR2\Directories"
SetOverwrite try
File /r "Directories\*.*"
SectionEnd
Function DirectoryPre
${Unless} ${SectionIsSelected} ${SECTIONDIRECTORIES}
Abort
${EndUnless}
StrCpy $INSTDIR2 "$PROGRAMFILES\Data"
FunctionEnd
----------------------------------------------
But I wonder, your post and code is similar to my first one and it works also? Hmm
Some additonal questions.
1. is the include of
!include logiclib.nsh
!include sections.nsh
really neccessary? or is the logic in mui2.nsh also included?
Is there a little bit more detailed description for LogicLib ?
http://nsis.sourceforge.net/LogicLib
regards
hawk
jpderuiter
26th April 2010 12:37 UTC
Well, your first post didn't have the dirPre function
1.
No, those are not required, since MUI2.nsh includes LogicLib.nsh, which in turn includes Sections.nsh.
But it makes it clearer if you include them anyway.
2.
Have a look at the LogicLib.nsi script in the Examples directory.