Computer Science Canada Proc help needed |
Author: | Walker [ Sun Mar 21, 2004 11:53 am ] |
Post subject: | Proc help needed |
okay i have 2 procedures but they call on each other so how can i do that because turing nneds to have the procedures above each other but i cant do that as no matter which one i put first it will still have an error, so short of making lots of mini procs how can i do this? is there a way to make turing read both at he same time? |
Author: | Delos [ Sun Mar 21, 2004 12:11 pm ] | ||
Post subject: | |||
Ah...inter-dependant procedures. I believe the use of forward can accomplish this:
I did try this once before, but the environment continually crashed. My best advice in this sit, try to avoid such a sit...it's a helluvalot more to your advantage to not have to make such structures in Turing, seeing as there's a good chance it won't be able to handle them. But if it can, then go for it! And enjoy... |
Author: | Walker [ Sun Mar 21, 2004 12:20 pm ] |
Post subject: | |
this forward you speak of, what deos it do? not mentioned in the f10 is it |
Author: | AsianSensation [ Sun Mar 21, 2004 1:39 pm ] |
Post subject: | |
it's like function prototyping. You can declare the prototype above and have the main body somewhere else. So you can technically call procedures that you have not written a body for yet. |
Author: | Walker [ Sun Mar 21, 2004 1:40 pm ] |
Post subject: | |
thank you, another question how does this interact with the include command? |
Author: | AsianSensation [ Sun Mar 21, 2004 1:42 pm ] |
Post subject: | |
nothing? |
Author: | Delos [ Sun Mar 21, 2004 5:51 pm ] | ||||||
Post subject: | |||||||
Include is of a totally different standpoint. Include is used when one wants to...er...include one file in another. For example, say you have the following code:
and it is saved under world.t. Then you have another piece of code:
saved under like.t Then you have a third file, let's say thirdfile.t, with the following code:
The output when you ran thirdfile.t would have all 3 puts. Notice that when you include a file, any extraneous code is automatically processed and/or displayed. The same happens w/ contained code, but as it is contained, it can't go anywhere until it is called. So, includes are rather handy when you have a bunch of procs in one file, and don't want to copy them directly to another...the best eg. I can think of is if you have one file that has a bunch of procedurized error traps, and you include that file at the header of another file... ...of course this all brings up questions about imports instead...but that's a discussion best left for another time. |