Jump to content

Recommended Posts

Posted
  On 12/20/2019 at 3:37 AM, 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
Expand  

First, very nice. (Though I'm jelly that you win :D 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.

  Reveal hidden contents
Posted

@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.
autoit_scripter_blue_userbar.png

Posted (edited)
  On 12/23/2019 at 9:39 PM, argumentum said:

why not code a complete solution ?

Expand  

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

  Reveal hidden contents

 

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted
  On 12/23/2019 at 6:29 PM, seadoggie01 said:

First, very nice. (Though I'm jelly that you win :D 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.

Expand  

Thanks!

The {1} left it for being lazy while testing and I believe the ini section will accept brackets inside itself.

Posted (edited)
  On 12/23/2019 at 10:22 PM, 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.

Expand  

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 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.

  Reveal hidden contents

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)

userbar.png

Posted (edited)
  On 12/23/2019 at 10:55 PM, Progh0st said:

I believe the ini section will accept brackets inside itself.

Expand  

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 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.

  Reveal hidden contents

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)

userbar.png

Posted (edited)
  On 12/23/2019 at 10:22 PM, argumentum said:

here is the code I used for testing

Expand  

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 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.

  Reveal hidden contents

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)

userbar.png

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...