Buffer:pack(format, value1, value2,...) method

Reinitialize the Buffer with serialized values.

Parameters

format

A format string to specify the binary layout to serialize the values. See Lua programming reference "string.pack" for available sequence of conversions options.

values1, values2, ...

The values to serialize in binary format.

Return value

Returns no value.

Example

local date = sys.Datetime() local b = sys.Buffer(1) -- serialize date fields in bytes b:pack("BBB", date.day, date.month, date.year-2000) -- outputs 3 print(b.size) print("Today is "..b[1].."/"..b[2].."/20"..b[3])