Info Posted August 25, 2009 Share Posted August 25, 2009 How can I do that? >_ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 25, 2009 Moderators Share Posted August 25, 2009 Info,I would think a combination of:_FileListToArrayUBoundGUICtrlCreateListViewGUICtrlSetDataFor...Nextand couple of If...Then linesshould do it without too much problem! >_< 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...
Info Posted August 25, 2009 Author Share Posted August 25, 2009 I'm not so fimiliar with these functions but I'll give it a try! Will update this thread later... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 25, 2009 Moderators Share Posted August 25, 2009 Info, I look forward to it! >_< 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...
Info Posted August 25, 2009 Author Share Posted August 25, 2009 After 50 minutes I've been trying to get it to work with the For...To...Next statement and failed, I tried to do it with the Do...Until statement and got it to work. My successful Do...Until try: $i = 1 $FileList = _FileListToArray('C:\') Do MsgBox(0,"",$FileList[$i]) $i += 1 Until $i = UBound($FileList) My failure For...To...Next try: For $i = $FileList[1] To $FileList[UBound($FileList)] MsgBox(0,"",$i) Next Could someone tell me what went wrong with the For statement? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 25, 2009 Moderators Share Posted August 25, 2009 Info,Try this - you need the array indices, not the values:For $i = 1 To UBound($FileList) - 1 MsgBox(0,"",$FileList[$i]) NextMy version of the whole script if you really want to look >_< :expandcollapse popup#include <GUIConstantsEx.au3> #Include <GuiListView.au3> #include <File.au3> $sPath = "M:\Program\Au3 Scripts" If Not FileExists($sPath) Then MsgBox(0, "Error", "Invalid path") Exit EndIf $aFiles = _FileListToArray("Your_Folder_Name", "*", 1) If Not IsArray($aFiles) Then MsgBox(0, "Error", "No files found") Exit EndIf $hGUI = GUICreate($sPath, 500, 500) $hList = GUICtrlCreateListView("_", 10, 10, 480, 250, $LVS_NOCOLUMNHEADER) _GUICtrlListView_SetColumnWidth(-1, 0, 480) For $i = 1 to UBound($aFiles) - 1 GUICtrlCreateListViewItem($aFiles[$i], $hList) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndI did say you needed a few If...Then lines.... 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...
Info Posted August 25, 2009 Author Share Posted August 25, 2009 Thanks Melba! >_ Link to comment Share on other sites More sharing options...
Info Posted August 25, 2009 Author Share Posted August 25, 2009 (edited) Just one more question: How can I add more than one file filter in _FileListToArray()? Edited August 26, 2009 by Info Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 26, 2009 Moderators Share Posted August 26, 2009 Info,You cannot!Two solutions:1. Run _FileListToArray several times with the different filters and then use _ArrayConcatenate to join them all together. Just do not forget to _ArrayDelete the [0] element each time!2. Look for one of the many "improved" _FileListToArray functions which litter these forums. This is my version:expandcollapse popup#include-once ; #FUNCTION# ==================================================================================================================== ; Name...........: _FileListToArrayEx ; Description ...: Lists files and\or folders in a specified path with optional recursion. Compatible with existing _FileListToArray syntax ; Syntax.........: _FileListToArrayEx($sPath[, $sInclude_List = "*"[, $iReturn = 0[, $fRecur = 0[, $sExclude_List = ""[, $iFullPath = 0]]]]]) ; Parameters ....: $sPath - Initial path used to generate filelist ; $sInclude_List - Optional: the filter for included results (default is "*"). Multiple filters must be separated by ";" ; $iReturn - Optional: specifies whether to return files, folders or both ; |$iReturn=0 (Default) Return both files and folders ; |$iReturn=1 Return files only ; |$iReturn=2 Return folders only ; $fRecur - Optional: specifies whether to search in subfolders ; |$fRecur=0 (Default) Do not search in subfolders ; |$fRecur=1 Search in subfolders ; $sExclude_List - Optional: the filter for excluded results (default is ""). Multiple filters must be separated by ";" ; $iFullPath - Optional: specifies path of result string ; |$iFullPath=0 (Default) Initial path not included ; |$iFullPath=1 Initial path included ; |$iFullPath=2 File/folder name only ; Requirement(s).: v3.3.1.1 or higher ; Return values .: Success: One-dimensional array made up as follows: ; |$array[0] = Number of Files\Folders returned ; |$array[1] = 1st File\Folder ; |$array[2] = 2nd File\Folder ; |... ; |$array[n] = nth File\Folder ; Failure: Null string and @error = 1 with @extended set as follows: ; |1 = Path not found or invalid ; |2 = Invalid $sInclude_List ; |3 = Invalid $iReturn ; |4 = Invalid $fRecur ; |5 = Invalid $sExclude_List ; |6 = Invalid $iFullPath ; |7 = No files/folders found ; Author ........: Melba23 using SRE code from forums ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _FileListToArrayEx($sInitialPath, $sInclude_List = "*", $iReturn = 0, $fRecur = 0, $sExclude_List = "", $iFullPath = 0) Local $asReturnList[1] = [0], $asFolderList[3] = [1], $sInclude_List_Mask, $sExclude_List_Mask Local $sCurrentPath, $hSearch, $sReturnPath = "", $sName, $fFolder ; Check valid path If Not FileExists($sInitialPath) Then Return SetError(1, 1, "") ; Ensure trailing \ If StringRight($sInitialPath, 1) <> "\" Then $sInitialPath = $sInitialPath & "\" ; Add path to folder list $asFolderList[1] = $sInitialPath ; Determine Filter mask for SRE check If StringRegExp($sInclude_List, "\\|/|:|\<|\>|\|") Then Return SetError(1, 2, "") ; Check for invalid characters $sInclude_List = StringReplace(StringStripWS(StringRegExpReplace($sInclude_List, "\s*;\s*", ";"), 3), ";", "|") ; Strip WS and swap :/| $sInclude_List_Mask = "(?i)^" & StringReplace(StringReplace(StringReplace($sInclude_List, ".", "\."), "*", ".*"), "?", ".") & "\z" ; Convert to SRE pattern ; Determine Exclude mask for SRE check If $sExclude_List = "" Then $sExclude_List_Mask = ":" ; Set unmatchable mask Else If StringRegExp($sExclude_List, "\\|/|:|\<|\>|\|") Then Return SetError(1, 5, "") ; Check for invalid characters $sExclude_List = StringReplace(StringStripWS(StringRegExpReplace($sExclude_List, "\s*;\s*", ";"), 3), ";", "|") ; Strip WS and swap ;/| $sExclude_List_Mask = "(?i)^" & StringReplace(StringReplace(StringReplace($sInclude_List, ".", "\."), "*", ".*"), "?", ".") & "\z" ; Convert to SRE pattern EndIf ; Verify other parameter values If Not ($iReturn = 0 Or $iReturn = 1 Or $iReturn = 2) Then Return SetError(1, 3, "") If Not ($fRecur = 0 Or $fRecur = 1) Then Return SetError(1, 4, "") If Not ($iFullPath = 0 Or $iFullPath = 1 Or $iFullPath = 2) Then Return SetError(1, 6, "") ; Search in listed folders While $asFolderList[0] > 0 ; Set path to search $sCurrentPath = $asFolderList[$asFolderList[0]] ; Reduce folder array count $asFolderList[0] -= 1 ; Get search handle $hSearch = FileFindFirstFile($sCurrentPath & "*") ; If folder empty move to next in list If $hSearch = -1 Then ContinueLoop ; Determine path to add to file/folder name Switch $iFullPath Case 0 ; Initial path not included $sReturnPath = StringReplace($sCurrentPath, $sInitialPath, "") Case 1 ; Initial path included $sReturnPath = $sCurrentPath ; Case 2 ; Name only so leave as "" EndSwitch ; Search folder While 1 $sName = FileFindNextFile($hSearch) ; Check for end of folder If @error Then ExitLoop ; Check for subfolder - @extended set in 3.3.1.1 + $fFolder = @extended ; If recursive search, add subfolder to folder list If $fRecur And $fFolder Then ; Increase folder array count $asFolderList[0] += 1 ; Double folder array size if too small (fewer ReDim needed) If UBound($asFolderList) <= $asFolderList[0] + 1 Then ReDim $asFolderList[UBound($asFolderList) * 2] ; Add subfolder to list $asFolderList[$asFolderList[0]] = $sCurrentPath & $sName & "\" EndIf ; Check file/folder type against required return value and file/folder name against Include/Exclude masks If $fFolder + $iReturn <> 2 And StringRegExp($sName, $sInclude_List_Mask) And Not StringRegExp($sName, $sExclude_List_Mask) Then ; Increase return array count $asReturnList[0] += 1 ; Double return array size if too small (fewer ReDim needed) If UBound($asReturnList) <= $asReturnList[0] Then ReDim $asReturnList[UBound($asReturnList) * 2] ; Add required path to file/folder name and add to array $asReturnList[$asReturnList[0]] = $sReturnPath & $sName EndIf WEnd ; Close current search FileClose($hSearch) WEnd ; Check if any file/folders to return If $asReturnList[0] = 0 Then Return SetError(1, 7, "") ; Remove unused return array elements from last ReDim ReDim $asReturnList[$asReturnList[0] + 1] Return $asReturnList EndFunc ;==>_FileListToArrayExHave fun!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...
Info Posted August 26, 2009 Author Share Posted August 26, 2009 I'll use your UDF, T-H-A-N-K-S! >_< 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