TheDcoder Posted May 2, 2015 Posted May 2, 2015 Hello, I am using this function:Func ListScripts($sPath) Local $aFilesAU3 = _FileListToArray($sPath, "*.au3", 1, True) If @error = 4 Then Local $aFilesAU3[1] $aFilesAU3[0] = 0 EndIf Local $aFilesA3X = _FileListToArray($sPath, "*.a3x", 1, True) If @error = 4 Then Local $aFilesA3X[1] = 0 $aFilesA3X[0] = 0 EndIf If $aFilesAU3[0] = 0 And $aFilesAU3[0] = 0 Then Return Local $aReturn[UBound($aFilesAU3) + UBound($aFilesA3X) - 2] $aReturn[0] = $aFilesAU3[0] + $aFilesA3X[0] $iFileCount = $aFilesAU3[0] + $aFilesA3X[0] For $i = 1 To $aFilesAU3[0] $aReturn[$i] = $aFilesAU3[$i] Next _ArrayConcatenate($aReturn, $aFilesA3X, 1) Return $aReturn EndFuncBut It works only when the path contains both au3 & a3x filesI get this error: Missing subscript dimensions in "Dim" statement. Thanks in advance, TD EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion
iamtheky Posted May 2, 2015 Posted May 2, 2015 If $aFilesAU3[0] = 0 And $aFilesAU3[0] = 0going to guess you meant to check the a3x array with one of those ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
Luigi Posted May 2, 2015 Posted May 2, 2015 You can try:Local $aFilesAU3 = _FileListToArrayRec($sPath, "*.au3;a3x", 1, True) Visit my repository
jguinch Posted May 2, 2015 Posted May 2, 2015 (edited) Instead of using _FileListToArray twice, you could use _FileListToArrayRec in non-recursive mode :#Include <Array.au3> #Include <File.au3> ListScripts(@ScriptDir) Func ListScripts($sPath) Return _FileListToArrayRec($sPath, "*.au3;*.a3x", 1, 0, 0, 1) EndFuncEdit : Luigi was faster... Edited May 2, 2015 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
Moderators Melba23 Posted May 2, 2015 Moderators Posted May 2, 2015 TheDcoder,This works for me:#include <Array.au3> #include <File.au3> $sPath = @ScriptDir _ArrayDisplay(ListScripts($sPath), "", Default, 8) Func ListScripts($sPath) Local $aFilesAU3 = _FileListToArray($sPath, "*.au3", 1, True) If @error = 4 Then Local $aFilesAU3[1] = [0] EndIf Local $aFilesA3X = _FileListToArray($sPath, "*.a3x", 1, True) If @error = 4 Then Local $aFilesA3X[1] = [0] EndIf ; Check if any returns If $aFilesAU3[0] + $aFilesAU3[0] = 0 Then Return "" ; Best to return something! ; Concatenate the arrays _ArrayConcatenate($aFilesAU3, $aFilesA3X, 1) ; Add the count of the second array $aFilesAU3[0] += $aFilesA3X[0] ; Return the concatenated array Return $aFilesAU3 EndFuncM23 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
TheDcoder Posted May 2, 2015 Author Posted May 2, 2015 Thanks @Luigi & @jguinch!I adopted Melba's version of ListScripts, Thanks a lot @Melba23 for the less resource consumptive function EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion
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