Difference between revisions of "RawData.setByte"

From MiniScript Wiki
Jump to navigation Jump to search
(Created page with "<c>RawData.setByte</c> writes an unsigned byte into a RawData buffer. === Arguments === {| class="wikitable" |- ! Parameter Name !! Type !! Default Value !! Meaning...")
 
m
 
Line 25: Line 25:
 
</ms>
 
</ms>
 
This example creates a [[RawData]] buffer, sizes it to length of data array, and then writes each byte of data array in the buffer, and finally print the buffer as an UTF-8 string (here : a little ASCII art of a cat).
 
This example creates a [[RawData]] buffer, sizes it to length of data array, and then writes each byte of data array in the buffer, and finally print the buffer as an UTF-8 string (here : a little ASCII art of a cat).
 +
 +
See also : [[RawData.byte]]
  
 
[[Category:Mini Micro]]
 
[[Category:Mini Micro]]

Latest revision as of 00:38, 30 January 2025

RawData.setByte writes an unsigned byte into a RawData buffer.

Arguments

Parameter Name Type Default Value Meaning
offset number 0 position in buffer at which to start writing
value number 0 unsigned byte to write

Example

data = [13, 32, 47, 92, 95, 47, 92, 13, 40, 32, 111, 46, 111, 32, 41, 13, 32, 62, 32, 94, 32, 60, 13, 32, 77, 69, 79, 87, 33, 13]

a = new RawData
a.resize data.len
for i in range (0, data.len - 1)
	a.setByte i, data[i]
end for

print a.utf8

This example creates a RawData buffer, sizes it to length of data array, and then writes each byte of data array in the buffer, and finally print the buffer as an UTF-8 string (here : a little ASCII art of a cat).

See also : RawData.byte