Archive: How to get text box output via installoptions


How to get text box output via installoptions
Hi,
I'm adding an option to my installer for the user to enter a license key, and the installer than posts some details to my server and download an encrypted license file. I've got this latter part working OK when I hard-code the initial license key.

The area I'm having problems is getting the user input.

Here's my code:


# Ask for license registration details
Function CheckLicenseShow
!insertmacro MUI_HEADER_TEXT "Enter License Key" "Enter the license key mailed to you when you purchased the software."
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "CheckLicenseShow"

FunctionEnd

## Validate license
Function CheckLicenseLeave
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "getlicense.ini" "Field 1" "State"

StrCmp $R0 '' GotLicense NoLicense
Abort
NoLicense:
; Box is checked, so enable the next button:
MessageBox MB_OK "Please enter your license key"
Abort
GotLicense:
; Get the license
MessageBox MB_OK "Got license: $R0"
Exit:
; user pressed 'next' so exit!

!insertmacro MUI_HEADER_TEXT "Getting License File" "Please wait whilst your license key is verified and the license file downloaded."

; Code to download license file goes here
FunctionEnd

When I don't enter a license key,and just press "Next", I get no message box, and do NOT go to the next page.

If I do enter a license key, I get "Got License: " in the pop-up box, no actual key. And then I DO go onto the next page.

Any ideas why $R0 is not populated with the contents of the text box.

Also, I've set up the ini file as follows:


; Ini file generated by the HM NIS Edit IO designer.
[Settings]
NumFields=2

[Field 1]
Type=Text
Left=113
Right=236
Top=16
Bottom=28
MinLen=1
Flags=WANTRETURN
ValidateText=Please enter your license key.

[Field 2]
Type=Label
Text=Insert your license key from your emailed purchase receipt
Left=8
Right=112
Top=14
Bottom=33


But I don't even get the "Please enter your license key" validation text.

Any ideas?

Andy

StrCmp $R0 '' GotLicense NoLicense ->

StrCmp $R0 '' NoLicense GotLicense

Also remove the exit: label while you're not actually use it.


Thanks Red Wine.
That helped, but I still couldn't get the value. However, a few hours later I've gotten there.

I was calling the .ini as


Function .onInit
!insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "getlicense.ini" "CheckLicenseShow"
FunctionEnd

And then had


Function CheckLicenseShow
!insertmacro MUI_HEADER_TEXT "Enter License Key" "Enter the license key mailed to you when you purchased the software."
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "getlicense.ini"

FunctionEnd


Some confusion over the CheckLicenseShow I think.

I now have
Function .onInit
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "getlicense.ini"
FunctionEnd

and

Function CheckLicenseShow
!insertmacro MUI_HEADER_TEXT "Enter License Key" "Enter the license key mailed to you when you purchased the software."
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "getlicense.ini"

FunctionEnd


and it works perfectly.

Andy