This is something i never remember..
If i have a buffer (ie, a pointer and a size), how do i obtain a string?
[pascal]function BufferToString(prtointer; size:cardinal):string;
begin
result:=
end;[/pascal]
This is something i never remember..
If i have a buffer (ie, a pointer and a size), how do i obtain a string?
[pascal]function BufferToString(prtointer; size:cardinal):string;
begin
result:=
end;[/pascal]
If you save your data in a proprietary format, the owner of the format owns your data.
<br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>
Code:function BufferToString(Src: Pointer; Size: Integer): AnsiString; begin SetLength(Result, Size); Move(Src^, Pointer(Result)^, Size); end;
ah perfect i'll try to keep it in mind!
If you save your data in a proprietary format, the owner of the format owns your data.
<br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>
Looks a little fishy to me. This might compile and work but isn't it a bit c-ish. What type will a pointer have when dereferenced? Yes, I know Move works with untyped parameters but I still don't like it. I would rather write it like this:Originally Posted by Setharian
Wouldn't Pointer(Result)^ be incorrect too? (Pointer(Result[1])^)?Code:function BufferToString(Src: Pointer; Size: Integer): AnsiString; begin SetLength(Result, Size); Move(PByteArray(Src)^[0], Result[1], Size); end;
Edit: Excuse me my nosy-ness. I've been programming C for 16 hours :shock:
Peregrinus, expectavi pedes meos in cymbalis
Nullus norvegicorum sole urinat
It will compile down to the same code. Your code will just cause a bigger headache for the compiler.
Bookmarks