Archive: Use NSH file for custom page code


Use NSH file for custom page code
Can it be done or am I just barking up the wrong tree here.

I have an NSIS installer (that works) but it has ablut 50 custom pages with both enter and leave functions. In addition many of the pages have several other functions and macros that are used to manipulate the entry data. Since the Installer is now over 20,000 lines I wanted to make things a bit morre manageable by moving code for the custom page functions to NSH files for each page. For example I have a custom page

Page custom Whatever WhateverLeave
I wanted to move these functions to a Whatever.nsh and then just have
!Include "Whatever.nsh" at the start of my script (After I defined the variables used)
But I get an error in the MUI_Header_Text of the function. :eek:

Is it a matter of the placement of the Include and if so What is the order in which the Define, Include, Var, Page, ReserveFile should be (I have all of these prior to any section code)

Any help with this would be appriciated as I am somewhat inexperienced ith NSIS but am learning fast.:)


well if you're going to use includes at all - and we do, too.. every page is a separate include - you should at least use .nsi rather than .nsh. It may be semantic, but .nsh is intended for Headers, and .nsi for actual installer scripts. I suppose neither technically fit the bill, but .nsi seems more appropriate - we use a main.nsi that has all the main installer code and page.*.nsi to hold the pages with their locally-required defines, variables (typically nsDialogs-related), macros, etc.

That said - if you put the !include in -exactly- the same spot where the code used to be before, you should be fine.

Odds are that your MUI_Header_Text define -is- missing *something* that you had defined earlier before, and is now lost in context after putting all of your includes near the top.

So the order of placement really depends on what you had originally - try keeping that structure at first and make sure that's still working.. you can distill things later if it is.


For scripting itself there's not much of a 'standard' in how people order things. The only important ones that I can think of right now is that defines, variables and macros you use -must- be defined -before- you use them.