Computer Science Canada GUI.CreateButton calling a procedure with a parameter list? |
Author: | skootles [ Fri Jan 13, 2006 12:47 am ] | ||||
Post subject: | GUI.CreateButton calling a procedure with a parameter list? | ||||
I want to make it so that when I press a button that I have created, it will call a procedure that has a parameter list. Now, when I put what variable I wanted to put into the procedure after the name of the procedure:
I got an error, saying that the procedure Begin cannot return a value. Here is my full code:
Any ideas as to why this doesn't work? I asked my teacher, but he couldn't figure it out either ![]() |
Author: | Geminias [ Fri Jan 13, 2006 5:48 am ] |
Post subject: | |
First off, why is the return of your: createbutton () function placed into an array? Secondly, you're problem is that you are trying to add an argument when you are just supposed to tell it the procedure to execute when the button is pressed. SO in actual fact if you want it to execute a procudure that takes parameters then you make the action procedure of the button call the procedure that takes parameters... keeping in mind that the parameters have to be localized to the action procedure unless they are declared globally. |
Author: | skootles [ Fri Jan 13, 2006 3:58 pm ] |
Post subject: | |
I put it in an array, because I didn't want to make 26 individual variables and procedures ![]() And I don't think that solution would work. Ok, it creates 26 buttons, one for each letter in the alphabet. I wanted it so that when you pressed, for example, "a", it would call a procedure, and it would forward (not sure if that's correct terminology, but whatever) the value 1 into the procedure, with 1 being the index of that variable (b would 'forward' 2, c would 'forward' 3, etc, etc.) I got it working.. with a few bugs, but I had to make 26 individual procedures ![]() Thanks anyways ![]() |
Author: | Geminias [ Fri Jan 13, 2006 5:46 pm ] |
Post subject: | |
you should just make one procedure with a bunch of if statements, and depending on what button was pressed you call the action procedure with your parameter. That would just help to organize things. |
Author: | skootles [ Fri Jan 13, 2006 6:57 pm ] |
Post subject: | |
Yes, that's somewhat what I wanted to do, but how would I determine which button was pressed? |
Author: | MysticVegeta [ Fri Jan 13, 2006 8:15 pm ] | ||
Post subject: | |||
Look up for GUI.GetEventWidgetID, its a boolean value for example:
|
Author: | skootles [ Fri Jan 13, 2006 9:37 pm ] | ||||||
Post subject: | |||||||
MysticVegeta wrote: Look up for GUI.GetEventWidgetID, its a boolean value for example:
Thanks, that really helped. My code's about 1/6 of what it was ![]() I'm still having one issue however. So, in the beginning you're presented with 26 buttons (a-z), and you try and guess the word. When you click on one, the program determines if the leter corresponding to the button you pushed is in the word, and if it is, it displays all instances of that letter on the screen. So, that works all fine and dandy. When the program realizes that the letter (button) you pushed isn't part of the word, it adds 1 to a variable, then changes the value of another so that the button won't be re-drawn when the DrawButtons Procedure is called. Now, I had a background that would change based on this variable, but it was messing up. So, I inserted "put WrongGuess", and it showed that it was going up by 19 when I clicked any button. Then, I moved it into the "else" part of the if statement, and it started going up by random numbers when I clicked a button. I put comments below to mark where I put it:
Now, here is my full code below:
I'm really confused as to what's going on.. can anyone offer (more) help? Thanks! |