Deleting variables in a file - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html) +--- Forum: QB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-11.html) +--- Thread: Deleting variables in a file (/thread-114.html) |
Deleting variables in a file - joey7643 - 01-30-2003 I know that you can use the KILL statement to delete a file from your hard drive within Qbasic, but if I wanted to remove a variable from a sequential file, how would I do that? Use the KILL command? Thanks. Deleting variables in a file - na_th_an - 01-30-2003 WOW!! NOOO!! KILL erases files, not records inside a file. To delete a record from a secuential file, you have to open it, read it, and write it again to an emplty file without adding that record. For example, let's say that you want to erase value "99" from an integer sequential file (for example). The file is NUMBERS.DAT Code: OPEN "NUMBERS.DAT" FOR INPUT AS #1 Deleting variables in a file - Antoni Gual - 01-30-2003 If it's a file of records: -Seek the position of the record -mark the record as empty by overwriting it with an impossible value. ..This way you don't need to rewrite the whole file. Next time you read the file just remember the impossible value means a deleted record and skip it each time you find it. Deleting variables in a file - Neo - 01-30-2003 Just wrap the whole file to the front then, instead of leaving a blank space. 8) Deleting variables in a file - joey7643 - 01-31-2003 How would I go about "wrapping" to the front? |