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 Discussion / open to write

Author
Message
pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 17th Sep 2009 05:54
im having problems with this command i have an area in my code that attempts to create a file and write to it, but when I use this code. half the time it works. the other half it doesnt. help please
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 17th Sep 2009 07:48
Make sure to delete the file in-between tests. Without code its hard to guess.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 12th Oct 2009 04:25
Like BN2 says, the file has to be deleted. Open to write creates a file, then loads data to it. If there is a file already with the name you're trying to use, then it will return an error. Therefore this code may cause problems

where this code would work fine



However it is worth remembering that deleting files haphazardly may cause problems. Therefore, if the file is required for your game (for example a high score table) it may be worthwhile loading all the data into your program using open to read, then storing it, before you delete the original file. That way, important data won't be lost.

"A West Texas girl, just like me"
-Bush
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Oct 2009 04:55
Quote: "That way, important data won't be lost."


AMEN! so many problems with that in my time

New Site! Check it out \/
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Oct 2009 21:54
Yodaman Jer
User Banned
Posted: 17th Oct 2009 22:12
@TDK:

Your tutorial on file access is simply brilliant. It helped me out a lot when I started learning how to create game files. Now you should make a tutorial on how to make a basic level editor!

Cheers!

Click the pic:
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Oct 2009 21:56
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 19th Oct 2009 01:21
Just had a look at your tutorial Phaelax - you can't do types in DBC can you? would be good...

"A West Texas girl, just like me"
-Bush

Login to post a reply

Server time is: 2024-05-03 22:20:10
Your offset time is: 2024-05-03 22:20:10