Computer Science Canada Procedure Problems |
Author: | ipwnuha [ Wed Mar 28, 2012 1:19 pm ] | ||
Post subject: | Procedure Problems | ||
What is it you are trying to achieve? Text adventure game with procedures. What is the problem you are having? I need to call upon procedures but am having problems with them not being declared. is there a way around the "procedure not declared" problem? Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) This is the code i am using
Please specify what version of Turing you are using I am using version 4.1 for turing Aditional note. this is my first post and i am sorry for any formatting problems. |
Author: | Dreadnought [ Wed Mar 28, 2012 2:05 pm ] | ||
Post subject: | Re: Procedure Problems | ||
The problem is that you have procedures that call each other in a circular way. To do this you must use forward to declare the header for the procedure before declaring the body. Later in the code you can use body to declare the body of the procedure. Example:
|
Author: | ipwnuha [ Wed Mar 28, 2012 6:05 pm ] |
Post subject: | RE:Procedure Problems |
Thank you very much that fixed everything. |
Author: | Tony [ Wed Mar 28, 2012 6:32 pm ] |
Post subject: | RE:Procedure Problems |
unlikely to actually happen if you require user input in every procedure, but in long-enough games you run the risk of stack overflow exception (as there is no tail-end recursive call optimization -- that is, you just keep on building up a stack of new procedure calls on top of each other, never exiting from them). |