SRL Archive - OSR Help

Array Problems


bud_wis_er_420

2013-02-16 18:46:41

Why is this procedure not removing the stings 'cod' and 'bass' from the ItemList array like it should?

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

bud_wis_er_420

2013-02-16 18:54:40

+1 rep to me lol

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;

i luffs yeww

2013-02-16 19:45:14


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.

bud_wis_er_420

2013-02-17 00:48:04

how do I do this?

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?

i luffs yeww

2013-02-17 02:36:16


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.

bud_wis_er_420

2013-02-17 06:25:29

thx again

Runehack123

2013-02-17 07:34:31

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. :)

Sjoe

2013-02-17 08:06:36

From: Runehack123
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 :p