Jump to content

Recommended Posts

Posted

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.
Posted

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
^ ERROR

2. 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
EndIf

instead of this:

If $hSearch = -1 Then ContinueLoop

Especialy in loops.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: 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 Program

AutoIt_Icon_small.pngUDFs: 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
 
AutoIt_Icon_small.pngExamples: 
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 AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • Moderators
Posted

MrCreatoR,

Thanks for the comments. I worked very hard on the speed - you would not have been impressed by the early versions. :D

- 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. :P

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (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 by KaFu
  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (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 by KaFu
  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

...

- 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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

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'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 structure

A 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_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: 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 Program

AutoIt_Icon_small.pngUDFs: 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
 
AutoIt_Icon_small.pngExamples: 
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 AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted (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.00586525457404322

Note: Of course its not humanly noticeable!

Edited 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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Posted

@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 Gude
How 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
Posted

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. :P

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. :D

- 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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Posted (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 by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: 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 Program

AutoIt_Icon_small.pngUDFs: 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
 
AutoIt_Icon_small.pngExamples: 
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 AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • Moderators
Posted

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! :P

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • Moderators
Posted

New Version - 6 Mar 2011

Fixed - 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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • Moderators
Posted (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! :)

M23

Edit: Added time stamp as the initial panic is over. :)

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

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
Posted

supersonic,

Shouldn't it be "Local $iLastIndex = UBound($asReturnList) - 1"?

No! :P

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...