forums

TNT Basic Forums > Bugs!
File Exists failing when given paths?
< Last Thread     Next Thread >
Author
Thread        Post A Reply

05-31-2003 23:04

Posted by:
anoved

Location:
Upstate NY

Find more posts by anoved

Hi, getting back in the swing of things here, and I think I may have found a bug with the File Exists command. It works fine, except when I pass it a path (such as ":Data:file.txt") to a file that I expect to be in a subfolder of the folder I'm currently in - it always returns true in this case, even if the file is not there. I'm calling it to make sure I don't try to open data files that aren't there. Here's an example:

Set Directory Game

if ( File Exists(":Data:file.txt") )
int f = open file( ":Data:file.txt",false,"TEXT","Text")
... stuff ...
else
... handle the error ...
end if

This code crashes on the open file line even if there is no file.txt or Data folder whatsoever, so I guess file exists gets confused when you give it a directory path? Not sure.

In any case, I just read the 'Giving values to arrays' thread in programming Q&A and I realize I may be able to take care of my data needs much more elegantly with data and read - I never knew about the restore command!

06-01-2003 18:10

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

Aren't directories represented by a "/" ?

06-01-2003 19:14

Posted by:
anoved

Location:
Upstate NY

Find more posts by anoved

directory

Look under the 'Set Directory' help page... TNT basic uses a colon to indicate directories (as is the classic Mac OS tradition). The 'open file' command understands this meaning of the colon just fine, and I just tried testing file exists with a slash - it doesn't do the trick. (It wouldn't make sense for different commands to use different separators anyway)

Thanks though!

06-01-2003 19:17

Posted by:
anoved

Location:
Upstate NY

Find more posts by anoved

Well, perhaps it is a Mac OS 9 vs Mac OS X problem, since OS 9 uses the colon to indicate directories and OS X uses the slash. Maybe file open 'understands' this and follows the path appropriately, while file exists doesn't convert paths to / if on OS X? I don't know. It's not a big deal.

06-01-2003 21:45

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

Or maybe you're not in the right directory? ( I don't know what you're trying to access, just remember you have to start from a directoory, you can't just enter an address )

06-01-2003 22:20

Posted by:
anoved

Location:
Upstate NY

Find more posts by anoved

Good suggestion, but yes, I'm certain I'm in the right directory. Should I assume from your suggestions that you cannot reproduce the problem I'm having with file exists? Otherwise, my guess is that it is a bug.

06-02-2003 22:09

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

In fact, I've never tried reading files from a subdirectory.

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.