Struct.pack Method
Serializes the current instance of the Struct class.
Syntax
public container pack()
Run On
Called
Return Value
Type: container
A container that contains the current instance of the Struct class.
Remarks
The pack method is called on each field that holds an object, to yield a (sub) container.
The struct may be recreated from the container by using the Struct.create method.
Examples
The following example creates a struct with two items in it (name and age), and then adds values to the items. The struct is packed into a container, and this container is then used to create a new struct.
{
container packedStruct;
Struct s1, s = new Struct ("str name; int age");
s.value ("name", "Jane Dow");
s.value ("age", 34);
// Struct is packed into a container
packedStruct = s.pack();
// A new struct is created from the container
s1 = Struct::create(packedStruct);
// Both structs have the same contents
print s.toString();
print s1.toString();
pause;
}