SRL Archive - Research & Development Lounge

SlotsWithItemDtm


MylesMadness

2008-05-24 19:22:45

Function SlotsWithItemDtm(Dtm:Integer):Array of boolean;
var
box:TBox;
I, x, y:Integer;
begin
SetArrayLength(Result, 27)
for I:=1 to 28 do
begin
Box:=InvBox(I)
If FindDTM(dtm, x, y, Box.x1, Box.y1, Box.x2, Box.y2)then Result[I-1]:=True;
end;
end;
Note: slot one is really result[0] and solt two is result[1] and so on

Wizzup?

2008-05-25 05:22:51

If you want 1 to 28 you could do
Function SlotsWithItemDtm(Dtm:Integer):Array [1..28] of boolean;
var
box:TBox;
I, x, y:Integer;
begin
for I:=1 to 28 do
begin
Box:=InvBox(I)
Result[I] := FindDTM(dtm, x, y, Box.x1, Box.y1, Box.x2, Box.y2);
end;
end;

The Result := FindDTM is shorter but also more accurate, otherwhise you'll have to set every slot's boolean which has no dtm to false, pascal and delphi have these annyoing variable initialisation bugs. ;)

mixster

2008-05-25 06:42:12

IMO a TIntegerArray returned would be more useful so you could then just run a for loop through them all and do whatever, but it's a simple little function that does what it should, so that makes it good :)

MylesMadness

2008-05-25 10:24:56

From: Wizzup?
If you want 1 to 28 you could do
Function SlotsWithItemDtm(Dtm:Integer):Array [1..28] of boolean;
var
box:TBox;
I, x, y:Integer;
begin
for I:=1 to 28 do
begin
Box:=InvBox(I)
Result[I] := FindDTM(dtm, x, y, Box.x1, Box.y1, Box.x2, Box.y2);
end;
end;

The Result := FindDTM is shorter but also more accurate, otherwhise you'll have to set every slot's boolean which has no dtm to false, pascal and delphi have these annyoing variable initialisation bugs. ;)
I tried doing the 1-28 thing and it wouldn't compile, now it does