Product: GetChildren

Reading child products of a Product container. The GetChildren function is used to retrieve any product that was moved to the product container and returns an array of products. If the container has no children then null is returned

Function

Array GetChildren()

Parameters

None

Return Value

An array of product. Cane be null or empty if none.

Example

Loads two products onto the first placed on a conveyor then reads the children on each product

var Product0 = CreateProduct("Cart0"); // Create Product0 where Cart0 is the identifier
var Product1 = CreateProduct("Cart1");
var Product2 = CreateProduct("Cart2");
MoveProduct(Product0, "Conveyor1", 0); // Place on Conveyor1
MoveProduct(Product1, Product0.Name, 0, -0.25); // Place as first child of Product0
MoveProduct(Product2, Product0.Name, 0, +0.25); // Place as second child of Product0
LogDebug("Children of Product0"); 
HandleProducts(Product0.GetChildren()); // Display the children of Product0
LogDebug("Children of Product1"); 
HandleProducts(Product1.GetChildren()); // Display the children of Product1


function HandleProducts(aProducts) {

    if (aProducts != null) {

        for (var i=0; i < aProducts.length; i++) {

            LogDebug("Product "+aProducts[i].Identifier);
        }
    }
}