- NSIS Discussion
- UI flow control : function / label use outside sections ??
Archive: UI flow control : function / label use outside sections ??
wfredk
26th July 2004 15:17 UTC
UI flow control : function / label use outside sections ??
I've tried to put logic in to the NSIS script I'm writing to see if ActiveSync is installed, and to either display an error message if it's not found, or continue. However, it seems NSIS doesn't have any support for flow control during the "wizard" portion of the installer, only during installation itself: When I try to compile the script, it tells me the (jump target) labels can only be used inside a function or a section. Sections are installation code blocks that are executed after the UI finishes. Functions cannot be called except from inside a function or a section - so they're effectively only available in the post-UI phase, too.
Is there no way to have flow control during the UI phase of NSIS operation, or am I missing something?
Afrow UK
26th July 2004 16:06 UTC
You need to insert your code into a Pre or Leave function of one of the Installer Pages.
-Stu
wfredk
26th July 2004 20:12 UTC
ok, that will work. having the page code buried inside insertmacro statements makes that option rather less obvious, but now that you've pointed it out, I'm quite certain I can figure out how to do it :cool:
Afrow UK
26th July 2004 21:29 UTC
Well, you're using MUI right, so...
!define MUI_PAGE_CUSTOMFUNCTION_PRE CheckActiveSync
!insertmacro MUI_PAGE_COMPONENTS
Function CheckActiveSync
...
FunctionEnd
This will call the 'CheckActiveSync' function just before the Components Page.
-Stu
wfredk
26th July 2004 21:42 UTC
I go to the grocery store and I come back and find my code written for me!
:) :) :) :)
FWIW, I'll actually be putting the function call before MUI_PAGE_DIRECTORY, but that doesn't change your example significantly.
Thanks, you've saved me a bunch of time!
:up:
flyakite
29th July 2004 21:06 UTC
Couldn't you just use:
Function .onInit
Call CheckActiveSync
FuntionEnd
Anders
29th July 2004 21:21 UTC
Originally posted by flyakite
Couldn't you just use:
Function .onInit
Call CheckActiveSync
FuntionEnd
Not when you are using the modern ui
flyakite
30th July 2004 06:57 UTC
I think you're wrong. I'm using Modern UI, and this is in my .onInit
call CheckSP1
and this is my CheckSP1 function:
Function CheckSP1
ReadRegStr $R3 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CSDVersion
StrCmp $R3 "Service Pack 1" "" +2
Return
MessageBox MB_OK "You do not have Windows XP Service Pack 1 installed.$\n$\n Make sure to choose the 'Extract Files Only' install type when installing."
FunctionEnd
and here is code DIRECTLY in my .onInit obtained from the Archive using a jump:
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "72") i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK "The installer is already running."
Abort
iceman_k
31st July 2004 05:14 UTC
flyakite is 100% correct.
.onInit can most certainly be called when using MUI.
It's .onGUIInit which has been taken over by MUI.
In that case you have to !define MUI_CUSTOMFUNCTION_GUIINIT if you want to do any special GUI initialization steps.
Afrow UK
31st July 2004 13:54 UTC
I tend not to use .onInit for long calculations or file searches etc, as the user may think the installer has crashed.
If you do though, make sure you use the banner plugin to display a message.
-Stu
deguix
31st July 2004 17:25 UTC
I tend not to use .onInit for long calculations or file searches etc, as the user may think the installer has crashed.
If you do though, make sure you use the banner plugin to display a message.
I was exactly talking about this in other forums, because I done it in the past, and so were the users complaining about the installer...