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

Username:   Password: 
 RegisterRegister   
 info in procedures
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Legionoflight




PostPosted: Tue May 31, 2005 7:35 pm   Post subject: info in procedures

I am sorry for making so many topics....but...

anyways..i was wondering how you could trasfer info from inside one procedure to antoher

For exmple.
I figured out a score in procedure A. However, when i try to use the same variable for the score in procedure B, it does not reconize it and says it is not delcared."

My question is...what could i use to transfer my score from one proc to antoher?
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Tue May 31, 2005 7:42 pm   Post subject: (No subject)

Declare the variable outside the procedure.

Turing:
var foo : string

procedure hello
   foo := "Hello"
end hello

procedure world
   foo := "world"
end world


But, this is just silly. Instead, you should use functions, which can calculate some new value, and return it to the program. You can then do whatever you want with that value.

Turing:
function hello : string
   result "Hello"
end hello

function world : string
   result "world"
end world
Legionoflight




PostPosted: Tue May 31, 2005 8:17 pm   Post subject: (No subject)

Is it the same for int?
wtd




PostPosted: Tue May 31, 2005 10:28 pm   Post subject: (No subject)

Legionoflight wrote:
Is it the same for int?


Essentially yes.

code:
function foo : int
   result 42
end foo


Of course, yours would likely be more sophisticated.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: