Archive: Repeat Install Page for user Input


Repeat Install Page for user Input
Hi,

I have searched the forums for a way to repeat a custom page which collects a servername, IP address and MAC address from a user during install without success. I use a 'standard' custom page and ioA.ini file to collect the input in text input boxes.

I write these numbers into a csv file and I want the installer to keep asking the user if they have another set of server details to add into the csv file until they have reached the end. The minimum number of entries will be one server, but there may be multpile. Ideally I would like the installer to detect that the user has put no more details into the servername, IP address and MAC address input boxes and then continue through the installer.

Is this possible? Thanks in anticipation.


in your custom page's Leave function, you could check if the value of the installoptions status is 0 (Next button pressed), write out the data, then pop up a YES_NO messagebox that asks the user if they want to add more data. If they answer 'yes', call Abort (the same page remains displayed) and clear any fields that might need clearing (blank slate). If they answer 'no', simply don't do anything - it will carry on. Checking if the fields are empty as an additional means of carrying on should be straightforward as well.

Alternatively, and this is probably cleaner, add a button on that same form that reads something like "Add another...". In the Leave function, check if that button was pressed, then do much the same as before. This prevents a pop-up messagebox that tends to hinder workflow.

Also, if you expect that a user may enter multiple values, consider whether your target audience may be knowledgeable enough to work with a multi-line text field, entering IP / MAC addresses per-line. This would save a lot of code on your end, and possibly a lot of frustration on the user's end.
( If your target audience requires hand-holding, this may seem too confusing, so it is something you need to give a good bit of thought. )


Sorry for the slow reply to this - have been away for a week or two.

My installer is copied below and it is the custom page B that I want to repeatedly collect the 3 user inputs and write them to the csv file until the user has entered all server details. The user will always enter at least one set of data.

I am trying to add another button called 'Add another machine' to the custom page B, and then call abort if this button is selected. In addition to this if the 'add another button' is slected then I want to write the current set of inputs into the csv before collecting the next set that the user enters.

I have copied my installer so far (I have removed the 'obvious' lines), but am struggling to get further at the moment. Any assitance appreciated to complete the two above steps. Searching through the forums has not helped me so far.

Thanks again.

Start of installer.......................

!include "MUI.nsh"
!include "LogicLib.nsh"


; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
;Page to enter the IP Address of system and Number of Systems, drive to map and biometric enabled
Page custom CustomPageA
;Page to enter the IP Address, MAC address and name of server for WOL feature
Page custom CustomPageB
;Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!insertmacro MUI_PAGE_FINISH
;--------------------------------

; Language files
!insertmacro MUI_LANGUAGE "English"
;--------------------------------


ReserveFile "ioA.ini"
ReserveFile "ioB.ini"
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS


Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "xxx.exe"
InstallDir "$PROGRAMFILES\XXXX"
ShowInstDetails hide

Section "MainSection" SEC01

.....................................................................

.....................................................................
;Read a value from an InstallOptions INI file
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "ioA.ini" "Field 2" "State" ;"IP"
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "ioA.ini" "Field 4" "State" ;"X"
!insertmacro MUI_INSTALLOPTIONS_READ $R2 "ioA.ini" "Field 5" "State" ;for biometrics
!insertmacro MUI_INSTALLOPTIONS_READ $R3 "ioA.ini" "Field 7" "State" ;for drive letter
!insertmacro MUI_INSTALLOPTIONS_READ $R5 "ioB.ini" "Field 2" "State" ;for servername
!insertmacro MUI_INSTALLOPTIONS_READ $R8 "ioB.ini" "Field 4" "State" ;for mac address
!insertmacro MUI_INSTALLOPTIONS_READ $R7 "ioB.ini" "Field 6" "State" ;for ip address

.....................................................................

SectionEnd

Section -Post
.............................................

.............................................
SectionEnd


section -mapped_drive

..............................................

..............................................

sectionend

section -write_csv_file
fileopen $R4 "C:\program files\XXXXX\servermacs.csv" a
filewrite $R4 '$R5,$R8,$R7$\r$\n'
fileclose $R4
sectionend

;Installer Functions

Function .onInit

;Extract InstallOptions INI files
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "ioA.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "ioB.ini"
FunctionEnd

LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Registration System Set Up"
LangString TEXT_IO_SUBTITLE ${LANG_ENGLISH} "This Page will set up your Registration System"

Function CustomPageA

!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "ioA.ini"

FunctionEnd

Function CustomPageB

!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "Please enter description, MAC Address and IP for each kiosk for the wake on LAN feature. (PAERS Server kiosk first)"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "ioB.ini"

FunctionEnd