Jump to content

_FileListToArray issue


Recommended Posts

Having an issue with _FileListToArray and the possible error codes. I'm doing searches for different file types and when it doesn't find a file type in a folder, it errors. First I'm sending a directory list out to a txt file and then reading that list one by one. I'm writing the output to a csv - will be using it to find the number of different file types. I have a msgbox to tell me what the error code is at the time, but when it says its got error code 4 (no files), it skips the case @error=4 statement and goes to one of the others where it tries to execute "$xlsnum=$xlsfiles[0]", which is the read of row/col 0,0..the number of files in that folder. That throws an error. Is there a reason why when it doesn't file files it can't just show 0 instead of being blank?

$xlsnum=$xlsfiles[0]

$xlsnum=$xlsfiles^ ERROR

Sorry if this is crappy coding...just trying to put something together quickly:

#Include <File.au3>
#Include <Array.au3>

$xlsnum=1

runwait (@Comspec &" /c dir c:\temp\*. /s /b > c:\temp\dirlist.txt")

If FileExists("c:\temp\output.csv") Then
    FileDelete("c:\temp\output.csv")
Endif

$output=FileOpen("c:\temp\Output.csv",2)
FileWriteLine($output,"Directory,Excel,Word,PowerPoint,Visio")


$dirlist=FileOpen("c:\temp\dirlist.txt",0)
While 1
    $dirline=FileReadLine($dirlist)
;Msgbox(0,"test",$dirline&":"&@error)
    If @error= -1 Then ExitLoop
        $xlsfiles=_FileListToArray($dirline,"*.xls",1)
            Msgbox(0,"Test",$dirline&":"&@error)
           Select
            Case @error=4
                Msgbox(0,"Error 4","Test")
                $xlsnum=0
                FileWriteLine($output, $dirline&","&$xlsnum)
            Case $xlsnum<>0
                $xlsnum=$xlsfiles[0]
                FileWriteLine($output, $dirline&","&$xlsnum)
            Case @error=0
                $xlsnum=$xlsfiles[0]
                FileWriteLine($output, $dirline&","&$xlsnum)
            Case @error=1 
                ExitLoop
            EndSelect
WEnd
Link to comment
Share on other sites

  • Moderators

MsgBox() kills the @error set by _FileListToArray()

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

MsgBox() kills the @error set by _FileListToArray()

OMG dude...I'm such an idiot. I had a feeling there was an @error conflict but I didn't even think about msgbox. I use that for figuring out where the script is puking.

That did the trick...took those out and was able to test for the correct error codes.

Thanks man!!!

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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