Page 1 of 1 1
Topic Options
#141152 - 2005-06-07 04:52 PM ReadProfileString limitations?
YaleCoder Offline
Getting the hang of it

Registered: 2001-12-18
Posts: 61
Loc: Jelenia Gora, Poland
Are there limitiations on the number of sections (or size of the array) that ReadProfileString can process? I am reading a huge file, almost 8500 sections, and I get an error that the expression when the code reaches
$fSectList = ReadProfileString($fSrcFile, $fSectName, '').

If I try to read a shorter file, the codeworks fine. I am using Kix 4.22 and the ini file I am trying to read is here http://castlecops.com/startuplist.php

Thanks
_________________________
"When fascism comes to America, it will be wrapped in the flag, carrying a cross."
Sinclair Lewis

Top
#141153 - 2005-06-07 06:19 PM Re: ReadProfileString limitations?
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Is that the actual code? Shouldn't there be two "'s? Looking at that .INI file, maybe it's the special character in the last entry that is messing it up?

Edit: Just notice you are in CT - small world.


Edited by oobnuker (2005-06-07 06:22 PM)
_________________________
-- oobnuker - .KIX hack - no really.

Top
#141154 - 2005-06-07 06:29 PM Re: ReadProfileString limitations?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Just to repeat (in case you missed it) some versions of Windows (Win9x? NT?) are limited by the Windows API to a maximum INI file size. Off the top of my head I cannot remember if it was 32KB or 64KB.

KiXtart has a documented string limit of 32KB. This is very rarely imposed - however it's possible that it is in this case.

What version of Windows / KiXtart are you using?

Top
#141155 - 2005-06-07 06:33 PM Re: ReadProfileString limitations?
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Richard,

You are correct. When Windows 95 was introduced, Microsoft had the limitation of 64kb for INI files. That is why the Registry is so heavily utilized for the OS.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#141156 - 2005-06-07 06:54 PM Re: ReadProfileString limitations?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
oob,
If you copy/paste that line into an editor, you will see that in fact, he uses two single(') quotes.
Code:

$fSectList = ReadProfileString($fSrcFile, $fSectName, '')

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#141157 - 2005-06-07 07:28 PM Re: ReadProfileString limitations?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
he just copied the line from enumini(), the simplest one.

what he is doing is same as:
Code:

$myfile="c:\myini.ini"
$returnValue = ReadProfileString($myfile, "", "")

_________________________
!

download KiXnet

Top
#141158 - 2005-06-07 08:29 PM Re: ReadProfileString limitations?
YaleCoder Offline
Getting the hang of it

Registered: 2001-12-18
Posts: 61
Loc: Jelenia Gora, Poland
Thanks all. I guess I'll have to break the file apart into smaller chunks.

'Tis a small world oob. Had the bike out over the weekend and rode through your town.
_________________________
"When fascism comes to America, it will be wrapped in the flag, carrying a cross."
Sinclair Lewis

Top
#141159 - 2005-06-07 10:50 PM Re: ReadProfileString limitations?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
not really...
first you need to determine is that the reason or is there some problem with the ini.
_________________________
!

download KiXnet

Top
#141160 - 2005-06-08 12:57 AM Re: ReadProfileString limitations?
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
Or......change to other format like XML, still green but as I have seen it can deal with that amount of size.
Just suggesting.
_________________________
Life is fine.

Top
#141161 - 2005-06-08 01:15 AM Re: ReadProfileString limitations?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
lol, sure can ini's too.
_________________________
!

download KiXnet

Top
#141162 - 2005-06-08 03:02 AM Re: ReadProfileString limitations?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Well, so far I've not been able to find any Microsoft whitepaper saying if there is still a 64KB limit on the .INI file or not. I know that in the past this limit did exist, but perhaps not since the dawn of NT.

If that limit exists then yeah there is a problem with that STARTUP list.

2.7MB file size.
  • 2,720,590 StartupList.ini

Top
#141163 - 2005-06-08 03:46 AM Re: ReadProfileString limitations?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, as far as I remember the old discussions, this limit is not there anymore but there can be an limit somewhere upwards the road...
anyways, if readprofilestring gets non-working, one can always write udf for it.
_________________________
!

download KiXnet

Top
#141164 - 2005-06-08 03:56 AM Re: ReadProfileString limitations?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Well so far in my testing once you get close to around 725K the ReadProfileString errors out.

I'll leave it up to others to do further testing. I've got other work to complete right now.
 

Top
#141165 - 2005-06-08 04:10 AM Re: ReadProfileString limitations?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ja, and I did some testing.

BOYS,
I FOUND THE 32000 CHARACTER STRING LIMIT THINGIE!

maximum length for section headers combined is 31998.
no matter how big or small the ini is, if your header names are too long, you get in trouble.

to make sure, I did some variations of ini size and header styles and etc, but it always came with largest possible:
len(readprofilestring(@scriptdir+"\a.ini","",""))

being 31998. 31999 errors out.
_________________________
!

download KiXnet

Top
#141166 - 2005-06-08 10:32 AM Re: ReadProfileString limitations?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Thanks for the further testing Lonk.

Not that one often has such a use but wonder if similar issue might be encountered in the XML UDF scripts

 

Top
#141167 - 2005-06-08 10:39 AM Re: ReadProfileString limitations?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
UDF to enumerate huge ini files.

Note, your will want to use native ReadProfileString() to read the entries in individual sections (unless they are also huge) as the process gets slower towards the end of the file.

Code:
Break ON
$=SetOption("Explicit","ON")

Dim $sIni,$sSections,$sEntries,$sSection,$sEntry

$sIni=".\hugeini.ini"

$sSections=udfEnumHugeIni($sIni)
If @ERROR "["+@ERROR+"] "+@SERROR+@CRLF EndIf

For Each $sSection In Split($sSections,Chr(10))
"SECTION: "+$sSection+@CRLF

$sEntries=udfEnumHugeIni($sINI,$sSection)
If @ERROR "["+@ERROR+"] "+@SERROR+@CRLF EndIf

For Each $sEntry in Split($sEntries,Chr(10))
" ENTRY: "+$sEntry+@CRLF
Next
Next

Exit 0

Function udfEnumHugeIni($sPath,Optional $sSection)
Dim $fhIni,$sLine,$iSectionFlag,$sKey,$iExitFlag

$udfEnumHugeIni=""
$iExitFlag=0

$fhIni=FreeFileHandle()
If @ERROR Exit @ERROR EndIF

If Open($fhIni,$sPath) Exit @ERROR EndIf

$sLine=ReadLine($fhIni)
While Not @ERROR AND $iExitFlag=0
$sLine=Trim($sLine)
$sKey=""
If $sLine<>""
If Left($sLine,1)="["
If $iSectionFlag
$iExitFlag=1
Else
$iSectionFlag=0
If $sSection="" $sKey=SubStr($sLine,2,InStr($sline+"]","]")-2) EndIf
If $sLine="["+$sSection+"]" $iSectionFlag=1 $sSection=" " EndIf
EndIf
Else
If $iSectionFlag AND Left($sLine,1)<>";" $sKey=Left($sLine,InStr($sLine+"=","=")-1) EndIf
EndIf
EndIf
If $sKey<>"" $udfEnumHugeIni=$udfEnumHugeIni+$sKey+Chr(10) EndIf
$sLine=ReadLine($fhIni)
Loop

$iExitFlag=Close($fhINI)
Exit 0
EndFunction


Top
#141168 - 2005-06-08 10:47 AM Re: ReadProfileString limitations?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Thanks Richard for the code... but onl reads sections

How would one use this to read both SECTIONS and real KEY data?

Sorry, maybe it already does and it's just too late and I'm too tired to see it.

 
Sample output was:
Quote:

SECTION: BitDefender Scan Server
ENTRY: Confirmed
ENTRY: Filename
ENTRY: Description
ENTRY: Source
ENTRY:
SECTION: BitDefender Virus Shield
ENTRY: Confirmed
ENTRY: Filename
ENTRY: Description
ENTRY: Source
ENTRY:
SECTION: bitdefenderlive
ENTRY: Confirmed
ENTRY: Filename
ENTRY: Description
ENTRY: Source
ENTRY:
SECTION: BitDefender_P2P_Startup
ENTRY: Confirmed
ENTRY: Filename
ENTRY: Description
ENTRY: Source
ENTRY:



Top
#141169 - 2005-06-08 01:23 PM Re: ReadProfileString limitations?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

Thanks Richard for the code... but onl reads sections

How would one use this to read both SECTIONS and real KEY data




Well this is just for enumerating the sections (and entry keys) where they might exceed the 32KB limit.

Once you have the section and/or key you would use the stock ReadProfileString() to read it.

To re-iterate my comments in the last post, unless your section is likely to contain more than 32KB of entry names, it is better to use ReadProfileString() to enumerate the entries once you've used udfEnumHugeIni() to get the section names.

For example:
Code:
Break ON
$=SetOption("Explicit","ON")

Dim $sIni,$sSections,$sEntries,$sSection,$sEntry

$sIni=".\hugeini.ini"

$sSections=udfEnumHugeIni($sIni)
If @ERROR "["+@ERROR+"] "+@SERROR+@CRLF EndIf

For Each $sSection In Split($sSections,Chr(10))
"SECTION: "+$sSection+@CRLF

$sEntries=udfEnumHugeIni($sINI,$sSection)
If @ERROR "["+@ERROR+"] "+@SERROR+@CRLF EndIf

For Each $sEntry in Split($sEntries,Chr(10))
" ENTRY: "+$sEntry+@CRLF
" Data: "+ReadProfileString($sINI,$sSection,$sEntry)+@CRLF
Next
Next

Exit 0


Top
#141170 - 2005-06-08 02:04 PM Re: ReadProfileString limitations?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
richie, can you post in the other forum too?
if not every day used, it's good have it around still.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 837 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.135 seconds in which 0.066 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org