buffer_tell

This function gets the current "seek" position for use in other buffer functions.

When you read or write data to a buffer using the buffer_read or buffer_write functions, the current "seek" position is advanced by the bytes written or read. For example, if your buffer alignment is set to 4 bytes and you write a single piece of data which is 1 byte in size then do a buffer_tell, you'll get a return value of 1. However, if you write another piece of data, also 1 byte in size, then do a buffer_tell, you'll get a return value of 5 as the alignment has "padded" the data to that position.

To change the seek value of a buffer, use buffer_seek.

 

Syntax:

buffer_tell(buffer);

ArgumentTypeDescription
bufferBufferThe buffer to use.

 

Returns:

Real

 

Example:

var _pos = buffer_tell(buff); buffer_seek(buff, buffer_seek_start, 0);
val[0] = buffer_read(buff, buffer_S16);
val[1] = buffer_read(buff, buffer_S16);
val[2] = buffer_read(buff, buffer_S16);
buffer_seek(buff, buffer_seek_start, _pos);

The above code will store the current seek position within the buffer stored in the variable buff to the local variable _pos. The buffer seek position will then be set to the start of the buffer, and three pieces of data read into an array, before finally resetting the buffer seek position to where it was previously.