
-----------------------------------
Homer_simpson
Wed May 28, 2003 9:45 pm

simple data base....
-----------------------------------
this is a simple (not completed) data base took me short time to make it but here it is...
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

-----------------------------------
Tony
Wed May 28, 2003 11:08 pm


-----------------------------------
i dont like that static 1..1000 array :?

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) )

-----------------------------------
Mazer
Thu May 29, 2003 6:36 am


-----------------------------------
couldn't you just use a flexible array instead of 1..1000?

-----------------------------------
Homer_simpson
Thu May 29, 2003 2:10 pm


-----------------------------------
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
Fri May 30, 2003 4:40 pm


-----------------------------------
i dont like that static 1..1000 array :?

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
Fri May 30, 2003 5:01 pm


-----------------------------------
wut, u dunno wut MS access is? IF u dun't, its a database program.  fairly ez to use

-----------------------------------
Tony
Fri May 30, 2003 7:57 pm


-----------------------------------
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.

-----------------------------------
krishon
Fri May 30, 2003 9:02 pm


-----------------------------------
oh, lol, mbmb

-----------------------------------
rizzix
Sat May 31, 2003 8:57 am


-----------------------------------
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!
