Archive: ReadINIStr Question


ReadINIStr Question
the ReadINIStr is used as followed.

ReadINIStr user_var(output) ini_filename section_name entry_name


is there a possibility to set a wildcard for section_name? maybe i describe my problem. my .ini looks like this

[section_name 1]
entry_name=FirstName

[section_name 2]
entry_name=SecondName


two entry_name will never have the same value. to avoid my installer using a already existing value i want to use the ReadINIStr command to check if the entry_name exists. but i it to do this for all section_names and i cant specify all of them, since there can be limitless sections.

Well..
Haven't actually looked through that portion of the NSIS source, but I'm going on the assumption they are passing things along to ReadPrivateProfileTYPE and WritePrivateProfileTYPE. You need to specify a section name, so NSIS would basically have to do the same thing you are doing. I'd think your best bet would be to use the file reading functions. You know that each section is [SectionX], so read for "\n[", read the name, and keep track of them all as you go along. That would probably be the way I would handle it, but haven't really thought too long about your problem.


Use this, and add some additional commands like FileOpen and initiating of parameters...

;$R7 is your name you want to implement.
loop:
FileRead $0 $1
StrCmp $1 "" ExitLoop
StrLen $2 $R7
StrCpy $1 $1 $2
StrCmp $1 $R7 0 loop
MessageBox MB_OK "EntryName $R7 Exists!"
return
ExitLoop:
FileClose $0

But you can also find this in your inbox.

-Hendri.