Jump to content

IniReadSection: Problem with big INI file

Recommended Posts


==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.

Global $INIFile = @ScriptDir & '\IniCheck.ini'
Global $NumKEY = 5000
Global $randomDataLen = 10

FileWriteLine($INIFile, '[Ciao]')
For $i = 1 To $NumKEY
    FileWriteLine($INIFile, "Aloha[" & $i & ']=' & danRom($randomDataLen))
;~      If (FileGetSize($INIFile) / 1024) >= 64 Then
;~          ExitLoop
;~      EndIf
Local $i, $aArray = IniReadSection($INIFile, 'Ciao')
ConsoleWrite('Section Read Test:' & $aArray[$NumKEY][0] & "=" & $aArray[$NumKEY][1] & @CRLF)

;~ For $i = 1 To $aArray[0][0]
;~    ConsoleWrite('Section Read Test:'& $aArray[$i][0] &"=" & $aArray[$i][1] &@CRLF)
;~ Next

Func danRom($digits = 15)
    Local $pwd = ""
    Dim $aSpace[3]
    For $i = 1 To $digits
        $aSpace[0] = Chr(Random(65, 90, 1)) ;A-Z
        $aSpace[1] = Chr(Random(97, 122, 1)) ;a-z
        $aSpace[2] = Chr(Random(48, 57, 1)) ;0-9
        $pwd &= $aSpace[Random(0, 2, 1)]
    Return $pwd
EndFunc   ;==>danRom

What IniReadSection limit ?



Share this post

Link to post
Share on other sites


Windows limits the size of any section to 32k - when I run your code I only get 1472 elements filled when I run IniReadSection. You will need to write your own function or change the whole script to read the data another way. :(>

And your code to fill the ini file is horribly inefficient as you are opening and closing the file each time you write a line. It would be much better to do something like this: ;)

; Start the data with the section name
$sData = '[Ciao]' & @CRLF
For $i = 1 To $NumKEY
    ; Add the lines one at a time
    $sData &= "Aloha[" & $i & ']=' & danRom($randomDataLen) & @CRLF
 Remove final @CRLF
$sData = StringTrimRight($sData, 2)

; And write the whole thing in one go
FileWrite($INIFile, $sData)
  • Like 1

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______Open Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites


  • Like 1

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

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