Jump to content

IniReadSectionNames problems


Recommended Posts

Hi,

For my program i am using a few ini files to gather data. There are 3 sections (Ethernet Patches, Phone and some numbers)

Section 1:

- This one has got 35 seperate ini files (for every switch we have, 1 inifile)

- This one loads FINE. Maximum number of entries is 300 so thats not a problem

- Size is around 1 to 5kB, so not a problem

Section 2:

- This one has got 1 big file of 181kB, 1009 entries (the [...] ones)

- This one loads fine (even if its biger then 64kB)

Section 3:

- This one has got one big file of 52 kB, around 550 entries.

- Loads fine.

But now i am using an extra script for Section 2, apart from the one i already use. This is a file with a large number of entries, more then 6000 to be precise. This file is 100kB in size.

I use IniReadSectionNames to fill an array. The problem is this array/inilist doesn't have all the entries in my .ini file! It just stops at a point, after ~ 2300 entries.

The structure of this INI file is not that complex, for example:

[AA-BB-CC-AA]

Test=1

[AA-BB-CC-BB]

Test=0

Is this the 32/64kB issue? If it is, why is section 2 working without any problems? Is there a workaround for it?

Link to comment
Share on other sites

Thanks, i'll look into that.

For the record, my app is only running on XP computers so that shouldn't be any problem..

[edit]

Looked in to it. The code in the thread is not working here, but i just think its strange that my 183kB file loads fine and my 100kB doesn't...

[Edit2]

_IniReadSectionNames seems to work but it takes... 23 seconds to read the whole file.

Edited by Sypher
Link to comment
Share on other sites

Thanks, i'll look into that.

For the record, my app is only running on XP computers so that shouldn't be any problem..

[edit]

Looked in to it. The code in the thread is not working here, but i just think its strange that my 183kB file loads fine and my 100kB doesn't...

It may depend on the amount of Section Names required to be buffered. You may an excess of 32KB of Section Names in your 100KB file.

The 23 seconds would account for all the string handling needed to be done.

Edit:

Removed UDF. Was not Section Names

Edited by MHz
Link to comment
Share on other sites

Here's an example how the file is structured:

[1-2.1-E-11-16]

Kamer=A009

[1-2.1-A-01-01]

Kamer=A010

There are 6924 lines so that means there are 3462 (6924/2) section names.

What if i modify my file to look like something like:

[Numbers]

1-2.1-E-11-16=A009

1-2.1-A-01-01=A010

Would that be better/faster/easier? Edited by Sypher
Link to comment
Share on other sites

  • Moderators

This is as fast as I could get it for larger files:

#include <array.au3>
;#cs
#region Create Test File
FileClose(FileOpen('TestIniReadSectionNames.ini', 2))
While (FileGetSize('TestIniReadSectionNames.ini') / 1024) < 100
    $nCharLen = Random(3, 10, 1)
    $sChar = ''
    For $iCC = 1 To $nCharLen
        $sChar &= Chr(Random(65, 90, 1))
    Next
    FileWrite('TestIniReadSectionNames.ini', '[' & $sChar & ']' & @CRLF)
WEnd
#endregion
;#ce
$nTimer = TimerInit()
$aArray = _IniReadSectionNamesEx('TestIniReadSectionNames.ini');Will return a 0 base array or @error if no section names exist or file couldn't be read
$iDiff = TimerDiff($nTimer)
_ArrayDisplay($aArray, 'Total:' & UBound($aArray))
ConsoleWrite(@LF & 'There are: ' & UBound($aArray) & ' Sections.' & @LF & 'It took: ' & $iDiff / 1000 & ' seconds.')

Func _IniReadSectionNamesEx($hFile)
    Local $aSectionNames = StringRegExp(@CRLF & FileRead($hFile) & @CRLF, '(?s)\n\s*\[(.*?)\]s*\r', 3)
    If IsArray($aSectionNames) Then Return $aSectionNames
    Return SetError(1, 0, '')
EndFunc
It will create a 100kb test file with over 9500 sections... Still takes a while, but not as long as 23 seconds.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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