
-----------------------------------
hey_joe42
Sat Mar 15, 2003 8:53 pm

deleting record from binary file
-----------------------------------
k im trying to have in my program it delete records here is the basics in somewhat pseudocode fashion of what its supposed to do, sorry my pseudocode isn't too good,
get name from user
read the first field(name field) from record, from file
loop
    exit when eof(file1)
    compare name and namefield and if they are not the same,
 write the record to the temp file
end loop

loop
exit when eof(file2)
write file2 to file 1
end if

now here is the code, for some reason this doesn't work that my problem?
%delete
body proc delete
    var fn2 : int
    var deletewho : string (20)
    put "Enter the name of the product to delete"
    get deletewho : *
    open : fn, "inventoryish.bin", read, write, mod, seek
    open : fn2, "temp.bin", write, seek %temporary file to store and move data
    seek : fn, 0
    loop
        exit when eof (fn)
        read : fn, prod
        put deletewho
        put prod.product
        delay(10)
        if prod.product not= deletewho then
put"heartofgold"
delay(20)
            write : fn2, prod   %writes everyfile except one chosen to delete
        end if
    end loop
    seek : fn, 0
    seek : fn2, 0
    loop
        exit when eof (fn2)
        read : fn2, prod
        put prod.product
        write : fn, prod
    end loop
    close : fn
    close : fn2


end delete

if you can't figure out what is wrong plz feel free to run program attached, but enter your on data first, i suggest sample data or instrustions
hit 1 then key in this (mouse,ibm,9.99,2,1,2,111-111,computer,yes :  keyboard,ibm,19.99,4,2,4,111-112,computer,no  :  back)

-----------------------------------
Tony
Sun Mar 16, 2003 4:07 pm


-----------------------------------

    open : fn2, "temp.bin", write, seek %temporary file to store and move 
 
   loop 
        exit when eof (fn2) 
        read : fn2, prod  %