On 17 Mar 2008, at 12:34, [EMAIL PROTECTED] wrote:
I need more informations about the move() procedure form unit system.
I want to shift an array (values:array[0..Maximum-1] of single) like
the
following lines:
for i:=Maximum-1 downto 1 do values[i]:=values[i-1];
values[0]:=sameothervalue;
I found the move procedure (unit system) and wrote this lines:
move(values[0],values[1],Maximum*sizeof(single));
values[0]:=sameothervalue;
I would use the move procedure, because the move procedure is very
quickly.
The program runs very well with move, but I would avoid access
violations in
future. That are the reasons of my questions:
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;
Jonas
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal