Computer Science Canada Returning to a Procedure |
Author: | Anonymous [ Thu May 25, 2006 6:04 pm ] | ||
Post subject: | Returning to a Procedure | ||
Is it possible to say, have this:
I really need this to help me in my RPG to make it so when I touch the town I enter it, then when I touch the gate to the outside, I come back out. |
Author: | TheOneTrueGod [ Thu May 25, 2006 6:17 pm ] | ||
Post subject: | |||
This is the circular dependance problem. No, in a language like turing, It is not possible to have that directly. HOWEVER, there are ways to simulate things like this. Read Cervantes' topic in the tutorials about turing as a functional language. You can simulate a procedure using a function. There are a couple other options, depending on what you need done. #1) You could use recursion,
#2) You could have a variable that returns from the procedure, and tells you if you need to call the second procedure or not. #3) Use a different programming language ![]() |
Author: | MysticVegeta [ Thu May 25, 2006 6:39 pm ] | ||
Post subject: | Re: Returning to a Procedure | ||
vahnx wrote: Is it possible to say, have this:
I really need this to help me in my RPG to make it so when I touch the town I enter it, then when I touch the gate to the outside, I come back out. well you need an exit condition on one of the proc.. so that it doesnt get stuck in a circle... |
Author: | TheOneTrueGod [ Thu May 25, 2006 6:45 pm ] |
Post subject: | |
lol, mystic vegeta, its not possible. It'll give you the error "MAP_2" has not been declared. Turing works linearly. Ready my previous post, and try it out if you don't believe me ![]() |
Author: | MysticVegeta [ Thu May 25, 2006 6:51 pm ] | ||
Post subject: | |||
I thought you were familiar with forward and body procs...
|
Author: | TheOneTrueGod [ Thu May 25, 2006 7:41 pm ] |
Post subject: | |
lol, nope. I've used em in classes, but only to have multiple copies of the same procedure ![]() ![]() |
Author: | Anonymous [ Thu May 25, 2006 8:40 pm ] |
Post subject: | |
Thanks so much MysticVegeta! I've been wondering this since i started Turing like 4/5ths a semester ago. You truly are a programming god. Did I ever tell you that.... I...... Love you.... (*kiss*) Also, is there a way to also transfer a variable from inside that body procedure? |
Author: | TheOneTrueGod [ Thu May 25, 2006 9:03 pm ] |
Post subject: | |
either global variables or forward proc MAP_2 (var x : int, y : boolean /*etc*/) |
Author: | MysticVegeta [ Fri May 26, 2006 2:12 pm ] | ||
Post subject: | |||
vahnx wrote: Also, is there a way to also transfer a variable from inside that body procedure? Do you mean transfer a variable from inside to the outside or from outside to the inside..
Cause if its from outside to inside then truegod's post will help you else if its from inside to outside then you need "functions" that return a value like..
|
Author: | Anonymous [ Sat May 27, 2006 8:16 am ] |
Post subject: | |
Yeah for my game I just made it a global variable, so it doesnt really matter now. And I could use () probably. |