----------------------------------- JR Wed Mar 24, 2004 5:17 pm 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. ----------------------------------- Delos Wed Mar 24, 2004 5:45 pm ----------------------------------- 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 Thu Mar 25, 2004 11:54 am ----------------------------------- 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 Thu Mar 25, 2004 3:49 pm ----------------------------------- 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 Thu Mar 25, 2004 5:07 pm ----------------------------------- i whould go with GUI's way, i think it whould be more effection if you whont to comply kill the old file. ----------------------------------- Delos Thu Mar 25, 2004 5:32 pm ----------------------------------- Well, depends on what he wants to do really. Wipe the file? GUI's method for sure. Just bits and drabs? My method. ----------------------------------- we64 Thu Mar 25, 2004 8:46 pm ----------------------------------- strongly agree with Delos. I think most of the time Delos' way is more useful. ----------------------------------- Dan Thu Mar 25, 2004 10:27 pm ----------------------------------- 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