Click to Rate and Give Feedback
MSDN
MSDN Library
 
Arrays

Arrays may hold values of any one, given type, including objects and records (contrary to the arrays built into the X++ language). The values are stored sequentially. The arrays expand as needed, so no specific dimension of the array is supplied.

Example

{
 

array oarray = new array (types::class);

oarray.value(1, new query());

oarray.value(2, new query());

oarray.value(4, new query());

print oarray.toString();

print oarray.definitionString();

pause;

 

}

 

 

The following methods exist on array objects:

  • public new (types type)
    Create an array where each element has the type given by the argument.
     

  • public any value(int index, any value=NULL)
    Set and get the value of the array value stored at the given index. If an attempt is made to read a value at an index that is above the last index having a value, an exception is raised.
     

  • public int typeId()
    Returns the type of the values in the set.
     

  • public str toString()
    Returns a human readable form of the array, e.g (“Peter”, “Paul”, “Mary”).
     

  • public str definitionString()
    Returns a string containing the definition of the array, for example “array of class”
     

  • container pack()
    Packs the array into a container, suitable for saving in a database etc. If the keys or the values are objects, the pack method is called on each object to yield a (sub) container.
     

  • public int lastIndex()
    Returns the highest index used to store a value.
     

  • public static array create (container c)
    Creates the array from the container obtained from a prior call to pack. This is limitless. If the values in the array are objects, the objects must have an unpack method that is called to reestablish their internal state from a container.

© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker