tlokz Posted July 15, 2008 Posted July 15, 2008 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], "") Next GUICtrlSetData($Edit1, _ArrayToString($templine, @CRLF))
enaiman Posted July 15, 2008 Posted July 15, 2008 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 :)
smashly Posted July 15, 2008 Posted July 15, 2008 (edited) 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 _Main() Func _Main() Local $hEdit ; Create GUI GUICreate("Edit Get Text", 400, 300) $hEdit = GUICtrlCreateEdit("", 2, 2, 394, 268) GUISetState() ; 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 Next MsgBox(4160, "Striped of blank lines", StringStripWS($sTmp, 2)) _GUICtrlEdit_SetText($hEdit, StringStripWS($sTmp, 2)) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main Cheers Edited July 15, 2008 by smashly
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now