blue_harvester
8th May 2006 14:56 UTC
Reading config values in NSIS 2.07 and above?
I am looking to read in values from a configuration file and assign these values to a particular variable. I was having a look at the ConfigRead function here, which can be used for NSIS 2.07 and below. However I'm using v2.16, so I was wondering is there an equivalent function for this later version, or what needs changed in the ConfigRead function to make it compatible with 2.16?
Thanks in advance.
Afrow UK
8th May 2006 15:03 UTC
That would mean that it was tested for v2.07, but that doesn't mean that it doesn't work on v2.16. Have you tried it?
There have been no big changes to the NSIS base code that this function uses. There hardly ever is, so that we can upgrade NSIS and not have to worry about updating our scripts as well.
That said, what does the format of this configuration file look like? This function works without section headers, but for those INI files with section headers, you can use ReadINIStr.
-Stu
blue_harvester
8th May 2006 15:16 UTC
Originally posted by Afrow UK
That would mean that it has tested for v2.07, but that doesn't mean that it doesn't work on v2.16. Have you tried it?
There have been no big changes to the NSIS base code that this function uses. There hardly ever is, so that we can upgrade NSIS and not have to worry about updating our scripts as well.
That said, what does the format of this configuration file look like? This function works without section headers, but for those INI files with section headers, you can use ReadINIStr.
-Stu
The name of the config file is 'services.properties' and the value within the file is a database username as follows:
global.database.username=my_username
Therefore I have the ConfigRead function within my script and I call it like this:
${ConfigRead} "D:\app\services.properties" "global.database.username=" $var_FL_DB_USERNAME
But when I compile the script I get the following error:
Invalid command: ${ConfigRead}
Error in script "D:\projects\Installer\Install.nsi" on line 149 -- aborting creation process
Any ideas?
Afrow UK
8th May 2006 15:18 UTC
Make sure you put the script code above where you call the function in your script.
-Stu
galil
8th May 2006 15:27 UTC
ConfigRead is in TextFunc.nsh, which is in NSIS 2.16.
RTFM "Appendix E: Useful Headers".
blue_harvester
8th May 2006 15:45 UTC
Originally posted by Afrow UK
Make sure you put the script code above where you call the function in your script.
-Stu
Brilliant Stu, that was it! Thank you so much!