Jump to content

Edit Box Help


tlokz
 Share

Recommended Posts

I have an edit box that will create ini's for a program, now I made error checking for it and want it to remove empty lines

Now, I tried using Send("{BACKSPACE}")

But that only deletes it if its the first line, and I don't see and _GUICtrlEdit Etc. commands to delete lines

Any help?

Link to comment
Share on other sites

Is this a start?

Dim $templine[_GUICtrlEdit_GetLineCount($Edit1) - 1]
    For $tem = 0 To _GUICtrlEdit_GetLineCount($Edit1) - 2 Step 1
        $templine[$tem] = _GUICtrlEdit_GetLine($Edit1, $tem)
    Next
    $temp = _ArrayToString($templine, @CRLF)
Link to comment
Share on other sites

Help plz, I tried this also

Dim $templine[_GUICtrlEdit_GetLineCount($Edit1) - 1]
    For $tem = 0 To _GUICtrlEdit_GetLineCount($Edit1) - 2 Step 1
        $templine[$tem] = _GUICtrlEdit_GetLine($Edit1, $tem)
    Next
    Dim $newtempline[_GUICtrlEdit_GetLineCount($Edit1) - 1]
    For $element In $templine
        If Not $element = "" Then
            _ArrayAdd($newtempline, $element)
        EndIf
    Next
    $temp = _ArrayToString($newtempline, @CRLF)
    GUICtrlSetData($Edit1, $temp)
Link to comment
Share on other sites

I've seen you did some work on that muttley

Try this code:

$content = _GUICtrlEdit_GetText($Edit1)
$lines = StringSplit($content, @CRLF, 1)
$new_content = ""
For $i=1 to UBound($lines) - 1
    If $lines[$i] <> "" Then $new_content &= $lines[$i]&@CRLF
Next
_GUICtrlEdit_SetText($Edit1, $new_content)  ;if this doesn't work

;replace the above line with the following 2 lines

;_GUICtrlEdit_SetSel($Edit1, 0, -1)
;_GUICtrlEdit_ReplaceSel($Edit1, $new_content)

What I did here? I've got the edit text in a string, did a stringsplit for @CRLF and put everything "not empty" in a new string.

If it doesn't work at the first try you can play with it for a while ... use messageboxes, ArrayDisplay ... to debug your script.

Good luck,

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 :)

Link to comment
Share on other sites

You could also use a regular expression to keep things simple:

$content = _GUICtrlEdit_GetText($Edit1)
$new_content = StringRegExpReplace($content, "\r\n\w*(\Z|\r\n)", @CRLF)
_GUICtrlEdit_SetText($Edit1, $new_content)

What this is doing is checking $content for a new line (\r\n), with an number of white space characters (\w*), followed by another new line or the end of the string (\Z|\r\n)

Regards,Josh

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...