[fpc-pascal] Move() vs MemCopy()

Graeme Geldenhuys graemeg.lists at gmail.com
Tue Sep 29 15:31:53 CEST 2009


Hi,

I'm still porting code from SpeedSoft's Pascal compiler. The code I am
porting often uses MemCopy(), but Free Pascal doesn't seem to have
such an implementation. So I looked at the next best thing... Move()

But as the name suggests (...Move()...), I would have expected it to
actually move the data and not copy the data. The following example
program demonstrates this. Shouldn't S1 = '' after the Move() call?

------------------------------------
Program Example42;

{ Program to demonstrate the Move function. }

Var S1,S2 : String [30];

begin
  S1 := 'Hello World!';
  S2 := 'Bye, bye   !';
  Move (S1,S2,Sizeof(S1));

  Writeln ('S2:', S2);
  Writeln ('S1:', S1);   // Why does this still hold "Hello World!"

end.

------------------------------------


Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-pascal mailing list