Gianluca Posted March 30, 2011 Share Posted March 30, 2011 What I want to reach is a Gui in which are listed a specific type of file (in the example below I used txt files); with these files I addictionally want to interact.The main problem I have is this: how can I set a number of item that I don't previously know? I mean:$item1 =$item2 =etc. I thought I can use array but I don't exactly know how... Local $x = 0 $Form1 = GUICreate("", 663, 514, 192, 124) $Group1 = GUICtrlCreateGroup("", 11, 96, 641, 401) $view = GUICtrlCreateButton("Read item selected", 366, 464, 147, 25) $new = GUICtrlCreateButton("New", 95, 464, 147, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Search", 167, 16, 329, 65) $Button1 = GUICtrlCreateButton("Search", 407, 40, 75, 25) $Date1 = GUICtrlCreateDate("2011/03/30 19:18:4", 183, 40, 186, 21) $listview = GUICtrlCreateListView(" Date | Time ", 23, 112, 617, 337,$LVS_SORTDESCENDING) ; Here starts the "listing phase" $search = FileFindFirstFile($global_path&"*.txt") If $search = -1 Then ; Check if the search was successful MsgBox(0, $title, "No file found.") Exit EndIf While 1 $a = FileFindNextFile($search) If @error Then ExitLoop ; ####### HERE THE PROBLEM ######## $item1 = GUICtrlCreateListViewItem("item2|col22|col23", $listview) ; ################################# $x += 1 WEnd GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 30, 2011 Moderators Share Posted March 30, 2011 Gianluca,Welcome to the AutoIt forum. Firstly, use _FileListToArray to get an array of the files you are looking for - much simpler than using FileFindFirst/NextFile. Then use a simple loop to run through the file names - for each one you can use FileGetTime to get the date and time of the file (which looks to be what you want to display) and then use GUICtrlCreateListViewItem to add a row to the ListView to show what you get. Give it a go and see if you can get it to work. If not you know where we are! 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 Link to comment Share on other sites More sharing options...
Gianluca Posted March 30, 2011 Author Share Posted March 30, 2011 Gianluca,Welcome to the AutoIt forum. Firstly, use _FileListToArray to get an array of the files you are looking for - much simpler than using FileFindFirst/NextFile. Then use a simple loop to run through the file names - for each one you can use FileGetTime to get the date and time of the file (which looks to be what you want to display) and then use GUICtrlCreateListViewItem to add a row to the ListView to show what you get. Give it a go and see if you can get it to work. If not you know where we are! M23M23,Thank you VERY VERY VERY much for you quick and exaustive answer. I'll try and post the result if I'll make it, otherwise I'll report issues Thanks bro:) Link to comment Share on other sites More sharing options...
Gianluca Posted March 30, 2011 Author Share Posted March 30, 2011 That's it! Thanks bro!!!!! $search = _FileListToArray($global_path,"*.dapvm",1) If @Error=4 Then MsgBox(0, $title, "No file.") EndIf Local $item[$search[0]] For $i = 0 to UBound($item)-1 $item[$i] = GUICtrlCreateListViewItem($search[$i+1], $listview) Next 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