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 / Little Save Code

Author
Message
Rknight
20
Years of Service
User Offline
Joined: 25th Sep 2003
Location: NJ
Posted: 24th Jan 2004 01:49
For some reason this little piece of code isn't working for me. I wondered if someone could point out what my blindspot is missing?

Basically I'm left with a "TEMP.DAT" file at 0 bytes with no information, when I'm trying to save a string in byte form.

Anyone without the BGUI can easily just put a test string in the GET GADGET TEXT command to try this thing out. Basically it defines areas of bytes to save information in, at 16000 byte field intervals.
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 24th Jan 2004 04:22 Edited at: 24th Jan 2004 04:27
perhaps move the close file command to the end of the commands so its closed after the data is stored within the file.

example code

Rknight
20
Years of Service
User Offline
Joined: 25th Sep 2003
Location: NJ
Posted: 24th Jan 2004 04:25
Would it were so, but no luck. I don't even know if it's necessary to create a blank file in the first place. The 'write byte to file' command help is a little spartan.
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 24th Jan 2004 04:28
perhaps the command is faulty.. does my example convert to what you want?
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 24th Jan 2004 04:34
perhaps its ok yes?

the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 24th Jan 2004 04:37
Use write byte instead eg


I think write byte to file requires the position you are writing to in the file to exist.

Can I scream?
Rknight
20
Years of Service
User Offline
Joined: 25th Sep 2003
Location: NJ
Posted: 24th Jan 2004 04:52 Edited at: 24th Jan 2004 04:53
Hrrrm. I just tried filling a file with zeros and using the write byte position but it doesn't seem to have worked.

I do have to use the positional byte writing/reading, or it's pointless however, I won't be able to find the information I need fast enough.
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 24th Jan 2004 06:11 Edited at: 24th Jan 2004 06:13
I think there are a couple of problems.

1. You need to make the file as big as you are going to need, the position you are writing to must be part of the file.

2. this line
POSADJ=((MARKER*16000)-15999)
In the code you posted MARKER isn't set a value so
((MARKER*16000)-15999) = POSADJ (0*16000) -15999 = -15999
You obviously can't write to a negative position in a file.

Hope I helped this time

Can I scream?
Rknight
20
Years of Service
User Offline
Joined: 25th Sep 2003
Location: NJ
Posted: 24th Jan 2004 14:10
Thanks guys. Good advice and made me think through the last steps. It's working finally.
Rknight
20
Years of Service
User Offline
Joined: 25th Sep 2003
Location: NJ
Posted: 24th Jan 2004 17:11
Hrmm.. Now if only I could figure out how to add on to a data file.

I've tested out creating a file, initializing it full of zeros which is necessary before you use the 'write byte to file' command, but I can find no command that allows one to add onto a file like that.

IE, if I want to increase the file size I have to rewrite the entire file from the start, which is troublesome with large files. I can't just add on another 16k of zeros at the end of the file each time I want to create a new entry.
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 25th Jan 2004 02:20
The lack on an append is a bit of a pain, I think the only way to do it would be a plugin.
Rknight
20
Years of Service
User Offline
Joined: 25th Sep 2003
Location: NJ
Posted: 25th Jan 2004 21:35
Hmm. I'm looking through the handy plugins list up top but..

Wow. Surprising someone hasn't done that for a plugin already. It's so simple and so useful at once.

Even that 'underware' design guy doesn't have it as far as I can tell.

Login to post a reply

Server time is: 2024-09-21 18:07:13
Your offset time is: 2024-09-21 18:07:13