Jump to content

Recommended Posts

Posted

I have an AutoIt script that lets the user choose a folder containing the files, then processes the files one by one in an image processing program. It creates an array of file names and opens the files one at a time. When I have a folder with 50 files or more,  the script quits right after making the array. If I have 49 or less, it works perfectly. The code is below. I have a Windows 7, 64 bit system. I tried compiling it in 32 and 64 bit versions and it did the same thing.

Is there any reason why it should not work? Or is there a better way to pick files and go through the list one at a time?

;Define some variables upfront
$ProgName = "Fta32 Video 2.1"
$ProgAddress = "C:\Program Files (x86)\Fta32\FTA32.exe"

ChooseFolder()
$filesList = _FileListToArray ($sFileSelectFolder,"*.mdb")

WinActivate ($ProgName)
;_ArrayDisplay ($filesList)
For $j = 1 to _ArrayMaxIndex($filesList)
;Code to process files
Next

Func ChooseFolder()
    ; Create a constant variable in Local scope of the message to display in FileSelectFolder.
    Local Const $sMessage = "Select a folder"

    ; Display an open dialog to select a file.
    Global $sFileSelectFolder = FileSelectFolder($sMessage, "")
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.")
        Exit
    EndIf
EndFunc

 

Posted

The issue is using _ArrayMaxIndex($filesList); re-read help for understanding why.

Use Ubound($filelist) - 1 instead.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted

Reread the help of this function: it doesn't do what you think it does. It returns the index of the greatest (sort-wise) element, compared to UBound which returns the number of elements in the given dimension or D1 by default.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted

AH! Now I see. I was lucky that the files just happened to be in alphabetical order. So the largest value was coincidentally the highest index. But on another set of files I had a different naming scheme and it was not in order. Thank you for the enlightenment.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...