Computer Science Canada Calling a procedure help! |
Author: | tecnikal [ Tue Jun 02, 2009 2:24 pm ] |
Post subject: | Calling a procedure help! |
The title might be a little misleading but bare with me ![]() Here is the basic structure of my code: > Variables Set > procedure PLAYER 1 -> PLAYER 1 wants to end their turn, call PLAYER2 procedure > procedure PLAYER 2 -> PLAYER 2 wants to end their turn, call PLAYER1 procedure. As you can see, player two has no problem. The problem is with Player 1. How can i call a procedure below? is there another way of doing this? |
Author: | TheGuardian001 [ Tue Jun 02, 2009 3:13 pm ] | ||
Post subject: | Re: Calling a procedure help! | ||
If i understand the question, you should look into the forward and body commands. They allow you to create the procedure at the start of your program, but not define the contents until later. Example
the contents of procedure first are allowed to call procedure last because last was declared earlier using forward. |
Author: | tecnikal [ Tue Jun 02, 2009 3:58 pm ] |
Post subject: | RE:Calling a procedure help! |
Thanks so much. you understood my problem completely ![]() Got it working now compsci rocks haha ![]() |
Author: | DemonWasp [ Tue Jun 02, 2009 6:31 pm ] | ||
Post subject: | RE:Calling a procedure help! | ||
While your program may work, there's a potential problem to this kind of solution, which is that there is a limit to the number of "nested" procedure calls you can do. This is because of something called the stack, and the fact that you will overflow it. Without getting into the long explanations ready for that, let me just say that the following is better:
It is still worth knowing how to use forward and body though, as they have other, more important, uses. |