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

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




PostPosted: Tue May 30, 2006 8:08 pm   Post subject: Detecting Files?

Does turing have code for detecting files? My program creates files but it also has the delete file functionality. So, would I need a separate file with all the filenames saved in it, or is there some way I can directly list the files in a certain directory?
Sponsor
Sponsor
Sponsor
sponsor
Guest




PostPosted: Tue May 30, 2006 9:01 pm   Post subject: Listing Directory

Here's a little fun program I made:
code:

%Directory Listing Program
loop
    var winID := Window.Open ("graphics:0;0")
    var dir : string
    setscreen ("text")
    put "Enter a directory ('.' for current, '..' for back): " ..
    get dir : *
    put ""
    var streamNumber := Dir.Open (dir)
    var num : int
    var fileName : string
    var q : char

    for i : 1 .. streamNumber
        fileName := Dir.Get (streamNumber)
        put fileName
        exit when fileName = ""
    end for

    Dir.Close (streamNumber)

    put "Press any key to exit " ..
    Input.Pause
    Window.Close (winID)
end loop
[/code]
Cervantes




PostPosted: Tue May 30, 2006 9:04 pm   Post subject: (No subject)

You might want to check out the Dir tutorial.

Also, File.Exists may be of help to you. At least, that's what first came to mind when I was reading your question, though it seems to me now that the Dir module is what you're looking for.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: