Old 26th July 2012, 20:50   #1
nawfal
Junior Member
 
Join Date: Jul 2012
Posts: 22
What's with NSIS namespaces?

Ok I called those parts of the NSIS script that look like !include MUI2.nsh namespaces. I need a little more clarity on which are the namespaces that I really should !include in my code. Here are my confusions:

1) I have codes like this:

code:
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
Page custom DbPage "" ": Information Page"
Page instfiles
!insertmacro MUI_PAGE_FINISH



which basically means I am using a custom InstallOptions page as well. So I thought I need to include !include InstallOptions.nsh and !include MUI.nsh. It works. But to my surprise even if I am not including !include InstallOptions.nsh the code compiles, and I see no difference in end result !! But if I am including only !include MUI2.nsh, the code doesn't compile. But it compiles and works normally if I include !include MUI2.nsh & !include InstallOptions.nsh. So what should I include, !include MUI.nsh alone or a combo of !include MUI2.nsh & !include InstallOptions.nsh ?? . The code compiles if I include all !include MUI2.nsh, !include InstallOptions.nsh and !include MUI.nsh. In that case, the macros and functions will be loaded from !include MUI2.nsh or !include MUI.nsh ??



2) I use a function defined here to see if a section is selected or not like this:

code:
SectionGetFlags ${Section_Name} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} show



The link asks to include !include Sections.nsh, but for me the script compiles even without including that. Why is it?? Should I ideally !include it?



3) I have code like:

code:
${If} ${FileExists} `$0\*.*`
${Else}
CreateDirectory $0
${EndIf}

${If} $2 != <
StrCpy $2 >
${EndIf}

${If} $3 != <
StrCpy $3 >
${EndIf}



etc. So shouldn't I !include LogicLib ? I get the code compiled even without using !include LogicLib.

Why is that I am able to compile NSIS script without including appropriate packages/references?
nawfal is offline   Reply With Quote
Old 27th July 2012, 05:07   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
1. MUI1 uses InstallOptions, so if you include the MUI1 headers it will then include the installoptions headers for you. MUI2 uses nsDialogs instead of installoptions, so if you want to use IO you'll have to include it manually. Note that nsDialogs has superceded IO long ago, please use nsDialogs for your custom pages.

2. The ${SF_SELECTED} define is defined in sections.nsh. You must include it, otherwise the compiler won't know what ${SF_SELECTED} means. It should give you a compiler warning about it.

3. Yes, you should. Again, if the defines and macros work it's only because logiclib has already been included by some other header file. It's all very logical: As long as logiclib is included *somewhere* before you use the macros/defines in your script, the compiler will be able to use those macros without trouble.
MSG is offline   Reply With Quote
Old 27th July 2012, 06:53   #3
nawfal
Junior Member
 
Join Date: Jul 2012
Posts: 22
Hi MSG, thanks for reply.

1. Ok I understand IO.nsh is deprecated, but it will be too much work now to replace it with nsDialogs. My script is fully working, and compiles with no warning, no errors. My question now is should I include MUI alone or a combo of MUI2 and InstallOptions. I suppose the latter since I think MUI2 is better than MUI.

2. That is my confusion MSG, the code works perfectly even without adding sections.nsh. It compiles with no errors, no warnings, and even works exactly as expected (regarding section selected logic and all). So my confusion is why is it working even without adding !include Sections.nsh ? In case its working, I can drop that include header right? Just thinking of right coding practice.

3. Which is that somewhere? Because all the header I'm including is just MUI as of now. Does MUI have even LogicLib?
nawfal is offline   Reply With Quote
Old 27th July 2012, 09:47   #4
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
1. As far as I know the only difference between MUI 1 and 2 is the use of IO vs nsD. If you're using IO anyway, there's little point to using MUI2 - only adds to installer size.

2. If the compiler does not throw a warning about an unknown + ignored define, then sections.nsh was already included somewhere. Probably by one of your other includes. But if you're thinking of good coding practice, you should always !include everything you know you need. Because you cannot be certain that the other nsh files will keep including your requirements forever - they might change with different NSIS versions.

3. If you want to know whether MUI.nsh includes logiclib.nsh, why don't you just take a look in MUI.nsh? (Pro tip: mui.nsh includes nsis\contrib\modern ui\system.nsh, which in turn includes installoptions.nsh, which in turn includes logiclib.nsh.)
MSG is offline   Reply With Quote
Old 27th July 2012, 11:01   #5
nawfal
Junior Member
 
Join Date: Jul 2012
Posts: 22
Smile

MSG, thanks for the tips, it was helpful.

2. I was wondering all I included was just MUI, and not any other headers, but only now I know they were included inside the includes of MUI.

3. I didn't have a clue I could check it that way. (Pro tip: mui.nsh includes nsis\contrib\modern ui\system.nsh, which in turn includes installoptions.nsh, which in turn includes logiclib.nsh which in turn includes Sections.nsh )

Your tip on coding practice was helpful, thanks again. Chapter/Thread Closed !!
nawfal is offline   Reply With Quote
Old 27th July 2012, 11:08   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
code:
Page instfiles
This should be replaced with !insertmacro MUI_PAGE_INSTFILES. You should not mix MUI and non MUI pages (you still use Page Custom for custom pages though).
code:
SectionGetFlags ${Section_Name} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} show

You can use this instead:
code:
${If} ${SectionIsSelected} ${Section_Name}
And finally, instead of this:
code:
${If} ${FileExists} `$0\*.*`
${Else}
CreateDirectory $0
${EndIf}

You have ${IfNot}:
code:
${IfNot} ${FileExists} `$0\*.*`
CreateDirectory $0
${EndIf}

Stu
Afrow UK is offline   Reply With Quote
Old 27th July 2012, 19:47   #7
nawfal
Junior Member
 
Join Date: Jul 2012
Posts: 22
Afrow UK, very many thanks.. makes sense..
nawfal is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
header, include, installoptions, logiclib, mui

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump