Jump to content
Sign in to follow this  
taurus905

Read data from Edit control to .ini file.

Recommended Posts

taurus905

I would appreciate any help in understanding the behavior of the following short example script. I am trying to capture data that is copied and pasted in to an edit box and write it to an .ini file.

Please try the following:

#include <GUIConstants.au3>
; Data to copy and paste in to Edit Box:
#cs

123
456
789

#ce
GUICreate("Enter data to write to .ini file.", 200, 300, -1, -1)
$Input= GuiCtrlCreateEdit("", 10, 10, 100, 200)
$Button_Ok = GUICtrlCreateButton("Ok", 50, 250, 50, 25)
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $Button_Ok
            $Input_Split = StringSplit(GUICtrlRead($Input), @CR)
            For $i = 1 To $Input_Split[0]
                MsgBox(0, $i, $Input_Split[$i])
                IniWrite("Edit Test.ini", "Data", $i, $Input_Split[$i])
            Next
            Exit
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd
I would welcome a better way to accomplish this task, but I would still be curious to why this method does not work correctly.

Thanks to anyone who can help me figure this one out.

taurus905


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Share this post


Link to post
Share on other sites
Lapo

Quick test and all OK here Win98se + Autoit 3, 2, 1, 11

EDIT:

NO it's NOT ok un multiline .. no time ti chek it now

PS:

try

$Input_Split = StringSplit(GUICtrlRead($Input), @CRLF)

Edited by Lapo

Share this post


Link to post
Share on other sites
taurus905

Quick test and all OK here Win98se + Autoit 3, 2, 1, 11

EDIT:

NO it's NOT ok un multiline .. no time ti chek it now

Lapo,

Thanks for trying my example and confirming that it does not work as expected.

taurus905


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Share this post


Link to post
Share on other sites
Lapo

Lapo,

Thanks for trying my example and confirming that it does not work as expected.

taurus905

see the edit on the above post

here again

try

$Input_Split = StringSplit(GUICtrlRead($Input), @CRLF)

and maybe split out NullLines

Edited by Lapo

Share this post


Link to post
Share on other sites
taurus905

PS:

try

$Input_Split = StringSplit(GUICtrlRead($Input), @CRLF)

Lapo,

I thought of that and did not try it.

The outputted data looks like this:

1=123
2=
3=456
4=
5=789

But I can work with that.

Thanks again.

taurus905


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Share this post


Link to post
Share on other sites
Lapo

But I can work with that.

Maybe :

$Input_Split = StringSplit(GUICtrlRead($Input), @LF)

Edited by Lapo

Share this post


Link to post
Share on other sites
taurus905

Maybe :

$Input_Split = StringSplit(GUICtrlRead($Input), @LF)

Lapo,

Perfect. That did the trick.

Thanks for taking the time to help me.

taurus905


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

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.