Home   Help Search Login Register  

Author Topic: Packing and unpacking publicVariable data  (Read 1230 times)

0 Members and 1 Guest are viewing this topic.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Packing and unpacking publicVariable data
« on: 09 Sep 2008, 18:25:46 »
I am trying to make an enhanced publicvariable system in which each node has its own "channel", data may be sent from node to node, and a simple handshake verifies data delivery. As I plowed forward I suddenly realised "How the hell am I going to pack and unpack the data?"

Each node has a its own variable it monitors through a public event handler. Each "message" publicVariable'd through that variable has the form of an array:
Code: [Select]
[_tx, _datapack] where _tx is a header and
Code: [Select]
_datapack = []; {_datapack = _datapack + [[_x, call compile _x]]} forEach _data; where _data is an array of the variable names you want to PV.

How would I go about unpacking the data? Somehow I know:
Code: [Select]
{call compile (_x select 0) + " = " + str(_x select 1);} forEach _datapack;is garbage since the call compile _x used in data packing would, for objects, return local pointers not valid on the receiving machine. Help...  :blink:
« Last Edit: 09 Sep 2008, 18:28:42 by Mr.Peanut »
urp!

Offline i0n0s

  • Former Staff
  • ****
Re: Packing and unpacking publicVariable data
« Reply #1 on: 09 Sep 2008, 19:34:20 »
The user has to give you the variable names and not the variable itself.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Packing and unpacking publicVariable data
« Reply #2 on: 09 Sep 2008, 20:31:52 »
He is, but I am wrapping them.

How about:
Code: [Select]
{_tmp = _x select 1; call compile (_x select 0) + " = _tmp;";} forEach _datapack;
« Last Edit: 09 Sep 2008, 20:42:05 by Mr.Peanut »
urp!

Offline i0n0s

  • Former Staff
  • ****
Re: Packing and unpacking publicVariable data
« Reply #3 on: 09 Sep 2008, 21:35:51 »
That should work.