tbednarz
5th January 2006 18:17 UTC
Newbee question - how does the program flow work?
I need to show pages depending on user input. If a user installs the software he can register as a new user and gets a new subscriber license or if the user already has such a license and just needs to reinstall the software he just can enter his subscriber key.
So I have to show a page asking whether he has a subscription key or not. Depending on the answer I have to show diffenent pages and the following actions are somewhat different until the moment where files are copied etc. (If it is a new user he has to enter personal information which is sent over the internet to a database server which returns the license key. If it is an existing user, he has to enter his key which is veryfied on the database server and some data is returned to the setup program.)
Could anybody please explain how such a script needs to be structured? I do not understand, where I can place optional pages. I should do something like:
- do defines
- include MUI
- define MUI settings
- define pages:
page welcome
page license
page question
if (answer on question is A)
{
page A
page b
...
} else
{
page x
page y
...
}
- installer config
- sections....
- functions ...
To check the return values of the question page I need to call:
!insertmacro MUI_INSTALLOPTIONS_READ "SubscriptionType.ini" $ST_NEW "Field 1" "State"
But this statement can be executed only within a section or function. But I have to declare my pages earlier. (See pseudo code above). So how does this work? Do I need to make hidden sections for each case? And how do I assign pages to sections (or sections to pages)?
Many thanks for your help
Tom
kichik
5th January 2006 18:25 UTC
You cannot condition the deceleration of a page, however you can skip pages.
Deceleration of a custom page requires a function name. That function is responsible of calling the plug-in that creates the page. In that function, you can also check the return values of the page. There's no need to create a section for it.
The complete flow of the installer is described in the tutorial. If after reading the tutorial something is still unclear, please let us know so the tutorial can be improved.
tbednarz
5th January 2006 22:16 UTC
Thanks a lot. "Skipping pages" is a good hint but I still do not fully understand: I need to skip multiple pages and I have the impression 'Abort' stops the installation completely. I also get an error using the following code:
!insertmacro MUI_PAGE_WELCOME
!define MUI_LICENSEPAGE_CHECKBOX
!insertmacro MUI_PAGE_LICENSE $(myLicenseData)
Page custom SubscriptionType
!define MUI_PAGE_CUSTOMFUNCTION_PRE SubsKeyPre
Page custom SubscriptionKey
!define MUI_PAGE_CUSTOMFUNCTION_PRE SubsDataPre
Page custom SubscriberData
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
If I define MUI_PAGE_CUSTOMFUNCTION_PRE twice I get an error.
The page SubscriptionType asks the user if he is already a subscriber. If he says NO the page SubscriptionKey should be skipped, if he says YES, the page SubscriberData should be skipped.
I defined the following functions:
Function SubsKeyPre
${If} $IsNewSubscriber == 0
Abort
${EndIf}
FunctionEnd
Function SubsDataPre
${If} $IsNewSubscriber == 1
Abort
${EndIf}
FunctionEnd
I guess I still misunderstand something, it does not work as expected!
Tom
Afrow UK
5th January 2006 23:04 UTC
The MUI_PAGE_CUSTOMFUNCTION_PRE defines are for MUI_PAGE_* macros only... not for Custom pages.
For Custom pages you do not need to call Abort at all, but simply skip over the InstallOptions plugin call (or MUI_INSTALLOPTIONS_DISPLAY) instead.
-Stu
kichik
6th January 2006 08:36 UTC
I've added information about skipping custom pages to the FAQ item.
tbednarz
6th January 2006 09:17 UTC
Thank you all very much. Got it now and it works just fine!
Tom