How can I copy a record ?
Posted on 2003-11-03
How can I copy a pointer to a record into another variable of the same record type ?
For example, I have the following code which obviously doesn't work but might give you an idea of what I want to accomplish.
PSOME_RECORD = ^TSOME_RECORD;
TSOME_RECORD = record
And then I have the following
function getRecord(offset: integer) : PSOME_RECORD;
//This function works correctly
Result := PSOME_RECORD_Func(offset);
FRecords : array of TSOME_RECORD;
for i=0 to 9 do
FRecords[I] := GetRecord(i)^; <- this is the part I'm having problems with ...
I know I can easily do this by copying every member explicitly, but since TSOME_RECORD might change at some time, I want a solution that will require the least maintenance possible. I.E. copy the record-pointers directly into a records-array.
If the solution is simpler, FRecords can be switched to
FRecords : array of PSOME_RECORD, but the pointers must not point to the original result of GetRecord();