Transformation should work like this:
type
TRec = record
D: DWord;
B: Byte;
end;
TRecArrays = record
PD: PDWord;
PB: PByte;
end;
var
i: Integer;
Arr: array of TRec;
RArr: TRecArrays;
begin
RArr.PD:= GetMem(Length(Arr) * SizeOf(DWord));
RArr.PB:= GetMem(Length(Arr) * SizeOf(Byte));
for i:= 0 to High(Arr) do begin
RArr.PD[i]:= Arr[i].D;
RArr.PB[i]:= Arr[i].B;
end;
end.
As you can see in this code I done it by hand, but I am interesting if there is an automatic way to do that.
Если мы создали структуру, то к данным структуры можно сразу обращаться через указатель. Например, добавить указатель PRec := ^TRec и работать от него. Например:
----------------------------------------------------
If we've created a structure, we can directly access the structure's data via a pointer. For example, we can add a pointer PRec := ^TRec and work from it. For example:
type
PRec = ^TRec;
TRec = record
D: DWord;
B: Byte;
end;
var
i: Integer;
PArr: array of PRec;
не забываем выделить память.
------------------------------------------------
don't forget to allocate memory.
Если вы желаете, вы можете объявить обычный массив и устанавливать указатель на начало массива или на начало позиции в массиве. Так можно менять позицию в массиве и получать нужный элемент. Если вы ошибётесь, то вы будете обращаться не к тем данным.
Можно выставить указатель один раз и смещать его в нужную сторону. Можно каждый раз указателю давать новый адрес.
--------------------------------------------------
If you prefer, you can declare a regular array and set the pointer to the beginning of the array or to the beginning of a position within the array. This way, you can change the position in the array and retrieve the desired element. If you make a mistake, you'll access the wrong data.
You can set the pointer once and move it in the desired direction. You can also assign a new address to the pointer each time.
type
PRec = ^TRec;
TRec = record
D: DWord;
B: Byte;
end;
var
i: Integer;
PArr: PRec;
Arr: array of Rec;
begin
...
PArr := @Arr[0];
PArr := @Arr[10];
...
// or
...
PArr := @Arr[0];
inc(PArr, 10); // There might be a mistake here, perhaps you'll need to use sizeof
...
end;