Sign in to follow this  
Followers 0
J_Y_C

FileFindFirstFile()

6 posts in this topic

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?

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

show us your script - so we can debug it

and show us a portion of the file you are reading to be sure of the returned information

8)


NEWHeader1.png

Share this post


Link to post
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?

Share this post


Link to post
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!!

Share this post


Link to post
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
Sign in to follow this  
Followers 0