Computer Science Canada Can you have if statements in with GUI buttons? |
Author: | Jesse.A [ Sun May 25, 2014 1:34 pm ] | ||
Post subject: | Can you have if statements in with GUI buttons? | ||
What is it you are trying to achieve? I am trying to use if statements with buttons. What is the problem you are having? I realy have no idea how i would go about doing it. Describe what you have tried to solve this problem I have messed around a little bit but nothing seems to be working. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using 4.1.1 |
Author: | Insectoid [ Sun May 25, 2014 4:01 pm ] | ||
Post subject: | RE:Can you have if statements in with GUI buttons? | ||
Instead of using an if statement, have your display procedure take x as a parameter and pass it on your button lines.
|
Author: | Zren [ Sun May 25, 2014 8:14 pm ] | ||
Post subject: | Re: RE:Can you have if statements in with GUI buttons? | ||
Insectoid @ Sun May 25, 2014 4:01 pm wrote: Instead of using an if statement, have your display procedure take x as a parameter and pass it on your button lines.
That doesn't work. Turing doesn't support lambdas, so you can't make simple callbacks like that. |
Author: | Tony [ Mon May 26, 2014 2:31 am ] |
Post subject: | RE:Can you have if statements in with GUI buttons? |
That's not lambda (in a way of anonymous function definition). The display is assumed to be already defined, and here it's referenced with an argument. I'm pretty sure that this works, although in a non-documented way. Oddly enough, there's GUI.GetEventWidgetID, which could be used to distinguish between different widgets calling the same procedure. |
Author: | Jesse.A [ Mon May 26, 2014 8:35 pm ] |
Post subject: | RE:Can you have if statements in with GUI buttons? |
Thank you very much! |
Author: | Zren [ Mon May 26, 2014 8:56 pm ] |
Post subject: | Re: RE:Can you have if statements in with GUI buttons? |
Tony @ Mon May 26, 2014 2:31 am wrote: That's not lambda (in a way of anonymous function definition). The display is assumed to be already defined, and here it's referenced with an argument. I'm pretty sure that this works, although in a non-documented way.
Oddly enough, there's GUI.GetEventWidgetID, which could be used to distinguish between different widgets calling the same procedure. So wait, calling a procedure with arguments returns a value? That value being a new procedure without parameters? What version of Turing supports this? |
Author: | Tony [ Tue May 27, 2014 12:48 pm ] |
Post subject: | RE:Can you have if statements in with GUI buttons? |
I don't remember this well, you might be right -- an argumented procedure might been to return a procedure without parameters. Turing does support procedures as types -- see subprogramType |