Libre Posted March 22, 2006 Share Posted March 22, 2006 (edited) i want to delete all the same lines in a listview. and i aply this script to a long listview to delete all the DUPLICATE LINES. _GUICtrlListViewSort($List_Drv, $B_DESCENDING, 0) DeleteDup($List_Drv) Func DeleteDup($List_view) for $i= 0 to _GUICtrlListViewGetItemCount($List_view) if _GUICtrlListViewGetItemText ($List_view,$i,0) == $LV_ERR then ExitLoop if _GUICtrlListViewGetItemText ($List_view,$i,0) == _GUICtrlListViewGetItemText ($List_view,$i+1,0) Then _GUICtrlListViewDeleteItem($List_view, $i) $i = $i -1 EndIf Next EndFunc After this, windows only responses when i minimize and restore the windows. i think is rare dÖob can someone say me what is bad? Edited March 22, 2006 by Libre I love this Game :p----------------------Freeware Multilange support or Translate your scripts----------------------aNyBoDy KnOwS WhY A LiGhT iN My KeYbOaRd iS aLlWaIs BlInKiNg !?Who is "General Failure" and what is he doing in my hard disk !!!!!? Link to comment Share on other sites More sharing options...
Developers Jos Posted March 22, 2006 Developers Share Posted March 22, 2006 Sounds like a support questions to me... not a bug report. -> moving post You probably need to post more so we can duplicate the issue you see... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Libre Posted March 22, 2006 Author Share Posted March 22, 2006 Well, i hope here we found the answer. thanks I love this Game :p----------------------Freeware Multilange support or Translate your scripts----------------------aNyBoDy KnOwS WhY A LiGhT iN My KeYbOaRd iS aLlWaIs BlInKiNg !?Who is "General Failure" and what is he doing in my hard disk !!!!!? Link to comment Share on other sites More sharing options...
Developers Jos Posted March 22, 2006 Developers Share Posted March 22, 2006 Well, i hope here we found the answer. thanks did you also see the question ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Libre Posted March 22, 2006 Author Share Posted March 22, 2006 did you also see the question ?The question is, why it blocks , and only works when i minimize and restores de windows ? I love this Game :p----------------------Freeware Multilange support or Translate your scripts----------------------aNyBoDy KnOwS WhY A LiGhT iN My KeYbOaRd iS aLlWaIs BlInKiNg !?Who is "General Failure" and what is he doing in my hard disk !!!!!? Link to comment Share on other sites More sharing options...
Developers Jos Posted March 22, 2006 Developers Share Posted March 22, 2006 The question is, why it blocks , and only works when i minimize and restores de windows ?NoNo.. I think we need more of your script to be able to test and see why you get this "Hanging" window... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 22, 2006 Developers Share Posted March 22, 2006 think your DeleteDup func has a logic eror.It should not test the last value:For $i = 0 To _GUICtrlListViewGetItemCount ($list_view) -1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 22, 2006 Developers Share Posted March 22, 2006 (edited) i think your anwer will better, after try that yourself. Is NOT the error u said. it works fine.Not sure what you mean/suggest but the code you posted went into a endless loop with the Value of I being 199 .....So I did test the posted code (not the attached) and when I changed the code the list showed...and when you change the While...wend loop to:While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoopWEndthe CloseWindow also works fine.... Edited March 22, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
GaryFrost Posted March 22, 2006 Share Posted March 22, 2006 think your DeleteDup func has a logic eror. It should not test the last value: For $i = 0 To _GUICtrlListViewGetItemCount ($list_view) -1 also should go in reverse, because you'll delete an index and it changes the index for the remainder i.e. For $i = _GUICtrlListViewGetItemCount ($list_view) -1 to 0 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Libre Posted March 22, 2006 Author Share Posted March 22, 2006 (edited) well sorry, for the last posts. this is the finaly script will show you the real problem. run it , please. expandcollapse popup#include <GuiConstants.au3> #include <GuiListView.au3> GUICreate("", 480, 390, 348, 128,BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $list_view = GUICtrlCreateListView("--- |----|----|----|---|--",30, 60, 420, 150,BitOR($LVS_NOSORTHEADER, $LVS_REPORT, $LVS_SHOWSELALWAYS)) $BotonRefresh = GUICtrlCreateButton("Refresh", 120, 216, 81, 33, 0,$BS_MULTILINE) $cap = GUICtrlCreateLabel("try to refresh one time, and then if dont work, minimize and restores the window", 30, 255, 230, 35,$BS_MULTILINE) GUISetState(@SW_SHOW) showlist() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $BotonRefresh showlist() EndSelect WEnd func showlist() _GUICtrlListViewDeleteAllItems($list_view) dim $DataSubItem[7] Dim $B_DESCENDING[6] ;GUICtrlSetState ( $list_view, $GUI_HIDE ) ;GUICtrlSetState ( $list_view, $GUI_DISABLE) For $i= 1 to 100 $DataSubItem[1] = $i * 1 $DataSubItem[5] = $i * 2 $DataSubItem[3] = $i * 3 $DataSubItem[4] = $i * 4 $DataSubItem[2] = round ( $i * 5 / 10 ) $DataSubItem[6] = $i * 6 GUICtrlCreateListViewItem( $DataSubItem[2] & "|" & $DataSubItem[3] & "|" &$DataSubItem[4] & "|" & $DataSubItem[5] & "|" & $DataSubItem[1] & "|" & $DataSubItem[6],$list_view) Next _GUICtrlListViewSort($list_view, $B_DESCENDING, 0) DeleteDup($List_view) EndFunc Func DeleteDup($List_view) for $i= 0 to _GUICtrlListViewGetItemCount($List_view) -1 if _GUICtrlListViewGetItemText ($List_view,$i,0) == $LV_ERR then ExitLoop if _GUICtrlListViewGetItemText ($List_view,$i,0) == _GUICtrlListViewGetItemText ($List_view,$i+1,0) Then _GUICtrlListViewDeleteItem($List_view, $i) $i = $i -1 EndIf Next EndFunc Edited March 22, 2006 by Libre I love this Game :p----------------------Freeware Multilange support or Translate your scripts----------------------aNyBoDy KnOwS WhY A LiGhT iN My KeYbOaRd iS aLlWaIs BlInKiNg !?Who is "General Failure" and what is he doing in my hard disk !!!!!? Link to comment Share on other sites More sharing options...
GaryFrost Posted March 22, 2006 Share Posted March 22, 2006 Func DeleteDup($list_view) $end = _GUICtrlListViewGetItemCount ($list_view) - 1 For $i = 0 To $end If _GUICtrlListViewGetItemText ($list_view, $i, 0) == $LV_ERR Then ExitLoop If _GUICtrlListViewGetItemText ($list_view, $i, 0) == _GUICtrlListViewGetItemText ($list_view, $i + 1, 0) Then _GUICtrlListViewDeleteItem ($list_view, $i) $end = _GUICtrlListViewGetItemCount ($list_view) - 1 EndIf Next EndFunc ;==>DeleteDup SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 22, 2006 Developers Share Posted March 22, 2006 as GAFROST suggested : with this changed DeleteDup() func things work fine... I can keep on clicking refresh: Func DeleteDup($list_view) For $i = _GUICtrlListViewGetItemCount ($list_view) To 2 Step -1 If _GUICtrlListViewGetItemText ($list_view, $i, 0) == $LV_ERR Then ExitLoop If _GUICtrlListViewGetItemText ($list_view, $i, 0) == _GUICtrlListViewGetItemText ($list_view, $i + 1, 0) Then _GUICtrlListViewDeleteItem ($list_view, $i) EndIf Next EndFunc ;==>DeleteDup SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Libre Posted March 22, 2006 Author Share Posted March 22, 2006 Func DeleteDup($list_view) $end = _GUICtrlListViewGetItemCount ($list_view) - 1 For $i = 0 To $end If _GUICtrlListViewGetItemText ($list_view, $i, 0) == $LV_ERR Then ExitLoop If _GUICtrlListViewGetItemText ($list_view, $i, 0) == _GUICtrlListViewGetItemText ($list_view, $i + 1, 0) Then _GUICtrlListViewDeleteItem ($list_view, $i) $end = _GUICtrlListViewGetItemCount ($list_view) - 1 EndIf Next EndFunc ;==>DeleteDupTHANKS SO MUCH, now it works. I love this Game :p----------------------Freeware Multilange support or Translate your scripts----------------------aNyBoDy KnOwS WhY A LiGhT iN My KeYbOaRd iS aLlWaIs BlInKiNg !?Who is "General Failure" and what is he doing in my hard disk !!!!!? Link to comment Share on other sites More sharing options...
Libre Posted March 22, 2006 Author Share Posted March 22, 2006 (edited) Func DeleteDup($list_view) $end = _GUICtrlListViewGetItemCount ($list_view) - 1 For $i = 0 To $end If _GUICtrlListViewGetItemText ($list_view, $i, 0) == $LV_ERR Then ExitLoop If _GUICtrlListViewGetItemText ($list_view, $i, 0) == _GUICtrlListViewGetItemText ($list_view, $i + 1, 0) Then _GUICtrlListViewDeleteItem ($list_view, $i) $end = _GUICtrlListViewGetItemCount ($list_view) - 1 EndIf Next EndFunc;==>DeleteDup thanks man. i was needing that help. but u forgot that line Func DeleteDup($list_view) $end = _GUICtrlListViewGetItemCount ($list_view) - 1 For $i = 0 To $end If _GUICtrlListViewGetItemText ($list_view, $i, 0) == $LV_ERR Then ExitLoop If _GUICtrlListViewGetItemText ($list_view, $i, 0) == _GUICtrlListViewGetItemText ($list_view, $i + 1, 0) Then _GUICtrlListViewDeleteItem ($list_view, $i) $end = _GUICtrlListViewGetItemCount ($list_view) - 1 if $i <= $end then $i = $i - 1; <-------------------< Now no one duplicated EndIf Next EndFunc;==>DeleteDup Edited March 22, 2006 by Libre I love this Game :p----------------------Freeware Multilange support or Translate your scripts----------------------aNyBoDy KnOwS WhY A LiGhT iN My KeYbOaRd iS aLlWaIs BlInKiNg !?Who is "General Failure" and what is he doing in my hard disk !!!!!? 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