seadoggie01 Posted December 23, 2019 Share Posted December 23, 2019 On 12/19/2019 at 10:37 PM, Progh0st said: A little faster, using it directly like (seadoggie01) Func MyIniReadSectionNames($Path) $File = FileRead($Path) If Not @error Then $Str = StringRegExp($File, "(?m)^\[{1}([^\[\]]+)\]{1}", 3) If IsArray($Str) Then Return $Str EndIf EndIf EndFunc First, very nice. (Though I'm jelly that you win Ours are very similar though) Second, the {1} after your open/close brackets aren't necessary as 1 character is implied, right? And broadly, are open brackets allowed in the name of a ini section? I assumed not, but I haven't seen anything strictly prohibiting it. All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
argumentum Posted December 23, 2019 Share Posted December 23, 2019 @TheSaint I'm a pain but here I go. If reading the INI section names requires a special, "non build in" solution, it does nothing unless the ini write/read/delete are also in a custom functions, to overcome the 32k limitation. So..., why not code a complete solution ?, why just the section names ?, I'm curious. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
argumentum Posted December 23, 2019 Share Posted December 23, 2019 (edited) 1 hour ago, argumentum said: why not code a complete solution ? I'd test the build in functions. In my tests, there is no 32k limit. Is very possible that the manual is not up to date and the win9x idea is just wrong for the latter releases. Edit: here is the code I used for testing Spoiler expandcollapse popup#include <Debug.au3> ;~ IniReadSectionNamesTEST() Func IniReadSectionNamesTEST() Local $aIniSec = IniReadSectionNames('test.ini') _DebugArrayDisplay($aIniSec) Exit EndFunc ;==>IniReadSectionNamesTEST ;~ IniWriteTEST() Func IniWriteTEST() Local $count = 1048 Local $content = '1234567890abcdef' Local $start = 0 ; write the section header ;~ $hIniFile = FileOpen('test.ini', 2) ;~ If $hIniFile = -1 Then Exit 1 ;~ FileClose($hIniFile) Local $sec = -1, $section = "" Do Sleep(100) ; write key value pairs $hIniFile = FileOpen('test.ini', 1) If $hIniFile = -1 Then ExitLoop For $1 = $start To $count If $sec <> @SEC Then $sec = @SEC $section = @MIN & @SEC & @MSEC FileWrite($hIniFile, '[' & $section & ']' & @CRLF) EndIf FileWrite($hIniFile, $1 & '=' & $content & @CRLF) Next $last = $count + 1 ; use a last key to read from FileWrite($hIniFile, $last & '=' & $content & '&' & $count & @CRLF) FileClose($hIniFile) ; ConsoleWrite($count & ' ' & Round(FileGetSize('test.ini') / 1048, 2) & @CRLF) $start = $last + 1 $count = $start + 1048 Until IniRead('test.ini', $section, $last, 'failed') == 'failed' MsgBox(0, '', $count) Exit EndFunc ;==>IniWriteTEST Edited December 23, 2019 by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Progh0st Posted December 23, 2019 Share Posted December 23, 2019 4 hours ago, seadoggie01 said: First, very nice. (Though I'm jelly that you win Ours are very similar though) Second, the {1} after your open/close brackets aren't necessary as 1 character is implied, right? And broadly, are open brackets allowed in the name of a ini section? I assumed not, but I haven't seen anything strictly prohibiting it. Thanks! The {1} left it for being lazy while testing and I believe the ini section will accept brackets inside itself. Link to comment Share on other sites More sharing options...
TheSaint Posted December 24, 2019 Author Share Posted December 24, 2019 (edited) 4 hours ago, argumentum said: I'd test the build in functions. In my tests, there is no 32k limit. Is very possible that the manual is not up to date and the win9x idea is just wrong for the latter releases. It is indeed still relevant ... at least in my circumstance. I haven't had it impact me yet in my KindEbook Wishlist program, but I must be pretty close, as another companion program, AZWPlug, did refuse to show me recent INI additions. I did a character count to confirm the issue, but more importantly I overcame the issue using FileRead etc. I believe from discussions here some time ago, that the issue is not an AutoIt one, but a Windows limitation. Note though, that I am still mostly using Win7 and Win XP, so perhaps in newer versions of Windows, the limitation has been overcome ... so you might be right? Edited December 24, 2019 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
TheSaint Posted December 24, 2019 Author Share Posted December 24, 2019 (edited) 6 hours ago, Progh0st said: I believe the ini section will accept brackets inside itself. It does indeed ... not too many characters an INI entry won't accept. If I recall right, it is just quotes at the start and end of an INI entry that give grief. I was involved in a discussion here about the quotes some years ago ... probably only in the MVP Chat section though. So compared to XML and SQL, INI is more flexible or forgiving ... though at least with them you can use Escape characters ... other tricks are needed with INI for the quotes. However, INI is more forgiving in the sense the quotes are just stripped, not the whole entry ... and generally I can live with that. Edited December 24, 2019 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
TheSaint Posted December 24, 2019 Author Share Posted December 24, 2019 (edited) 7 hours ago, argumentum said: here is the code I used for testing I tried that, but it went too overboard ... way too many keys per section. Keys are not that relevant to the issue, and neither is file size. Here is my simpler version, which is one key per section. #include <Array.au3> IniWriteTEST_2() Exit Func IniWriteTEST_2() Local $inifle = @ScriptDir & "\Testing_2.ini" Local $file = FileOpen($inifle, 1) If $file <> -1 Then For $i = 1 To 3000 ;IniWrite($inifle, "Section_" & $i, "key", "1234567890abcdef") FileWrite($file, "[Section_" & $i & "]" & @CRLF) FileWrite($file, "key=1234567890abcdef" & @CRLF) ConsoleWrite("Section_" & $i & @CRLF) Next FileClose($file) Local $value = IniRead($inifle, "Section_3000", "key", "") MsgBox(262192, "Last Section", "key = " & $value) Local $sections = IniReadSectionNames($inifle) _ArrayDisplay($sections) MsgBox(262192, "Last Section Name Reported", $sections[0]) ; NOTE - Limit for IniReadSectionNames is 32767 characters. Local $count = StringLen(_ArrayToString($sections, "|", 1)) MsgBox(262192, "Character Count", $count & " characters in Section Names!") EndIf EndFunc ;==>IniWriteTEST_2 Of those 3,000 sections, only the first 2,605 were returned for me in _ArrayDisplay, where the count [0] was also 2,605. This is with Windows 7 32 Bit. So IniReadSectionNames is definitely limited. 32,757 characters was returned, as the next section name would have taken it over the 32,767 limit. File size is 441 Kb. Opening the 'Testing_2.ini' file with SciTE, you can see that all 3,000 sections and keys exist. So it is only that one INI function that appears to be limited. Writing and Reading still work. Edited December 24, 2019 by TheSaint Inpho and argumentum 1 1 Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now