Old 27th March 2015, 19:57   #1
coderwolf
Junior Member
 
Join Date: Feb 2015
Posts: 25
call single InstallOptions Dialog n times.

I have a dialog that will be called n times (up to a maximum of 75 times)(number determined by the user). But when I call it from the create section of the Pages custom declaration it only shows the dialog one time.
Quote:
Page custom fnc_FtpProfile_PreShow

Function fnc_FtpProfile_PreShow
${For} $R1 1 $NoTimes
Call fnc_FtpProfile_Show
${Next}
FunctionEnd
When I try to loop the page declaration I get an error from the compiler.
Quote:
${For} $R1 1 $NoTimes
Page custom fnc_FtpProfile_PreShow
${Next}
Due to the possible high number of profiles, it is very prohibitive to manually code 75 instances of the code in a file. Is there any way I can loop the showing of dialogs?
This is an installation for a system where some installs actually already have over 60 profiles.
coderwolf is offline   Reply With Quote
Old 27th March 2015, 20:12   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,321
Have you tried http://nsis.sourceforge.net/Go_to_a_NSIS_page ?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 27th March 2015, 20:35   #3
coderwolf
Junior Member
 
Join Date: Feb 2015
Posts: 25
Quote:
Originally Posted by Anders View Post
I have not. If I understand this right, For my implementation, I would have to define a custom Abort function. Similar to the "Special Usage" section?

This may take a bit of digestion to fully understand.
coderwolf is offline   Reply With Quote
Old 27th March 2015, 20:56   #4
coderwolf
Junior Member
 
Join Date: Feb 2015
Posts: 25
Quote:
Originally Posted by Anders View Post
Quote:
Originally Posted by coderwolf View Post
I have not. If I understand this right, For my implementation, I would have to define a custom Abort function. Similar to the "Special Usage" section?

This may take a bit of digestion to fully understand.
I am going to have to eat my words here. I just learned that nsdialogs is not really a subset of the InstallOptions set. I had somehow give myself that impression on previous doc readthroughs.

Is there any way to replicate the page loop structure I mentioned earlier using the nsdialogs system? (that is the way I have my form defined currently)
coderwolf is offline   Reply With Quote
Old 27th March 2015, 21:50   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,321
Showing 60 pages in a installer is insane!

There are several ways to show the same page several times, they all suck:

Quote:
!include LogicLib.nsh
var test_max
var test_num
!macro InitPageLoopTest
StrCpy $test_num 0
!macroend
!macro _ShowAnotherTestPage _a _b _t _f
IntOp $test_num $test_num + 1
IntCmp $test_num $test_max `${_f}` `${_t}` `${_f}`
!macroend
!define ShowAnotherTestPage `"" ShowAnotherTestPage ""`

!include nsDialogs.nsh
Page Components
Page Custom myCreate_Method1 myLeave_Method1
Page Custom myCreate_Method2 myLeave_Method2
Page Custom myCreate_Method3 myLeave_Method3
Page InstFiles



Function LoadProfileData
System::Call 'ADVAPI32::SystemFunction036(*i.r0,i4)' ; Generate some data for this page
${NSD_SetText} $1 $0
System::Call 'KERNEL32::GetTickCount()i.r0'
${NSD_SetText} $2 $0
FunctionEnd


Function myCreate_Method1
StrCpy $test_max 3
${If} $test_num > 0
GetDlgItem $0 $hwndparent 3
EnableWindow $0 0 ; Disable back button
${EndIf}
nsDialogs::Create 1018
Pop $0
${NSD_CreateLabel} 0 -12u 100% 12u "Method1"
Pop $0
${NSD_CreateText} 3u 13u 50% 13u ""
Pop $1
${NSD_CreateText} 3u 30u 50% 13u ""
Pop $2
Call LoadProfileData
nsDialogs::Show
FunctionEnd

Function myLeave_Method1
${If} ${ShowAnotherTestPage}
SendMessage $HWNDPARENT 0x408 0 "" # Go to NSIS page
${EndIf}
FunctionEnd


Function myCreate_Method2
GetDlgItem $0 $hwndparent 1
${NSD_SetText} $0 "$(^NextBtn)"
!insertmacro InitPageLoopTest
again:
nsDialogs::Create 1018
Pop $0
${NSD_CreateLabel} 0 -12u 100% 12u "Method2"
Pop $0
${NSD_CreateText} 3u 13u 50% 13u ""
Pop $1
${NSD_CreateText} 3u 30u 50% 13u ""
Pop $2
Call LoadProfileData
StrCpy $0 0
nsDialogs::Show
${If} $0 <> 0 ; Cancel or Next?
${AndIf} ${ShowAnotherTestPage}
GetDlgItem $0 $hwndparent 3
EnableWindow $0 0 ; Disable back button
Goto again
${EndIf}
FunctionEnd

Function myLeave_Method2
StrCpy $0 1
FunctionEnd


Function myCreate_Method3
GetDlgItem $0 $hwndparent 1
${NSD_SetText} $0 "$(^NextBtn)"
!insertmacro InitPageLoopTest
nsDialogs::Create 1018
Pop $0
${NSD_CreateLabel} 0 -12u 100% 12u "Method3"
Pop $0
${NSD_CreateText} 3u 13u 50% 13u ""
Pop $1
${NSD_CreateText} 3u 30u 50% 13u ""
Pop $2
Call LoadProfileData
nsDialogs::Show
FunctionEnd

Function myLeave_Method3
${If} ${ShowAnotherTestPage}
# Fake another page by staying on this page but with new values
Call LoadProfileData
GetDlgItem $0 $hwndparent 3
EnableWindow $0 0 ; Disable back button
Abort
${EndIf}
FunctionEnd
I would recommend that you just have 2 custom pages. Page 1 would contain a list of profiles and page 2 would edit the selected profile. You would then skip the 2nd page if no profile is selected or jump back to page 1 after editing a profile...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 30th March 2015, 21:58   #6
coderwolf
Junior Member
 
Join Date: Feb 2015
Posts: 25
Quote:
Originally Posted by Anders View Post
Showing 60 pages in a installer is insane!

There are several ways to show the same page several times, they all suck:



I would recommend that you just have 2 custom pages. Page 1 would contain a list of profiles and page 2 would edit the selected profile. You would then skip the 2nd page if no profile is selected or jump back to page 1 after editing a profile...
trying to follow option 2 for a pattern. The code you gave is repeating the dialog. My code is showing the dialog one time. I am missing something. Below is my code.

Quote:
!include MUI2.nsh
!include "nsDialogs.nsh"
!include "LogicLib.nsh"
!include "FtpProfile.nsdinc"

Var max_Profiles ; Maximum number of profiles
Var ndx_num ; index of where we are in the Profile Loop

Var ProfileName
Var LclPSDir
Var RmtPSDir
Var LclConDir

Page components
Page custom fnc_FtpProfile_PreShow fnc_FtpProfile_AfterShow

Section /o "Config Profiles" Profiles ;FTPCFGXX.CMD {Steps 16-19, 23}
SectionIn 1 7
;StrCpy $max_Profiles 15
SectionEnd

!macro _ShowAnotherFTPPage _a _b _t _f
IntOp $ndx_num $ndx_num + 1
IntCmp $ndx_num $max_Profiles `${_f}` `${_t}` `${_f}`
!macroend
!define ShowAnotherFTPPage `"" ShowAnotherFTPPage ""`

!macro InitFTPPageLoop
StrCpy $ndx_num 0
StrCpy $max_Profiles 15
!macroend

Function fnc_FtpProfile_PreShow
SectionGetFlags ${Profiles} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} show

Abort

show:
GetDlgItem $0 $hwndparent 1
${NSD_SetText} $0 "$(^NextBtn)"
;!insertmacro InitFTPPageLoop

reloadFTPProfile:
Call fnc_FtpProfile_Create2
Call LoadFTPProfileData
StrCpy $0 0
Call fnc_FtpProfile_Show

${If} $0 <> 0
${AndIf} ${ShowAnotherFTPPage}
MessageBox MB_OK "Showing Dialog again"
GetDlgItem $0 $hwndparent 3
EnableWindow $0 0 ; Disable back button
Goto reloadFTPProfile
${EndIf}

FunctionEnd

Function LoadFTPProfileData

ReadINIStr $ProfileName "$Temp\DosB\FTP" "Profiles" "ProfileName$ndx_num"
ReadINIStr $LclPSDir "$Temp\DosB\FTP" "Profiles" "LclPSDir$ndx_num"
ReadINIStr $RmtPSDir "$Temp\DosB\FTP" "Profiles" "RmtPSDir$ndx_num"
WriteINIStr $LclConDir "$Temp\DosB\FTP" "Profiles" "LclConDir$ndx_num"

${NSD_SetText} $hCtl_FtpProfile_TB_ProfName $ProfileName
${NSD_SetText} $hCtl_FtpProfile_TB_LCLPSDir $LclPSDir
${NSD_SetText} $hCtl_FtpProfile_TB_RmtPSDir $RmtPSDir
${NSD_SetText} $hCtl_FtpProfile_TB_LclConDir $LclConDir
FunctionEnd

Function fnc_FtpProfile_AfterShow
${NSD_GetText} $hCtl_FtpProfile_TB_ProfName $ProfileName
${NSD_GetText} $hCtl_FtpProfile_TB_LCLPSDir $LclPSDir
${NSD_GetText} $hCtl_FtpProfile_TB_RmtPSDir $RmtPSDir
${NSD_GetText} $hCtl_FtpProfile_TB_LclConDir $LclConDir

WriteINIStr "$Temp\DosB\FTP" "Profiles" "ProfileName$ndx_num" $ProfileName
WriteINIStr "$Temp\DosB\FTP" "Profiles" "LclPSDir$ndx_num" $LclPSDir
WriteINIStr "$Temp\DosB\FTP" "Profiles" "RmtPSDir$ndx_num" $RmtPSDir
WriteINIStr "$Temp\DosB\FTP" "Profiles" "LclConDir$ndx_num" $LclConDir
FunctionEnd
coderwolf is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump