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 / Having trouble writing string to file

Author
Message
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 22nd Jul 2013 22:12 Edited at: 22nd Jul 2013 22:16
I have this code, modified for testing purpose, that produces an empty file :-(



Does anybody have a clue as to why filename.dat is empty when I open it in notepad?? It is part of a much larger project if anybody was wondering, this is just the part that is troubling me right now.

EDIT: Compiling that piece of code alone also produces an empty file.

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Kezzla
17
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 22nd Jul 2013 23:35
I have had that issue before
so far as i know, open to write creates a new file too.
You have created a new empty file called filename.dat
you then try to make another filename.dat and write data to it which fails because the file already exists.

get rid of the first line and see how it goes.

I'm not a complete idiot -- Some parts are just missing.
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 22nd Jul 2013 23:37 Edited at: 22nd Jul 2013 23:37
This one had me confused for quite a while too, you're not alone
The command 'open to write' doesn't just open a file, it creates a blank file too! If the file it tries to create already exists, it simply aborts with the creating/opening. So basically, remove 'make file', and it should all work ok! Good luck

Edit: Kezzla, you beat me xP
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 23rd Jul 2013 03:45
Which makes you wonder when you would ever create a file without storing anything inside it...


"Why do programmers get Halloween and Christmas mixed up?"
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 23rd Jul 2013 11:09
Thanks guys! This solved my issue

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd Jul 2013 15:17
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 23rd Jul 2013 22:08
I already made file access much like you describe in your tutorial

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...

Login to post a reply

Server time is: 2026-07-06 20:52:49
Your offset time is: 2026-07-06 20:52:49