I need to use the TMemoryStream class in WEBLib.Utils to save variaous kinds of data such as integers and doubles. In Delphi System.Classes contains the TMemoryStream where to write a value to the stream I would use:
s.write (value, sizeof (value));
where s is the stream and write is declared as
function Write(const Buffer; Count: Longint): Longint;
WebLib.Utils contains the TMemoryStream but does not have the equivalent function, it only has:
function Write(const ABuffer: TBytes; const ACount: Longint): Longint;
What's the approach one should take to use this method? Do I need to declare a variable of type TBytes of the right size, copy the value (using move) into the TBytes variable and call write? Its seems combersome?
If you want to process fixed size data, please use TBytes.
Thanks for the reply. However. what is the best way to use TBytes? I noticed there is a copy function in system, is that the recomended way? For example, if I wanted to copy an integer into a TBytes? variable?
Ignore last email, I can't use System.Copy as it only copies strings. The question is how do I copy an integer or double value into a TBytes variable?
I've found an alternative solution that doesn't use streams. Would still be interesting to know the approach we would use to fill a TByte variable.