[fpc-pascal] Using Move() with dynamic arrays -> RunError(0)
Žilvinas Ledas
zilvinas.ledas at dict.lt
Tue Dec 8 23:43:16 CET 2009
Hello all,
I'm trying to use Move() with dynamic arrays, but don't know why it
fails...
When instead commented out "for .. do" code I use Move() code my app
gets RunError(0) after some time. When I use "for .. do" everything
works ok.
I'm using Free Pascal Compiler version 2.3.1 [2009/11/03] for i386 on
Windows 7.
What can be the problem here?
type
TArrayOfSmallInt = array of SmallInt;
function TFrame.getAllFrame(): TArrayOfSmallInt;
var
tmpBuf: TArrayOfSmallInt;
i: Integer;
begin
startOverlapLen := Length(startOverlap);
mainAreaLen := Length(mainArea);
endOverlapLen := Length(endOverlap);
SetLength(tmpBuf, startOverlapLen+mainAreaLen+endOverlapLen);
{
for i := 0 to startOverlapLen-1 do
tmpBuf[i] := startOverlap[i];
for i := 0 to mainAreaLen-1 do
tmpBuf[i+startOverlapLen] := mainArea[i];
for i := 0 to endOverlapLen-1 do
tmpBuf[i+startOverlapLen+mainAreaLen] := endOverlap[i];
}
Move(startOverlap[0], tmpBuf[0], SizeOf(SmallInt)*startOverlapLen);
Move(mainArea[0], tmpBuf[startOverlapLen], SizeOf(SmallInt)*mainAreaLen);
Move(endOverlap[0], tmpBuf[startOverlapLen+mainAreaLen],
SizeOf(SmallInt)*endOverlapLen);
Result := tmpBuf;
end;
Regards,
Žilvinas
More information about the fpc-pascal
mailing list