Jump to content
Sign in to follow this  

Edit Box Help

Recommended Posts


Ok , I want to remove all dead lines from an edit box. I have put all the lines in an array. Now when using _ArrayDelete() it deletes the string properly but also removes the last line do to that the array did not correct itself by changing numbers.

Dim $templine[_GUICtrlEdit_GetLineCount($Edit1) - 1]
    For $tem = 0 To _GUICtrlEdit_GetLineCount($Edit1) - 2 Step 1
        $templine[$tem] = _GUICtrlEdit_GetLine($Edit1, $tem)
        If $templine[$tem] = "" Then _ArrayDelete($templine[$tem], "")
    GUICtrlSetData($Edit1, _ArrayToString($templine, @CRLF))

Share this post

Link to post
Share on other sites

Please don't double post - I've already answered to your post in GUI Help Forum.

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

Hi, I used the _GUICtrlEdit_GetText() example from the help file and added StringSplit() and StringStripWS() loop to filter the lines.

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiEdit.au3>
#include <GuiConstantsEx.au3>

Opt('MustDeclareVars', 1)

$Debug_Ed = False


Func _Main()
    Local $hEdit

    ; Create GUI
    GUICreate("Edit Get Text", 400, 300)
    $hEdit = GUICtrlCreateEdit("", 2, 2, 394, 268)

    ; Set Text
    _GUICtrlEdit_SetText($hEdit, "This is a test" & @CRLF & "Another Line" & @CRLF & "Append to the end?" & _
    @CRLF & @CRLF & "So a needle pulling thread" & @CRLF & @CRLF & "Another Line" & @CRLF & "Append to the end?" & _
    @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & "Last line of gibberish.")
    ;Strip blank lines
    Local $sTmp, $aTmp = StringSplit(_GUICtrlEdit_GetText($hEdit), @CRLF)
    For $i = 1 To $aTmp[0]
        If StringStripWS($aTmp[$i], 8) <> "" Then $sTmp &= StringStripWS($aTmp[$i], 2) & @CRLF
    MsgBox(4160, "Striped of blank lines", StringStripWS($sTmp, 2))
    _GUICtrlEdit_SetText($hEdit, StringStripWS($sTmp, 2))
    ; Loop until user exits
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>_Main


Edited by smashly

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