User Tools

Site Tools


Serialize (Function)


serialize ( variable[] )
serialize ( { x1, y1, x2, y2, x3, y3 ... } )

returns string_expression


The serialize statement creates a string that encodes the dimensions, types, and values in an array. The Unserialize function will take a “serialized” string and return an array or list.

Often developers will create a serialized string so that they may save the values in an array into a data file or a database table.

Format of the Serialized Array

The string representing the array's data is a series of values separated by a colon ':'. The first value represents the number of rows and the second the number of columns. A one dimensional array will have a single row (1), with the length in the second value. The elements of the array follow. The first character of each value contains a marker byte defining the data type ('0'-unassigned, '1'-integer, '2'-float, and '3'-string). The actual array data follows. Strings are converted to hexadecimal so that any Unicode or special characters will be stored without change. The strings returned will contain ONLY ':', '.', '0'-'9', and 'a'-'f'.

The array {1,2,3,4,5.555,“six”} would be serialized to “1:6:11:12:13:14:25.555:3736978” and the array {{1,2},{3,4}} would be serialized to “2:2:11:12:13:14”.


dim a(3,4)
a[0,0] = 0
a[1,1] = 1
a[2,2] = 2
a[0,1] = 'string with "quotes"'
a[1,2] = 1.234

stuff = serialize(a[])
print stuff

dim c = unserialize(stuff)
# the array c is an exact copy of the array a

will display


See Also

History to Version required [] to passing variable array
en/serialize.txt · Last modified: 2016/11/07 12:20 by admin