Hi, either use "Move( SendBuffer, rcvData, count )" (recommended since its from rtl, not windows api) or "CopyMemory( @rcvData[0], @SendBuffer, count )". Its a common mistake to use @<dynamic array var> instead of @<dynamic array var>[ 0 ].
regards On Sat, Oct 10, 2009 at 11:51 AM, yu ping <spin...@gmail.com> wrote: > TCommsBuffer = packed record > UnitID: Byte; > FunctionCode: TModBusFunction; > MBPData: TModBusDataBuffer; > Spare: Byte; > end; { TCommsBuffer } > > > SendBuffer: TCommsBuffer; > > -------------------------- > I want to send the data in SendBuffer to serial port > I define a array type: > > rcvData:TDataByte;(TDataByte = array of byte) > setlength(rcvData, sizeof(SendBuffer ) ); > count := datatosend; > CopyMemory( @rcvData, @ SendBuffer , count); > SeriComm.SendBuffer(@rcvData,count); > > when run to "CopyMemory( @rcvData, @ SendBuffer , count);" the program crash, > what's wrong with me? Thanks. > _______________________________________________ > fpc-pascal maillist - fpc-pas...@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal