Personally, I prefer this way =D
Simba Code:
function CountInventoryDTM(DTMToCount: Integer): Integer;
var
CurrentCount, i, x, y: Integer;
Sequence: TIntegerArray;
InventorySlot: TBox;
begin
CurrentCount := 0;
Sequence := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 28];
for i := 0 to 27 do
begin
InventorySlot := InvBox(Sequence[i]);
if FindDTM(DTMToCount, x, y, InventorySlot.X1, InventorySlot.Y1,
InventorySlot.X2, InventorySlot.Y2) then
begin
CurrentCount := CurrentCount + 1;
end;
end;
Result := CurrentCount;
writeln(IntToStr(CurrentCount));
FreeDTM(DTMToCount);
end;