Friday, October 18, 2019

180. Qbasic sequential file handling to Delete some records from “neps.dat” file


180.Delete some records from “neps.dat” file where computer ask user to enter the record, which is to be deleted. (Fields are name, address, and telephone number)

OPEN “NEPS.DAT” FOR INPUT AS #1
OPEN “TEMP.DAT” FOR OUTPUT AS #1
CLS
INPUT “Enter name which is to be deleted”; D$
WHILE NOT EOF(1)
INPUT #1, N$, A$, T#
IF UCASE$(D$)<>UCASE$(N$) THEN
WRITE #2, N$, A$, T#
ELSE
PRINT “Deleted data=”; N$, A$, T#
END IF
WEND
CLOSE #1, #2
 KILL “NEPS.DAT”
NAME “TEMP.DAT” AS “NEPS.DAT”
END

2 comments: