Jump to content

Recommended Posts

Posted

Hi everyone. I have an simple edit control in one of my scripts, and I save it's contents to an .ini file. Pretty straightforward. The problem is when I press enter, it puts in a line-break (I think that's the term) which messes with the .ini file. When I go to read it back from the .ini file, everything after the first enter press is on a separate in in the .ini file, and thus, doesn't read.

As a temporary crutch, I threw in $ES_MULTILINE, so I can't press enter, and it wraps automatically. Not being able to make new paragraphs is a pain, and I'm also limited to the the physical size of the edit box, it doesn't scroll with the $ES_MULTILINE flag.

I'de like figure out a more permanent solution. I think I want to search for line breaks, and replace them with " & @LF & " or something similar. How would I go about searching for the line breaks. I don't even know what I'm looking for. I'm learning the very basics of html, would I be searching for the html line break code? Is there a simple, built-in way of doing this that perhaps I missed? Thanks SO much for your help!

Daniel Mohr

P.S. The ideal way would be to use something like $ES_WANTRETURN where It automatically wraps for me, but still leaves the option of manually creating a new line. Two problems here, one I need to search for and remove the line breaks before writing to the .ini. Second, I need to get the scroll option back in. Not sure if this is even possible, but I'de love to hear any ideas...

Posted

Here you go:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 209, 145, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Edit1 = GUICtrlCreateEdit("", 8, 8, 193, 97, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, "Just typr in here and see what happens.")
$Button1 = GUICtrlCreateButton("Button1", 56, 112, 75, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func Button1Click()
    $IniTxt = StringReplace(GUICtrlRead($Edit1), @CRLF, "@CRLF")
    MsgBox(0, "This is the text to go to ini", $IniTxt)
EndFunc

Func Form1Close()
    Exit
EndFunc

If you play long enough with styles for edit box, you end up discovering the good one.

When you read the message from *.ini file and put it back in the Edit, just replace "@CRLF" with @CRLF and it will look OK.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

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
  • Recently Browsing   0 members

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