Hi All,

On 7 Mar 2007, at 12:20, Marielle Lange wrote:

I agree I wouldn't want a dialog box either, but it would be good if it either just refused to delete the file silently, returned an error code and/or threw an an exception that could be "caught".

if there is a file tTargetFile then
throw "the file already exists" -- replace by a more appropriate error message
else
        rename file tSourceFile to tTargetFile
end if

Well that will work unless of course the target file just happens to be a Mac OS X bundle file. Then of course it won't work at all.

Also note that the "file" keyword above is incorrect. The "rename" command does not follow the same syntax as "delete file" and since rename works on folders too you'd have to use the a "folder" keyword for folders.

I expect you to tell me: If this is that simple,

It's not that simple to do in RunRev, see above, it would much simpler and straight forward implemented inside RunRev.

why didn't they code it like this?

God Knows! But I have a clue. See below!

Because sometimes you want the ability to overwrite the file without an error to be thrown.

Why would you want to do this when there is a delete file function? Also it's just as simple (or not so simple) to do this:

if there is a file tTargetFile then
   delete file iTargetFile
else
  rename tSourceFile to tTargetFile
end if

This way if you don't explicitly delete the file you will get an error. This is a much safer and better way of doing things.

The responsibility to check for file existence is therefore left to the programmer so to give him more flexibility.

I disagree. It doesn't give any more flexibility since there are other ways to do it that are far less dangerous. But I really don't think that "flexibility" had anything to do with how this command works. I think it was one or more of the following:

1.  They couldn't be bothered to do it properly.
2.  They didn't have enough time to do it properly
3. They thought that the so called purity of Unix Commands should be brought into RunRev or whatever it was called then.
4.  It was easier to do it like this.
5.  They didn't realize it did overwrite the file.

Sure, a warning in the docs of the like "if the file exists, it will be overwitten" could be added.

I agree, at the very least this should be done.

Are you seriously telling us that you believe that the way that the "rename" works is a good way to implement a "rename" function in a high level programming environment aimed at novice programers?

All the Best
Dave

_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to