Pointers are best avoided, but sometimes you just have to use them!
You can use PChar to extract the string, as described in this excellent
article http://www.delphibasics.co.uk/Article.asp?Name=Pointers by Neil
Moffat which contains much more useful information about using pointers.
Regards,
Brendan.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Jack
Sent: 18 March 2007 03:43
To: [email protected]
Subject: From pointer to string
Pointer in Delphi is one of the things that I'm not
so sure about anytime I use one.
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 s here
...
end;
--
Best regards,
Jack
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi