View Full Version : copying into var buffer

23-11-2008, 01:08 PM
Delphi 2005 Pro / Windows XP Home
Pointer / var buffer / TStream

for addressing memory inside a pointer i now use: TBuffer = array of byte;
it works nicely but i need to use a for loop and a temp buffer.
So i do a read from a TSream into a tempbuffer and copy it using the TBuffer trick into my var buffer.

Now i would like to move larger blocks of memory at once. E.g. directly from stream.read into the var buffer without the temp buffer.
Now how do i control the position inside the var buffer? Using the TBuffer to assign a start does not work.

23-11-2008, 01:24 PM
Is it something like this you are after?

Buf : array of byte;
Str : TStream;
Str.Read(Buf[0],1000); //Read a chunk of data to the beginning of buf
Str.Read(Buf[500],1000); //Read a chunk of data to position 500 in buf

23-11-2008, 02:15 PM
thanks, but i needed to do it diffently.

solved it:
does the trick

the @ before buffer is essential as it is a var buffer and not yet a pointer. And i forgot that the first time :oops: