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

Username:   Password: 
 RegisterRegister   
 turing gui help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
qprime




PostPosted: 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
Sponsor
sponsor
Delos




PostPosted: 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




PostPosted: 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)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
qprime




PostPosted: 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




PostPosted: 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




PostPosted: 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))

?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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 1  [ 6 Posts ]
Jump to:   


Style:  
Search: