
-----------------------------------
jamonathin
Fri Jan 27, 2006 1:33 pm

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? . :?

-----------------------------------
Cervantes
Fri Jan 27, 2006 4:37 pm


-----------------------------------
Check out the Dir module.  I think that'll do it.

-----------------------------------
AzureFire
Sun Jan 29, 2006 1:46 pm


-----------------------------------
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
Mon Jan 30, 2006 2:27 pm


-----------------------------------
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 ;).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]
Mon Jan 30, 2006 6:51 pm


-----------------------------------
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
Mon Jan 30, 2006 11:07 pm


-----------------------------------
. is the current directory

-----------------------------------
jamonathin
Tue Jan 31, 2006 1:26 pm


-----------------------------------
Ok, as long as i know what it is, thanks.
