exit button 
	 
	
		| Author | 
		Message | 
	 
		 
		nin
 
 
 
    
		 | 
		
		
			
				  Posted: Sun Dec 31, 2006 2:06 pm    Post subject: exit button  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				i need help on my exit button because it doesnt work =/... so can anyone help me please >.<" n thank you anyway
 
 
% Declaration Section
 
var finished := false
 
var rangex, rangey, button : int
 
 
% Set screen mode and size
 
setscreen ("graphics: 300;300")
 
 
%Title
 
procedure title
 
    cls
 
    locate (1, 16)
 
    put "Colours"
 
end title
 
 
%Introduction
 
procedure introduction
 
    title
 
    locate (3, 1)
 
    put "Click a square to find out"
 
    put "what colour it is."
 
end introduction
 
 
%Display
 
procedure display
 
 
    % Light blue square
 
    drawfillbox (0, 120, 95, 220, 101)
 
    mousewhere (rangex, rangey, button)
 
    if button = 1 then
 
        if rangex >= 0 and rangex <= 95 and rangey >= 120 and rangey <= 220 then
 
            locate (13, 1)
 
            put "Selected square: Light blue."
 
            put " "
 
            delay (1000)
 
            finished := true
 
        else
 
            locate (13, 1)
 
            put "You clicked at : ", rangex, ", ", rangey
 
            put " "
 
        end if
 
    end if
 
 
    % Yellow square
 
    drawfillbox (100, 120, 195, 220, yellow)
 
    mousewhere (rangex, rangey, button)
 
    if button = 1 then
 
        if rangex >= 100 and rangex <= 195 and rangey >= 120 and rangey <= 220 then
 
            locate (13, 1)
 
            put "Selected square: Yellow."
 
            put " "
 
            delay (1000)
 
            finished := true
 
        else
 
            locate (13, 1)
 
            put "You clicked at : ", rangex, ", ", rangey
 
            put " "
 
        end if
 
    end if
 
 
    % Black square
 
    drawfillbox (200, 120, 300, 220, 7)
 
    mousewhere (rangex, rangey, button)
 
    if button = 1 then
 
        if rangex >= 200 and rangex <= 300 and rangey >= 120 and rangey <= 220 then
 
            locate (13, 1)
 
            put "Selected square: Black."
 
            put " "
 
            delay (1000)
 
            finished := true
 
        else
 
            locate (13, 1)
 
            put "You clicked at : ", rangex, ", ", rangey
 
        end if
 
    end if
 
 
    %Exit button
 
    drawbox (205, 10, 100, 30, 3)
 
    locate (18, 18)
 
    put "EXIT" ..
 
end display
 
 
%Goodbye
 
procedure goodBye
 
    locate (6, 5)
 
    put "Brought to you by: "
 
    locate (7, 20)
 
    put "Ninanori Agustin"
 
end goodBye
 
 
% Main program
 
introduction
 
loop
 
    display
 
    mousewhere (rangex, rangey, button)
 
    if button = 1 then
 
        exit when rangex >= 205 and rangex <= 100 and rangey >= 10 and rangey <= 30
 
    else
 
        locate (14, 1)
 
        put "You clicked at : ", rangex, ", ", rangey
 
    end if
 
end loop
 
cls
 
goodBye | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		CodeMonkey2000
 
 
 
    
		 | 
		
		
			
				  Posted: Sun Dec 31, 2006 3:15 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				Please use code tags next time. it's [code ] inset code here[/code ] without the spaces. And your problem is:	  | code: | 	 		   exit when rangex >= 205 and rangex <= 100 and rangey >= 10 and rangey <= 30 then  | 	   it should be 	  | code: | 	 		  exit when rangex <= 205 and rangex >= 100 and rangey >= 10 and rangey <= 30 then  | 	   You should really clean up your code, you should be useing mousewhere only once in your program. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		BenLi
 
  
 
    
		 | 
		
		
			
				  Posted: Sun Dec 31, 2006 3:26 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				you program doesn't look too big right now, but if you are going to create a bigger program, i suggest a buttontrue function, because small mistakes like that can really waste your time. This bit of code will help a lot in bigger programs with many buttons. 
 
 
ie.
 
	  | code: | 	 		  
 
fcn buttontrue (x1,y1,x2,y2, x,y,b:int):boolean
 
if x > x1 and x < x2, and y > y1, and y< y2 and b = 1 then
 
result true
 
else
 
result false
 
end if
 
end buttontrue
 
  | 	 
  | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		CodeMonkey2000
 
 
 
    
		 | 
		
		
			
				  Posted: Sun Dec 31, 2006 3:31 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| Or just make you own button class. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		nin
 
 
 
    
		 | 
		
		
			
				  Posted: Mon Jan 01, 2007 10:05 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| k thank you soo  much for ur help =) | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		BenLi
 
  
 
    
		 | 
		
		
			
				  Posted: Tue Jan 02, 2007 10:35 am    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| spearmonkey2000: ...under the assumption that this user has knowledge of classes, which is doubtful based on the project he's undertaken. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |