buffer_read(buffer, type)

参数 描述
buffer The index of the buffer to read from.
type The type of data that is to be read from the buffer (see the list of constants below).

Returns: Real/String or one of the following constants if the function fails:

常量 描述
buffer_outofspace is returned when reading from a buffer beyond its capacity
buffer_outofbounds is when an explicit operation is outside of the buffer capacity (i.e. index is < 0 or > capacity)
buffer_invalidtype is when a you try to read a non u8 value from a fast buffer type.


This function can be used to read data from a previously created buffer. The return value will depend on the type of data that you are reading, which in itself is defined by the following constants:

常量 描述
buffer_u8 无符号 8 位整型。值域为 0 到 255。
buffer_s8 有符号 8 位整型。值域为 -128 到 127(0为正数)。
buffer_u16 无符号 16 位整型。值域为 0 到 65535 。
buffer_s16 有符号 16 位整型。值域为 -32768 到 32767(0为正数)。
buffer_u32 无符号 32 位整型。值域为 0 到 4,294,967,295。
buffer_s32 有符号 32 位整形。值域为 -2,147,483,648 到 2,147,483,647(0为正数)。
buffer_u64 An unsigned 64bit integer.
buffer_f16 A 16bit float. 值域为 -65504 到 +65504。(Not currently supported!)
buffer_f32 A 32bit float. 值域为 -16777216 到 +16777216。
buffer_f64 A 64bit float.
buffer_bool 布尔类型。只能为 1 或 0 (truefalse)
buffer_string A string of any size.
buffer_text A string of any size, without the final null terminating character.

NOTE: Using the incorrect data type for the data being read will result in erroneous values!


var cmd = buffer_read(buff, buffer_s16);

The above code reads from the buffer with the id stored in the variable "buff" a signed 16bit value into the local variable "cmd".