john123 Posted December 20, 2009 Share Posted December 20, 2009 Hi everyone! I use IniReadSection to read a .ini file. In this file have one section and 1000 key, the number of key return only 537. Example: #include <Array.au3> $section = IniReadSection("c:\test.ini", "backup") msgbox(0,"results", $section[0][0]) test.ini: [backup] key1=xxx key2=yyy ........ key537=hhh key538=ttt ........ key1000=zzz The result I get : 537 key The result only true if number of key < 537, With 538 or higher, to 1000 key, the result still: 537 Please help me get all key in test.ini file, what's problem this? Thank you for your help. Link to comment Share on other sites More sharing options...
danielkza Posted December 20, 2009 Share Posted December 20, 2009 You seem to be hitting the 32767 chars. limit mentioned in the help file. "Only the first 32767 chars are taken in account in an section due to Win9x compatibility." Link to comment Share on other sites More sharing options...
john123 Posted December 20, 2009 Author Share Posted December 20, 2009 Thank you. Have any the way to fix this? Please help me. Thanks so much. Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 20, 2009 Share Posted December 20, 2009 (edited) You seem to be hitting the 32767 chars. limit mentioned in the help file. "Only the first 32767 chars are taken in account in an section due to Win9x compatibility." Hmm... that limitation is not supposed to be valid anymore. AutoIt has dropped Win9x compatibility for full Win32/Win64 APIs. First test (before realizing it didn't exactly duplicate the problem) was creating this INI file (comes out to 341KB): $sINI = @ScriptDir & "\Test.ini" $hINI = FileOpen($sINI, 2) For $s = 0 To 99 FileWriteLine($hINI, "[Section" & $s & "]") For $k = 0 To 99 FileWriteLine($hINI, "Key" & $k & "=This is section " & $s & ", key " & $k & ".") Next Next FileClose($hINI) Read it fine with this: $sINI = @ScriptDir & "\Test.ini" For $s = 0 To 99 $aINI = IniReadSection($sINI, "Section" & $s) ConsoleWrite("Section" & $s & " = " & $aINI[0][0] & @LF) Next That made a big INI file, but not especially big sections, so I redid the file this way (now 369KB) all in one section: $sINI = @ScriptDir & "\Test.ini" $hINI = FileOpen($sINI, 2) FileWriteLine($hINI, "[Section0]") For $k = 0 To 9999 FileWriteLine($hINI, "Key" & $k & "=This is section 0, key " & $k & ".") Next FileClose($hINI) And read it with this: $sINI = @ScriptDir & "\Test.ini" $aINI = IniReadSection($sINI, "Section0") ConsoleWrite("Section0 = " & $aINI[0][0] & @LF) The result should have been 10000 entries, but I got: >Running:(3.3.2.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Program Files\AutoIt3\Scripts\Test_1.au3" Section0 = 942 +>08:36:07 AutoIT3.exe ended.rc:0 So it's OK with huge INI files, just not huge individual sections. Options are to break it into smaller sections (since total file size is not an issue, only section size), recode in some other format (i.e. XML or a flat file), or parse the INI with a custom UDF that doesn't use that IniReadSection() function. P.S. That problem appears to be unique to IniReadSection(). IniRead() can read the entire huge section: $sINI = @ScriptDir & "\Test.ini" $sINI = IniRead($sINI, "Section0", "Key9999", "") ConsoleWrite("Key9999 = " & $sINI & @LF) ; Returns: Key9999 = This is section 0, key 9999. P.P.S. BugTacks on this are being closed: i.e. #1197 and #795 But it appears to be an open feature request that nobody has had time for yet: #15 Edited December 20, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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