Results 1 to 15 of 15

Thread: adding tinteger array to an existing array??

  1. #1
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default adding tinteger array to an existing array??

    Ok lets say i got this.

    SCAR Code:
    Item := [995, ArrowID[0], ArrowID[1], ArrowID[2], ArrowID[3], ArrowID[4]];

    and i want to add to the value of Item

    SCAR Code:
    ids:tintegerarray

    I can't just do

    SCAR Code:
    Item := Ids, [blah,blah];

    So help?
    I do visit every 2-6 months

  2. #2
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    function CombineIntArray(Ar1:TIntegerArray;Ar2:TIntegerArray):TIntegerArray;

  3. #3
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    ty

    What about combining strings?
    I do visit every 2-6 months

  4. #4
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Are you really going to do this or do you want me to make something for you to do that?

  5. #5
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I need it for my script, so I will use it.
    I do visit every 2-6 months

  6. #6
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    var Strings: TStringArray; StringtoAdd: String;

    begin
      L := GetArrayLength(Strings);
      SetArrayLength(Strings, L+1);
      Strings[L] := StringtoAdd;
    end.

    get the idea?
    “Ignorance, the root and the stem of every evil.”

  7. #7
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    function CombineStrArray(A1, A2 : TStringArray) : TStringArray;
    var
      i : integer;
    begin
      for i := 0 to GetArrayLength(A1) - 1 do
      begin
        SetArrayLength(Result, GetArrayLength(Result) + 1);
        Result[GetArrayLength(Result) - 1] := A1[i];
      end;
      for i := 0 to GetArrayLength(A2) - 1 do
      begin
        SetArrayLength(Result, GetArrayLength(Result) + 1);
        Result[GetArrayLength(Result) - 1] := A2[i];
      end;
    end;
    Last edited by Da 0wner; 05-11-2009 at 10:17 AM.

  8. #8
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Woot ty. I gave you creds on that procedure in my script.
    I do visit every 2-6 months

  9. #9
    Join Date
    Dec 2008
    Location
    In a galaxy far, far away...
    Posts
    584
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    haha nice! Its actually pretty cool! I never knew it wasn't already in SCAR!

  10. #10
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Did you check arrayLoader.scar for these?
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  11. #11
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I doubt he did as it is not a core file and not included by default .
    If there is one in there use that one :P.

  12. #12
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    @Da Owner: Just noting that that code could be optimized quite a bit:

    SCAR Code:
    function CombineStrArray(A1, A2 : TStringArray) : TStringArray;
    var
      i, A1L, A2L : integer;
    begin
      SetLength(Result, Length(A1) + Length(A2));
      A1L := high(A1);
      A2L := high(A2);
     
      for i := 0 to A1L do
        Result[i] := A1[i];
       
      for i := 0 to A2L do
        Result[A1L + 1 + i] := A2[i];
    end;
    Interested in C# and Electrical Engineering? This might interest you.

  13. #13
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yes, I know .

    SetArrayLength is faster than SetLength and GetArrayLength is faster than High though.

  14. #14
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    True, but the couple 1/000000 seconds saved isn't worth my typing

    It really only makes a difference in the looping, know what I mean?
    Interested in C# and Electrical Engineering? This might interest you.

  15. #15
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Oh yea, calling it every time XD.

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
  •