Jump to content

Multiple Line Input to .ini file.


m00
 Share

Recommended Posts

Aloha,

I am having some trouble getting this to work:

I have a multiple line Input box that is exported to an .ini file.

When I open the ini file, it has all of the information, in the correct section, with the correct key, but when I try to read it out of the ini file, it only returns the first line of that key.

I suspect that it is a formatting issue; I may need to manipulate the text being sent to the ini file so that it fits on one line (lf or cr or something), but I am not sure if that is right, and if it is, I am not sure how to do it.

Here is some snippet of what I currently have going.

$sample_input = GUICtrlCreateInput("blah",5,500,150,90, $ES_WANTRETURN + $ES_MULTILINE)
$inputbutt = GUICtrlCreateButton("Ok", 5, 652, 60, 20)

;----------------------

While 1
  $msg1 = GUIGetMsg()

 If $msg1 = $inputbutt Then
     IniDelete("flamingo_opt.ini","Input1 Test")
     IniWrite("flamingo_opt.ini","Input1 Test","1",GuiCtrlRead($sample_input))
     ;msgbox(4096,"title",guictrlread($sample_input))
     $var = IniReadSection("flamingo_opt.ini", "Input1 Test")
        For $testi = 1 To $var[0][0]
            MsgBox(4096, "", "Key: " & $var[$testi][0] & @CRLF & "Value: " & $var[$testi][1])
        Next
Link to comment
Share on other sites

New Line is the terminator for the key value, so it is truncating there when reading back.

There is also around 255 character limit.

A suggestion is to replace the new line character with a pipe (|) or other character before writing and do the reverse when reading back.

Link to comment
Share on other sites

New Line is the terminator for the key value, so it is truncating there when reading back.

There is also around 255 character limit.

A suggestion is to replace the new line character with a pipe (|) or other character before writing and do the reverse when reading back.

OK, I thought that may be the case with the new line ending a key value.

What has the 255 char limit? The ini value?

Replacing the new line char with a pipe sounds great, but I don't know how to do it. I can't find documentation on what a multiple line input box does to text and/or don't quite understand how to add/swap a character instead of a new line.

Link to comment
Share on other sites

OK, I thought that may be the case with the new line ending a key value.

What has the 255 char limit? The ini value?

Replacing the new line char with a pipe sounds great, but I don't know how to do it. I can't find documentation on what a multiple line input box does to text and/or don't quite understand how to add/swap a character instead of a new line.

Yes the value. Has to do with the buffer size used when calling the "GetPrivateProfileString" Windows API.

Before Writing to INI:

StringReplace(contents_of_input_box, @CRLF, "|")

After Reading:

StringReplace(text_read_from_ini_file, "|", @CRLF)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...