Results 1 to 8 of 8

Thread: Array Problems

  1. #1
    Join Date
    Mar 2007
    Location
    Mars, I thought all men were from Mars.
    Posts
    513
    Mentioned
    7 Post(s)
    Quoted
    124 Post(s)

    Default Array Problems

    Why is this procedure not removing the stings 'cod' and 'bass' from the ItemList array like it should?
    Simba Code:
    procedure RemoveString;
    var
      i, j, c: integer;
      ItemList, DropList, ItemsToKeep: TStringArray;
      add: Boolean;
    begin
      ItemsToKeep := ['cod', 'bass'];
      ItemList := ['shark', 'lobster', 'swordfish', 'cod', 'bass', 'mackerel',
      'boots', 'gloves', 'seaweed', 'casket', 'oyster'];
      c := 0;
      SetLength(DropList, 11);
      for i := 0 to High(ItemList) do
      begin
        add := false;
        for j := 0 to High(ItemsToKeep) do
        begin
          if (ItemsToKeep[j] <> ItemList[i]) then
            add := true;
        end;
        if (add = true) then
          DropList[c] := ItemList[i];
          inc(c)
      end;

      for i := 0 to High(DropList) do
        writeln(DropList[i]);
    end;

    and of couse as soon as I post I figure it out. It's with the add true. Gotta figure out a way for it to check more than more string but not keep adding to the DropList
    Last edited by bud_wis_er_420; 02-16-2013 at 11:51 PM.
    Not scripting for RS anymore, sorry. Banned too many times.
    MY SCRIPTS

  2. #2
    Join Date
    Mar 2007
    Location
    Mars, I thought all men were from Mars.
    Posts
    513
    Mentioned
    7 Post(s)
    Quoted
    124 Post(s)

    Default

    +1 rep to me lol

    Simba Code:
    procedure RemoveString;
    var
      i, j, c: integer;
      ItemList, DropList, ItemsToKeep: TStringArray;
      add: Boolean;
    begin
      ItemsToKeep := ['cod', 'bass'];
      ItemList := ['shark', 'lobster', 'swordfish', 'cod', 'bass', 'mackerel',
      'boots', 'gloves', 'seaweed', 'casket', 'oyster'];
      c := 0;
      SetLength(DropList, 11);
      for i := 0 to High(ItemList) do
      begin
        add := true;
        for j := 0 to High(ItemsToKeep) do
        begin
          if (ItemsToKeep[j] = ItemList[i]) then
            add := false;
        end;
        if (add = true) then
          DropList[c] := ItemList[i];
          inc(c)
      end;

      for i := 0 to High(DropList) do
        writeln(DropList[i]);
    end;
    Not scripting for RS anymore, sorry. Banned too many times.
    MY SCRIPTS

  3. #3
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Simba Code:
    for i := 0 to High(ItemList) do
        if not (StrInArr(ItemList[i], ItemsToKeep)) then
          DropList[i] := ItemList[i];

    There's the same thing in a lot less lines. I don't like how you just have empty strings in DropList, but meh.

  4. #4
    Join Date
    Mar 2007
    Location
    Mars, I thought all men were from Mars.
    Posts
    513
    Mentioned
    7 Post(s)
    Quoted
    124 Post(s)

    Default

    how do I do this?

    Simba Code:
    bmp := GetBmp(x1,y2,x2,y2)

    if FindBitmapToleranceIn(bmp,x,y,x1,y2,x2,y2,20) then
      DoThis;

    I don't know how to get and load a bmp from the screen and into a variable on the fly. Can someone pls tell me?
    Not scripting for RS anymore, sorry. Banned too many times.
    MY SCRIPTS

  5. #5
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Simba Code:
    var
      bmp, x, y: Integer;

    begin
      bmp := BitmapFromClient(200, 200, 400, 400);
      if (FindBitmap(bmp, x, y)) then
        Writeln('found bitmap at ' + ToStr(x) + ', ' + ToStr(y));
      FreeBitmap(bmp);
    end.

  6. #6
    Join Date
    Mar 2007
    Location
    Mars, I thought all men were from Mars.
    Posts
    513
    Mentioned
    7 Post(s)
    Quoted
    124 Post(s)

    Default

    thx again
    Not scripting for RS anymore, sorry. Banned too many times.
    MY SCRIPTS

  7. #7
    Join Date
    Oct 2012
    Posts
    758
    Mentioned
    6 Post(s)
    Quoted
    282 Post(s)

    Default

    Just adding to that - calling your bitmaps only once and freeing them at the very end of the script is a lot more efficient than going through that process everytime you loop through your functions/procedures.

  8. #8
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    3,564
    Mentioned
    111 Post(s)
    Quoted
    1475 Post(s)

    Default

    Quote Originally Posted by Runehack123 View Post
    Just adding to that - calling your bitmaps only once and freeing them at the very end of the script is a lot more efficient than going through that process everytime you loop through your functions/procedures.
    Maybe it helps with memory leaks?
    I would like to hear some opinions bout this matter

    Creds to DannyRS for this wonderful sig!

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
  •