Dispose buttons help
Author |
Message |
14fenix
|
Posted: Mon Jan 05, 2004 8:08 pm Post subject: Dispose buttons help |
|
|
Ok, this program looks pretty rough so far so please bear with me.. I got a new school assignment that calls for implementing buttons into an old program I've made. Here is part of the code
code: | import GUI in "%oot/support/lib/GUI"
%Variables
var FontID : int := Font.New ("PL arsic:30")
var FontID1 : int := Font.New ("impact:50:italic, bold, underline")
var FontID2 : int := Font.New ("arial black:50: bold, italic")
var FontID3 : int := Font.New ("impact:17:italic, bold")
View.Set ("graphics:max;max,position:0;0,nobuttonbar,title: GUI: 20 Questions")
View.Update
%Processes
process mainframe
drawfillbox (0, 0, maxx, maxy, black)
drawbox (3, 3, maxx - 3, maxy - 3, white)
drawbox (5, 5, maxx - 5, maxy - 5, white)
drawline (6, 600, maxx - 6, 600, white)
drawline (6, 602, maxx - 6, 602, white)
Font.Draw ("20 Questions GUI", 280, 620, FontID1, 14)
Pic.ScreenLoad ("C:\\My Documents\\Paul\\School\\Programs\\Turing\\School Work\\20 Questions\\PabProductionslogo.bmp", 870, 650, picCopy)
Pic.ScreenLoad ("C:\\My Documents\\Paul\\School\\Programs\\Turing\\School Work\\20 Questions\\PabProductionslogo.bmp", 10, 650, picCopy)
View.Update
end mainframe
%Procedures
forward procedure quitbutton
forward procedure quest1
forward procedure quest1but
forward procedure but1ax
forward procedure but1bx
forward procedure but1cx
forward procedure but1dx
forward procedure but1ex
forward procedure quest2
forward procedure quest2but
forward procedure but2ax
forward procedure but2bx
forward procedure but2cx
forward procedure but2dx
forward procedure but2ex
forward procedure quest3
forward procedure quest3but
forward procedure but3ax
forward procedure but3bx
forward procedure but3cx
forward procedure but3dx
forward procedure but3ex
body procedure quitbutton
GUI.Quit
end quitbutton
% - - - - - - - - - - Question 1
body procedure quest1
cls
fork mainframe
delay (5)
Font.Draw ("At which of the following times do you wake up before school?", 65, maxy div 2 - 50, FontID3, red)
quest1but
end quest1
body procedure quest1but
var but1a : int := GUI.CreateButton (750, 360, 120, "5:30", but1ax)
var but1b : int := GUI.CreateButton (750, 310, 120, "6:00", but1bx)
var but1c : int := GUI.CreateButton (750, 260, 120, "6:30", but1cx)
var but1d : int := GUI.CreateButton (750, 210, 120, "7:00", but1dx)
var but1e : int := GUI.CreateButton (750, 160, 120, "7:30", but1ex)
var but1quit : int := GUI.CreateButton (940, GUI.RIGHT, 70, "Quit", quitbutton)
end quest1but
body procedure but1ax
fork mainframe
delay (5)
Font.Draw ("Wow, that's really early!", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest2
end but1ax
body procedure but1bx
fork mainframe
delay (5)
Font.Draw ("That's a little too early for me.", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest2
end but1bx
body procedure but1cx
fork mainframe
delay (5)
Font.Draw ("That's about when I wake up.", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest2
end but1cx
body procedure but1dx
fork mainframe
delay (5)
Font.Draw ("That's cutting it short for the bus, you must walk.", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest2
end but1dx
body procedure but1ex
fork mainframe
delay (5)
Font.Draw ("You probably walk to school.", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest2
end but1ex
% - - - - - - - - - - Question 2
body procedure quest2
cls
fork mainframe
delay (5)
Font.Draw ("If you had a chance to win a million dollars,", 35, maxy div 2 - 20, FontID3, red)
Font.Draw ("which of the following numbers would you choose?", 25, maxy div 2 - 50, FontID3, red)
quest2but
end quest2
body procedure quest2but
var but2a : int := GUI.CreateButton (750, 360, 120, "14", but2ax)
var but2b : int := GUI.CreateButton (750, 310, 120, "1", but2bx)
var but2c : int := GUI.CreateButton (750, 260, 120, "246", but2cx)
var but2d : int := GUI.CreateButton (750, 210, 120, "1987", but2dx)
var but2e : int := GUI.CreateButton (750, 160, 120, "938201", but2ex)
var but2quit : int := GUI.CreateButton (940, GUI.RIGHT, 70, "Quit", quitbutton)
end quest2but
body procedure but2ax
fork mainframe
delay (5)
Font.Draw ("So would I!", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest3
end but2ax
body procedure but2bx
fork mainframe
delay (5)
Font.Draw ("1 is the loneliest number.", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest3
end but2bx
body procedure but2cx
fork mainframe
delay (5)
Font.Draw ("Interesting...", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest3
end but2cx
body procedure but2dx
fork mainframe
delay (5)
Font.Draw ("That's when I was born.", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest3
end but2dx
body procedure but2ex
fork mainframe
delay (5)
Font.Draw ("You like to think big.", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest3
end but2ex
% - - - - - - - - - - Question 3
body procedure quest3
cls
fork mainframe
delay (5)
Font.Draw ("Which of the following cuisines is your favourite?", 165, maxy div 2 - 50, FontID3, red)
quest3but
end quest3
body procedure quest3but
var but3a : int := GUI.CreateButton (550, 360, 120, "Italian", but3ax)
var but3b : int := GUI.CreateButton (550, 310, 120, "Chinese", but3bx)
var but3c : int := GUI.CreateButton (550, 210, 120, "Polish", but3cx)
var but3d : int := GUI.CreateButton (550, 160, 120, "Japanese", but3dx)
var but3e : int := GUI.CreateButton (550, 460, 120, "Mongolian", but3ex)
var but3quit : int := GUI.CreateButton (940, GUI.RIGHT, 70, "Quit", quitbutton)
end quest3but
body procedure but3ax
fork mainframe
delay (5)
Font.Draw ("Mmm Pizza", 165, maxy div 2 - 50, FontID3, red)
end but3ax
body procedure but3bx
Font.Draw ("Mmm Pizaa", 165, maxy div 2 - 50, FontID3, red)
end but3bx
body procedure but3cx
Font.Draw ("Mmm Pizaa", 165, maxy div 2 - 50, FontID3, red)
end but3cx
body procedure but3dx
Font.Draw ("Mmm Pizaa", 165, maxy div 2 - 50, FontID3, red)
end but3dx
body procedure but3ex
Font.Draw ("Mmm Pizaa", 165, maxy div 2 - 50, FontID3, red)
end but3ex
fork mainframe
delay (5)
Font.Draw ("After answering the 20 questions, you will be told a story thats uses the answers that you select", 10, maxy div 2, FontID3, red)
delay (2000)
quest1
loop
exit when GUI.ProcessEvent
end loop |
OK, my problem is I cant dispose of the buttons from previous questions.. The program can't go past the first question really... And don't worry about some of the content, it'll be changed heh. Can anyone help?
Thanx |
|
|
|
|
|
Sponsor Sponsor
|
|
|
14fenix
|
Posted: Mon Jan 05, 2004 8:11 pm Post subject: (No subject) |
|
|
CLS'ing doesnt do dick and I'm not sure of how to use GUI.Dispose |
|
|
|
|
|
Dan
|
Posted: Mon Jan 05, 2004 9:57 pm Post subject: (No subject) |
|
|
you got to make the buttion vars golabe if you are to uses them like that.
he i did it for your 1st one:
code: |
import GUI in "%oot/support/lib/GUI"
%Variables
var FontID : int := Font.New ("PL arsic:30")
var FontID1 : int := Font.New ("impact:50:italic, bold, underline")
var FontID2 : int := Font.New ("arial black:50: bold, italic")
var FontID3 : int := Font.New ("impact:17:italic, bold")
View.Set ("graphics:max;max,position:0;0,nobuttonbar,title: GUI: 20 Questions")
View.Update
%Processes
process mainframe
drawfillbox (0, 0, maxx, maxy, black)
drawbox (3, 3, maxx - 3, maxy - 3, white)
drawbox (5, 5, maxx - 5, maxy - 5, white)
drawline (6, 600, maxx - 6, 600, white)
drawline (6, 602, maxx - 6, 602, white)
Font.Draw ("20 Questions GUI", 280, 620, FontID1, 14)
Pic.ScreenLoad ("C:\\My Documents\\Paul\\School\\Programs\\Turing\\School Work\\20 Questions\\PabProductionslogo.bmp", 870, 650, picCopy)
Pic.ScreenLoad ("C:\\My Documents\\Paul\\School\\Programs\\Turing\\School Work\\20 Questions\\PabProductionslogo.bmp", 10, 650, picCopy)
View.Update
end mainframe
%Procedures
forward procedure quitbutton
forward procedure quest1
forward procedure quest1but
forward procedure but1ax
forward procedure but1bx
forward procedure but1cx
forward procedure but1dx
forward procedure but1ex
forward procedure quest2
forward procedure quest2but
forward procedure but2ax
forward procedure but2bx
forward procedure but2cx
forward procedure but2dx
forward procedure but2ex
forward procedure quest3
forward procedure quest3but
forward procedure but3ax
forward procedure but3bx
forward procedure but3cx
forward procedure but3dx
forward procedure but3ex
body procedure quitbutton
GUI.Quit
end quitbutton
% - - - - - - - - - - Question 1
body procedure quest1
cls
fork mainframe
delay (5)
Font.Draw ("At which of the following times do you wake up before school?", 65, maxy div 2 - 50, FontID3, red)
quest1but
end quest1
var but1a : int
var but1b : int
var but1c : int
var but1d : int
var but1e : int
var but1quit : int
body procedure quest1but
but1a := GUI.CreateButton (750, 360, 120, "5:30", but1ax)
but1b := GUI.CreateButton (750, 310, 120, "6:00", but1bx)
but1c := GUI.CreateButton (750, 260, 120, "6:30", but1cx)
but1d := GUI.CreateButton (750, 210, 120, "7:00", but1dx)
but1e := GUI.CreateButton (750, 160, 120, "7:30", but1ex)
but1quit := GUI.CreateButton (940, GUI.RIGHT, 70, "Quit", quitbutton)
end quest1but
body procedure but1ax
fork mainframe
delay (5)
Font.Draw ("Wow, that's really early!", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
GUI.Dispose (but1a)
GUI.Dispose (but1b)
GUI.Dispose (but1c)
GUI.Dispose (but1d)
GUI.Dispose (but1e)
GUI.Dispose (but1quit)
quest2
end but1ax
body procedure but1bx
fork mainframe
delay (5)
Font.Draw ("That's a little too early for me.", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest2
end but1bx
body procedure but1cx
fork mainframe
delay (5)
Font.Draw ("That's about when I wake up.", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest2
end but1cx
body procedure but1dx
fork mainframe
delay (5)
Font.Draw ("That's cutting it short for the bus, you must walk.", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest2
end but1dx
body procedure but1ex
fork mainframe
delay (5)
Font.Draw ("You probably walk to school.", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest2
end but1ex
% - - - - - - - - - - Question 2
body procedure quest2
cls
fork mainframe
delay (5)
Font.Draw ("If you had a chance to win a million dollars,", 35, maxy div 2 - 20, FontID3, red)
Font.Draw ("which of the following numbers would you choose?", 25, maxy div 2 - 50, FontID3, red)
quest2but
end quest2
body procedure quest2but
var but2a : int := GUI.CreateButton (750, 360, 120, "14", but2ax)
var but2b : int := GUI.CreateButton (750, 310, 120, "1", but2bx)
var but2c : int := GUI.CreateButton (750, 260, 120, "246", but2cx)
var but2d : int := GUI.CreateButton (750, 210, 120, "1987", but2dx)
var but2e : int := GUI.CreateButton (750, 160, 120, "938201", but2ex)
var but2quit : int := GUI.CreateButton (940, GUI.RIGHT, 70, "Quit", quitbutton)
end quest2but
body procedure but2ax
fork mainframe
delay (5)
Font.Draw ("So would I!", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest3
end but2ax
body procedure but2bx
fork mainframe
delay (5)
Font.Draw ("1 is the loneliest number.", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest3
end but2bx
body procedure but2cx
fork mainframe
delay (5)
Font.Draw ("Interesting...", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest3
end but2cx
body procedure but2dx
fork mainframe
delay (5)
Font.Draw ("That's when I was born.", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest3
end but2dx
body procedure but2ex
fork mainframe
delay (5)
Font.Draw ("You like to think big.", 165, maxy div 2 - 50, FontID3, red)
delay (1000)
quest3
end but2ex
% - - - - - - - - - - Question 3
body procedure quest3
cls
fork mainframe
delay (5)
Font.Draw ("Which of the following cuisines is your favourite?", 165, maxy div 2 - 50, FontID3, red)
quest3but
end quest3
body procedure quest3but
var but3a : int := GUI.CreateButton (550, 360, 120, "Italian", but3ax)
var but3b : int := GUI.CreateButton (550, 310, 120, "Chinese", but3bx)
var but3c : int := GUI.CreateButton (550, 210, 120, "Polish", but3cx)
var but3d : int := GUI.CreateButton (550, 160, 120, "Japanese", but3dx)
var but3e : int := GUI.CreateButton (550, 460, 120, "Mongolian", but3ex)
var but3quit : int := GUI.CreateButton (940, GUI.RIGHT, 70, "Quit", quitbutton)
end quest3but
body procedure but3ax
fork mainframe
delay (5)
Font.Draw ("Mmm Pizza", 165, maxy div 2 - 50, FontID3, red)
end but3ax
body procedure but3bx
Font.Draw ("Mmm Pizaa", 165, maxy div 2 - 50, FontID3, red)
end but3bx
body procedure but3cx
Font.Draw ("Mmm Pizaa", 165, maxy div 2 - 50, FontID3, red)
end but3cx
body procedure but3dx
Font.Draw ("Mmm Pizaa", 165, maxy div 2 - 50, FontID3, red)
end but3dx
body procedure but3ex
Font.Draw ("Mmm Pizaa", 165, maxy div 2 - 50, FontID3, red)
end but3ex
fork mainframe
delay (5)
Font.Draw ("After answering the 20 questions, you will be told a story thats uses the answers that you select", 10, maxy div 2, FontID3, red)
delay (2000)
quest1
loop
exit when GUI.ProcessEvent
end loop
|
<- dan's victory dance |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
14fenix
|
Posted: Mon Jan 05, 2004 10:50 pm Post subject: (No subject) |
|
|
Wow man, your a god. Thanks |
|
|
|
|
|
14fenix
|
Posted: Mon Jan 05, 2004 11:02 pm Post subject: (No subject) |
|
|
Its funny though, I noticed you added in;
var but1a : int
var but1b : int
var but1c : int
var but1d : int
var but1e : int
var but1quit : int
But I still dont understand how that works... |
|
|
|
|
|
14fenix
|
Posted: Mon Jan 05, 2004 11:03 pm Post subject: (No subject) |
|
|
Ahhhhhh.. NM, you erased a bit below it in the GUI.CreateButton lines.
Forget it lol. Im an idiot |
|
|
|
|
|
|
|