Results 1 to 6 of 6

Thread: Functions and Procedures

  1. #1
    Join Date
    Nov 2011
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Functions and Procedures

    hey, i understand a Function returns something if i am right it will return a Integer, Boolean or string(think theres one more but cant remember it) and a Function is just a list of commands. But im just not getting to grip what a function would return as in a tutorial i have seen it could return how many trips of something it has done but where does it return this to? im just not understanding it fully.

  2. #2
    Join Date
    May 2012
    Posts
    70
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    A procedure just executes or DOES something, while a function actually returns a value.

    By return, we mean it returns a variable which can usually be used on later in the function:

    function IntToStr(i: LongInt): String;

    In that example, the function would return a string (which you could call anything, not "String") which we would use later, maybe like so:

    Writeln('Number of logs:' + String);

    Hope I helped.

  3. #3
    Join Date
    Nov 2011
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Word View Post
    A procedure just executes or DOES something, while a function actually returns a value.

    By return, we mean it returns a variable which can usually be used on later in the function:

    function IntToStr(i: LongInt): String;

    In that example, the function would return a string (which you could call anything, not "String") which we would use later, maybe like so:

    Writeln('Number of logs:' + String);

    Hope I helped.
    ok thanks, so anything with variables is a function? or a function is when the script finds say a color then returns the coordinates of that color?

  4. #4
    Join Date
    May 2012
    Posts
    70
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    Quote Originally Posted by Ducksarecool View Post
    ok thanks, so anything with variables is a function? or a function is when the script finds say a color then returns the coordinates of that color?
    No, for the first question. You can declare variables at the beginning of the script, yet it's not a function.

    A function returns a variable type, while a procedure merely executes - follows certain steps - without returning anything.

    They are very similar, but one just returns a value, while the other doesn't. Like you said in the second part, yes, that would be a function. A procedure in this case could be to click the colour (where nothing would therefore be returned; just an action would be performed).
    Last edited by Word; 05-07-2012 at 07:38 PM.

  5. #5
    Join Date
    Nov 2011
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Word View Post
    No, for the first question. You can declare variables at the beginning of the script, yet it's not a function.

    A function returns a variable type, while a procedure merely executes - follows certain steps - without returning anything.

    They are very similar, but one just returns a value, while the other doesn't. Like you said in the second part, yes, that would be a function.
    ok got it thanks man

  6. #6
    Join Date
    May 2012
    Posts
    70
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    Quote Originally Posted by Ducksarecool View Post
    ok got it thanks man
    No problem. They are quite similar, so maybe I confused you a little (it is pretty hard to explain).

    Check out: http://villavu.com/forum/showthread....64#post1006864 for an explanation with examples, will be much easier to understand.

    Also, no problem.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •