Jump to content
Sign in to follow this  
OmYcroN

Array size

Recommended Posts

OmYcroN

Hi. I'm using IniReadSection() to read some data and i have 440 values in the ini file. The returning array shows me only 435. What it's happening? It's the max size for the returning array ?

Share this post


Link to post
Share on other sites
Mat

Only the first 32767 chars are taken in account in an section due to Win9x compatibility.

Is that it? How big is the file? if its smaller than 30kb then ignore me.

MDiesel

Edited by mdiesel

Share this post


Link to post
Share on other sites
OmYcroN

Is that it? How big is the file? if its smaller than 30kb then ignore me.

MDiesel

And if i want to "brake" that compatibility ?

Share this post


Link to post
Share on other sites
Mat

umm...

Split up the file into seperate sections, 2 sections of 200 should do. I you don't want to do that then...

Write your own function! Shouldn't be too hard:

For $i = 1 to FileGetLines ($sIni)
If StringLeft (FileReadLine ($i), 1) = "[" Then; is key
    $Start = $i
    ExitLoop
EndIf
Next
If $Start = "" Then Return SetError (1, 0, 0)
For $i = $Start + 1 To FileGetLines ($sIni)
If StringLeft (FileReadLine ($i), 1) = "[" Then; is key
    $End = $i
    ExitLoop
EndIf
Next
If $End = "" Then $End =  FileGetLines ($sIni)
For $i = $Start + 1 To $End - 1
$Line = Filereadline ($i)
$Split = StringSplit ($line, "=")
If $Split[0] <> 2 then Return SetError (1, 0, 0)
;;;;
Next

basic code, and untested, but you get the idea.

Edited by mdiesel

Share this post


Link to post
Share on other sites
Richard Robertson

The problem is that AutoIt currently uses the Windows API for reading INI files. Windows has that limitation.

Share this post


Link to post
Share on other sites
OmYcroN

umm...

Split up the file into seperate sections, 2 sections of 200 should do. I you don't want to do that then...

Write your own function! Shouldn't be too hard:

For $i = 1 to FileGetLines ($sIni)
If StringLeft (FileReadLine ($i), 1) = "[" Then; is key
    $Start = $i
    ExitLoop
EndIf
Next
For $i = $Start + 1 To FileGetLines ($sIni)
If StringLeft (FileReadLine ($i), 1) = "[" Then; is key
    $End = $i
    ExitLoop
EndIf
Next
For $i = $Start + 1 To $End - 1
$Line = Filereadline ($i)
$Split = StringSplit ($line, "=")
If $Split[0] <> 2 then Return SetError (1, 0, 0)
;;;;
Next

basic code, and untested, but you get the idea.

So it's 32767 chars per section ? Or per file ?

Share this post


Link to post
Share on other sites
Richard Robertson

Per file.

Share this post


Link to post
Share on other sites
Mat

So it's 32767 chars per section ? Or per file ?

I don't know, I just happened to be doing this today (messing around with ini's) and I saw the limit. When you posted, I replied with an answer. I am presuming its section though, try it, if it works then it works! There you go then!

@Rich

Do you have a link to the page where it gives the commands? I can only find stuff on fmapi's, which is not right.

MDiesel

Edited by mdiesel

Share this post


Link to post
Share on other sites
OmYcroN

The problem is that AutoIt currently uses the Windows API for reading INI files. Windows has that limitation.

I see ... Thanks for this info.

Share this post


Link to post
Share on other sites
Richard Robertson

Do you mean the native INI reading? I can look.

Share this post


Link to post
Share on other sites
OmYcroN

Do you mean the native INI reading? I can look.

I understand that inireadsection() reads a max of 32767 chars.

So i use n sections for n * 32767 chars. Right ?

Share this post


Link to post
Share on other sites
Richard Robertson

http://msdn.microsoft.com/en-us/library/ms724353(VS.85).aspx

This function, GetPrivateProfileString, is probably it. I assume that since it hasn't been rewritten to avoid this limit, that it still uses this.

It doesn't say anything about the limit other than saying that it was kept for 16 bit app compatibility. 16 bit addresses could only address 65535 locations, and half of that minus one is 32767 (two's compliment). That's my guess..?

Edited by Richard Robertson

Share this post


Link to post
Share on other sites
Inverted

You could be a little more economical with the variable names to stay under the character limit, or get rid of comments/spaces/unused stuff. If it's your ini of course :-D

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.