[fpc-pascal] unit system;  procedure move();

Pete Cervasio cervasio at airmail.net
Mon Mar 17 19:21:05 CET 2008

On Monday 17 March 2008 06:40:51 Jonas Maebe wrote:
> On 17 Mar 2008, at 12:34, fpc at xgelb.de wrote:
> > Is the use of the move procedure right? The array length is
> > Maximum-1. When I
> > put this length on value[1], the last entry value[Maximum-1] would
> > be deleted
> > or would be shifted in an different memory area?
> It would overwrite whatever is placed in memory after the array
> (which, in case there is nothing, indeed causes an access violation).
> Use this instead:
> move(values[0],values[1],(Maximum-1)*sizeof(single));
> values[0]:=sameothervalue;

Wouldn't it be better to use the length function on the array?  Or does that 
not work in some compiler modes?

    move(values[0], values[1], (length(values)-1) * sizeof(single));

If the size of the array is ever changed, no code change is required.

Best regards,
Pete C.

More information about the fpc-pascal mailing list