Pos фигня, зацените мой вариант
Код:
function SubArrayPos(const SubArr, Arr: array of byte; Offset: Integer): Integer;
var
I, LIterCnt, L, J: Integer;
PSubStr, PS: PByte;
begin
L := Length(SubArr);
{ Calculate the number of possible iterations. Not valid if Offset < 1. }
LIterCnt := Length(Arr) - Offset - L + 1;
{ Only continue if the number of iterations is positive or zero (there is space to check) }
if (LIterCnt >= 0) and (L > 0) then
begin
PSubStr := @SubArr[0];
PS := @Arr[0];
Inc(PS, Offset - 1 );
for I := 0 to LIterCnt do
begin
J := 0;
while (J >= 0) and (J < L) do
begin
if PS[I + J] = PSubStr[J] then
Inc(J)
else
J := -1;
end;
if J >= L then
Exit(I + Offset - 1);
end;
end;
Result := -1;
end;