Routines (alphabetical) > Routines: H > HDF Routines > HDF_SD_NAMETOINDEX

# HDF_SD_NAMETOINDEX

The HDF_SD_NAMETOINDEX function returns an SD dataset index given its name and SD interface ID. An error message is printed if the dataset cannot be located. The returned index can be used by HDF_SD_SELECT to access an SD dataset.

## Examples

; Start the SD interface:

SDinterface_id = HDF_SD_START('demo.hdf')

; Return the index of the 'variable_2' dataset:

index = HDF_SD_NAMETOINDEX(SDinterface_id, 'variable_2')

; Access the dataset:

SDdataset_id=HDF_SD_SELECT(SDinterface_id,index)

; End access:

HDF_SD_ENDACCESS, SDdataset_id

HDF_SD_END, SDinterface_id

## Syntax

Result = HDF_SD_NAMETOINDEX(SDinterface_id, SDS_Name)

## Return Value

Returns the specified SD dataset index number.

## Arguments

### SDinterface_id

An SD interface ID as returned by HDF_SD_START.

### SDS_Name

A string containing the name of the SD dataset be located.

## Keywords

None

## Version History

4.0 | Introduced

## See Also

HDF_SD_REFTOINDEX, HDF_SD_SELECT, HDF_SD_START