Collection Class Methods
In this section, the Collection class methods are presented in alphabetical order.
Syntax
AppendItem(&Elem)
Description
Use this method to append an element as the last element of the collection. The item must be instantiated first by using the CreateItem method.
Parameters
Field or Control |
Definition |
---|---|
&Elem |
Specifies the element to be appended as an object: a Collection object, a Compound object, or a Primitive object. |
Returns
A Boolean value: True if the append was completed successfully, False otherwise.
Example
The following example demonstrates how to use Collection and Compound methods to create, populate, and append a compound item within a collection:
Local DocumentKey &DOCKEY;
Local Document &DOC;
Local Compound &COM, &Com_Rdr;
Local Collection &Coll_Rdr;
Local Primitive &PRIM;
&DOCKEY = CreateDocumentKey("FlightStatus", "FlightData", "v1");
&DOC = CreateDocument(&DOCKEY);
&COM = &DOC.DocumentElement;
&Coll_Rdr = &COM.GetPropertyByName("RdrCollection");
&Com_Rdr = &Coll_Rdr.CreateItem();
&PRIM = &Com_Rdr.GetPropertyByName("QE_ACNUMBER");
&PRIM.Value = 105;
&PRIM = &Com_Rdr.GetPropertyByName("QE_AZIMUTH");
&PRIM.Value = "40";
&PRIM = &Com_Rdr.GetPropertyByIndex(3);
&PRIM.Value = "4B";
&nRet = &Coll_Rdr.AppendItem(&Com_Rdr);
Syntax
CreateItem()
Description
Use this method to instantiate an empty object for this collection as defined by the CollectionElementType property.
Parameters
None.
Returns
A Collection object, a Compound object, or a Primitive object as defined by the CollectionElementType property.
Syntax
DeleteItem(index)
Description
Use this method to delete the specified element from the collection.
Parameters
Field or Control |
Definition |
---|---|
index |
Specifies the sequence number of the element to be deleted as an integer. |
Returns
A Boolean value: True if the delete was successful, False otherwise.
Syntax
GetItem(index)
Description
Use this method to return the specified element from the collection.
Parameters
Field or Control |
Definition |
---|---|
index |
Specifies the sequence number of the element to be retrieved as an integer. |
Returns
A Collection object, a Compound object, or a Primitive object as defined by the CollectionElementType property.
Syntax
GetParent()
Description
Use this method to return the parent object of the collection element.
Parameters
None.
Returns
A Collection object or a Compound object.
Syntax
GetPath()
Description
Use this method to return the absolute path to the collection element within the document's structure.
For example, for the Item_Collection collection of the PuchaseOrder document, GetPath would return the following absolute path:
PurchaseOrder/Item_Collection
Parameters
None.
Returns
A string representing the absolute path to the collection element.
Syntax
InsertItem(&Elem, index)
Description
Use this method to insert an element at the specified location in the collection. The item must be instantiated first by using the CreateItem method.
Parameters
Field or Control |
Definition |
---|---|
&Elem |
Specifies the element to be inserted as an object: a Collection object, a Compound object, or a Primitive object. |
index |
Specifies the sequence number for the element to be inserted as an integer. |
Returns
A Boolean value : True if the insertion was completed successfully, False otherwise.
Example
For example, for a collection with four items (a, b, c, d), the following call to insert item f would result in a collection with five items (a, f, b, c, d):
&ret = &Coll.InsertItem(&f, 2);