Skip to main content

blob.writen(value, dataType)

Writes a value into the blob

Availability

Device + Agent

Parameters

Name Type Description
value Integer or float The value to be written to the blob
dataType Constant A single-character string constant indicating the value’s data type

Returns

Nothing

Description

This method writes a single value of a specified type into the blob at the byte indicated by the blob’s read/write pointer. The written value type is specified by a single-character string which must be delimited with single-quote characters, for example:

aBlob.writen(myFloat, 'f');

The method’s first parameter — the number to be written into the blob — must be an integer or float. Other data types will not be cast into these types by the method: no error will be issued and the results are undefined. From impOS™ 36, if you attempt to write other data types into a blob, zeros will be written instead. The number of zeros will match the number of bytes specified by the dataType constant.

Of Squirrel’s own data types only float and integer (both are 32-bit values) can be stored in the blob (using the ‘i’ and ‘f’ markers), but writen() additionally supports a number of the most common 8-bit and 16-bit standard variable types. The following table lists the data types supported and their data type strings:

String Constant Type
'c' 8-bit signed integer
'b' 8-bit unsigned integer
's' 16-bit signed integer
'w' 16-bit unsigned integer
'i' 32-bit signed integer
'f' 32-bit float
'd' 64-bit float

Note a written 64-bit value — an IEEE 754 double-precision float — will only have the precision of the 32-bit standard Squirrel float from which it was derived.

All imps are little endian, so multi-byte values will written into a blob or read from it in order of least byte significance. For example, if a 16-bit unsigned integer is written into a blob (the 'w' option, above), the least-significant byte is written first (at blob pointer location n) and followed by the most-significant byte (at blob pointer location n+1).

Example Code