Archive: Repeating fails


Repeating fails
Hi, I want the files to be downloaded only if the user selects the file name by marking the checkbox (File name : Something). If the user doesn't select the checkbox it prompts for a message sayng "Do you want to quit?" If the user enters NO, then it should take to the same screen where the user will be asked to to enter his choice again.

The problem is , if the user marks the checkbox first time itself everything works fine. If not the user doesn't mark the checkbox initially, later comes back and marks the checkbox. The program isn't able to identify it.

I don't know the exact reason but I assume it is due the flow of program i..e initially it is done sequentially but later we are using call function to execute them.

Here is my code, please let me know if you have any suggestions.

/*To reduce the complexity I commented/removed the files 2 download n uninstall */


!include MUI.nsh
!include LogicLib.nsh
!include WinMessages.nsh
!include FileFunc.nsh
!include nsDialogs.nsh

!insertmacro MUI_LANGUAGE English

DirText "Please choose a directory to which you'd like to install this application."

Name "HUD Systems"
OutFile "Rewrite.exe"

installDir "C:\work\H"


Page custom nsDialogsWelcome
Page custom nsDialogsWelcome1 nsDialogsWelcome1Leave
!insertmacro MUI_PAGE_DIRECTORY
Page custom show
!insertmacro MUI_PAGE_INSTFILES

XPStyle on

Var Dialog
Var Label
Var Text
Var Text_State
Var Checkbox
Var Checkbox_State
Var one

Function .onInit
${NSD_SetState} $Checkbox_State ${BST_UNCHECKED}
FunctionEnd

Function nsDialogsWelcome

nsDialogs::Create 1044
Pop $DIALOG

${If} $Dialog == error
Abort
${EndIf}

${NSD_CreateLabel} 7u 7u 100% 100% "Welcome "
Pop $Label

${NSD_CreateLabel} 11u 14u 95% 100% "Creating a label"
Pop $Label

nsDialogs::Show
FunctionEnd


Function nsDialogsWelcome1

${NSD_SetState} $Checkbox_State ${BST_UNCHECKED}


nsDialogs::Create 1018
Pop $Dialog

${If} $Dialog == error
Abort
${EndIf}

${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
Pop $Label

${NSD_CreateCheckbox} 0 30u 100% 10u "Something"
Pop $Checkbox

; ${NSD_SetState} $Checkbox_State $Checkbox
${If} $Checkbox_State == ${BST_CHECKED}
${NSD_Check} $Checkbox
${EndIf}

nsDialogs::Show

FunctionEnd

Function nsDialogsWelcome1Leave

${NSD_GetState} $Checkbox $Checkbox_State
MessageBox MB_OK "The values is $Checkbox_State"
FunctionEnd

Function show ; "All zip files"
show1:
${If} $Checkbox_State == ${BST_CHECKED}

IfFileExists "$INSTDIR\*.*" 0 Createdir
MessageBox MB_YESNO "Do you want to override this file??" IDNO no
SetOutPath "$INSTDIR\deliverables"
; File client_9_6_0_0.zip
;WriteUninstaller $INSTDIR\Uninstall.exe
;ZipDLL::extractall "$INSTDIR\deliverables"\deploy_9_6_0_0.zip" "$INSTDIR"
Goto End

no:
MessageBox MB_YESNO "You do not want to override the files, so quitting??" IDNO no1
Quit

no1:
Goto show1

CreateDir:
MessageBox MB_OK "Folder does not exists, sorry we cannot copy the files."
Quit
${Else}
MessageBox MB_YESNO "You didn't select any files. Do you want to quit??" IDNO no2
Quit

no2:
MessageBox MB_YESNO "You want to go back and select files?" IDNO Q
Call nsDialogsWelcome1
Call nsDialogsWelcome1Leave
Call show
${EndIf}

Q:
Quit

End:
FunctionEnd

Section "ABC"
Strcpy $one 0
SectionEnd

Section "Uninstall"
RMDir $INSTDIR
SectionEnd


You cannot call a page function manually. You can only page creation functions with the page custom command.

To get back to the page, call 'abort' in the page's leave function. So in your case, move your messageboxes to the leave function, and call abort if the user wants to go back to the page.

(Notice that your second messagebox is kind of stupid. You first ask 'quit yes/no', then if the user selects no twice, you still quit anyway. You should simply say 'please select some files', then call abort immediately. If the user wants to quit, he/she can click the Cancel button.)


Yeah I tried. But it's just quitting the program.

What I had done is modified the lines as shown below (just adding Abort and commenting the rest) :

no2:
Abort

;MessageBox MB_YESNO "You want to go back and select files?" IDNO Q
;Call nsDialogsWelcome1
;Call nsDialogsWelcome1Leave
;Call show


I want the program to go back to the screen with checkbox and if checkbox is marked it should update it's value to 1, indicating that the user needs to download the file


I already told you, you need to call abort in the leave function, not in the show function.


Oh sorry I didn't go through it properly.
That worked thank you.


No problem. :)