Old 4th January 2011, 11:49   #1
Junior Member
Join Date: Jan 2011
Posts: 4
nsDialog page re-use


I am wondering the best way to achieve this...

I have to collect data from the installer multiple times based on a user input integer.

As far as I am aware I can't add pages in dynamically I have to add a bunch in and then skip them (please correct me if I am wrong )

I know I can add the same page multiple times by simply calling

Page custom pageName

multiple times. The problem arises when I need to collect the data from the page to process it on installation. Is there a simple way to customise the variable names to make them unique without defining the pages multiple times?

All help appreciated!

MrMR is offline   Reply With Quote
Old 4th January 2011, 15:10   #2
Major Dude
T.Slappy's Avatar
Join Date: Jan 2006
Location: Slovakia
Posts: 566
Send a message via ICQ to T.Slappy
I am not sure whether you mean this, but you can have a try:

You can define a symbol with some "prefix" or string in it like here:


So you can call functions like this:



Hope it helps...

I found this in MUI2.nsh related files, maybe you could check them.

Cool looking installers with custom design: www.graphical-installer.com
Create Setup Pages easily: www.install-designer.com
Build installers in Visual Studio 2005-2022: www.visual-installer.com
or RAD Studio 2009 - 11 Alexandria: www.rad-installer.com
T.Slappy is offline   Reply With Quote
Old 4th January 2011, 16:31   #3
Junior Member
Join Date: Aug 2010
Posts: 29
As you probably know, Variables in NSIS are global no matter where they are declared (top of file, function, or section. See: http://nsis.sourceforge.net/Docs/Chapter4.html#4.2). If you declare them in a function, you have to place /GLOBAL in front of it to indicate this. When you declare a custom page to use:

page custom MyPage MyPageLeave ;where MyPage is the function to define the page and MyPageLeave is called when the page is left.

Then you would have two fxns somewhere in your nsi file:

Function MyPage
Var /GLOBAL someVar
;some code to define and display your page

Function MyPageLeave
;maybe manipulate the user provided integer here.

It is possible that if you manipulate the user provided integer right away, you could do so in the MyPageLeave function and only ever need one variable for this integer. However, if you obtain a series of integers before you do anything with them, then you likely need to create separate variables for however many instances you will need. So if you will display the page five times and require five inputs, declare five variables (kind of ugly, I know and someone may have a better suggestion). Also, I suggest you consider using an array for this if it fits what you are trying to do because it could be cleaner. Hope this helps.
blh83 is offline   Reply With Quote
Old 5th January 2011, 09:39   #4
Junior Member
Join Date: Jan 2011
Posts: 4
Thank you.

I have located the Array plugin (NSISArray) which is working well.

I have created a function for each page and another for the page leave. Inside the functions I am calling a macro with a unique id from the calling page (function). All the UI widgets for the common pages are created in the macro (which makes the code cleaner) and the unique id is used to index the data in the array.

I am also using the integer passed in from the user to let the page decide if it should show its self (Abort) or not which makes the pages (appear to) show dynamically.
MrMR is offline   Reply With Quote
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

dynamic, nsdialogs, pages

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