turing gui help 
	 
	
		| Author | 
		Message | 
	 
		 
		qprime
 
 
 
    
		 | 
		
		
			
				  Posted: Fri Apr 02, 2004 11:38 am    Post subject: turing gui help  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| is there a way to pass a variable from gui button or menu to a procedure? i tried adding another paramater but it would not accept it. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		Delos
 
  
 
    
		 | 
		
		
			
				  Posted: Fri Apr 02, 2004 11:57 am    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				Please expand a bit on this.
 
What exactly do you mean?  Post your code (with the [code] tags) so that we can better understand your question.
 
 
Generally, use the GUI.Get... commands to get data about the widgets.  However, I'm sensing that this is not what you're asking.
 
 
As a guess, you could do something like this:
 
 
[code]
 
import GUI
 
 
var num1 : int := 0
 
% Variable to be changed by buttons.
 
var b1, b2 : int
 
 
proc b1proc
 
num1 += 1
 
% add to num1.
 
end b1proc
 
 
proc b2proc
 
GUI.Quit
 
end b2proc
 
 
b1 := GUI.CreateButton (100, 100, 20, "1", b1proc)
 
b2 := GUI.CreateButton (150, 100, 20, "X", b2proc)
 
 
loop
 
exit when GUI.ProcessEvent
 
end loop
 
 
put num1
 
[/code]
 
 
 
That would 'pass' a variable by the button to the outside...sorta... | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Tony
 
  
 
    
		 | 
		
		
			
				  Posted: Fri Apr 02, 2004 3:01 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| what kind of variable are we talking about here? Button doesn't exactly have much info (well... atleast not in turing since nothing is exported and everything is constants anyways) | 
			 
			
				 
Tony's programming blog. DWITE - a programming contest. | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		qprime
 
 
 
    
		 | 
		
		
			
				  Posted: Fri Apr 02, 2004 3:45 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| i want to load information from an array into a menu, then when the user clicks on a menu button it loads a proc that does something with the value of the menu button but i dont want to have 20 procs, one for each item. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Delos
 
  
 
    
		 | 
		
		
			
				  Posted: Fri Apr 02, 2004 5:03 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				Hmm...chances are that the you will need 20 procs...but you could cut down a bit using this:
 
 
- all buttons/menu items refer to one central proc
 
- for buttons, this will check their X/Y values (GUI.GetX...) and accordingly run a procedure.
 
 
Yeah...it doensn't do much.  Turing is like that, you'll probably need those 20 procs. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Tony
 
  
 
    
		 | 
		
		
			
				  Posted: Fri Apr 02, 2004 9:35 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				eh... does this help in any way?
 
	  | code: | 	 		  
 
proc something(num:int)
 
     put num
 
end something
 
 
var value:int := 5
 
 
b := GUI.CreateButton (100, 100, 20, "press me", something(value))
 
  | 	  
 
? | 
			 
			
				 
Tony's programming blog. DWITE - a programming contest. | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |