Netol Posted August 21, 2024 Posted August 21, 2024 Hi my friend i need help to create a code. I have 2 lists. List #1 with two columns that has a list of files, the first column has the file name and the full path and the second column has the date. global $idListview = GUICtrlCreateListView("Archivo a procesar|Fecha", 20, 20, 900, 400, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) List #2 The other list also has 2 columns and contains files that I must delete by coincidence from list #1 global $idListview2 = GUICtrlCreateListView("Archivo a procesar|Fecha", 530, 40, 400, 400, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) Help me with a code that does this, List #1 contain example F:\Enel\Backup Full\Dia 5\_srt\DJI_0009.KML List #2 contain example F:\Enel\Backup Full\Dia 5\_srt\DJI_0009.SRT The element os the list #1: F:\Enel\Backup Full\Dia 5\_srt\DJI_0009.KML i need to delete, because the first part of the text repeat F:\Enel\Backup Full\Dia 5\_srt\DJI_0009 Reference image attached best reqards
Solution Andreik Posted August 21, 2024 Solution Posted August 21, 2024 Not tested as a fully script but something like this: #include <Array.au3> #include <GuiListView.au3> ; Create GUI here $aList1 = ListColumnToArray($cList1, 1) ; $cList1 - handle or ctrl id of the first list $aList2 = ListColumnToArray($cList2, 1) ; $cList2 - handle or ctrl id of the second list For $Index = 1 To $aList1[0] _ArraySearch($aList2, StringReplace($aList1[$Index], '.kml', '.srt')) If Not @error Then _GUICtrlListView_DeleteItem($cList1, $Index - 1) Next Func ListColumnToArray($List, $Column) Local $sData If $Column > _GUICtrlListView_GetColumnCount($List) Then Return SetError(1, 0, Null) Local $NumOfItems = _GUICtrlListView_GetItemCount($List) For $Index = 0 To $NumOfItems - 1 $sData &= _GUICtrlListView_GetItemText($List, $Index, $Column) & '|' Next Return StringSplit(StringTrimRight($sData, 1), '|') EndFunc Netol 1
Netol Posted August 21, 2024 Author Posted August 21, 2024 15 hours ago, Andreik said: Not tested as a fully script but something like this: #include <Array.au3> #include <GuiListView.au3> ; Create GUI here $aList1 = ListColumnToArray($cList1, 1) ; $cList1 - handle or ctrl id of the first list $aList2 = ListColumnToArray($cList2, 1) ; $cList2 - handle or ctrl id of the second list For $Index = 1 To $aList1[0] _ArraySearch($aList2, StringReplace($aList1[$Index], '.kml', '.srt')) If Not @error Then _GUICtrlListView_DeleteItem($cList1, $Index - 1) Next Func ListColumnToArray($List, $Column) Local $sData If $Column > _GUICtrlListView_GetColumnCount($List) Then Return SetError(1, 0, Null) Local $NumOfItems = _GUICtrlListView_GetItemCount($List) For $Index = 0 To $NumOfItems - 1 $sData &= _GUICtrlListView_GetItemText($List, $Index, $Column) & '|' Next Return StringSplit(StringTrimRight($sData, 1), '|') EndFunc Very good job as always Andreik, it worked on the first try, thank you very much Best regards
Andreik Posted August 22, 2024 Posted August 22, 2024 It was more like a starter example without the GUI part so I didn't run the code but I am glad it worked. Netol 1
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