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.

Newcomers DBPro Corner / writing to file question,not working

Author
Message
David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 17th May 2009 23:11
hi im trying to write a variable to a file but its not writing the
variable correctly.when i look at the file its wrong,it has like a symbol or something,what am i doing wrong??
heres my code..

Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 17th May 2009 23:25
When you open to write, the file must first not exist. You need to make a check to see if it exist and if it does then you have to delete it.

Insert this line or something equivalent right befor the Open to Write line.
David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 17th May 2009 23:30
i did make sure the file didnt exist. your suggestion didnt help either. i typed in 44 and it wrote a comma into the file. :/
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 17th May 2009 23:47
I think your code is working, just not the way you are expecting.

Try READ WORD and see if you get back the value you think you should be getting.

Basically, although you have called the file "myfile.txt", it isn't a text file ^_^ DBP has written the value 44 as a word to the file, which the text editor is then intepreting as a comma.

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 18th May 2009 02:00
Ya, Dream And Death is right. If you want the number to appear as a number in the text file rather than as raw data, you need to convert it to a string with Str$(), then write the string to the file with Write String.

i like orange
David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 18th May 2009 02:30
thanks! i guess dbp encrypts the file or something.
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 18th May 2009 02:37
It isn't encryption - DBP is just writing data in binary. When your text editor reads the binary, it tries to read it as text, which results in a lot of wierd symbols. As stated, if you opened up the file in a hex editor or read it back from DBP, you would see your value right there.



Login to post a reply

Server time is: 2024-09-28 06:24:52
Your offset time is: 2024-09-28 06:24:52