On Sun, 18 Mar 2007 10:43, Jack wrote:

> Suppose I have a data buffer, and I'd like to copy
> byte 10 to 20 of the data buffer to a string. What
> is the best way to do it?
> 
> var Buf: Array [0..65535] of Byte; s: String;
> begin
>   // modify value in buf
>   ...
> 
>   // How to copy Buf[9..19] to String s?
>   s := Copy(Buf, 9, 10); // this gets an "Incompatible types" error

Use this instead:

     SetString(s, PChar(@Buf[9]), 10);

>   // Use s here
>   ...
> end;


hans
-- 
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to