Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / File exist doesn't work properly

Author
Message
Mr Kohlenstoff
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 8th Sep 2010 23:19 Edited at: 8th Sep 2010 23:22
Well, I'm working on a game for quite some time now and while I had a few dbp-related bugs here and there, it never was a big problem, I always found some kind of acceptable workaround. However, this time it's really strange and I have no idea what I could do about it.

Have a look at this line:



I wrote it for debugging purposes since a function didn't do what it's supposed to do. So, f2$ is a filename, in this case "temp" + a number + ".prf", for instance "temp000009.prf".
When the program reaches this line, the dir-command reveals that the file f2$ actually does exist. However, the program doesn't leave this loop and "file exist(f2$)" always returns 0.
It makes absolutely no sense to me, especially since this is nearly exactly the same piece of code I've used several times in my project, and it always worked fine.



Just in case that might help, here the full function:



Oh, and by the way, I'm still using DBP 6.6. And since the project is near its completion, I don't really want to install the newest update so soon.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 8th Sep 2010 23:52 Edited at: 8th Sep 2010 23:52
Quote: "Oh, and by the way, I'm still using DBP 6.6. And since the project is near its completion, I don't really want to install the newest update so soon."


That's probably why you're having problems. It's got to be the fact that you haven't updated because for you to create the file and one line under the closing of that file it just doesn't make sense that FILE EXIST() doesn't work right.

Using the current update it goes right through the REPEAT/UNTIL loop as it should. You really should update.

http://www.thegamecreators.com/?m=view_product&id=2000&page=upgrade7-5

Mr Kohlenstoff
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 9th Sep 2010 00:09 Edited at: 9th Sep 2010 00:11
Oh, well. You're probably right, but I'm a bit afraid of the possibility that my projects won't compile/run anymore due to the changes. And, furthermore, I've just found out why it didn't work, or, at least, what caused the bug:

"open to write F, f2$
if Feature_Selected = ft_coop then f = Feature_Prev else f = Feature_Selected"

I'm using "F" as File-ID and "f" as temporary variable to store a value. Since DBP isn't case-sensitive, f will overwrite F and thus all the information are written into File that isn't even opened... kinda. I'm not that sure why that didn't result in a runtime-error, but however, it works now.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 9th Sep 2010 10:52
Quote: "Oh, well. You're probably right, but I'm a bit afraid of the possibility that my projects won't compile/run anymore due to the changes. And, furthermore, I've just found out why it didn't work, or, at least, what caused the bug: "


Copy your Darkbasic directory to another location and update. You may have to change a few things. But your program may work better with the newest update. If you can't get your program going in a few days with 7.5 use the 6.6 copy.

Quote: "if Feature_Selected = ft_coop then f = Feature_Prev else f = Feature_Selected""


Oh, I didn't even notice that line... sorry about that. Yeah that is weird it didn't give you a major error when trying to write to a file that's not open.

Login to post a reply

Server time is: 2026-07-22 12:41:17
Your offset time is: 2026-07-22 12:41:17