- NSIS Discussion
- After call to function section code isn't executed
Archive: After call to function section code isn't executed
mergisius
29th August 2007 11:23 UTC
After call to function section code isn't executed
After I call the function which displays custom page, code after the fucniton call isn't executed and buttons are disabled.
It means, that messagebox never appears. But the buttons aren't active, so it's imposible to press them. So how to leave the function code?
Well, I got this:
[quote]
Section "DB paruošimas" Server_Recreate
; Call here!
Call SettingsPageDB
; this MessageBox never appears
MessageBox MB_OK "SettingsPageDB done"
SetOutPath $INSTDIR
!insertmacro MUI_INSTALLOPTIONS_READ $DBSERVER_NAME "ServerSettingsPageDB.ini" "Field 3" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $DATABASE_NAME "ServerSettingsPageDB.ini" "Field 5" "State"
SetOutPath "$TEMP\EMC"
File ..\EMC.Setup\bin\C5.dll
File ..\EMC.Setup\bin\Castle.ActiveRecord.dll
File ..\EMC.Setup\bin\Castle.Components.Validator.dll
....................
[quote]
And the function:
Function SettingsPageDB
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "ServerSettingsPageDB.ini"
FunctionEnd
And the ServerSettingsPageDB.ini:
[Settings]
NumFields=5
[Field 1]
Type=groupBox
Text=Nurodykite įdiegimo parametrus
Left=0
Right=-1
Top=5
Bottom=182
[Field 2]
Type=label
Text=Duomenų bazės serverio vardas
Left=10
Right=-10
Top=20
Bottom=30
[Field 3]
Type=text
Left=10
Right=-10
Top=30
Bottom=42
MinLen=1
ValidateText=Nurodykite duomenų bazės serverio vardą
[Field 4]
Type=label
Text=Duomenų bazė
Left=10
Right=-10
Top=50
Bottom=60
[Field 5]
Type=text
Left=10
Right=-10
Top=60
Bottom=72
MinLen=1
ValidateText=Nurodykite duomenų bazės pavadinimą
Also tried this:
Function FuncSettingsPageDB
${If} ${SectionIsSelected} ${Server_Recreate}
MessageBox MB_OK "Server_Recreate is selected"
InstallOptions::dialog "ServerSettingsPageDB.ini"
${EndUnless}
MessageBox MB_OK "Serve_Recreate isn't selected"
FunctionEnd
In both ways the result is the same. I can't click any buttons on the window, but content of the window is what i want it to be.
Here is the picture:
http://www.talpykla.com/files/1305/ServerDB.jpgSo, how to make button "next" clickable? :)
Laslie
29th August 2007 11:36 UTC
Don't call the SettingsPageDB function in section. Use the Page command outside the sections.
mergisius
29th August 2007 11:39 UTC
Originally posted by Laslie
Don't call the SettingsPageDB function in section. Use the Page command outside the sections.
I need to show this page ONLY if section is selected.
Laslie
29th August 2007 12:12 UTC
Use pre function for Page command and check in the section is selected or not. If section is not selected use abort command.
for example:
...
!insertmacro MUI_PAGE_COMPONENTS
Page custom ServerSettingsPageDBShow ServerSettingsPageDBLeave ""
;other pages
...
Function ServerSettingsPageDBShow
!insertmacro SectionFlagIsSet ${Server_Recreate} ${SF_SELECTED} +2
Abort
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "ServerSettingsPageDB.ini"
FunctionEnd
Function ServerSettingsPageDBLeave
..
!insertmacro MUI_INSTALLOPTIONS_READ $DBSERVER_NAME "ServerSettingsPageDB.ini" "Field 3" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $DATABASE_NAME "ServerSettingsPageDB.ini" "Field 5" "State"
FunctionEnd
mergisius
29th August 2007 12:32 UTC
Error: could not resolve label "Abort" in function "ServerSettingsPageDBShow"
Error - aborting creation process
Well, i tried like this
Function ServerSettingsPageDBShow
!insertmacro SectionFlagIsSet ${Server_Recreate} ${SF_SELECTED} +2 abort
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "ServerSettingsPageDB.ini"
Goto end
abort:
Abort
end:
FunctionEnd
And now the error is:
[quote]
Processed 1 file, writing output:
Adding plug-ins initializing function... Done!
Error: resolving create-page function "SettingsPageDBShow" in install pages
Note: uninstall functions must begin with "un.", and install functions must not
Error - aborting creation process
[/qoute]
What it's trying to say?
And "Abort" function will exit only the function or whole installation?
Laslie
29th August 2007 12:44 UTC
Oops, sorry! Miss 0.
Correct script:
...
Function ServerSettingsPageDBShow
!insertmacro SectionFlagIsSet ${Server_Recreate} ${SF_SELECTED} +2 0
Abort
...
Abort calling from Page Pre CallBack function mean: don't show the page, post Page CallBack function: don't leave the page. Other place exit installation.
mergisius
29th August 2007 13:07 UTC
Yes, it works fine ;) thank you for your time ;)
And i got one more question. What about this:
Function PickDirectory
!insertmacro SectionFlagIsSet ${Server_Docs} ${SF_SELECTED} +2 0
Abort
!insertmacro MUI_PAGE_DIRECTORY
FunctionEnd
Error:
!insertmacro: MUI_PAGE_DIRECTORY
Error: command PageEx not valid in Function
Error in macro MUI_PAGE_DIRECTORY on macroline 12
Error in script "Dlc_Install_server.nsi" on line 252 -- aborting creation proces
s
So, I will need to make new macro "MUI_PAGE_DIRECTORY"? Or is there any way to pass this limitation, that I cannot use it in a function?
Laslie
29th August 2007 13:24 UTC
Don't mention it. :)
Yes, you cannot use it in a function.
Rightly:
...
!insertmacro MUI_PAGE_COMPONENTS
Page custom ServerSettingsPageDBShow ServerSettingsPageDBLeave ""
!define MUI_PAGE_CUSTOMFUNCTION_PRE PickDirectory
!insertmacro MUI_PAGE_DIRECTORY
...
You create PickDirectory function, and you put the check in this function.
Laslie
29th August 2007 13:29 UTC
The 3 functions together need using!
...
!define MUI_PAGE_CUSTOMFUNCTION_PRE PickDirectoryPre
!define MUI_PAGE_CUSTOMFUNCTION_SHOW PickDirectoryShow
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE PickDirectoryLeave
!insertmacro MUI_PAGE_DIRECTORY
...
mergisius
29th August 2007 13:50 UTC
As far as I know !define just makes some global variables like (it's from nsis help):
!define USE_SOMETHING
!define VERSION 1.2
!define /date NOW "%H:%M:%S %d %b, %Y"
!define /math RESULT 3 + 10
!define /math REST 15 % ${RESULT}
So, 3 defined variables does what? "!define" gives to variables PickDirectoryPre, PickDirectoryShow, PickDirectoryLeave value according if function "PickDirectory" was executed?
So, this function should be called in the section which requires to pick directory.
If yes, then what to write in the "PickDirectory" function to skip or run "!insertmacro MUI_PAGE_DIRECTORY" according to selected section?
Laslie
29th August 2007 14:13 UTC
To create the global variable use Var command, not !define.
If you need show or not pick directory page check it in PickDirectoryPre function. Pages code running before section code running. Section code running after last page.
mergisius
29th August 2007 14:19 UTC
But how to do it?
Function PickDirectoryPre
!insertmacro SectionFlagIsSet ${Server_Recreate} ${SF_SELECTED} 0 end
;what to write here?
end:
FunctionEnd
I check it, and what to do if i don't need to show directory page? The part I don't get is, that i don't know how to make it not to appear in the screen.
Laslie
29th August 2007 14:24 UTC
The other way round.
Function PickDirectoryPre
!insertmacro SectionFlagIsSet ${Server_Recreate} ${SF_SELECTED} +2 0
Abort ; hide screen
; show screen
FunctionEnd
Laslie
29th August 2007 14:26 UTC
So, 3 defined variables does what? "!define" gives to variables PickDirectoryPre, PickDirectoryShow, PickDirectoryLeave value according if function "PickDirectory" was executed?
The MUI know this.
mergisius
29th August 2007 14:32 UTC
Yes it works, but this way only:
Function PickDirectoryPre
!insertmacro SectionFlagIsSet ${Server_Docs} ${SF_SELECTED} end here
here:
Abort
end:
FunctionEnd
It's something strange with that numbers.. I make it work corectly only with labels. I, also made other custom pages with labels, because numbers didn't work for me.
Well, i thought, that "Abort" will only exits the function.
Thank you very much :)*
Laslie
29th August 2007 14:36 UTC
Try this:
Function PickDirectoryPre
!insertmacro SectionFlagIsSet ${Server_Docs} ${SF_SELECTED} end ""
Abort
end:
FunctionEnd
wraithdu
29th August 2007 15:42 UTC
I ran into that problem with relative jumps and macros too. It's because when the script is compiled the macro is expanded into all its lines of code. So a relative jump will jump somewhere into those lines.
So you are correct to use labels.