Sign in Join
Wiki copytemporary

move

The procedure Move (originated from Borland Pascal) copies data from one location in memory to another. Unlike the name suggests, no data is “lost” at the source. Its signature reads:

delphi
procedure Move(const source; var destination; count: sizeInt)

Note that source and destination do not have a data type, thus specifying an Identifier without (necessarily) applying the address‑operator is sufficient.

Application

Move can be considered a very “low-level” routine. It was originally developed to copy char values within the same string, but has ever since been (ab‑)used for other purposes, too:

Note: Using move often makes your code very unportable since it often makes assumptions about endianness, internal structures or similar things.

A quick demo should not be missing. Nevertheless, this example is bad in nature. A plain := assignment would have been sufficient. Note, using move possibly prevents the compiler from performing certain optimizations.

delphi
program moveDemo(input, output, stdErr);
var
    x, y: integer;
begin
    x := 42;
    move(x, y, sizeOf(x));
    writeLn(y);
end.

See also


From the Free Pascal wiki, page "move", as it stood on 2022-01-28 after a change by Alextp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.