Hello,
This is my function:
class function TCelebrity.ReadArray<T>(length:integer): byte;
var b:pointer;
begin
b := @Result;
if IndexR + SizeOf(T) * length > High(DataRead) + 1 then
raise Exception.Create('error');
Move(DataRead[IndexR],b,SizeOf(T) * length);
Inc(IndexR,SizeOf(T) * length);
end;
IndexR is an integer,DataRead is an array of byte.
The function reads length from DataRead at IndexR(position). In my case it reads 4 bytes at position 0.
The problem is that I'd like to call the function like that:
ar[5] := c.ReadArray<byte>(4); or - @ar[5] := c.ReadArray<byte>(4); //ar is Byte array
I know I could create a parameter with a pointer to the Byte array,but I'd like to know is it possible to be done that way?
EDIT:
I also tried this function,it changes only the ar[5] and its supposed to change from ar[5] to ar[8].
class function TCelebrity.ReadArray<T>(length:integer): byte;
var b:^byte; i:integer;
begin
b := @Result;
for I := 0 to length - 1 do
begin
b^ := DataRead[IndexR];
Inc(IndexR);
Inc(b);
end;
end;
The second example should work.If ar[0] is placed at $400000 then ar[1] should be placed at $400001 and so on.This is what my function does,but unfortunately it works only to the first parameter.