Skip to content
⌘ NSIS Forum Archive

Writing strings to Non NSIS INI files

17 posts

jimpy22#

Writing strings to Non NSIS INI files

Hi, can someone tell me how to write a user input string requested from a text box during installation into one of my own .ini files (ie not a NSIS .ini file?)

Thank you in anticipation
jimpy22#
Thanks for your reply. I have been reading documentation and forums for 3 hours now and am just very confused.

My file ia touch.ini:

[Software Title]
-------------------- Browser System Variables -------------------------------

--[Address Settings]
BrwDefaultAddress=http://IP:77/config_ip.asp?Where=RegX
BrwReportAddress=

--[System Settings]
SystemKeys=ON
SysDeskTop=ON

BrowserDiagMode=OFF
BrowserKioksMode=OFF
BrowserControlBar=ON

etc etc etc etc

I want to take an IP address that the user puts into a text box in the installer during installation and write it into the 'IP' bit of this line above BrwDefaultAddress=http://IP:77/config_ip.asp?Where=RegX.

And then put a value into 'X' in the same line above.

Can any one give me the code to do that - I have just ended up going around and around in circles for hours!!! Thanks.
Anders#
it would be easier to first get the text from the textbox
then build the whole url with a couple of StrCpy's
then write the whole line to the .ini file
jimpy22#
I don't even seem to be able to hold on to the text string entered during the installation to be able to re-write the whole line and then replace it in the touch.ini file???
deguix#
ReadINIStr $0 "Page.ini" "Field #" "State" ;"IP" value as you said
StrCpy $1 "X" ;"X" value as you said
WriteINIStr "Touch.ini" "Address Settings" "BrwDefaultAddress" \
"http://$0:77/config_ip.asp?Where=Reg$1"
Replace "Page.ini" with your page INI file, "#" with the number of the "Field" of the textbox that gets the IP.

[EDIT] Ops! Fixed code. [/EDIT]
Afrow UK#
Using an InstallOptions dialogue, the user will enter the data into the necessary fields. He click's next, and his data will be saved into the InstallOptions INI dialogue file. You can then use ReadINIStr $R0 "IOfile.ini" "Field X" "State" to retrieve the data.
Then use WriteINIStr "touch.ini" "Address Settings" "http://IP:$R0/config_ip.asp?Where=RegX"

-Stu
jimpy22#
I put:
ReadINIStr $0 "ioA.ini" "Field 2" "State" ;"IP" value as you said
ReadINIStr $1 "ioA.ini" "Field 4" "State" ;"X" value as you said
WriteINIStr "$INSTDIR\PAERS Registration system\iTouch_BR.ini" "Address Settings" "BrwDefaultAddress" "http://$0:77/config_ip.asp?Where=Reg$1"


In the main section. After I ran the install the touch.ini file looked like this:

[Software Title]

-------------------- Browser System Variables -------------------------------

--[Address Settings]
BrwDefaultAddress=
--http://192.134.0.122:77/config_ip.asp?Where=Reg1
BrwReportAddress=

--[System Settings]
SystemKeys=ON
SysDeskTop=ON

BrowserDiagMode=OFF
BrowserKioksMode=OFF
BrowserControlBar=ON
BrowserBiometrics=ON
BrowserNeedsFapi=YES

BrowserReportEvents=OFF

--[System Livery]
BrowserTitle=PAERS Registration
BrowserLogo=
BrowserBackground=
BrowserPosTop=84
BrowserPosLeft=112
BrowserSizeWidth=600
BrowserSizeHeight=450

[Address Settings]
BrwDefaultAddress=http://:77/config_ip.asp?Where=Reg


It added the string at the end and did not have the user entered values? What am I doing wrong? (Thanks for the help so far)
deguix#
Are you copying the page to the $PLUGINSDIR before and showing the page from there? Are you using MUI (Modern User Interface)?
deguix#
Oh yeah, that's because you're using Modern UI. Instead of using ReadINIStr you should use "!insertmacro MUI_INSTALLOPTIONS_READ".
jimpy22#
OK - so have changed it to:

---------------------------------
!insertmacro MUI_INSTALLOPTIONS_READ $0 "ioA.ini" "Field 2" "State" ;"IP" value as you said
!insertmacro MUI_INSTALLOPTIONS_READ $1 "ioA.ini" "Field 4" "State" ;"X" value as you said
WriteINIStr "$INSTDIR\PAERS Registration system\iTouch_BR.ini" "Address Settings" "BrwDefaultAddress" "http://$0:77/config_ip.asp?Where=Reg$1"
--------------------------------------


As suggested but I still get the following written in to my touch.ini file (ie adds lines at end instead of adding value to brwdefaultaddress and does not enter the values entered by user?

---------------------------------------------
[Software Title]

-------------------- Browser System Variables -------------------------------

--[Address Settings]
BrwDefaultAddress=
--http://192.12.0.22:77/config_ip.asp?Where=Reg1
BrwReportAddress=

--[System Settings]
SystemKeys=ON
SysDeskTop=ON

BrowserDiagMode=OFF
BrowserKioksMode=OFF
BrowserControlBar=ON
BrowserBiometrics=ON
BrowserNeedsFapi=YES

BrowserReportEvents=OFF

--[System Livery]
BrowserTitle=PAERS Registration
BrowserLogo=
BrowserBackground=
BrowserPosTop=84
BrowserPosLeft=112
BrowserSizeWidth=600
BrowserSizeHeight=450

[Address Settings]
BrwDefaultAddress=http://:77/config_ip.asp?Where=Reg

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


What is the other thing you said to do?

Thanks
Afrow UK#
Have you tried removing the -- from in front of all your section headings (in iTouch_BR.ini)?

-Stu
deguix#
!insertmacro MUI_PAGE_INSTFILES
Page custom CustomPageA
You did put that code I said to you in a Section. This happens before you get to the page, so there will ever be an empty string. To solve this just put that code after you show "ioA.ini" (which is in the Function CustomPageA).