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

Username:   Password: 
 RegisterRegister   
 Writing to a file without overwriting anything
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ans4




PostPosted: Sun May 20, 2007 10:53 am   Post subject: Writing to a file without overwriting anything

Is there a way that you can go to the end of a file and write something to there without erasing everything in the file?
Sponsor
Sponsor
Sponsor
sponsor
DIIST




PostPosted: Sun May 20, 2007 11:25 am   Post subject: Re: Writing to a file without overwriting anything

Use mod in the open file command. Like shown here:
Turing:

var stream : int
var variable : string := ""
open : stream, "file.txt",get,put,mod

loop
    exit when eof (stream)
    get : stream, variable :*      %reads the line
end loop

%Now at the end of file, it writes some new line.
put:stream, "Some string at the end of the file"

close:file


I modified my the example i posted in you last thread! It would be the same for binary files except you replace put and get with write and read. Hope this was helpfull. Wink
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  [ 2 Posts ]
Jump to:   


Style:  
Search: