Trying To Save Data In A Binary File @_@
Author |
Message |
Tubby_Kat
|
Posted: Tue May 12, 2009 7:24 pm Post subject: Trying To Save Data In A Binary File @_@ |
|
|
What is it you are trying to achieve?
Help with saving modified data in a binary file. @_@
What is the problem you are having?
The modified data isn't being saved in the end.
Describe what you have tried to solve this problem
I kept trying different ways in saving the data...I need help.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
This is just a part of the program so please don't comment on the lack of variables, and also if you want to see the rest or the beginning of the program just ask.
Turing: |
open : fileNum, "ContactRecords.bin", read, mod, seek
put "Enter new email address: " ..
get student.emailAddress
put "Do you want to save the modification? (Y/N) " ..
if answer = "Y" or answer = "y" or answer = "yes" then
open : fileNum, "ContactRecords.bin", write
write : fileNum, student.emailAddress
close : fileNum
put "Changes were saved"
else
%changes were saved
put "No changes were saved"
end if
close : fileNum
|
Please specify what version of Turing you are using
4.1
THANKS FOR YOUR HELP!!!
Quote: |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
DemonWasp
|
Posted: Tue May 12, 2009 7:35 pm Post subject: RE:Trying To Save Data In A Binary File @_@ |
|
|
You're opening the file twice before you ever write to it. Try removing the second open statement (and the close statement that it's coupled with) and try that instead. |
|
|
|
|
![](images/spacer.gif) |
Tubby_Kat
|
Posted: Tue May 12, 2009 7:38 pm Post subject: Re: Trying To Save Data In A Binary File @_@ |
|
|
I tried that. >____<
It didn't work
[/url] |
|
|
|
|
![](images/spacer.gif) |
Tubby_Kat
|
Posted: Tue May 12, 2009 7:39 pm Post subject: Re: Trying To Save Data In A Binary File @_@ |
|
|
This is the whole program
(Snip!)
Mod edit: Removed program per user's request. |
|
|
|
|
![](images/spacer.gif) |
rdrake
![](http://compsci.ca/v3/uploads/user_avatars/113417932472fc6c9cd916.png)
|
Posted: Tue May 12, 2009 8:07 pm Post subject: RE:Trying To Save Data In A Binary File @_@ |
|
|
I just deleted 5 of your posts. If you accidentally post a thread or post twice, PM a mod and they can take care of it for you.
Thank you for using the syntax tags, though. |
|
|
|
|
![](images/spacer.gif) |
Tubby_Kat
|
Posted: Tue May 12, 2009 8:22 pm Post subject: Re: Trying To Save Data In A Binary File @_@ |
|
|
thanx
-patiently waiting for some help- |
|
|
|
|
![](images/spacer.gif) |
Dusk Eagle
![](http://compsci.ca/v3/uploads/user_avatars/78727197549dd7290a342c.png)
|
Posted: Tue May 12, 2009 10:40 pm Post subject: Re: Trying To Save Data In A Binary File @_@ |
|
|
Every time you open a file to write to it, you must include a mod[ify] statement to tell the computer to modify the existing file, and not to overwrite it. Like this:
Turing: |
open : fileNum, "filename", write, mod
|
|
|
|
|
|
![](images/spacer.gif) |
|
|