Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Trying To Save Data In A Binary File @_@
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Tubby_Kat




PostPosted: 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:
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: 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.
Tubby_Kat




PostPosted: 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]
Tubby_Kat




PostPosted: 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.
rdrake




PostPosted: 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.
Tubby_Kat




PostPosted: Tue May 12, 2009 8:22 pm   Post subject: Re: Trying To Save Data In A Binary File @_@

thanx
-patiently waiting for some help-
Dusk Eagle




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: