Archive: CustomPage with input from "type=text"


CustomPage with input from "type=text"
  Again me -

After successfully working with 'RadioButtons' and 'CheckBoxes' on CustomPages, I need some help on 'Type=text'

What I am looking for is a description on how the input is written down e.g.

[Field n] 
Type=text
Left=...
Right=...
Top=...
Bottom=...
State=123


The value from the 'state' (I take this as default value and as an example for users, if they don't know what they should type) should be written down to a file with the good old search and replace-function. So the 'state' value should replace a placeholder in a ascii-file.

The other question is:
There must be a value given back, even when the user clears the input.
(see attached image). How can this be achieved?

Thx in advance
Chris

Originally posted by Mosestycoon
There must be a value given back, even when the user clears the input. How can this be achieved?

Thx in advance
Chris
Use:

;Read the old value


>!insertmacro MUI_INSTALLOPTIONS_READ $0 "inifile.ini" "Field #" "State"

>;Show the page

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

>;Read the new value

>!insertmacro MUI_INSTALLOPTIONS_READ $1 "inifile.ini" "Field #" "State"

>StrCmp $1 "" 0 End

;If the user delete the state, write the old value...
!insertmacro MUI_INSTALLOPTIONS_WRITE "inifile.ini" "Field #" "State" "$0"

>End:

I'll give it a try deguix

Thx
Chris

P.S.: I won't reply for now, because its 1:10 am and I'll go to bed. (Even cigaretts don't make me fit anymore and I feel like :igor: )
So tomorrow (or better said in a few hours) I'll give it a try and post the result.


In the NSIS Archives there is an article called "Complex validating of InstallOptions user input" which shows how to access data entered by the user.

The article can be found at
http://nsis.sourceforge.net/archive/...instances=0,64

If you want to prevent the user from clearing the text box, you could use MinLen and ValidateText in the INI file (see the InstallOptions manual for details). If the user clears all the text, InstallOptions will display a message box containing the text from ValidateText.


In this case not Pengyou, he wants to return the default value (the old state of the control) if the user delete the value and click next >.


That's right deguix.

First time the user reaches the CustomPage, several 'default' values are given. The user can accept these values (in this case the 'default' values are given back and written to an ascii-file).
If the user enters some other values, the new ones should be written to that file. If the user deletes one (or even more) the default values should be written.

Chris


You don't need to use search & replace, use the MUI_INSTALLOPTIONS_WRITE macro.


Joost -

"Ich verstehe im Moment nur Bahnhof!"

So if I get back the value from a "type=text" field how can I replace a default value in an ascii-file?

e.g.:
-----ascii-file-before----

....(more lines before)...

@@ServerName@@

....(more lines behind)...

-------------------
This is the written down value awaiting a new value given back with "type=text". If the user writes www.acme.tld the result should look like this

-----ascii-file-afterwards----

....(more lines before)...

ServerName www.acme.tld

....(more lines behind)...

-------------------

Understood what I mean?
Chris


Never mind, I thought you were talking about an INI file. Just use the search & replace function :D