
-----------------------------------
shoobyman
Sat Nov 18, 2006 4:00 pm

Adding onto datafile trouble
-----------------------------------
var age : flexible array 1 .. 1 of int
var fname, lname : flexible array 1 .. 1 of string
var choice : string (1)
var stream : int

proc addDATA
    open : stream, "data7.t", seek, put
    seek : stream, *
    loop
        put "Please enter the last name: "
        get lname (upper (lname))
        put "Please enter the first name: "
        get fname (upper (fname))
        put "Please enter the age: "
        get age (upper (age))
        put : stream, lname (upper (lname)), " ", fname (upper (fname)), " ", age (upper (age))
        new lname, upper (lname) + 1
        new fname, upper (fname) + 1
        new age, upper (age) + 1
        put "Would you like to keep adding people to the list?"
        put "y/n"
        loop
            getch (choice)
            if choice = "n" or choice = "N" then
                put "Proceeding back to menu..."
                delay (400)
                exit
            elsif choice = "y" or choice = "Y" then
                exit
            else
                put "THAT IS NOT A CHOICE"
            end if
        end loop
        if choice = "n" or choice = "N" then
            exit
        end if
    end loop
    close : stream
end addDATA


addDATA

I am sure that this is really simple to fix, but everytime that it writes onto the datafile, it erases what was on it previously (if you run the program more than once).  Can anyone tell me how to fix this?

-----------------------------------
Cervantes
Sat Nov 18, 2006 9:15 pm


-----------------------------------
Go to the mod to append stuff to the end of the file. And if you want to do some more fancy stuff, you'll want to look up tell and seek.
