Jump to content
Sign in to follow this  
hypertyper

Read ini to text box

Recommended Posts

hypertyper

I've tried looking at other peoples code but I still can't get it to work so I hope that someone can fix this. I just want to read the ini into the text box and save from the other into the ini. If I could get this one very basic example to work it would be very helpful. I've got a feeling like my UDF in the while loop isn't the bright way of doing it... I haven't even tried writin the bit where he saves from the other box into the ini. Just realised, having buttons to save and load from the ini would probably be good?!? Ok, I've added the buttons but not done anything with them :/

Thanks a lot!

#include <GUIConstants.au3>
#include <File.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 193, 125)
$readFromIni = GUICtrlCreateEdit("", 80, 96, 153, 241)
GUICtrlSetData(-1, "readFromIni")
$sendToIni = GUICtrlCreateEdit("", 336, 96, 169, 241)
GUICtrlSetData(-1, "sendToIni")
$SButton = GUICtrlCreateButton("Save", 80, 360, 145, 33, 0)
$LButton = GUICtrlCreateButton("Load", 344, 360, 161, 33, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


Dim $seb
$csvFile = "muster.ini"
_FileReadToArray($csvFile, $seb)


While 1
    
    $nMsg = GUIGetMsg()
print()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd



Func print()
    GUICtrlSetData ($readFromIni, $seb)
EndFunc

Share this post


Link to post
Share on other sites
redsleeves

Why not use IniRead() instead of reading your ini into an array?

Share this post


Link to post
Share on other sites
hypertyper

Because I have no idea how stuff works and that's what the one example I have in front of me did. Could you edit my code so it works please? If I have an example that works I can transfer it to everything I'm trying to do. Thanks

Share this post


Link to post
Share on other sites
redsleeves

Try this.

#include <GUIConstants.au3>

Dim $csvFile = "muster.ini"
$Form1 = GUICreate("Form1", 633, 447, 193, 125)
$readFromIni = GUICtrlCreateEdit("", 80, 96, 153, 241)
$sendToIni = GUICtrlCreateEdit("", 336, 96, 169, 241)
$SButton = GUICtrlCreateButton("Save", 80, 360, 145, 33, 0)
$LButton = GUICtrlCreateButton("Load", 344, 360, 161, 33, 0)
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Select 
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $SButton
            $IniWrite = GUICtrlRead($readFromIni)
            IniWrite($csvFile, "section2", "key", $IniWrite)
        Case $nMsg = $LButton
            $Iniread = IniRead($csvFile, "section2", "key", "default value if ini is not found")
            GUICtrlSetData($sendToIni, $Iniread)
    EndSelect
WEnd

Share this post


Link to post
Share on other sites
hypertyper

Try this.

#include <GUIConstants.au3>

Dim $csvFile = "muster.ini"
$Form1 = GUICreate("Form1", 633, 447, 193, 125)
$readFromIni = GUICtrlCreateEdit("", 80, 96, 153, 241)
$sendToIni = GUICtrlCreateEdit("", 336, 96, 169, 241)
$SButton = GUICtrlCreateButton("Save", 80, 360, 145, 33, 0)
$LButton = GUICtrlCreateButton("Load", 344, 360, 161, 33, 0)
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Select 
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $SButton
            $IniWrite = GUICtrlRead($readFromIni)
            IniWrite($csvFile, "section2", "key", $IniWrite)
        Case $nMsg = $LButton
            $Iniread = IniRead($csvFile, "section2", "key", "default value if ini is not found")
            GUICtrlSetData($sendToIni, $Iniread)
    EndSelect
WEnd
Awesoome thanks. I'll have to figure out how it works if you have new lines to save etc but it's a good starting point for me to play around with. Thanks a lot!

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  

×