Struct::create Method

Creates a struct from a container that is obtained from a prior call to Struct.pack.

Syntax

client server public static Struct create(container container)

Run On

Called

Parameters

  • container
    Type: container
    A container that contains the packed struct.

Return Value

Type: Struct Class
A struct equal to the one that was packed into the specified container.

Remarks

If the struct contains objects, these objects must have an unpack method that is called to re-establish their internal state from the container.

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 unpacked 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;  
}

See Also

Struct Class

Struct.pack Method