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

Username:   Password: 
 RegisterRegister   
 GUI program
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Punde




PostPosted: Sun Jun 01, 2003 2:02 pm   Post subject: 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:
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

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 <= maxsize and movies (size).name = name1 and movies (size).studio = studio1 and
%     movies (size).actor = actor1 and movies (size).genre = genre1 and movies (size).rating = rating1 and movies (size).dat = dat1 and movies (size).leng = leng1
%size += 1
%movies (size).name := name1
%movies (size).studio := studio1
%movies (size).actor := actor1
%movies (size).genre := genre1
%movies (size).rating := rating1
%movies (size).dat := dat1
%movies (size).leng := leng1
%end insert


And here is my main Program (the one that has the actual GUI)
code:

% Main Program
import GUI in "%oot/lib/GUI"
include "main.tu"
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
    if item (2) = GUI.GetEventWidgetID then     %View Files
        delay (1050)
        cls
    end if
    if item (4) = GUI.GetEventWidgetID then %Quit
        GUI.Quit
        put " "
        put " "
        put "Thank you for using our program."
    end if
    if item (5) = GUI.GetEventWidgetID then % Add movie
        put "hahah"
        delay (4000)
        cls
    end if
    if item (6) = GUI.GetEventWidgetID then % Delete Movie
        put "hahah"
        delay (4000)
        cls
    end if
    if item (7) = GUI.GetEventWidgetID then %By name...
        put "hahah"
        delay (4000)
        cls
    end if
    if item (8) = GUI.GetEventWidgetID then    %By studio...
        put "hahah"
        delay (4000)
        cls
    end if
    if item (9) = GUI.GetEventWidgetID then    %By length...
        put "hahah"
        delay (4000)
        cls
    end if
    if item (10) = GUI.GetEventWidgetID then    %By rating....
        put "hahah"
        delay (4000)
        cls
    end if
    if item (11) = GUI.GetEventWidgetID then        %Find...
        put "hahah"
        delay (4000)
        cls
    end if
    if item (12) = GUI.GetEventWidgetID then        %About Simon
        put "hahah"
        delay (4000)
        cls
    end if
    if item (13) = GUI.GetEventWidgetID then            %About Salman
        put "hahah"
        delay (4000)
        cls
    end if
    GUI.ShowMenuBar
end MenuSelected


%Create the menus
first := GUI.CreateMenu ("File")
for cnt : 1 .. 4
    item (cnt) := GUI.CreateMenuItem (name2 (cnt),
        MenuSelected)
end for

second := GUI.CreateMenu ("Edit")
for cnt : 5 .. 6
    item (cnt) := GUI.CreateMenuItem (name2 (cnt),
        MenuSelected)
end for
third := GUI.CreateMenu ("Sort")
for cnt : 7 .. 10
    item (cnt) := GUI.CreateMenuItem (name2 (cnt),
        MenuSelected)
end for
fourth := GUI.CreateMenu ("Search")
for cnt : 11 .. 11
    item (cnt) := GUI.CreateMenuItem (name2 (cnt),
        MenuSelected)
end for
fifth := GUI.CreateMenu ("About")
for cnt : 12 .. 13
    item (cnt) := GUI.CreateMenuItem (name2 (cnt),
        MenuSelected)
end for
loop
    exit when GUI.ProcessEvent
end loop


Sorry for the long post, I think it might help better if you can see the whole code. PLease help me with this. Thanks in advance.
Sponsor
Sponsor
Sponsor
sponsor
Punde




PostPosted: Mon Jun 02, 2003 6:45 pm   Post subject: (No subject)

how can noone help with this?! please people!!
Tony




PostPosted: Mon Jun 02, 2003 9:57 pm   Post subject: (No subject)

well maybe its because you just posted your whole code with saying "this dont work - fix it"

Seriosly though, if you want some feedback, you need to post a more specific problem. Line of code you have problem with, or what not...

GUI items perform procedure when activated.. its the part of their syntax, so I donno what you're having problems with there...

And dont really take this personally. Not many of us are coumfortable with GUI cuz we ether move on to a better language or just make our own since one in Turing sucks
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Punde




PostPosted: Tue Jun 03, 2003 5:11 pm   Post subject: (No subject)

I had a post before, same problems precise, and only the code that I needed help with, nobody replied, so I don't think that's it.
Homer_simpson




PostPosted: Tue Jun 03, 2003 5:33 pm   Post subject: (No subject)

the only reason i didn't look at it was that it was soooo long and i dont like reading other people's codes to understand them... =/
ShadowStorm




PostPosted: Tue Jun 03, 2003 6:39 pm   Post subject: (No subject)

yeah.. really man.. you're code is pretty long and i don't think anyone will sit down to read it all and then figure out your problem.. think about it.. would you sit down and read ALL that and figure out what\s the problem... Exactly... 8)
PaddyLong




PostPosted: Tue Jun 03, 2003 7:08 pm   Post subject: (No subject)

I'm on the same agree with Homer ... hate reading other people's code to try to find out what their program is suppose to do
Punde




PostPosted: Wed Jun 04, 2003 5:16 pm   Post subject: (No subject)

I agree so I redirect you to my old post:
http://www.compsci.ca/bbs/viewtopic.php?t=1115
Sponsor
Sponsor
Sponsor
sponsor
Homer_simpson




PostPosted: Wed Jun 04, 2003 8:16 pm   Post subject: (No subject)

come on ppl he might really need help... yo i'll read yer code as soon as i find the time...
Punde




PostPosted: Thu Jun 05, 2003 7:29 pm   Post subject: (No subject)

Thank you very much Smile
Homer_simpson




PostPosted: Thu Jun 05, 2003 9:20 pm   Post subject: (No subject)

yo i seem to b e needing some sorta file created by your program can u give me a sample file...?!
Homer_simpson




PostPosted: Thu Jun 05, 2003 9:41 pm   Post subject: (No subject)

i went to your gui it's seems to be working fine for me... isn't this what it's supposed to look like?!


gui Output.zip
 Description:

Download
 Filename:  gui Output.zip
 Filesize:  2.41 KB
 Downloaded:  375 Time(s)

Punde




PostPosted: Sun Jun 08, 2003 5:27 pm   Post subject: (No subject)

Yeah, the gui is fine, except I don't know how to make it do a procedure or a function when it is selected. For example when the Open menu is selected it needs to do function countrec, and procedure readrecords.
Homer_simpson




PostPosted: Sun Jun 08, 2003 5:54 pm   Post subject: (No subject)

here u go this should be what u want


main.zip
 Description:

Download
 Filename:  main.zip
 Filesize:  1.99 KB
 Downloaded:  363 Time(s)

Punde




PostPosted: Tue Jun 10, 2003 5:45 pm   Post subject: (No subject)

Thx a lot, but would you mind telling me what exactly you did in order to be able to call the function and the procedure when the menu is selected?? I want to be able to do it for the other ones too, but I can't seem to figure out what you did. Thanks again!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 22 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: