PDA

View Full Version : Global Proc - beginner question


PozestStar
11-14-2011, 02:12 PM
It seems like I haven't left this forum in a week, but I'm having fun here. I'm going to say in advance that this is a n00b question. There are several "explanations" out there, I'm trying to understand but they all confuse me.

Could some one explain this to me in the simplest terms possible?

global proc string Hello(int $something, string $somethingElse)

I don't understand the need for the things within the parenthesis. What do they do? Do you HAVE to put them there?

Thanks!

13xbmspec
11-14-2011, 04:10 PM
I believe those are called arguments and that they're used to pass information from one procedure to the next.

gtbull80
11-14-2011, 05:51 PM
Think of a procedure as a factory that does work. Like 13xbmspec said, arguments are inputs...ingredients that a factory needs to do its work. So for example:

global proc string Hello(string $firstName, string $lastName) {

string $result = $firstName + " " + $lastName;

return $result;

};


My inputs are $firstName and $lastName. And in this case, $result is my output. So to use this in a script, I'd say:


string $fullName = Hello("Mickey", "Mouse");
and "Mickey Mouse" would be placed into $fullName.


You use procedures to encapsulate tasks associated with a particular action. Hope that helps:)

berniebernie
11-15-2011, 10:45 AM
as for the 'global' and variable scope; http://accad.osu.edu/~aprice/courses/694/variables.html#scope

CGTalk Moderation
11-15-2011, 10:45 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.