buffer_fill

This function fills a previously created buffer with a given data type and value.

The data you fill the buffer with must be in agreement with the "type" argument of this function, meaning that you can't try to fill with a string and use the unsigned 16bit integer type, for example. The type constants are the same as those used by the buffer_read and buffer_write functions. The "size" is the size of the buffer (in bytes) that you wish to fill, while the offset is the offset value (also in bytes) from the start of the buffer to start the fill from.

 

Syntax:

buffer_fill(buffer, offset, type, value, size);

ArgumentTypeDescription
bufferBufferThe reference to the buffer to fill.
offsetRealThe data offset value (in bytes).
typeRealThe type of data that is to be written to the buffer (see the list of constants here).
valueRealThe data to write.
sizeRealThe size of the buffer (in bytes) that you wish to fill.

 

Returns:

N/A

 

Example:

map_buffer = buffer_create(16384, buffer_fixed, 0);
buffer_fill(map_buffer, 0, buffer_u16, 0, 16384);

The above code finds the start of the buffer stored in the variable buff then writes a series of signed 16bit integer values to it.