Computer Science Canada

Call procedure with GUI

Author:  Punde [ Thu May 29, 2003 7:03 pm ]
Post subject:  Call procedure with GUI

I have a module that contains the following function and procedure:
code:

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

These are used to open a file and to read it, so then they can be viewed.
I then have the main program with a GUI interface like this:
code:

import GUI in "%oot/lib/GUI"

View.Set ("graphics:800;600")
var first, second, third, fourth, fifth : int  % The menus.
var item : array 1 .. 24 of int % The menu items.
var name2 : array 1 .. 13 of string (25) :=
    init ("Open", "View", "---", "Quit", "Add movie", "Delete movie", "By name...", "By studio...", "By length...", "By rating...", "Find...",
    "About Simon", "About Salman")
procedure MenuSelected
    if item (1) = GUI.GetEventWidgetID then %Open
        delay (4000)
        cls
    end if
% ...
end MenuSelected


What I want to do is when the Open menu (item(1)) is selected it asks for a filename then it does the readrecords procedure. Basically I want it to perform the countrec function, and then the readrecords procedure when the Open menu is selected. Can anyone help me with this?? Thx.

P.S I know I have to include or import the module. If there is another way of doing this, please tell me too Smile

Author:  Punde [ Fri May 30, 2003 8:13 pm ]
Post subject: 

anyone plz??
Come on people, I need this for my final assignment. PLease help!!!!!!

Author:  Punde [ Sat May 31, 2003 5:13 pm ]
Post subject: 

tony or anyone can you help me out here please??


: