Sign in to follow this  
Followers 0
tlokz

Edit Box Help

6 posts in this topic

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?

Share this post


Link to post
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)

Share this post


Link to post
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)

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

Thanks, It works good! muttley Sorry for the double post

Share this post


Link to post
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

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  
Followers 0