Computer Science Canada

simple data base....

Author:  Homer_simpson [ 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

Author:  Tony [ Wed May 28, 2003 11:08 pm ]
Post 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) )

Author:  Mazer [ Thu May 29, 2003 6:36 am ]
Post subject: 

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

Author:  Homer_simpson [ Thu May 29, 2003 2:10 pm ]
Post 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 =/

Author:  rizzix [ Fri May 30, 2003 4:40 pm ]
Post 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?

Author:  krishon [ Fri May 30, 2003 5:01 pm ]
Post subject: 

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

Author:  Tony [ Fri May 30, 2003 7:57 pm ]
Post 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.

Author:  krishon [ Fri May 30, 2003 9:02 pm ]
Post subject: 

oh, lol, mbmb

Author:  rizzix [ Sat May 31, 2003 8:57 am ]
Post 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!


: