
-----------------------------------
Punde
Sun Jun 01, 2003 2:02 pm

GUI program
-----------------------------------
I posted a while ago but nobody helped, maybe it was the way it was posted I dunno.

I am using a GUI for a database, basically I need help calling the procedures to the main program i.e when menu is selected it will perform whatever procedure is called.

Here is my module:

type MOV :
    record
        name : string
        studio : string
        leng : string
        dat : string
        actor : string
        genre : string
        rating : string
    end record

var filename : string
function countrec : int
    var num := 0
    var stream : int
    var movies : MOV
    put "Please enter the name of the file you want to open"
    get filename
    open : stream, filename, get
    loop
        get : stream, skip
        exit when eof (stream)
        get : stream, movies.name : *
        get : stream, movies.studio : *
        get : stream, movies.leng : *
        get : stream, movies.dat : *
        get : stream, movies.actor : *
        get : stream, movies.genre : *
        get : stream, movies.rating : *
        num += 1
    end loop
    close : stream
    result num
end countrec

proc readrecords (var movies : array 1 .. * of MOV, num : int)
    var stream : int
    open : stream, filename, get
    for i : 1 .. num
        get : stream, movies (i).name : *
        get : stream, movies (i).studio : *
        get : stream, movies (i).leng : *
        get : stream, movies (i).dat : *
        get : stream, movies (i).actor : *
        get : stream, movies (i).genre : *
        get : stream, movies (i).rating : *
    end for
    close : stream
end readrecords
var numrecords := countrec

proc view_records (movies : array 1 .. * of MOV, num : int)
    put "Hollywod Movie Database"
    put " "
    put "Name" : 15, "Studio" : 25, "Length" : 10, "Date" : 7, "Actor" : 15, "Genre" : 15, "Rating"
    for i : 1 .. num

        put movies (i).name : 15, movies (i).studio : 25, movies (i).leng : 10, movies (i).dat : 7, movies (i).actor : 15, movies (i).genre : 15, movies (i).rating
        delay (800)
    end for
    delay (1050)
end view_records

proc sortrecords (t : string, var movies : array 1 .. * of MOV, num : int)
    for i : 1 .. num - 1
        for j : 1 .. num - 1
            if t = "1" then
                if movies (j).name > movies (j + 1).name then
                    var temp := movies (j)
                    movies (j) := movies (j + 1)
                    movies (j + 1) := temp
                end if
            elsif t = "2" then
                if movies (j).studio > movies (j + 1).studio then
                    var temp := movies (j)
                    movies (j) := movies (j + 1)
                    movies (j + 1) := temp
                end if
            elsif t = "3" then
                if movies (j).leng > movies (j + 1).leng then
                    var temp := movies (j)
                    movies (j) := movies (j + 1)
                    movies (j + 1) := temp
                end if
            elsif t = "4" then
                if movies (j).dat > movies (j + 1).dat then
                    var temp := movies (j)
                    movies (j) := movies (j + 1)
                    movies (j + 1) := temp
                end if
            elsif t = "5" then
                if movies (j).actor > movies (j + 1).actor then
                    var temp := movies (j)
                    movies (j) := movies (j + 1)
                    movies (j + 1) := temp
                end if
            elsif t = "6" then
                if movies (j).genre > movies (j + 1).genre then
                    var temp := movies (j)
                    movies (j) := movies (j + 1)
                    movies (j + 1) := temp
                end if
            elsif t = "7" then
                if movies (j).rating > movies (j + 1).rating then
                    var temp := movies (j)
                    movies (j) := movies (j + 1)
                    movies (j + 1) := temp
                end if
            end if


        end for
    end for
end sortrecords

proc search (var movies : array 1 .. * of MOV, num : int)
    var choice : string
    put ""
    put "Input the name you want to find: " ..
    get choice : *
    put "Name" : 15, "Studio" : 25, "Length" : 10, "Date" : 7, "Actor" : 15, "Genre" : 15, "Rating"
    for i : 1 .. num
        if choice = movies (i).name then
            put ">", movies (i).name : 15, movies (i).studio : 25, movies (i).leng : 10, movies (i).dat : 15, movies (i).actor : 7, movies (i).genre : 15, movies (i).rating
        elsif choice = movies (i).studio then
            put movies (i).name : 15, ">", movies (i).studio : 23, movies (i).leng : 10, movies (i).dat : 15, movies (i).actor : 7, movies (i).genre : 15, movies (i).rating
        elsif choice = movies (i).leng then
            put movies (i).name : 15, movies (i).studio : 25, ">", movies (i).leng : 8, movies (i).dat : 15, movies (i).actor : 7, movies (i).genre : 15, movies (i).rating
        elsif choice = movies (i).dat then
            put movies (i).name : 15, movies (i).studio : 25, movies (i).leng : 10, ">", movies (i).dat : 13, movies (i).actor : 7, movies (i).genre : 15, movies (i).rating
        elsif choice = movies (i).actor then
            put movies (i).name : 15, movies (i).studio : 25, movies (i).leng : 10, movies (i).dat : 15, ">", movies (i).actor : 5, movies (i).genre : 15, movies (i).rating
        elsif choice = movies (i).genre then
            put movies (i).name : 15, movies (i).studio : 25, movies (i).leng : 10, movies (i).dat : 15, movies (i).actor : 7, ">", movies (i).genre : 15, movies (i).rating
        elsif choice = movies (i).rating then
            put movies (i).name : 15, movies (i).studio : 25, movies (i).leng : 10, movies (i).dat : 15, movies (i).actor : 7, ">", movies (i).genre : 15, movies (i).rating
        end if
    end for
end search

%proc insert (name1, studio1, actor1, genre1, rating1, dat1 : string, num : int, leng1 : real)

%   pre size < maxsize
%  post size 