Array::create Method

Creates an array from the container that is obtained from a previous call to the Array.pack method.

Syntax

client server public static Array create(container container)

Run On

Called

Parameters

  • container
    Type: container
    A container that is created by using the Array.pack method. The container is unpacked to create an array.

Return Value

Type: Array Class
An array that holds the contents of the specified container.

Remarks

If the values in the array are objects, the objects must have an Array.unpack method that is called to reestablish their internal state from a container.

Examples

The following example creates an array and adds two sets to it. The array is packed and then used to create a new array.

{ 
    Array     myArray; 
    Array     newArray; 
    container packedArray; 
 
    Set set1 = new Set(Types::Integer); 
    Set set2 = new Set(Types::Integer); 
    int i; 
    int j; 
 
    myArray = new Array(Types::Class); 
  
    // Add some values to the set1 and set2 
    for (i = 0; i < 10; i++) 
    { 
        set1.add(i); 
        j = i+3; 
        set2.add(j); 
    } 
  
    // Add set1 and set2 to myArray 
    myArray.value(1, set1); 
    myArray.value(2, set2); 
  
    // Pack the myArray into a container 
    packedArray = myArray.pack(); 
  
    // Create a new array from the container 
    if(packedArray != connull()) 
    { 
        newArray = Array::create(packedArray); 
    } 
  
    // Test that newArray has same contents as myArray 
    print newArray.definitionString(); 
    print newArray.toString(); 
    pause; 
}

See Also

Array Class

Array.pack Method