Quirrel4.41.0

iostream.blob.writen

Method of blob, from module "iostream"
instance.writen(value: number, format: int)

Writes a numeric value in the given format

examples/iostream/blob/writen-basic.nut
from "iostream" import blob

let ammo = blob(0)
ammo.writen(200, 'i')

ammo.seek(0)
println("ammo.readn('i') =", ammo.readn('i'))
Output:
ammo.readn('i') = 200

Parameters

valuenumberthe value to write
formatinta character selecting the type and size to write

Errors

Throws invalid format when format is not one of the documented codes.

Notes

See iostream.stream.writen for the format codes, their sizes and the byte order used.

Writing past the current len grows this blob to fit: unlike a read past the end, a write past the end is never an error.

Example

examples/iostream/blob/writen.nut
from "iostream" import blob

let b = blob(0)         // empty: writing past the end must grow it
b.writen(0x11223344, 'i')
println("b.len() =", b.len())
Output:
b.len() = 4

See also

writenWrites a numeric value in the given format
readnReads a value of the given numeric format and returns it
resizeResizes the blob to the given size
blobclass index