buffer_seek

此函数移动缓冲区的查找位置,将其设置为相对于开始、结束或当前查找位置 (读取或写入数据时最后使用的位置)。

查找位置是距 写入 新值和 读取 值的缓冲区开头的偏移量 (以字节为单位)。当您读取或写入缓冲区时,它也会自动移动。

使用说明

接受以下常量作为"base"参数来寻求:

缓冲区寻道常量
常量描述
buffer_seek_startThe start of the buffer
buffer_seek_relativeA position relative to the current read/write position
buffer_seek_endThe end of the buffer

 

语法:

buffer_seek(buffer, base, offset);

参数类型描述
bufferBufferThe buffer to use.
baseReal寻求的基础位置。
offsetReal数据偏移值。

 

返回:

Real (the new seek position)

 

例子:

buffer_seek(buff, buffer_seek_start, 0);
buffer_write(buff, buffer_s16, 0);
buffer_write(buff, buffer_s16, x);
buffer_write(buff, buffer_s16, y);

上面的代码找到存储在变量 buff 中的缓冲区的开头,然后向其中写入一系列带符号的 16 位整数值。