232showtime Posted July 9, 2016 Posted July 9, 2016 @melba, sorry for the title dont know what title I need to use, I found some script of yours for filtering listview, Im already done with the filtering and made some small modification. I want to fully understand each line.. and if anyone has a kind heart to put more comment on each line, I am really squizzing my mind for this script.. pleaaaaaassssseeeee ??? here is the full script, expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" #include <Array.au3> Opt("GUIDataSeparatorChar", "/") $hGUI = GUICreate("Form1", 673, 433, -1, -1) $cListView = GUICtrlCreateListView("Name File / Value", 8, 64, 657, 361) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 380) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 270) $cButton_Load = GUICtrlCreateButton("Load", 8, 16, 105, 33) $cInput = GUICtrlCreateInput("", 136, 24, 145, 21) GUICtrlSendMsg(-1, $EM_SETCUEBANNER, True, "Search...") $cButton_Search = GUICtrlCreateButton("Search", 304, 16, 105, 33) GUISetState(@SW_SHOW) Global $aData[4][2] = [["Test1", "Test"], ["Test2", "Sun"], ["Sun1", "Sun"], ["Earth1", "Earth1"]] While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cButton_Search _GUICtrlListView_DeleteAllItems($cListView) ; -->>Remove all items $sText = GUICtrlRead($cInput) ;-->>Read Input Box If StringLen($sText) <> 0 Then ;-->>Read StringLen Greater or Less than 0 ; Create a list of matches Local $aMatch_List[1] = [0] ;-->>whats the use of this??????? $iStart = 1 ;-->> whats the use of this??? For $i = 0 To UBound($aData) - 1 ;-->> infinite array columns and rows??? ; Look for the match If StringInStr($aData[$i][0], $sText) Then ; Add to list $aMatch_List[0] += 1 ; -->>Declared same variable +1??? whats the use??? ReDim $aMatch_List[$aMatch_List[0] + 1]; -->> Resize an existing array. $aMatch_List[$aMatch_List[0]] = $aData[$i][0] & "/" & $aData[$i][0]; -->> whats the use of this??????? EndIf Next ; Add matches to ListView For $i = 1 To $aMatch_List[0] GUICtrlCreateListViewItem($aMatch_List[$i], $cListView) Next Else ; Reload everything ContinueCase EndIf Case $cButton_Load ; Remove all items _GUICtrlListView_DeleteAllItems($cListView) For $i = 0 To UBound($aData) - 1 GUICtrlCreateListViewItem($aData[$i][0] & "/" & $aData[$i][0], $cListView) Next EndSwitch WEnd TIA... ill get to that... i still need to learn and understand a lot of codes Correct answer, learn to walk before you take on that marathon.
SadBunny Posted July 9, 2016 Posted July 9, 2016 (edited) I gave it my best shot but I seem to be in a very verbose mood tonight If this is not the kind of information you were looking for, please be more specific in phrasing your questions. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" #include <Array.au3> Opt("GUIDataSeparatorChar", "/") $hGUI = GUICreate("Form1", 673, 433, -1, -1) $cListView = GUICtrlCreateListView("Name File / Value", 8, 64, 657, 361) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 380) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 270) $cButton_Load = GUICtrlCreateButton("Load", 8, 16, 105, 33) $cInput = GUICtrlCreateInput("", 136, 24, 145, 21) GUICtrlSendMsg(-1, $EM_SETCUEBANNER, True, "Search...") $cButton_Search = GUICtrlCreateButton("Search", 304, 16, 105, 33) GUISetState(@SW_SHOW) Global $aData[4][2] = [["Test1", "Test"], ["Test2", "Sun"], ["Sun1", "Sun"], ["Earth1", "Earth1"]] While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cButton_Search _GUICtrlListView_DeleteAllItems($cListView) ; -->>Remove all items $sText = GUICtrlRead($cInput) ;-->>Read Input Box If StringLen($sText) <> 0 Then ;-->>Read StringLen Greater or Less than 0 ; Create a list of matches Local $aMatch_List[1] = [0] ;-->>whats the use of this??????? ;---------------------- It calls the array into existence with 1 element, which is set to the value 0. ;---------------------- This array will be used to store a list of matches. $iStart = 1 ;-->> whats the use of this??? ;---------------------- It calls the variable $iStart into existence and sets the value to 1. ;---------------------- It is not used anywhere else in this script, hence is of no use. For $i = 0 To UBound($aData) - 1 ;-->> infinite array columns and rows??? ;---------------------- no, not infinite, this loops from 0 to the count of elements in the $aData array (which is a number), minus one. ;---------------------- So if $aData contains 3 elements, $i will be first 0, then 1 and then 2. ; Look for the match If StringInStr($aData[$i][0], $sText) Then ; Add to list $aMatch_List[0] += 1 ; -->>Declared same variable +1??? whats the use??? ;------------------------- The first element in the array is a counter that indicates the number of elements in the array. ;------------------------- This command increases that counter by one, because we're going to add a value to the array. ;------------------------- One could also use UBound($aMatch_List). Some like to have an array with only the elements themselves, ;------------------------- which makes it 0-based (zero-based) as the elements start at the "0-th" element. This is how $aData is ;------------------------- set up by virtue of the way it was created in the initialization in the beginning of the script. ;------------------------- Some prefer arrays that are "1-based" like mr. $aMatch_List here, which is a misnomer in autoit because ;------------------------- it is actually still a 0-based array, but with the counter of elements stored in the 0-th element, but ;------------------------- it's often convenient to think of it like a 1-based array. ;------------------------- NOTE: This means that if we want to store THREE values, we need FOUR array elements, because one of ;------------------------- them (namely the first one, which is element number 0) is needed to store the counter. ReDim $aMatch_List[$aMatch_List[0] + 1]; -->> Resize an existing array. ;------------------------- Indeed. Note that the new size of the array is now set to that counter, but +1. I.e. if a third value ;------------------------- is going to be stored, the counter was just upped to 3, but because we need that 0th element for the ;------------------------- counter, the size of the array must now be 3 + 1 = 4. $aMatch_List[$aMatch_List[0]] = $aData[$i][0] & "/" & $aData[$i][0]; -->> whats the use of this??????? ;------------------------- This command stores a value in a certain numbered element in the array. Which number? Well, the number ;------------------------- that is indicated by that counter we just increased, namely (in our example) 3. ;------------------------- Why it stores the same value twice with a slash in between: but I suspect it was a copypaste oversight, ;------------------------- it was probably meant to be: $aData[$i][0] & "/" & $aData[$i][1] (thus converting both values in the ;------------------------- second dimension into a single string, thus "stitching the second dimension together into a single ;------------------------- value", thus ending up with an array that has the same information but with only a single dimension. EndIf Next ; Add matches to ListView For $i = 1 To $aMatch_List[0] GUICtrlCreateListViewItem($aMatch_List[$i], $cListView) Next Else ; Reload everything ContinueCase EndIf Case $cButton_Load ; Remove all items _GUICtrlListView_DeleteAllItems($cListView) For $i = 0 To UBound($aData) - 1 GUICtrlCreateListViewItem($aData[$i][0] & "/" & $aData[$i][0], $cListView) Next EndSwitch WEnd Edited July 9, 2016 by SadBunny Code formatting jvds, 232showtime and dmob 3 Roses are FF0000, violets are 0000FF... All my base are belong to you.
Moderators Melba23 Posted July 9, 2016 Moderators Posted July 9, 2016 232showtime, SadBunny has explained the code perfectly - my thanks to him. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
SadBunny Posted July 9, 2016 Posted July 9, 2016 Aw, shucks Roses are FF0000, violets are 0000FF... All my base are belong to you.
232showtime Posted July 9, 2016 Author Posted July 9, 2016 this is exactly what I want. many thanks @SadBunny ill get to that... i still need to learn and understand a lot of codes Correct answer, learn to walk before you take on that marathon.
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