Important: The information in this document is obsolete and should not be used for new development.
GetCollectionItem
You can use theGetCollectionItemfunction to obtain a copy of the variable-length data associated with a collection item given the item's collection tag and collection ID.
OSErr GetCollectionItem(Collection source, CollectionTag tag, long id, long *itemSize, void *itemData);
source- A reference to the collection object containing the item whose data you want to retrieve.
tag- The collection tag associated with the item whose data you want to retrieve.
id- The collection ID associated with the item whose data you want to retrieve.
itemSize- A pointer to a
longvalue indicating the number of bytes of data you want returned in theitemDataparameter. On return, this value indicates the size in bytes of the variable-length data associated with the specified item. You may specify the constantdontWantSizefor this parameter to indicate that you want to copy all the specified item's variable-length data and you do not want to determine the size of this data.itemData- A pointer to a block of memory to contain the item's data. On return, this memory contains a copy of the data associated with the specified item. You may specify the constant
dontWantDatafor this parameter if you do not want a copy of the item's data.DESCRIPTION
TheGetCollectionItemfunction allows you to obtain a copy of the variable-length data associated with a specific collection item. You specify a collection object using thesourceparameter and you specify an item in that collection using thetagandidparameters.You use the
itemSizeparameter to specify how many bytes of data to return in theitemDataparameter. You may specify the constantdontWantSizefor this parameter to indicate that you want to copy all of the variable-length data from the specified item into theitemDataparameter. You may specify a value for theitemSizeparameter that is greater than the actual number of bytes in the specified item's variable-length data; however, this function never returns in theitemDataparameter more data than contained in the specified item's variable-length data.This function returns information in the
itemSizeanditemDataparameters:
If you don't know the size of the item you want to retrieve, you typically call this function twice. The first time you provide a pointer in the
- If you provide a pointer in the
itemSizeparameter, the function uses this parameter to return the size in bytes of the variable-length data associated with the specified collection item.- If you provide a pointer in the
itemDataparameter, the function uses this parameter to return a copy of the variable-length data associated with the specified collection item.
itemSizeparameter to determine the size of the specified item's data and you specifydontWantDatafor theitemDataparameter. Then you allocate a memory block large enough to hold a copy of the item's data. Then you call the function a second time. This time you specify the constantdontWantSizefor theitemSizeparameter and provide a pointer to the allocated memory block for theitemDataparameter. The function then copies the data into the allocated block of memory.RESULT CODES
collectionItemNotFoundErr -5751 Can't locate item. SEE ALSO
For information about collection items and their associated collection tags, collection IDs, and variable-length data, see "Collection Items" beginning on page 5-8.For examples using this function, see "Retrieving the Variable-Length Data From an Item" beginning on page 5-33.
To retrieve the data associated with a collection item given its collection index (rather than its collection tag and ID), use the
GetIndexedCollectionItemfunction, described in the next section.