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

Username:   Password: 
 RegisterRegister   
 simple data base....
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Homer_simpson




PostPosted: Wed May 28, 2003 9:45 pm   Post subject: simple data base....

this is a simple (not completed) data base took me short time to make it but here it is...
code:
type rec :
    record
        id : int
        name : string
        position : string
        points : int
        rebounds : int
        jersey : int
        age : int
    end record
var list : array 1 .. 1000 of rec
for i : 1 .. 1000
    list (i).id := -1
end for
var pid := 1
procedure getrecord (id : int)
    list (pid).id := pid
    put "name : " ..
    get list (pid).name
    put "position : " ..
    get list (pid).position
    put "points : " ..
    get list (pid).points
    put "rebounds : " ..
    get list (pid).rebounds
    put "jersy : " ..
    get list (pid).jersey
    put pid
    pid += 1
end getrecord
procedure deleterecord (id : int)
    list (id).id := -1
end deleterecord
procedure listdata (id : int)
    cls
    var y := 4
    if id = 0 then
        for i : 1 .. 1000
            if list (i).id not= -1 then
                locate (1, 1)
                put i
                if y >= 24 then
                    put "press any key to continue..."
                    loop
                        exit when hasch
                    end loop
                    cls
                    y := 4
                end if
                locate (y, 5)
                put list (i).name
                locate (y, 17)
                put list (i).position
                locate (y, 37)
                put list (i).points
                locate (y, 41)
                put list (i).rebounds
                locate (y, 48)
                put list (i).jersey
                locate (y, 53)
                put list (i).id
                y += 1
            end if
        end for
    else
        locate (y, 5)
        put list (id).name
        locate (y, 17)
        put list (id).position
        locate (y, 37)
        put list (id).points
        locate (y, 41)
        put list (id).rebounds
        locate (y, 48)
        put list (id).jersey
        locate (y, 53)
        put list (id).id
        y += 1
    end if
end listdata
function finddata (id : int, name : string, position : string, points : int, rebounds : int, jersey : int, age : int) : int %returns id
    for i : 1 .. 1000
        if id not= 0 then
            result id
        end if
        if name not= "" then
            if Str.index (list (pid).name, name) not= 1 then
                result i
            end if
        end if
    end for
end finddata
var id:=0
loop
    put "menu :"
    put "1. add record"
    put "2. list records"
    put "3. find records"
    put "4. delete records"

    case getchar of
        label "1" :
            getrecord (pid)
        label "2" :
            listdata (0)
        label "3" :
            put "Enter id# : "
            get id
            deleterecord (id)
        label :
    end case
end loop
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed May 28, 2003 11:08 pm   Post subject: (No subject)

i dont like that static 1..1000 array Confused

slows down the program and will crash when I go over the limit.

(database for my ISP will contain... up to 25,000 records spread over 50 tables... thats why I'm using MS Access 8) )
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Mazer




PostPosted: Thu May 29, 2003 6:36 am   Post subject: (No subject)

couldn't you just use a flexible array instead of 1..1000?
Homer_simpson




PostPosted: Thu May 29, 2003 2:10 pm   Post subject: (No subject)

arrays are not the proper way to do data base...
as i said b4 u haveto use pointers but since i'm not good at pointers in turing i used arrays =/
rizzix




PostPosted: Fri May 30, 2003 4:40 pm   Post subject: (No subject)

tony wrote:
i dont like that static 1..1000 array Confused

slows down the program and will crash when I go over the limit.

(database for my ISP will contain... up to 25,000 records spread over 50 tables... thats why I'm using MS Access 8) )


???

not Turing of course... VB?
krishon




PostPosted: Fri May 30, 2003 5:01 pm   Post subject: (No subject)

wut, u dunno wut MS access is? IF u dun't, its a database program. fairly ez to use
Tony




PostPosted: Fri May 30, 2003 7:57 pm   Post subject: (No subject)

rizzix knows what Access is... and he's right, I'm using VB to program my ISP 8) VB is the way to go for fast app development with some sweet GUI.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
krishon




PostPosted: Fri May 30, 2003 9:02 pm   Post subject: (No subject)

oh, lol, mbmb
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Sat May 31, 2003 8:57 am   Post subject: (No subject)

Homer_simpson wrote:
arrays are not the proper way to do data base...
as i said b4 u haveto use pointers but since i'm not good at pointers in turing i used arrays =/


i'm comming out with a easy-to-use solution for Turing. Just need to wait till my ISP is due, heh!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: