Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How to search for Files?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jamonathin




PostPosted: Fri Jan 27, 2006 1:33 pm   Post subject: How to search for Files?

How would you go about searching for a specific file in a folder? Such as, if I were to save a bunch of randomly named files in one folder, how could i get the names of every one of those files? It's easy enough after that, but how would I be able to get the names of files in a folder? . Confused
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Fri Jan 27, 2006 4:37 pm   Post subject: (No subject)

Check out the Dir module. I think that'll do it.
AzureFire




PostPosted: Sun Jan 29, 2006 1:46 pm   Post subject: (No subject)

Dir.Get - will tell you the name, you might be able to do a loop with an if statement to find it. That's all I know.
jamonathin




PostPosted: Mon Jan 30, 2006 2:27 pm   Post subject: (No subject)

Yeah Dir.Get was the right choice. You can simply put it into a flexible array and just store the values.

This is straight out of trusty F10 (edited of course), but I have one problem, well two. When the program runs, it displays whatever files there are in there plus the extension. The program does grab all files, but with some crap infront of it.

Problem: The first "filename" is '.'
and the second is '..'



Now I could just get around that in my program, by simply running a for loop and deleting any file that began with a ' . '
But if anyone knows how to stop that, from coming up, that'd be great, because then I'll throw that condition in as well, just to be safe Wink.
code:
var streamNumber : int
var fileName : flexible array 1 .. 0 of string
streamNumber := Dir.Open ("Misc")
assert streamNumber > 0
loop
    new fileName, upper (fileName) + 1
    fileName (upper (fileName)) := Dir.Get (streamNumber)
    exit when fileName (upper (fileName)) = ""
    put fileName (upper (fileName))
end loop
Dir.Close (streamNumber)
[Gandalf]




PostPosted: Mon Jan 30, 2006 6:51 pm   Post subject: (No subject)

Don't think so. If you've ever seen it in DOS or basically any old program, there will almost always be a . .. in the directory structure. I forget what the . means, but .. leads to the parent directory.
Andy




PostPosted: Mon Jan 30, 2006 11:07 pm   Post subject: (No subject)

. is the current directory
jamonathin




PostPosted: Tue Jan 31, 2006 1:26 pm   Post subject: (No subject)

Ok, as long as i know what it is, thanks.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: