Ecco Folders and Items
An Ecco folder is represented using an EccoFolder object. To initialize an EccoFolder object, you must first create the object with the Set statement, and then set either the Name or ID properties:
Dim MyFolder as EccoFolder Set MyFolder = New EccoFolder MyFolder.Name = "PhoneBook"
You can sort the items in the folder based on the item text or based on the folder value, using the SortItems method or the SortValues method, respectively.
MyFolder.SortItems MyFolder.SortValues
By default, this sort is performed in ascending order. To sort in descending order, add the boolean True:
MyFolder.SortItems True
The items in an Ecco folder are returned by the Items property. This returns an EccoItems collection, which is a collection of EccoItem objects, one for each item in the folder. This collection will be sorted based on the last sort command; or, if no sort command was specified, sorted based on item text in ascending order. For example, the following returns a collection consisting of all items in the PhoneBook:
MyFolder.Name = "PhoneBook" Set MyPhoneItems = MyFolder.Items
You can also use the FindItems and FindValues properties to return EccoItems collections limited to items in the folder meeting specified criteria, e.g.:
Set MyPhoneItems = MyFolder.FindValues("State - Business","PA")
The following properties generate EccoItems collections:
The Find property of the EccoItems collection object returns all items in the EccoItems collection that meet certain criteria. You may use this property to apply multiple filter criteria to a collection of items.
EccoItems collections can be filtered to create another EccoItems collection, using the Find property. You can use this technique to apply multiple filters. For example, the following would produce a collection of all persons in the phone book who have business addresses in Texas and who were born after 1960:
MyFolder.Name = "PhoneBook"
Set MyPhoneItems = MyFolder.Items
Set MyPhoneItems = MyPhoneItems.Find("State - Business = TX")
Set MyPhoneItems = MyPhoneItems.Find("Birthday > 1/1/60")
You can add and remove individual items from an EccoItems collection using the Add and Remove methods. Note that this does not remove items from the Ecco file, or change folder assignments; it merely changes the collection of items with which you are working. You can use this technique to remove individual items, or to join together more than one set of EccoItems, as in the following examples:
MyPhoneItems.Remove MyPhoneItems.Item("Doe, John")
Set MyTexasFriends = MyPhoneItems.Find("State - Business = TX")
Set MyHawaiiFriends = MyPhoneItems.Find("State - Business = HI")
Set MyFriends = New EccoItems
For Each MyItem In MyTexasFriends
MyFriends.Add MyItem
Next
For Each MyItem In MyHawaiiFriends
MyFriends.Add MyItem
Next
Individual items in an EccoItems collection can be read using the index number (starting at 1), or using the item text as an index. The following would access the fifth item in the collection:
Set MyItem = MyPhoneItems.Item(5)
The following would access a particular item using the item text as an index. Please note, the item text must match exactly – pattern matching and partial matches aren't supported. This is a quick way to get a known item in the Ecco file.
Set MyItem = MyEcco.Items("Smith, David")
You can process all individual items in an EccoItems collection using a For Each . . . Next loop, as shown below.
For Each MyItem In MyPhoneItems
ListBox1.AddItem MyItem.FullName
Next
The number of items in any EccoItems collection can be read using the Count property. For example:
If MyPhoneItems.Count > 0 then
For Each MyItem in MyPhoneItems
Print #1, MyItem.FullName, MyItem.BusPhone
Next
End If