Results 1 to 8 of 8

Thread: How do I return an array of integer?

  1. #1
    Join Date
    Dec 2006
    Location
    Banville
    Posts
    3,914
    Mentioned
    12 Post(s)
    Quoted
    98 Post(s)

    Default How do I return an array of integer?

    I want a function to return an array [0..3] of integer... How can I do that?
    The jealous temper of mankind, ever more disposed to censure than
    to praise the work of others, has constantly made the pursuit of new
    methods and systems no less perilous than the search after unknown
    lands and seas.

  2. #2
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    uhmm if this is what you want...

    SCAR Code:
    program New;
             // Example 1
    function GetNumbers : array of integer;
    begin
      Result := [1, 2, 3];
    end;

    var
      i : array of integer;
    begin
     i := GetNumbers;
     Writeln(inttostr(i[1]));
    end.

    SCAR Code:
    program New;
             // Example 2
    function GetNumbers : array of integer;
    begin
     SetArrayLength(Result, 3);
     Result[0] := 1;
     Result[1] := 2;
     Result[2] := 3;
    end;

    var
      i : array of integer;
    begin
     i := GetNumbers;
     Writeln(inttostr(i[1]));
    end.

  3. #3
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    SCAR Code:
    procedure WalkFromJetty;
    var
      Woo: array[0..3] of integer;
      i: integer;
    begin
    Woo[0]:=
    Woo[1]:=
    Woo[2]:=
    Woo[3]:=
      for i:=0 to 3 do
    //whatever
    end;
    i think is what you want?
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


  4. #4
    Join Date
    Dec 2006
    Location
    Banville
    Posts
    3,914
    Mentioned
    12 Post(s)
    Quoted
    98 Post(s)

    Default

    no< i meant that i want a function to return an array of integer>
    The jealous temper of mankind, ever more disposed to censure than
    to praise the work of others, has constantly made the pursuit of new
    methods and systems no less perilous than the search after unknown
    lands and seas.

  5. #5
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    whats shift broken mean? and can you tell me what you are trying to do(specifically)
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


  6. #6
    Join Date
    Dec 2006
    Location
    Banville
    Posts
    3,914
    Mentioned
    12 Post(s)
    Quoted
    98 Post(s)

    Default

    A function I have determines a box on the minimap as an array of integers. I want to output that to a clicking procedure.
    The jealous temper of mankind, ever more disposed to censure than
    to praise the work of others, has constantly made the pursuit of new
    methods and systems no less perilous than the search after unknown
    lands and seas.

  7. #7
    Join Date
    Feb 2006
    Location
    Helsinki, Finland
    Posts
    1,395
    Mentioned
    30 Post(s)
    Quoted
    107 Post(s)

    Default

    Then use this method (edited SKy's one a bit):

    Code:
    function GetNumbers: array of Integer;
    begin
      Result:= [1, 2, 3];
    end;
    
    var
      aoI: array of Integer;
      i: Integer;
    
    begin
      aoI:= GetNumbers;
      for i:= 0 to GetArrayLength(aoI) - 1 do
        WriteLn(IntToStr(aoI[i]));
    end.
    ?

    Just do some editing, from WriteLn's to clicking (or whatever you meant with clicking procedure)...

    If that doesn't help at all, then try to explain a bit better what you are trying to do and/or maybe post the part of your script to here.

  8. #8
    Join Date
    Feb 2006
    Location
    L.A, USA
    Posts
    1,632
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by r0b0t1 View Post
    A function I have determines a box on the minimap as an array of integers. I want to output that to a clicking procedure.
    Code:
    function IntToBox(x1, y1, x2, y2: Integer): TBox;
    Put in the 4 integers, and it'll return a TBox, a TBox stores 4 values

    Code:
    (x1, y1)-------- |
    |                     |
    |                     |  
    --------- (x2, y2)
    Hopefully that's what you want, and if you know TPoint's there's also.

    Code:
    function PointToBox(p1, p2: TPoint): TBox;

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Return an array of POINTS in a method?
    By R0b0t1 in forum C/C++ Help and Tutorials
    Replies: 0
    Last Post: 11-10-2007, 12:05 AM
  2. ItemColors: Array of Array of Integer
    By n3ss3s in forum Research & Development Lounge
    Replies: 5
    Last Post: 10-30-2007, 06:04 PM

Posting Permissions

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