Jump to content

FileFindFirstFile()


J_Y_C
 Share

Recommended Posts

For some reason, FileFindFirstFile() has been returning 3, 4, 5, 6,, etc. when it should only be returning 1, -1, or the file name. At least, according to the help file that's what it should return.

Why might I be seeing these values with this function?

Link to comment
Share on other sites

hmmm, that's probably the problem, I don't think I closed the file before iterating. You are correct though, I am using it in a loop, and I figured that it had something to do with that.

But, when I set up FileFindFirstFile() in a test situation, on success it returns the filename, not a positive integer. but when I put it into practice, it returns those integer values.

Now, if the operation was successful, why would it be returning integers saying it was successful? Why wouldn't it just return the filename?

Link to comment
Share on other sites

Okay, I am getting super frustrated with this now.

Under what conditions does it return an integer vs. when it returns the actual FileFind result?

For example, when I plug the following in (taken from the help file), it returns the file name as it should.

So, I have a file in c:\test\ called robot454-89.txt, and the following returns a box reporting the filename.

; Shows the filenames of all files in the current directory.
$sDir = "C:\test\"
$sFN = "r*-89.txt"

$search = FileFindFirstFile($sDir & $sFN)  

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    
    MsgBox(4096, "File:", $file)
WEnd

; Close the search handle
FileClose($search)

But when I set up the same conditions in the script I need it to work in, it doesn't return filenames to me, it returns integers.

What makes it decide to return an integer versus the file handle?

Edited by J_Y_C
Link to comment
Share on other sites

Hmmmm, that'll be kind of tough for me to post the actual script that I am using it with, it's laden with function calls and stuff that's pretty specific to my purposes.

Can you tell me, would not closing file handles used with this function cause it to return integers instead of filenames? Shouldn't it throw an error if that were the case?

Link to comment
Share on other sites

Damn, that's the problem. I didn't fully realize what exactly FileFindFirstFile

was giving me.

That was EXACTLY what I needed to hear, Larry. Everything works now!!!! :P

Once again, the mods and admins of this board come to my rescue!!

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