Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Proc help needed
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Walker




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Sun Mar 21, 2004 12:11 pm   Post subject: (No subject)

Ah...inter-dependant procedures.

I believe the use of forward can accomplish this:

code:

forward procedure a
forward procedure b

body procedure a
    b
end a

body procedure b
    a
end b



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...
Walker




PostPosted: Sun Mar 21, 2004 12:20 pm   Post subject: (No subject)

this forward you speak of, what deos it do? not mentioned in the f10 is it
AsianSensation




PostPosted: Sun Mar 21, 2004 1:39 pm   Post subject: (No 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.
Walker




PostPosted: Sun Mar 21, 2004 1:40 pm   Post subject: (No subject)

thank you, another question how does this interact with the include command?
AsianSensation




PostPosted: Sun Mar 21, 2004 1:42 pm   Post subject: (No subject)

nothing?
Delos




PostPosted: Sun Mar 21, 2004 5:51 pm   Post subject: (No 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:
code:

put "Hello world!"

and it is saved under world.t.

Then you have another piece of code:
code:

put "is what most ppl like to say when experimenting with programming languages."

saved under like.t

Then you have a third file, let's say thirdfile.t, with the following code:
code:

include world.t
include like.t

put "And that's how includes work."


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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: