| Window Help needed 
 
	 
	
		| Author | Message |   
		| iop 
 
 
 
 
 | 
			
				|  Posted: Fri May 21, 2004 5:54 pm    Post subject: Window Help needed |  |   
				| 
 |  
				| Why doesnt this work? 
 
 Quote: 
import GUI
 var b, r, d, win1, win2, win3, win4, rr, dd : int
 forward proc program
 proc setwin
 win1 := Window.Open ("position:middle;middle,graphics:middle;middle")
 Window.Hide (win1)
 win2 := Window.Open ("position:middle;middle,graphics:middle;middle")
 Window.Hide (win2)
 win3 := Window.Open ("position:middle;middle,graphics:middle;middle")
 Window.Hide (win3)
 win4 := Window.Open ("graphics:max;max")
 Window.Hide (win4)
 end setwin
 proc setb
 setwin
 Window.Show (win2)
 Window.SetActive (win2)
 locate (3, 16)
 put "How many Balls do you want to see on the Screen?"
 loop
 locate (5, 40)
 get b
 exit when b >= 1
 end loop
 delay (100)
 Window.Close (win2)
 end setb
 proc setr
 setwin
 Window.Show (win2)
 Window.SetActive (win2)
 locate (3, 11)
 put "What is the Size Balls that you want to see on the Screen?"
 loop
 locate (5, 40)
 get r
 exit when r >= 1
 end loop
 delay (100)
 Window.Close (win2)
 end setr
 proc setd
 setwin
 Window.Show (win2)
 Window.SetActive (win2)
 locate (3, 24)
 put "What is the delay that you want?"
 locate (5, 26)
 put "It is best to set delay as 0"
 loop
 locate (7, 40)
 get d
 exit when d >= 0
 end loop
 delay (100)
 Window.Close (win2)
 end setd
 proc SS
 setwin
 Window.Show (win4)
 Window.SetActive (win4)
 const BALLCOUNT : int := (b)
 var ballX : array 1 .. BALLCOUNT of int
 var ballY : array 1 .. BALLCOUNT of int
 var directionX : array 1 .. BALLCOUNT of int
 var directionY : array 1 .. BALLCOUNT of int
 const RADIUS : int := (r)
 var x, y, mb, ox, oy : int
 mousewhere (x, y, mb)
 ox := x
 oy := y
 for i : 1 .. BALLCOUNT
 randint (ballX (i), RADIUS * 2, maxx - RADIUS * 2)
 randint (ballY (i), RADIUS * 2, maxy - RADIUS * 2)
 loop
 randint (directionX (i), -3, 3)
 randint (directionY (i), -3, 3)
 exit when directionX (i) not= 0 and directionY (i) not= 0
 end loop
 end for
 loop
 for i : 1 .. BALLCOUNT
 drawfilloval (ballX (i), ballY (i), RADIUS, RADIUS, 0)
 ballX (i) := ballX (i) + directionX (i)
 ballY (i) := ballY (i) + directionY (i)
 if ballX (i) < RADIUS or ballX (i) > maxx - RADIUS then
 directionX (i) := -directionX (i)
 end if
 if ballY (i) < RADIUS or ballY (i) > maxy - RADIUS then
 directionY (i) := -directionY (i)
 end if
 drawfilloval (ballX (i), ballY (i), RADIUS, RADIUS, 12)
 end for
 delay (d)
 mousewhere (x, y, mb)
 if x not= ox then
 Window.Close (win4)
 exit
 elsif y not= oy then
 Window.Close (win4)
 exit
 end if
 end loop
 end SS
 proc screen1
 var b1, b2, b3, b4, b5 : int
 setwin
 Window.Show (win1)
 Window.SetActive (win1)
 locate (1, 27)
 put "Bouncing Ball Screen Saver"
 locate (3, 1)
 put "Notice: The screen saver will not run if you did not set amount, size and delay."
 b1 := GUI.CreateButton (0, 0, 0, "Adjust amount of balls", setb)
 b2 := GUI.CreateButton (maxx div 2 - 100, 0, 0, "Adjust Size of balls", setr)
 b3 := GUI.CreateButton (maxx div 2 + 100, 0, 0, "Adjust delay", setd)
 b4 := GUI.CreateButton (maxx div 2 - 25, maxy div 2, 0, "Show", SS)
 b5 := GUI.CreateButton (maxx - 55, 0, 0, "Main Menu", program)
 end screen1
 proc setrr
 setwin
 Window.Show (win2)
 Window.SetActive (win2)
 locate (1, 20)
 put "Please enter the desired size of the balls."
 loop
 locate (3, 40)
 get rr
 exit when rr >= 1
 end loop
 delay (100)
 Window.Close (win2)
 end setrr
 proc setdd
 setwin
 Window.Show (win2)
 Window.SetActive (win2)
 locate (1, 20)
 put "Please enter the desired delay on the balls"
 locate (3, 26)
 put "It is best to set delay as 0"
 loop
 locate (5, 40)
 get dd
 exit when dd >= 0
 end loop
 delay (100)
 Window.Close (win2)
 end setdd
 proc spawn
 setwin
 Window.Show (win4)
 Window.SetActive (win4)
 var x, y, c, mx, ox, oy, my, mb : int
 mousewhere (mx, my, mb)
 ox := mx
 oy := my
 loop
 mousewhere (mx, my, mb)
 if mx not= ox then
 Window.Close (win4)
 exit
 elsif my not= oy then
 Window.Close (win4)
 exit
 end if
 randomize
 randint (x, 0, maxx)
 randint (y, 0, maxy)
 randint (c, 1, 255)
 delay (dd)
 drawfilloval (x, y, rr, rr, c)
 end loop
 end spawn
 proc screen2
 setwin
 Window.Show (win1)
 Window.SetActive (win1)
 var b1, b2, b3, b4 : int
 locate (1, 26)
 put "Spawning Balls Screen Savor."
 locate (3, 21)
 put "For best results, edit settings first."
 b1 := GUI.CreateButton (0, 0, 0, "Edit size", setrr)
 b2 := GUI.CreateButton (maxx div 2 - 120, 0, 0, "Edit delay", setdd)
 b3 := GUI.CreateButton (maxx div 2 + 100, 0, 0, "Show", spawn)
 b4 := GUI.CreateButton (maxx - 90, 0, 0, "Main Menu", program)
 end screen2
 body program
 setwin
 Window.Show (win3)
 Window.SetActive (win3)
 var b1, b2, b3 : int
 locate (1, 23)
 put "Welcome to Costa's Screen Savors."
 b1 := GUI.CreateButton (0, 0, 0, "Screen Saver 1", screen1)
 b2 := GUI.CreateButton (maxx div 2 - 90, 0, 0, "Screen Saver 2", screen2)
 b3 := GUI.CreateButton (maxx - 90, 0, 0, "Quit", GUI.Quit)
 end program
 program
 loop
 exit when GUI.ProcessEvent
 end loop
 
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		| Tony 
 
  
 
 
 | 
			
				|  Posted: Fri May 21, 2004 7:42 pm    Post subject: (No subject) |  |   
				| 
 |  
				| that's a lot of lines, what exactly are you having problems with? |  
				|  Tony's programming blog. DWITE - a programming contest. |  |   
		|  |  |  
	  
		|  |   
		| iop 
 
 
 
 
 | 
			
				|  Posted: Fri May 21, 2004 7:45 pm    Post subject: (No subject) |  |   
				| 
 |  
				| my windows are messed up yet i think i did everything right.  if you run it once or twice in turing youll see that i have errors with the windows.  i dont know how to fix them.  (it just opens the wrong windows at the wrong time, and closes the wrong windows at the wrong time) |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Tony 
 
  
 
 
 | 
			
				|  Posted: Fri May 21, 2004 7:48 pm    Post subject: (No subject) |  |   
				| 
 |  
				| i don't understand why you opening 4 windows, if you end up hiding and never using 3 of them anyways   
 Also you're reopening those windows in multiple places... I think that might cause problems (even if it doesn't - why would you do that?)
 |  
				|  Tony's programming blog. DWITE - a programming contest. |  |   
		|  |  |  
	  
		|  |   
		| iop 
 
 
 
 
 | 
			
				|  Posted: Fri May 21, 2004 7:54 pm    Post subject: (No subject) |  |   
				| 
 |  
				| im trying to do this: open all windows and hide/close (make invisible)
 make window1 visible
 from window1, have a choice (lets call it choice1 and choice2)
 when i have the choice, i make window1 invisible and make window2 visible
 from window2, i have more choices.
 when you click on the choices in window2, you make window2 invisible and window3 visible. (when you have the choice in window3, you make window3 invisible and make window2 visible, if the user whats to make another choice, another window3 opens, but it has different writing)
 also, from window2, you have a choice to make window4 visible. in window4, if you move the mouse, you make it invisible and make window2 visible
 also, in window2, there is an option to make window2 invisible and make window1 visible.
 im having trouble doing this.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Tony 
 
  
 
 
 |  |   
		|  |  |  
	  
		|  |   
		| iop 
 
 
 
 
 | 
			
				|  Posted: Fri May 21, 2004 8:46 pm    Post subject: (No subject) |  |   
				| 
 |  
				| yah.. that helped so much |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Tony 
 
  
 
 
 | 
			
				|  Posted: Fri May 21, 2004 10:22 pm    Post subject: (No subject) |  |   
				| 
 |  
				| i know, I'm soo good   
 heh, sorry... I'm just confused as to why you have so many separate windows. One would seem to be enough to acomplish your task
   
 I think the confusion in code arrises when you switch between windows
 |  
				|  Tony's programming blog. DWITE - a programming contest. |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		| iop 
 
 
 
 
 | 
			
				|  Posted: Sat May 22, 2004 10:05 am    Post subject: (No subject) |  |   
				| 
 |  
				| because im using buttons and if draw a lot of buttons in one window youll be able to click on buttons that you arent suppose to click on |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Delta 
 
  
 
 
 | 
			
				|  Posted: Sat May 22, 2004 11:25 am    Post subject: (No subject) |  |   
				| 
 |  
				| Then just disable the buttons. 
 GUI.Disable (buttonName)
 
 that way you don't have to worry about people pressing buttons they aren't supposed to. Or if you really still want all your crazy windows. Then write down a summary of what is supposed to be in all your windows and I'll give you an example of how you'd do it.
 
 My msn is ssdelta_@hotmail.com, aim is OnlyDsr, yahoo is UCGDelta.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Delta 
 
  
 
 
 | 
			
				|  Posted: Sat May 22, 2004 11:33 am    Post subject: (No subject) |  |   
				| 
 |  
				| Sorry bout the double post, but after looking at your code, I've realized that you must be a noob with windows. 
 You are opening the windows over and over again. Everytime you press a button (hence the flashing of the windows). Your screensaver1, the one with the balls, gives an error. That's all I've been able to look at I've gotta go *stupid people making me do chores* anywho. Ya comment all your code and send it to me via email or something.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| iop 
 
 
 
 
 | 
			
				|  Posted: Sat May 22, 2004 1:02 pm    Post subject: (No subject) |  |   
				| 
 |  
				| this is the same program but a lil bit different and everything works fine here 
 Quote: import GUI
var b, r, d, win1, win2, win3 : int
 
 proc setwin
 win1 := Window.Open ("position:middle;middle,graphics:middle;middle")
 Window.Hide (win1)
 win2 := Window.Open ("position:middle;middle,graphics:middle;middle")
 Window.Hide (win2)
 win3 := Window.Open ("graphics:max;max")
 Window.Hide (win3)
 end setwin
 
 proc setb
 setwin
 Window.Show (win2)
 Window.SetActive (win2)
 locate (3, 16)
 put "How many Balls do you want to see on the Screen?"
 loop
 locate (5, 40)
 get b
 exit when b >= 1
 end loop
 delay (100)
 Window.Close (win2)
 end setb
 
 proc setr
 setwin
 Window.Show (win2)
 Window.SetActive (win2)
 locate (3, 11)
 put "What is the Size Balls that you want to see on the Screen?"
 loop
 locate (5, 40)
 get r
 exit when r >= 1
 end loop
 delay (100)
 Window.Close (win2)
 end setr
 
 proc setd
 setwin
 Window.Show (win2)
 Window.SetActive (win2)
 locate (3, 24)
 put "What is the delay that you want?"
 loop
 locate (5, 40)
 get d
 exit when d >= 0
 end loop
 delay (100)
 Window.Close (win2)
 end setd
 
 proc SS
 setwin
 Window.Show (win3)
 Window.SetActive (win3)
 const BALLCOUNT : int := (b)
 var ballX : array 1 .. BALLCOUNT of int
 var ballY : array 1 .. BALLCOUNT of int
 var directionX : array 1 .. BALLCOUNT of int
 var directionY : array 1 .. BALLCOUNT of int
 const RADIUS : int := (r)
 var x, y, mb, ox, oy : int
 mousewhere (x, y, mb)
 ox := x
 oy := y
 for i : 1 .. BALLCOUNT
 randint (ballX (i), RADIUS * 2, maxx - RADIUS * 2)
 randint (ballY (i), RADIUS * 2, maxy - RADIUS * 2)
 loop
 randint (directionX (i), -3, 3)
 randint (directionY (i), -3, 3)
 exit when directionX (i) not= 0 and directionY (i) not= 0
 end loop
 end for
 loop
 for i : 1 .. BALLCOUNT
 drawfilloval (ballX (i), ballY (i), RADIUS, RADIUS, 0)
 ballX (i) := ballX (i) + directionX (i)
 ballY (i) := ballY (i) + directionY (i)
 if ballX (i) < RADIUS or ballX (i) > maxx - RADIUS then
 directionX (i) := -directionX (i)
 end if
 if ballY (i) < RADIUS or ballY (i) > maxy - RADIUS then
 directionY (i) := -directionY (i)
 end if
 drawfilloval (ballX (i), ballY (i), RADIUS, RADIUS, 12)
 end for
 delay (d)
 mousewhere (x, y, mb)
 if x not= ox then
 Window.Close (win3)
 exit
 elsif y not= oy then
 Window.Close (win3)
 exit
 end if
 end loop
 end SS
 
 proc mn
 var b1, b2, b3, b4, b5 : int
 setwin
 Window.Show (win1)
 Window.SetActive (win1)
 locate (1, 27)
 put "Bouncing Ball Screen Saver"
 locate (3, 1)
 put "Notice: The screen saver will not run if you did not set amount, size and delay."
 b1 := GUI.CreateButton (0, 0, 0, "Adjust amount of balls", setb)
 b2 := GUI.CreateButton (maxx div 2 - 100, 0, 0, "Adjust Size of balls", setr)
 b3 := GUI.CreateButton (maxx div 2 + 100, 0, 0, "Adjust delay", setd)
 b4 := GUI.CreateButton (maxx div 2 - 25, maxy div 2, 0, "Show", SS)
 b5 := GUI.CreateButton (maxx - 55, 0, 0, "Quit", GUI.Quit)
 end mn
 
 mn
 
 loop
 exit when GUI.ProcessEvent
 end loop
 
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		|  |  
 |