Important: The information in this document is obsolete and should not be used for new development.
Cloning or Copying a Collection
You use theCloneCollectionandCopyCollectionfunctions to clone and copy collection objects. You clone a collection object if you want to make a copy of the reference to the collection object, and you copy a collection object if you want to make a copy of the entire object, including all of its items.For example, if you have a reference to a collection object stored in the variable
aCollection, you can create a new reference to this collection using
newCollection = CloneCollection(aCollection);which increments the owner count of the collection object referenced by theaCollectionvariable and returns a copy of the reference as the function result. After this call to theCloneCollectionfunction, thenewCollectionandaCollectionvariables reference the same collection object, which has an incremented owner count.You can create a copy of a collection object, including a copy of all its items, using
newCollection = CopyCollection(aCollection, nil);TheCopyCollectionfunction does not increment the owner count of theaCollectioncollection. Instead, it creates a new collection object with an owner count of 1, copies all of the information from theaCollectioncollection into the new collection, and returns a reference to the new collection. After this call to theCopyCollectionfunction, thenewCollectionandaCollectionvariables reference two distinct collections--you can make changes to one without affecting the other.You can use the second parameter of the
CopyCollectionfunction to provide a reference to an existing collection object, in which case the function copies the information from the collection referenced by the first parameter into the collection referenced by the second parameter. If the collection referenced by the second parameter already has information in it, the function
The
- removes all of the items in the second collection--including locked items--before copying the items from the first collection into the second collection
- copies the default attribute values from the first collection into the second collection
CopyCollectionfunction does not copy the owner count or the exception procedure of the first collection; it leaves the owner count and the exception procedure of the second collection unchanged.You can find more information about the
CloneCollectionfunction on page 5-56. You can find more information about theCopyCollectionfunction on page 5-57.