Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 changing datafile
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Michael




PostPosted: Fri Jan 19, 2007 8:52 pm   Post subject: changing datafile

hey people i got this problem with my datafile program

my program loads a datafile that display first names, last names, ages, genders and marks for a bunch of students.
I want the user to be able to change the datafile without actually going to the text file ...
i know how to erase all students.. just open and close the datafile but i want the user to be able to erase a certain name
how would i do that?

now the user is able to enter new students to the datafile but not erase/change info of current students

this is my proc for displaying the datafile

code:


%%%%%%%%%%%%% DISPLAY DATAFILE %%%%%%%%%%%5%
proc writeArrays %display datafile
    var count : int := 0
    var avgage : real
    var spacing : string := ".  "
    Initial
    storeValues

    include "colours.t"         %include background and colour settings

    colorback (40)
    color (white)
    locate (2, 3)
    put "#" : 2, " First name" : 21, "Last name" : 17, "Gender   " : 17, "Age" : 15, "Mark" .. %heading
    for ctr : 1 .. howMany
        if fname (ctr) > "0" then %check if datafile has records

            if gender (ctr) = "f" then %capitalize gender on output
                gender (ctr) := "F"
            elsif gender (ctr) = "m" then
                gender (ctr) := "M"
            end if

            if ctr > 9 then
                spacing := ". "
            else
                spacing := ".  "
            end if
            colorback (black)
            locate (ctr + 3, 3) %locate content
            put ctr, spacing, fname (ctr) : 20, lname (ctr) : 17, gender (ctr) : 17, age (ctr) : 3, mark (ctr) : 14, "%" ..                                 %display datafile
            delay (50)
            count += 1
        else
            colorback (black)

            locate (4, 3)
            put "Datafile has no student records" ..
            locate (5, 3)
            put "Please go back and add students to datafile" ..
        end if
    end for

    locate (24, 60)
    put "Total students: ", count ..
    locate (24, 3)
    include "wait1.t" %back to menu
end writeArrays



and this is the erase student proc

code:



proc nameErase (var a : array 1 .. * of int, var num2 : int, howMany : int)
    Initial
    storeValues
    var x, count, num : int := 5
    count := 0
    cls

    include "colours.t"                 %include background and colour settings
    colorback (40)
    color (white)
    locate (2, 3)


    put "Enter student # to erase"
    get num
for ctr : 1.. howMany
student.fname (num) := "0"
end for

    locate (24, 3)
    include "wait1.t"         %back to menu
end nameErase



but this doesnt work.. unless i display the datafile in that same proc but i want to physically delete it from the datafile
i know im missing something here.. like opening or closing datafile again but im not sure
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: