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
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to