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

Username:   Password: 
 RegisterRegister   
 File In Use
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
uberwalla




PostPosted: Tue Dec 19, 2006 6:59 pm   Post subject: File In Use

Hey I was just wondering if there is a way to tell through turing if there is a file in use. just to give an example of what i mean. You go to delete your c:/ drive but and then it stops and says file in use.

is there a way to tell if a file is/ isnt in use?
Sponsor
Sponsor
Sponsor
sponsor
ericfourfour




PostPosted: Tue Dec 19, 2006 7:43 pm   Post subject: (No subject)

Since you cannot delete a file that is in use this program might do the trick. This is straight out of the manual at File.Delete.
code:
% The "File.Delete" program.
const pathName : string := "myfile.txt"

% Create file
var f : int
var line : string
open : f, pathName, put
put : f, "There is a line here"
close : f
put pathName, " created"

% Delete the file
File.Delete (pathName)
if Error.Last = eNoError then
    put skip, pathName, " deleted"
else
    put skip, "Did not delete ", pathName
    put "Error: ", Error.LastMsg
end if
uberwalla




PostPosted: Tue Dec 19, 2006 7:49 pm   Post subject: (No subject)

ok thx. i think that works Razz i dont wanna actually test it on one of my files because it might not be in use Razz but ok ty
uberwalla




PostPosted: Tue Dec 19, 2006 7:53 pm   Post subject: (No subject)

ok sorry for double post but for some reason the help section (of all forums Shocked ) doesnt have edit button Sad

anyways when u said skip was an actual command so i looked it up in reference to get its actual definition in full.

my question is:
if i were to delete many files at once using turing; this say: 1.txt, 2.txt, and 3.txt

if 1.txt was in use would the skip command tell it to skip to the next file (2.txt)?

because in skips definition it says that it just skips a line. like the "/n" in front of text in quotations does.

thx.
Clayton




PostPosted: Tue Dec 19, 2006 8:09 pm   Post subject: (No subject)

No, skip would not skip that file. Like the help manual says, it simply skips a line in the run window. If you wanted to skip a file, just use an if statement.
uberwalla




PostPosted: Tue Dec 19, 2006 8:20 pm   Post subject: (No subject)

thats the problem i dont know how Sad lol

is there a command that skips a file? like
if filename = inUse then
File.Skip (filename)?????
end if

it doesnt work but Razz is there a command like that Smile especially the inuse one would be most useful Smile lol
Tony




PostPosted: Tue Dec 19, 2006 8:31 pm   Post subject: (No subject)

you just have to catch the error / exception, and continue on with the loop
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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: