info in procedures
Author |
Message |
Legionoflight
|
Posted: 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
|
|
|
wtd
|
Posted: 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
|
Posted: Tue May 31, 2005 8:17 pm Post subject: (No subject) |
|
|
Is it the same for int? |
|
|
|
|
|
wtd
|
Posted: 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. |
|
|
|
|
|
|
|