Results 1 to 6 of 6

Thread: Array Help,

  1. #1
    Join Date
    Nov 2011
    Posts
    1,589
    Mentioned
    9 Post(s)
    Quoted
    17 Post(s)

    Default Array Help,

    I have a Array, full on Extended's.
    I want to Take each one * by a number and add it to another array in the exact same position, I'm currently stumped atmo.
    Thanks
    Mat



    ^^

  2. #2
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    Simba Code:
    program new;
    var
      arrayOne, arrayTwo: array of Extended;
      i: integer;

    begin
      arrayOne:= [1,2,3,4,5,6,7];
      arrayTwo:= [7,6,5,4,3,2,1];

      for i:=0 to high(arrayOne)do
      begin
        arrayOne[i]:= arrayOne[i]*{insert num here};
      end;

      for i:=0 to high(arrayOne)do
      begin
        arrayTwo[i]:= arrayOne[i]+arrayTwo[i];
      end;
    end.

  3. #3
    Join Date
    Dec 2011
    Location
    New York, USA
    Posts
    1,242
    Mentioned
    12 Post(s)
    Quoted
    193 Post(s)

    Default

    Try Something like this... not sure if it will work though.

    Simba Code:
    Procedure mat;
    var
      StartArray, EndArray: TVariantArray;
    begin
       SetLength(EndArray, StartArray);
       For i := 0 to high(StartArray) do
         EndArray[i] := (StartArray[i] * ###);
    end;

  4. #4
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Nebula View Post
    Try Something like this... not sure if it will work though.

    Simba Code:
    Procedure mat;
    var
      StartArray, EndArray: TVariantArray;
    begin
       SetLength(EndArray, StartArray);
       For i := 0 to high(StartArray) do
         EndArray[i] := (StartArray[i] * ###);
    end;
    It will work if you do this:

    Simba Code:
    Procedure mat;
    var
      StartArray, EndArray: TVariantArray;
      i: Integer; // <- dat guy
    begin
       SetLength(EndArray, Length(StartArray)); // <- length too :P
       For i := 0 to high(StartArray) do
         EndArray[i] := (StartArray[i] * ###);
    end;

    Not entirely sure what you're trying to do, but replacing it's own values works just fine

    Simba Code:
    Procedure MultiplyArray(Num: Extended);
    var
      Arr: TExtendedArray;
      i: Integer;
    begin
       For i := 0 to High(Arr) do
         Arr[i] := Arr[i] * Num;
    end;

    Get a little fancy, maybe?

    Simba Code:
    Procedure MultiplyArray(Num: TExtendedArray);
    var
      Arr: TExtendedArray;
      i: Integer;
    begin
       For i := 0 to High(Arr) do
         Arr[i] := Arr[i] * Num[i];
    end;

    How about a few specific values?

    Simba Code:
    Procedure MultiplyArray(Num: Extended; Which: TExtendedArray);
    var
      Arr: TExtendedArray;
      i, ii: Integer;
    begin
      For i := 0 to High(Arr) do
      begin
        For ii := 0 to High(Which) do
        begin
          if (Arr[i] = Which[ii]) then
            Arr[i] := Arr[i] * Num;
        end;
      end;
    end;

    /bored

  5. #5
    Join Date
    Nov 2011
    Posts
    1,589
    Mentioned
    9 Post(s)
    Quoted
    17 Post(s)

    Default

    Lol, Thanks for neg rep I totally forgot about this I was to busy in code.



    ^^

  6. #6
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    Wow, someone neg repped you for that? What has Villavu come to??

    Forum account issues? Please send me a PM

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
  •