#include Dim $a1[4] = [TRUE, FALSE, "Richard", 25] Dim $a2[4] = [TRUE, $a1, "Richard", WinExists("firefox")] Dim $a[4] = [TRUE, $a2, 456, "Louis"] $b = _serialize($a) MsgBox(0,"",$b) $c = _unserialize($b) _ArrayDisplay($c) _ArrayDisplay($c[1]) func _serialize($x); if (isArray($x)) then; local $r; local $b = ubound($x); local $i; $r = $b & '-' for $i = 0 to $b - 1; ; Recursively call the serialize function to collect more data. $r &= _serialize($x[$i]); next; ; Return it. return '[' & stringLen($r) & '=' & $r; ; Other types? elseIf (isBinary($x)) then; return '#' & __serialize_DataFormat($x); elseIf (isBool($x)) then; if ($x) then; return '?1=t'; else return '?1=f'; endIf; elseIf (isHWnd($x)) then; return '*' & __serialize_DataFormat($x); elseIf (isNumber($x)) then; return '&' & __serialize_DataFormat($x); elseIf (isString($x)) then; return '$' & __serialize_DataFormat($x); endIf; endFunc; func _unserialize($x, $ia = 0); ; If this function was called recursively, $ia is set to 1. ; Don't set $ia outside this function! if ($ia) then ; Create a temp array. local $bnd = stringLeft($x, stringInStr($x, '-') - 1); local $rar[number($bnd)]; $x = stringMid($x, stringLen($bnd) + 2); endIf; local $typ; local $len; local $dst; local $i = 0; do; ; Loop, loop, loop. until $x is empty. ; Get the data type. $typ = stringMid($x, 1, 1); $x = stringMid($x, 2); ; Get the length of the data. $len = stringLeft($x, stringInStr($x, '=') - 1); ; Get the data. $dst = stringMid($x, stringLen($len) + 2, $len); $x = stringMid($x, stringLen($len) + 2 + $len); ; Not array? if ($typ = '#') then; if ($ia) then; $rar[$i] = StringToBinary($dst); $i += 1; else; return StringToBinary($dst); endIf; elseIf ($typ = '?') then; if ($ia) then; $rar[$i] = __serialize_UnBool($dst); $i += 1; else; return __serialize_UnBool($dst); endIf; elseIf ($typ = '*') then; if ($ia) then; $rar[$i] = hWnd($dst); $i += 1; else; return hWnd($dst); endIf; elseIf ($typ = '&') then; if ($ia) then; $rar[$i] = number($dst); $i += 1; else; return number($dst); endIf; elseIf ($typ = '$') then; if ($ia) then; $rar[$i] = string($dst); $i += 1; else; return string($dst); endIf; ; Array? elseIf ($typ = '[') then; if ($ia) then; $rar[$i] = _unserialize($dst, 1); $i += 1; else; return _unserialize($dst, 1); endIf; ; Unrecognized? else if ($ia) then; $rar[$i] = 'Error'; return $rar; $i += 1; else; return 'Error'; endIf; exitLoop; endIf; until not($ia and stringLen($x) > 0) ; Well, return it! if ($ia) then; return $rar; endIf; endFunc; func __serialize_DataFormat($x); $y = string(($x)); return stringLen($y) & '=' & ($y); endFunc; func __serialize_UnBool($v); if ($v == 't') then return true; else; return false; endIf; endFunc;