Archive: Call Abort in custom page


Call Abort in custom page
Hy I've make an custom page drop list. Now I would, when State=

I thought that it calls blank?

It shows a message box with an error to the user.

How can I do this

The message box should be have one OK Button


What I usually do is build the InstallOptions ini to have the first item say something "Please select..." This helps direct the end-users on what they are supposed to do.

Example:

 
[Field 1]
Type=Combobox
Text=Combobox
State=Please select something...
ListItems=Please select something...|Selection1|Selection2|Selection3
; size and position elements have been
; omitted in this example...

Then, in your exit function, do something like this:

ReadIniStr $0 '$PLUGINSDIR\myfile.ini' 'Field 1' 'State'
strcmp $0 'Please select something...' error ok
error:
MessageBox MB_OK "You didn't select anything!"
abort
ok:
; continue your code here

Hy thank you I've tested it and it works ... but not like it should

The error Please select something comes too late.

Can you show what is wrong


Please help me.

There must be an little problem but I don't find it.

Perhaps you can download the *.rar there is the full code


Or I it is enough to help me this is the code which is needed for the Call abort

The error " Please select something " comes when the MUI_PAGE_INSTFILES page is active and not when I click next on the Page custom NetsettingsPage.


THANK you to all people which help me


;Reserve File
ReserveFile "netsettings.ini"


Page custom NetsettingsPage
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES



; MUI end ------

Name "${PRODUCT_NAME}"
OutFile "Setup.exe"
InstallDir "$PROGRAMFILES\Droplist"
ShowInstDetails show
ShowUnInstDetails show

Section "Config & mehr" SEC01
Call CopyNetsettings
SectionEnd

Section -AdditionalIcons
SetOutPath $INSTDIR
CreateDirectory "$SMPROGRAMS\Droplist"
CreateShortCut "$SMPROGRAMS\Droplist\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\Droplist\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
SectionEnd

; Funtions
Function .onInit

!insertmacro MUI_INSTALLOPTIONS_EXTRACT "netsettings.ini"

FunctionEnd

; Netsettings Page
Function NetsettingsPage

!insertmacro MUI_HEADER_TEXT "Konfiguration des Erweiterungs System" "Wählen Sie, mit welcher Verbindung sie spielen."
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "netsettings.ini"

FunctionEnd

!macro COPY_FILES SOURCE
CopyFiles /silent "$INSTDIR\CONFIG & MEHR\Infos\Netsettings\${SOURCE}\netsettings.cfg" "$INSTDIR\CONFIG & MEHR\cstrike"
goto done
!macroend

; Page Leave Netsettings

Function CopyNetsettings

; THIS IS THE NEW CODE

ReadIniStr $0 '$PLUGINSDIR\netsettings.ini' 'Field 1' 'State'
strcmp $0 '' no ok
no:
MessageBox MB_OK "Sie haben keine Verbindung gewählt!"
abort
ok:

; THIS IS THE NEW CODE END

Push $R0
ReadINIStr $R0 "$PLUGINSDIR\netsettings.ini" "Field 1" "State"
StrCmp $R0 "LAN" 0 notLAN
!insertmacro COPY_FILES LAN

notLAN:
StrCmp $R0 "56K Modem" 0 not56K_Modem
!insertmacro COPY_FILES 56K_Modem

not56K_Modem:
StrCmp $R0 "ISDN" 0 notISDN
!insertmacro COPY_FILES ISDN

notISDN:
StrCmp $R0 "D-ISDN" 0 notD-ISDN
!insertmacro COPY_FILES D-ISDN

notD-ISDN:
StrCmp $R0 "S-DSL" 0 notS-DSL
!insertmacro COPY_FILES S-DSL

notS-DSL:
StrCmp $R0 "A-DSL" 0 notA-DSL
!insertmacro COPY_FILES A-DSL

notA-DSL:
StrCmp $R0 "Cable" 0 notCable
!insertmacro COPY_FILES Cable

notCable:
StrCmp $R0 "Q-DSL" 0 notQ-DSL
!insertmacro COPY_FILES Q-DSL

notQ-DSL:
StrCmp $R0 "DSL mit FP" 0 done
!insertmacro COPY_FILES DSL_mit_FP

done:

Pop $R0
FunctionEnd

The problem is that you are calling your 'CopyNetSettings' function from a section. Section are only processed during installing file. That's the reason you only see the error during installing files.

Take the 'new code' block out of the function 'CopyNetSettings' and make it a funtion on it's own. Something like this:


Function LeaveNetSettings
ReadIniStr $0 '$PLUGINSDIR\netsettings.ini' 'Field 1' 'State'
strcmp $0 '' no ok
no:
MessageBox MB_OK "Sie haben keine Verbindung gewählt!"
abort
ok:
FunctionEnd


Then, change your custom page call to this:

Page custom NetsettingsPage LeaveNetSettings


<<Edit>>
PS: Try to refrain from posting entire scripts when they are large. It makes the forums harder to read. ;)

THX IT WORKS