Results 1 to 8 of 8

Thread: Function Return two vals?

  1. #1
    Join Date
    Mar 2011
    Location
    Somerset, UK
    Posts
    304
    Mentioned
    0 Post(s)
    Quoted
    24 Post(s)

    Default Function Return two vals?

    Can a Function return two values ..

    for a auto color function i need to reurn turn the x and y's for the found color ..

    i've tried puting return:= MSCX,MSCY but i dosent work ..

    i need it to retturn something like ..124,321
    X Y

  2. #2
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    function a: TPoint;
    begin
    Result.x := x;
    Result.y := y;
    end;

  3. #3
    Join Date
    Oct 2010
    Location
    Under a bridge
    Posts
    648
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by mormonman View Post
    function a: TPoint;
    begin
    Result.x := x;
    Result.y := y;
    end;
    Then to use the X and Y, use .x and .y of the result you set it too E.x.

    MyPoints := a;
    a.x is x
    a.y is y
    Quote Originally Posted by DD on IRC
    wanted to troll the troll

  4. #4
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by mormonman View Post
    function a: TPoint;
    begin
    Result.x := x;
    Result.y := y;
    end;
    or Result := Point(x, y); if your looking to save some lines.

  5. #5
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Or for more.
    Simba Code:
    function Func : array [0..1] of integer;
    begin
      result := TIntegerArray([2, 3]);
    end;
    Etc.

    But for 2 value results just use the TPoint method mentioned above.
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  6. #6
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    Simba Code:
    function test(const varIn: Integer; out Result1: string): Integer;
    begin
    end;

    Would be the formal way to return multiple variables
    Hup Holland Hup!

  7. #7
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Isn't out like almost the same as var?
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  8. #8
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Quote Originally Posted by Sex View Post
    Isn't out like almost the same as var?
    Using const it should already be initialized and have a value. (In)
    Using var it should already be initialized and have a value. (In and Out)
    Using out it shouldn't. (Out)
    Using nothing is the same as const. (I think)

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

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
  •