Buffer.writestring: Difference between revisions

From GiderosMobile
Created page with "__NOTOC__ '''Available since:''' Gideros 2025.1<br/> '''Class:''' buffer_luau<br/> === Description === Writes data from a string into the ''buffer'' at the specified ''of..."
 
No edit summary
 
Line 4: Line 4:


=== Description ===
=== Description ===
Writes data from a string into the ''buffer'' at the specified ''offset''. If an optional count is specified, only count bytes are taken from the string.
Writes data from a string into the buffer ''b'' at the specified ''offset''. If an optional ''count'' is specified, only ''count'' bytes are taken from the string.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
buffer.writestring(b,offset,value,count)
buffer.writestring(b,offset,value[,count])
</syntaxhighlight>
</syntaxhighlight>
''count'' cannot be larger than the string length.


=== Parameters ===
=== Parameters ===
Line 13: Line 15:
'''offset''': (number) offset from the beginning of the buffer memory, starting from 0<br/>
'''offset''': (number) offset from the beginning of the buffer memory, starting from 0<br/>
'''value''': (string) data to write<br/>
'''value''': (string) data to write<br/>
'''count''': (number) number of bytes to take from the string. This value cannot be larger than the string length '''optional'''<br/>
'''count''': (number) number of bytes to take from the string. This value cannot be larger than the string length '''Optional'''<br/>


=== Example ===
=== Example ===

Latest revision as of 14:11, 3 February 2026

Available since: Gideros 2025.1
Class: buffer_luau

Description

Writes data from a string into the buffer b at the specified offset. If an optional count is specified, only count bytes are taken from the string.

buffer.writestring(b,offset,value[,count])

count cannot be larger than the string length.

Parameters

b: (buffer) the buffer
offset: (number) offset from the beginning of the buffer memory, starting from 0
value: (string) data to write
count: (number) number of bytes to take from the string. This value cannot be larger than the string length Optional

Example

local str = "Hello Gideros!"
local b = buffer.fromstring(str)
local offset = 1
local value = "A"
local count = 1
buffer.writestring(b, offset, value, count)
print(buffer.tostring(b))