Moderators Popular Post Melba23 Posted March 5, 2011 Moderators Popular Post Posted March 5, 2011 (edited) UDF Deprecated - 23 Dec 2013As since the release of v3.3.10.0 the basis of this UDF is now included in the standard AutoIt UDFs as _FileListToArrayRec in File.au3, support will end in this thread and any future bug reports or feature requests should be made via Trac. Note that there are a couple of major changes in the new function compared to this UDF:- You must place the Include|Exclude|Exclude_Folder masks in the single $sMask parameter, delimited by "|". The old syntax with the "exclude" masks at the end of the parameter list will no longer work, unlike this UDF.- The values returned in @extended in the event of an error have been reordered to reflect the above - so you might need to amend your errorchecking. But note that "no files found" still returns 9 in @extended - I am not that cruel! - The sort algorithm has been changed from QuickSort to DualPivot, which is significantly faster for large arrays. I hope you appreciate the faster return times.This zip remians available for those who do not wish to update immediately: RFLTA.zipM23 Edited December 23, 2013 by Melba23 Mechaflash, ineedh3lp, jaberwacky and 3 others 6 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
AppTux Posted March 5, 2011 Posted March 5, 2011 Whoa, a really useful script! Maybe for a explorer look-a-like with grouped extensions? PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.
MrCreatoR Posted March 5, 2011 Posted March 5, 2011 Well done, i impressed by the speed of that UDF!But here is a few problems and remarks...1. When i run this example:#include "RecFileListToArray.au3" ; A sorted list of all files and folders in the Program files dir $aArray = _RecFileListToArray(@ProgramFilesDir, "*", 0, 1, 1, 2)i got this error:RecFileListToArray.au3 (494) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $avArray[$iElement] = $vValue ^ ERROR2. StringRegExpReplace($sInitialPath, "\\", "") better replace with regular StringReplace function, i.e:StringReplace($sInitialPath, "\", "") ... StringReplace($sCurrentPath, "\", "")3. You can increase the speed even more, if you use this construction:If $hSearch = -1 Then ContinueLoop EndIfinstead of this:If $hSearch = -1 Then ContinueLoopEspecialy in loops. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
Moderators Melba23 Posted March 5, 2011 Author Moderators Posted March 5, 2011 MrCreatoR,Thanks for the comments. I worked very hard on the speed - you would not have been impressed by the early versions. - 1. Array variable has incorrect number of subscripts or subscript dimension range exceeded. I do not get that error when I run exactly the same code as you - so I cannot help there unless I can have some more clues. - 2. StringRegExpReplace vs StringReplace. Why do you suggest changing? - 3. Single line If vs If...EndIf. I did some timing tests on the various forms of If compared to Switch and Select some time ago and (on my machine at least) the single line If was faster then the If...End structure - although not by a lot. 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
KaFu Posted March 5, 2011 Posted March 5, 2011 (edited) I would even suggest to replace it with StringReplace($sInitialPath, "\", "", 0, 2). $sInitialPath = @ScriptFullPath $timer = TimerInit() For $i = 0 To 100000 StringRegExpReplace($sInitialPath, "\\", "") Next ConsoleWrite(TimerDiff($timer) & @CRLF) $timer = TimerInit() For $i = 0 To 100000 StringReplace($sInitialPath, "\", "") Next ConsoleWrite(TimerDiff($timer) & @CRLF) $timer = TimerInit() For $i = 0 To 100000 StringReplace($sInitialPath, "\", "", 0, 2) Next ConsoleWrite(TimerDiff($timer) & @CRLF) Edit: Maybe you want to check every standard function call supporting a "casesense" flag, as imho if you know the case (e.g. like "\" has no case) setting the flag to "2 = not case sensitive" is always much faster. Edited March 5, 2011 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Moderators Melba23 Posted March 5, 2011 Author Moderators Posted March 5, 2011 KaFu, Interesting timings - SRER = 1310 SR = 1248 SR flag 2 = 557 I will keep that in mind the next time I need to count character occurences in a string! But as the line is used just the one time in this UDF, it would only save around 0.05 ms - I am not sure that even you would notice the difference. 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
KaFu Posted March 5, 2011 Posted March 5, 2011 (edited) I think there are more lines which could be replaced as imho they do not need to be checked for case sensitivity... StringRegExpReplace($sInitialPath, "\\", "") $sRetPath = StringReplace($sCurrentPath, $sInitialPath, "") StringRegExpReplace($sCurrentPath, "\\", "") $sList = StringReplace(StringStripWS(StringRegExpReplace($sList, "\s*;\s*", ";"), 3), ";", "|") $sList = StringReplace(StringReplace(StringRegExpReplace($sList, "(\^|\$|\.)", "\\$1"), "?", "."), "*", ".*?") <<< double replacement possible Maybe also If StringInStr($avArray[$i], $vValue) > 0 Then Return $i StringCompare() ? And as you're defining array[0] = count, you could also drop some ubound() calls . Edited March 5, 2011 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Moderators Melba23 Posted March 5, 2011 Author Moderators Posted March 5, 2011 KaFu, The third one of those is probably worth doing as it is a loop - I will keep it in mind for the next update. Danke sehr. 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
UEZ Posted March 5, 2011 Posted March 5, 2011 ...- 1. Array variable has incorrect number of subscripts or subscript dimension range exceeded. I do not get that error when I run exactly the same code as you - so I cannot help there unless I can have some more clues. ...It runs properly on my system, too! Win7 SP1 x64.Br,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
MrCreatoR Posted March 5, 2011 Posted March 5, 2011 I do not get that error when I run exactly the same code as you - so I cannot help there unless I can have some more cluesIt's probably related to mount of files in the folder (i got 16519 files in my program files folder), you should never write code in the way that will trigger this kind of errors, use something like this: Func _RFLTA_ArrayInsert(ByRef $avArray, $iElement, $vValue = "") Local $iUBound = UBound($avArray) + 1 ReDim $avArray[$iUBound] For $i = $iUBound - 1 To $iElement + 1 Step -1 $avArray[$i] = $avArray[$i - 1] Next If $iElement >= $iUBound Then ReDim $avArray[$iElement+1] EndIf $avArray[$iElement] = $vValue EndFunc Btw, it's related to sort parameter, if it's 0 then no errors. StringRegExpReplace vs StringReplace. Why do you suggest changing?Why to use RegExp when it's not needed? I did some timing tests on the various forms of If compared to Switch and Select some time ago and (on my machine at least) the single line If was faster then the If...End structureA while ago i thought that way too, but i did some new tests and they shows other results. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
guinness Posted March 5, 2011 Posted March 5, 2011 (edited) I thought the same as Melba23 too, because I asked this question (about If Statements) a while back. It also it seems logical, less lines = more performance. But testing this I get a difference result to what I would have expected Global $Variable = 1, $Timer $Timer = TimerInit() If $Variable = 1 Then $Variable = 1 ConsoleWrite(TimerDiff($Timer) & @CRLF) ; Average = 0.00830911064656123 $Timer = TimerInit() If $Variable = 1 Then $Variable = 1 EndIf ConsoleWrite(TimerDiff($Timer) & @CRLF) ; Average = 0.00586525457404322Note: Of course its not humanly noticeable! Edited March 5, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
BrewManNH Posted March 5, 2011 Posted March 5, 2011 @guiness I modified the tests a bit, running each one 100 times and recording the results and running both test segments 100 times and comparing the results. So after running the tests 10,000 each the results are pretty consistent that the second test is a tiny bit faster. I don't think changing one for the other will affect much of anything in the long run unless you have 1000's of comparisons of this sort to run, but it's fun to find out the facts behind the conjecture. Here's the code I used Global $Variable = 1, $Timer Global $File = FileOpen("C:\Test.txt", 2) For $X = 1 To 100 $Timer = TimerInit() For $I = 1 To 100 If $Variable = 1 Then $Variable = 1 Next FileWrite($File, TimerDiff($Timer) & " -------- ") $Timer = TimerInit() For $I = 1 To 100 If $Variable = 1 Then $Variable = 1 EndIf Next FileWriteLine($File, TimerDiff($Timer) & @CRLF) Next And here's the results from one test run. Some of the results are very different than the rest probably due to the slow computer I'm running it on and hard drive access. 0.556495308761309 -------- 1.66697164025037 3.43647027764702 -------- 0.253384159159893 0.258971461456694 -------- 0.171809545626609 0.258971461456694 -------- 0.171809545626609 0.258412731227013 -------- 0.172088910741449 0.258692096341853 -------- 0.171809545626609 0.258692096341853 -------- 0.171530180511769 0.258133366112173 -------- 0.171530180511769 0.258692096341853 -------- 0.171809545626609 0.258412731227013 -------- 0.171809545626609 0.258133366112173 -------- 0.171809545626609 0.258412731227013 -------- 0.171530180511769 0.258412731227013 -------- 0.171809545626609 0.258133366112173 -------- 0.172368275856289 0.258971461456694 -------- 0.171809545626609 0.258971461456694 -------- 0.171530180511769 0.258412731227013 -------- 0.171809545626609 0.258692096341853 -------- 0.172088910741449 0.258692096341853 -------- 0.171809545626609 0.258133366112173 -------- 0.171809545626609 0.258692096341853 -------- 0.171809545626609 0.258692096341853 -------- 0.171530180511769 0.258133366112173 -------- 0.171809545626609 0.258412731227013 -------- 0.171809545626609 0.258692096341853 -------- 0.171809545626609 0.257854000997333 -------- 0.171809545626609 0.258412731227013 -------- 0.171809545626609 0.258412731227013 -------- 0.171809545626609 0.258412731227013 -------- 0.171250815396929 0.258971461456694 -------- 0.171809545626609 0.258692096341853 -------- 0.171809545626609 0.310374642587256 -------- 0.171809545626609 0.258971461456694 -------- 0.171809545626609 0.258692096341853 -------- 0.171809545626609 0.258412731227013 -------- 0.171809545626609 0.258692096341853 -------- 0.171530180511769 0.258692096341853 -------- 0.171809545626609 0.258133366112173 -------- 0.171809545626609 0.258412731227013 -------- 0.171809545626609 0.258412731227013 -------- 0.171809545626609 0.257854000997333 -------- 0.171809545626609 0.258412731227013 -------- 0.171530180511769 0.259530191686374 -------- 0.171809545626609 0.260088921916054 -------- 0.171809545626609 0.259250826571534 -------- 0.171530180511769 0.258692096341853 -------- 0.171809545626609 0.258133366112173 -------- 0.171809545626609 0.258971461456694 -------- 0.171809545626609 0.258971461456694 -------- 0.171530180511769 0.258133366112173 -------- 0.171809545626609 0.258692096341853 -------- 0.171530180511769 0.258692096341853 -------- 0.171809545626609 0.258133366112173 -------- 0.171809545626609 0.258412731227013 -------- 0.171809545626609 0.258412731227013 -------- 0.171809545626609 0.257854000997333 -------- 0.171809545626609 0.258133366112173 -------- 0.172368275856289 0.258971461456694 -------- 0.171809545626609 0.258412731227013 -------- 0.171809545626609 0.258692096341853 -------- 0.171530180511769 0.258971461456694 -------- 0.171809545626609 0.258412731227013 -------- 0.171809545626609 0.258692096341853 -------- 0.171809545626609 0.352838140042938 -------- 0.172088910741449 0.258412731227013 -------- 0.171809545626609 0.258692096341853 -------- 0.171809545626609 0.258692096341853 -------- 0.171809545626609 0.258133366112173 -------- 0.171809545626609 0.258412731227013 -------- 0.171809545626609 0.258692096341853 -------- 0.171530180511769 0.257854000997333 -------- 0.171530180511769 0.258133366112173 -------- 0.171809545626609 0.258971461456694 -------- 0.171809545626609 0.258412731227013 -------- 0.171530180511769 0.258692096341853 -------- 0.171530180511769 0.258971461456694 -------- 0.171809545626609 0.258133366112173 -------- 0.171809545626609 0.258692096341853 -------- 0.171809545626609 0.258692096341853 -------- 0.171809545626609 0.258412731227013 -------- 0.171809545626609 0.258412731227013 -------- 0.171809545626609 0.258412731227013 -------- 0.171809545626609 0.257854000997333 -------- 0.171809545626609 0.258692096341853 -------- 0.171809545626609 0.258133366112173 -------- 0.172088910741449 0.258971461456694 -------- 0.171809545626609 0.258971461456694 -------- 0.171809545626609 0.258971461456694 -------- 0.171809545626609 0.258692096341853 -------- 0.171809545626609 0.258692096341853 -------- 0.172088910741449 0.258971461456694 -------- 0.171809545626609 0.258412731227013 -------- 0.172088910741449 0.258692096341853 -------- 0.172088910741449 0.258692096341853 -------- 0.171809545626609 0.258133366112173 -------- 0.171809545626609 0.372393698081739 -------- 0.171809545626609 0.258692096341853 -------- 0.171809545626609 0.258133366112173 -------- 0.172088910741449 0.294730196156215 -------- 0.171809545626609 0.259809556801214 -------- 0.171530180511769 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Moderators Melba23 Posted March 6, 2011 Author Moderators Posted March 6, 2011 MrCreatoR,- 1. _ArrayInsert function.I do not think it is the number of files - I have nearly 70000 in my Programs folder and, although it takes some time, the UDF sorts them all perfectly well. Thanks for the coding suggestion, but it is not a valid one in this case - and I do try to put errorchecking in my code when it is needed. The value of $iElement passed to the function is the index of an existing array counting up from the max to 1, so it must be less that the current size of the array. And you can seee that the lines prior to the one which threw the error actually run from the new increased max to the value of $iElement. As I check in the main code to prevent -1 being passed, I am at a loss to explain to what might be happening. As it seems to be a problem unique to your machine and folder structure, would you mind running the code again with an added line at the very beginning of the function:ConsoleWrite($iElement & @CRLF)and seeing what value is passed when it crashes? Thanks in advance. - 2. SRER vs StringReplace. Good point - when I was writing this I was deep in my continuing struggle to learn about the dratted things and therefore an SRER jumped to mind. Having seen KaFu's results above I will change my coding strategy from now on. - 3. If structure differences. It seems to be very machine/code dependant. I remember going through all of my scripts checking that I had removed all the single item If..EndIf statements - looks like I might have to go back and do it again, but the other way round! ; -------guinness and BrewManNH,Go start your own topic if you want to discuss If speeds! 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
guinness Posted March 6, 2011 Posted March 6, 2011 Go start your own topic if you want to discuss If speeds!Sorry I use this UDF quite a bit so Thanks! UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
MrCreatoR Posted March 6, 2011 Posted March 6, 2011 (edited) would you mind running the code again with an added line at the very beginning of the function:I added theese lines: ConsoleWrite("Index:" & $iElement & @LF) ConsoleWrite("Ubound: " & UBound($avArray) & @LF) Here is what i got: Index: 16569 Ubound: 13205 as you can see, the index is grater than ubound. You can reproduce the problem like this: #include <Array.au3> #include "RecFileListToArray.au3" DirCreate("C:\Test\Folder\SubFolder") $aArray = _RecFileListToArray("C:\Test", "*", 0, 1, 1, 1) _ArrayDisplay($aArray) Edited March 6, 2011 by MrCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
Moderators Melba23 Posted March 6, 2011 Author Moderators Posted March 6, 2011 MrCreatoR,Thank you so much for that - I have identified the problem. It was entirely of my own making - I was using the [0] element as a count and increased it too early. I now use UBound and the problem is solved - for the test code you posted, at least. This error only seemed to occur if there were empty folders with subfolders at the end of the tree, which was not a scenario I had tested - I love how people manage to find dusty corners of the envelope to explore as soon as you release something! New version coming as soon as I can post it - and I promise to change some SRERs as well to keep you and KaFu happy! 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
Moderators Melba23 Posted March 6, 2011 Author Moderators Posted March 6, 2011 New Version - 6 Mar 2011Fixed - crash when sorting empty folders with subfolders at the end of the tree (thanks MrCreatoR)Changed - Should be even faster with some StringReplace and If structure changes (thanks KaFu and guinness)New UDF and zip in first post. 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
Moderators Melba23 Posted March 6, 2011 Author Moderators Posted March 6, 2011 (edited) Ooops!If you downloaded the new version before 1220 UTC Sun 6 Mar, please do it again - the wrong file was in the zip! M23Edit: Added time stamp as the initial panic is over. Edited March 6, 2011 by Melba23 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
supersonic Posted March 7, 2011 Posted March 7, 2011 Melba, greate UDF - one of my favs! You changed "Local $iLastIndex = $asReturnList[0]" (old version) to "Local $iLastIndex = UBound($asReturnList)" (new version). Is "$asReturnList" a one-based array, isn't it? Shouldn't it be "Local $iLastIndex = UBound($asReturnList) - 1"? I' am I wrong? Greets, -supersonic.
Moderators Melba23 Posted March 7, 2011 Author Moderators Posted March 7, 2011 supersonic, Shouldn't it be "Local $iLastIndex = UBound($asReturnList) - 1"?No! Explanation: The reason it is called $iLastIndex is not because it is the final index in the array, but the most recent index used to insert an element into the array. I needed to change its initial setting value to prevent the crash which MrCreatoR found. As you point out the old code looked at the count (and I had added the count too early in the process ) so in some very special circumstances I was trying to insert the new element beyond the end of the array. By using UBound($asReturnList) I know that the new element will always fit as the returned value will always match the final element index of the array once ReDim has added an additional element to hold the new value - which might well be at the end of the array. I hope that is clear enough. 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
Recommended Posts