kor Posted March 31, 2011 Share Posted March 31, 2011 expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #Include <GuiRichEdit.au3> #include <Array.au3> Example1() Func Example1() Local $msg Global $maingui = GUICreate("My GUI", 200, 200) ; will create a dialog box that when displayed is centered $button = GUICtrlCreateButton("Bulk", 50, 50, 80, 30) GuiCtrlSetState($button, $GUI_FOCUS) GUISetState(@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Switch $msg Case $button _Create() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() EndFunc ;==>Example1 Func _Create() Local $msg $creategui = GUICreate("bulk create", 250, 290) Global $edit = _GUICtrlRichEdit_Create($creategui, "FirstName,LastName" & @CR, 10, 10, 230, 230, BitOr($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $button1 = GUICtrlCreateButton("Ready", 70, 250, 80, 30) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $button1 _stuff() Case $GUI_EVENT_CLOSE GUIDelete() Exit EndSwitch WEnd EndFunc Func _stuff() Local $sTmp = '' $result = _GuiCtrlRichEdit_GetText($edit) msgbox(0, "", $result) $rows = StringSplit($result, @CRLF, 2) ;$rows = StringToASCIIArray($result) _ArrayDisplay($rows) Dim $list[2] $list[0] = "FirstName" $list[1] = @CRLF For $i = Ubound($rows) - 1 to 0 Step - 1 For $n = 0 to UBound($list) -1 If StringInStr($rows[$i], $list[$n]) then _ArrayDelete($rows, $i) EndIf Next Next _ArrayDisplay($rows) Exit EndFunc So if you take this code and type some random lines in the richedit box and hit enter a few times, then type some more random text and click ready you will see that the an array is created with each line, however the lines where you hit enter are efficiently blank, but my code isn't deleting those rows and it's driving me nuts. I've tried using @CRLF, @CR, @LF, @TAB in the $list array and none of them remove the blank rows. Link to comment Share on other sites More sharing options...
bwochinski Posted March 31, 2011 Share Posted March 31, 2011 You're not going to have a @CRLF in the array, since that's the delimiter you used in your StringSplit() call. The delimiter is discarded. Try simply testing for empty elements: For $i = Ubound($rows) - 1 to 0 Step - 1 If $rows[$i] == "" Or $rows[$i] == "FirstName" then _ArrayDelete($rows, $i) EndIf Next Link to comment Share on other sites More sharing options...
kor Posted March 31, 2011 Author Share Posted March 31, 2011 You're not going to have a @CRLF in the array, since that's the delimiter you used in your StringSplit() call. The delimiter is discarded. Try simply testing for empty elements: For $i = Ubound($rows) - 1 to 0 Step - 1 If $rows[$i] == "" Or $rows[$i] == "FirstName" then _ArrayDelete($rows, $i) EndIf Next makes sense. thank you. Link to comment Share on other sites More sharing options...
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