The HDF_SD_FILEINFO procedure retrieves the number of datasets and global attributes in an HDF file.
sd_id = HDF_SD_START('demo.hdf', /CREATE)
;
Start the SD interface.
HDF_SD_ATTRSET,sd_id, 'TITLE', 'MYTITLE'
;
Set a global attribute.
HDF_SD_ATTRSET,sd_id, 'TITLE2', 'MYTITLE2'
;
Set another one.
sds_id = HDF_SD_CREATE(sd_id, 'var1', [10,3])
;
Create a dataset.
HDF_SD_FILEINFO, sd_id, datasets, attributes
;
Retrieve info about the dataset.
HELP, datasets, attributes ; Print information about the returned variables.