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

Username:   Password: 
 RegisterRegister   
 how to delete data from a txt file?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
JR




PostPosted: Wed Mar 24, 2004 5:17 pm   Post subject: how to delete data from a txt file?

ok, in my program i made it so it would erase the data variable, but lets say i put some data into the file, then i want to delete that data from the file not all the file only the data. how do i do that? cause my prog deleted the data from the variable and inorder to delete it on the file i need to save it agian.
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Wed Mar 24, 2004 5:45 pm   Post subject: (No subject)

First, read in the entire file.
Then remove the necassary data from RAM.
Then write the file.

Method wrote a good eg. a while back...I'll try find it then repost.

Ah well, can't find it...but, try the method above (hehehe...ah, the irony).
GUI.GetScrollBarWidth : i




PostPosted: Thu Mar 25, 2004 11:54 am   Post subject: (No subject)

use file.deletetxt("filename") that will delete all the text in the file then you can write new stuff. that's the only way i knoww any way
Thuged_Out_G




PostPosted: Thu Mar 25, 2004 3:49 pm   Post subject: (No subject)

i would go with delos's way. read the whole file, delete the parts you want. then write it back to the same file
Dan




PostPosted: Thu Mar 25, 2004 5:07 pm   Post subject: (No subject)

i whould go with GUI's way, i think it whould be more effection if you whont to comply kill the old file.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Delos




PostPosted: Thu Mar 25, 2004 5:32 pm   Post subject: (No subject)

Well, depends on what he wants to do really.
Wipe the file? GUI's method for sure.
Just bits and drabs? My method.
we64




PostPosted: Thu Mar 25, 2004 8:46 pm   Post subject: (No subject)

strongly agree with Delos. I think most of the time Delos' way is more useful.
Dan




PostPosted: Thu Mar 25, 2004 10:27 pm   Post subject: (No subject)

that it is if u only whont to get ride scrent pices and not the hole thing witch he dose. i was just trying to say that but i think it made it look i ment that GUI's way is all ways better. But both will work fine realy and whould be very very close in exuction time.

if this is for a game the best way to go about it whould be to get all the data from the file at the start, do w/e with it to load th curnt spot in the game (asmuming it is for some kind of save file). keep mofining the vars during the game and the dump them back when u save your spot in the game. Also for a DB a method like that whould be a good idea as well. GUI's method whould be best for when u dont care waht is in the file and just whont it gone
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: