Old 22nd December 2006, 09:28   #1
automateyourbiz
Junior Member
 
Join Date: Dec 2006
Posts: 2
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:
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:

code:

; 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
automateyourbiz is offline   Reply With Quote
Old 22nd December 2006, 10:27   #2
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
StrCmp $R0 '' GotLicense NoLicense ->

StrCmp $R0 '' NoLicense GotLicense

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

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 22nd December 2006, 13:22   #3
automateyourbiz
Junior Member
 
Join Date: Dec 2006
Posts: 2
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

code:

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


And then had

code:

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
code:
Function .onInit
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "getlicense.ini"
FunctionEnd


and
code:

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
automateyourbiz 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