Jump to content
Sign in to follow this  

New Line in .ini file

Recommended Posts

How do I read after the last key in an ini and then go to the next line after the key so I can continue writing my ini keys and values. I want it to look like this:







            Share this post
            Link to post

                Share on other sites






















                Sure I'm senile. What's your excuse?





                10,348 posts






            First off your example hows 2 sections 1 which is unused.  I'm thinking that was just a mistake in the post and you were really trying to create a code box.  To create an entry you just do another IniWrite()  Not that if you choose No to the first Msg boxbelow then A new Section and a new Key are created
$Ini= @ScriptDir & "\my.ini"
If FileExists($Ini) Then FileDelete($Ini);; You will not likely be using this line in actual code
IniWrite($Ini, "Section", "Key", "1,2,3")
If MsgBox ( 36, 'TEST', 'Are you ready to create the NewKey entry?') = 6 Then
   IniWrite($Ini, "Section", "NewKey", "4,5,6")
   IniWrite($Ini, "Section2", "ThirdKey", "7,8,9")
   MsgBox ( 64, 'TEST', 'You chose No in the last msgbox so a ThirdKey entry was created in a new section instead.', 2)


Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver: - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post

Link to post
Share on other sites

It will go to the next line all by itself..

But to find the information in the INI you'll need a fiarly simple loop for read sections but to read the whole INI its a little more complex

This is an example of a whole INI being read to a treeview, which I don't think you will really understand

DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)  ;calls the classic theme
#include <guitreeview.au3>
#include <guiconstants.au3>
Global $Skin_bk = 0x00000
Global $Skin_txt = 0x00ffcc
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("To Do", 414, 268, -1, -1, $WS_SIZEBOX, $WS_EX_TOOLWINDOW)
Global $TreeView = GUICtrlCreateTreeView(0, 0, 409, 245)
#EndRegion ### END Koda GUI section ###
Ini_To_Treeview(@ScriptDir & '\TO_DO.ini',$treeview)
For $i = 0 to 20000
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE

    Func Ini_TO_Treeview($ld_val, $Treeview1, $Progress = '0' )
    _GUICtrlTreeViewDeleteAllItems( $TreeView1 )
    GuiCtrlSetState( $Treeview1, $GUI_Show )
    Global $secs = IniReadSectionNames( $ld_val )
    If IsArray( $secs ) Then
    If $progress = '1' then ProgressOn( "Reading INI 2 Treeview", "Working..." )
    $total = $secs[0]
    Dim $a[999]
    For $i = 1 to $secs[0]-1 step 1
        $a[$i] = GUICtrlCreateTreeViewItem( $secs[$i], $TreeView1 )
        _GUICtrlTreeViewSetIcon( $treeview, -1, 'C:\windows\system32\shell32.dll', 165 )
        $b = IniReadSection( $ld_val, $secs[$i] )
        If @error <> 1 Then
        For $c = 1 to $b[0][0] step 1
            GUICtrlCreateTreeViewItem( $b[$c][1], $a[$i] )
            _GUICtrlTreeViewSetIcon( $treeview, -1, 'C:\windows\system32\shell32.dll', 110 )
    If $progress = '1' then ProgressSet( (($i/$total)*100)-1, "Reading INI 2 Treeview", "Placing into a Treeview" )

This will only work in

But if you just want to read a section like all data under [section_name] then you need to look at the help file under IniReadSection PM me if you still have trouble after that

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  

  • Create New...