Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Deleting variables in a file
#2
WOW!!
NOOO!!

Smile

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
OPEN "NUMBERS.2" FOR OUTPUT AS #2
WHILE NOT EOF(1)
   INPUT #1, number%
   IF number% <> 99 THEN PRINT #2, number%
WEND
CLOSE
' Now we KILL the original file
KILL "NUMBERS.DAT"
' And we change the name of the new file:
NAME "NUMBERS.2" AS "NUMBERS.DAT"
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Messages In This Thread
Deleting variables in a file - by joey7643 - 01-30-2003, 03:02 AM
Deleting variables in a file - by na_th_an - 01-30-2003, 03:08 AM
Deleting variables in a file - by Antoni Gual - 01-30-2003, 04:39 AM
Deleting variables in a file - by Neo - 01-30-2003, 04:12 PM
Deleting variables in a file - by joey7643 - 01-31-2003, 01:50 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)