I suggest IniReadSection,<Filename>,<Section>,<%variable%>
IniReadSection does not fully support .ini files that have same sections.Only First from top read by PEBakery.
IniReadSection implemented in Build 20171225.Please note IniReadSection is designed solely for debugging, so it will return values in a human-readable form, not in a code-friendly form.
[*If IniReadSection is the way:Keep in mind:For now not required support for .ini files that have same named sections (I remember ms and some 3rd party have such .ini files in the past ....)So for now,when adding to help document,write info about .ini files having same named sections, and which one IniReadSection will read (first from top, first from bottom)ex:QuoteIniReadSection does not fully support .ini files that have same sections.Only First from top read by PEBakery.Support can be added much later when we have real life example.
5. [New] INIReadSectionSee the manual in GitHub.
Tip: Copy you can hit [Select] link on current post "Code: [Select]" and CTRL+C
As for IniRead and IniDelete, I would expect that PEBakery should consider duplicate sections a syntax/validation error, as that could cause multiple problems (ie. if I can Run,%ScriptFile%,mySection which section should be called?) I see allowing duplicate sections as a good way to cause headaches and unintended behavior.
This currently isn't the case and IniReadSection/IniDeleteSection grab the first section they see.
So if I call IniDeleteSection in one plugin, then test for that section in another plugin and there was a duplicate that got read, I would get the wrong data instead of no data. Granted this is an extreme case, and duplicate sections should be very rare if they do exist. Do you have any examples of non-standard .ini files using duplicate sections, where this is an issue?
Edit:As long asIniReadSectionIniDeleteSectionbehaviour is same for same sectioned .ini files (preferred first) all fine.
Continue with current behavior and only process/delete the first occurrence of a section, ignoring other sections with the same name.
Continue with the current behavior and only process/delete the first occurrence of a section, and add a warning in the log that other sections exist.
Modify the behavior of PEBakery and only process/delete the last occurrence of a section.
(preferred first)
Modify the behavior of PEBakery and only process/delete the last occurrence of a section , and add a warning in the log that other sections exist.
Modify the behavior of PEBakery and read (merge) duplicate sections as one section, with duplicate keys from the last occurrence of a section overwriting earlier occurrences. If IniDeleteX is used delete all occurrences of the section or key.
Something else.
well, I defiantly agree the behavior needs to be clarified and documented.
if someone else/needs expects multiple sections to be handled in a different way?
we should make sure the current PEBakery behavior is the way we want things to actually be handled for the good of everyone for years to come. (not changing things and breaking compatibility every other build like the old days) Then the code and/or documentation can be updated accordingly.
What do you see as the most desirable behavior considering that there is no formal standard for the .ini specification?Do we want PEBakery to:Continue with current behavior and only process/delete the first occurrence of a section, ignoring other sections with the same name.Continue with the current behavior and only process/delete the first occurrence of a section, and add a warning in the log that other sections exist.Modify the behavior of PEBakery and only process/delete the last occurrence of a section.Modify the behavior of PEBakery and only process/delete the last occurrence of a section , and add a warning in the log that other sections exist.Modify the behavior of PEBakery and read (merge) duplicate sections as one section, with duplicate keys from the last occurrence of a section overwriting earlier occurrences. If IniDeleteX is used delete all occurrences of the section or key.Something else.
I vote for option 1....My opinion is to follow WinAPI (WriteProfileString, GetProfileString) behavior.
PEBakery's ini file manipulation is a bottleneck of File IO and already is slow. Adding more checks will result much slower IO.My opinion is to follow WinAPI (WriteProfileString, GetProfileString) behavior.Many programs are still dependent on those APIs, so syncing behavior with other programs is better.
Hi ied206,Quote from: Lancelot on December 21, 2017, 10:14:22 PM*If IniReadSection is the way:Keep in mind:For now not required support for .ini files that have same named sections (I remember ms and some 3rd party have such .ini files in the past ....)So for now,when adding to help document,write info about .ini files having same named sections, and which one IniReadSection will read (first from top, first from bottom)ex:QuoteIniReadSection does not fully support .ini files that have same sections.Only First from top read by PEBakery.Support can be added much later when we have real life example. Quote from: ied206 on December 24, 2017, 05:14:52 PM5. [New] INIReadSectionSee the manual in GitHub.can you write help document:-->1)IniReadSection reads first (or last ? ) section from topex:IniReadSection,%SrcFile%,Test,%Dest%%SrcFile%[Test]1=One2=Two3=Three[Test]1=Un2=Dos3=Tres// IniReadSection will return these lines into %Dest%.[Test]1=One2=Two3=Three*2)Also when there is no such section behaviour of PEBakeryex:IniReadSection,%SrcFile%,TestNo,%Dest%If,%Dest%,Equal,#$pDest#$p,Echo,"No Section found"*3)also IniDeleteSection delete first (or last) section inside ini file.https://github.com/ied206/PEBakery/blob/master/Manual/Commands/04_Ini/IniDeleteSection.mdIniDeleteSection,%SrcFile%,Test,%Dest%%SrcFile%Code: [Select][Test]1=One2=Two3=Three[Test]1=Un2=Dos3=Tres// IniDeleteSection will delete first section%SrcFile%Code: [Select][Test]1=Un2=Dos3=Tresps:It will be good to have examples on help documentsex:https://www.autoitscript.com/autoit3/docs/functions/IniRead.htmeven much better when one can copy paste examples easilyex:Reply 184 http://theoven.org/index.php?topic=2271.msg25271#msg25271Quote from: Lancelot on December 22, 2017, 07:09:01 PM Tip: Copy you can hit [Select] link on current post "Code: [Select]" and CTRL+CEdit:As long asIniReadSectionIniDeleteSectionbehaviour is same for same sectioned .ini files (preferred first) all fine.
*If IniReadSection is the way:Keep in mind:For now not required support for .ini files that have same named sections (I remember ms and some 3rd party have such .ini files in the past ....)So for now,when adding to help document,write info about .ini files having same named sections, and which one IniReadSection will read (first from top, first from bottom)ex:QuoteIniReadSection does not fully support .ini files that have same sections.Only First from top read by PEBakery.Support can be added much later when we have real life example.