HDF_SD_ATTRFIND

The HDF_SD_ATTRFIND function locates the index of an HDF attribute given its name. The attribute can be global or from a specific dataset. If an attribute is located, its index is returned. Otherwise, -1 is returned. Once an attribute's index is known, the HDF_SD_ATTRINFO function can be used to read that attribute.

Calling Sequence

Result = HDF_SD_ATTRFIND( S_ID, Name )

Arguments

S_ID

An SD interface ID as returned by HDF_SD_START (i.e., a global attribute's " SD_ID "), or HDF_SD_SELECT/HDF_SD_CREATE (i.e., a dataset's " SDS_ID ").

Name

A string containing the name of the attribute whose index is to be returned.

Example

sd_id = HDF_SD_START('demo.hdf') ; Open an HDF file and start the SD interface.

gindex = HDF_SD_ATTRFIND(sd_id, 'TITLE')
; Find "TITLE", a global attribute.

sds_id = HDF_SD_SELECT(sd_id, 1) ; Get the ID for the first dataset.

HDF_SD_ATTRINFO,sd_id,gindex, NAME=name, TYPE=type, COUNT=count
; Read attribute info.

HELP, type, count, name ; Print info about the returned variables.

; IDL prints:

TYPE STRING = 'STRING'

COUNT LONG = 8

NAME STRING = 'TITLE'

dindex = HDF_SD_ATTRFIND(sds_id, 'LOCATION')
; Find the "LOCATION" dataset attribute.

HDF_SD_ATTRINFO,sds_id,dindex,NAME=name,TYPE=type,COUNT=count
; Read attribute info.

See Also

HDF_SD_ATTRINFO , HDF_SD_ATTRSET , HDF_SD_SELECT