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

# HDF_SD_SETEXTFILE

The HDF_SD_SETEXTFILE procedure moves data values from a dataset into an external file. Only the data is moved—all other information remains in the original file. This routine can only be used with HDF version 3.3 (and later) files, not on older HDF files or NetCDF files. Data can only be moved once, and the user must keep track of the external file(s). The OFFSET keyword allows writing to an arbitrary location in the external file.

As shown in the example, when adding data to an external file SD, you must first use HDF_SD_ENDACCESS to sync the file, then reacquire the SDS ID with HDF_SD_SELECT before using HDF_SD_SETEXTFILE.

## Examples

; Create an HDF file:

SDinterface_id = HDF_SD_START('ext_main.hdf', /CREATE)

; Add an SD:

SDdataset_id = HDF_SD_CREATE(SDinterface_id, 'float_findgen', [3,5], /FLOAT)

; Put some data into the SD:

HDF_SD_ADDDATA, SDdataset_id, FINDGEN(3,5)

; Call HDF_SD_ENDACCESS to sync the file:

HDF_SD_ENDACCESS,SDdataset_id

; Reacquire the SDdataset_id:

SDdataset_id = HDF_SD_SELECT(SDinterface_id, 0)

; Move data to an external file named findgen.hdf:

HDF_SD_SETEXTFILE, SDdataset_id, 'findgen.hdf'

; Retrieve data from the external file into the variable fout:

HDF_SD_GETDATA, SDdataset_id, fout

; Print the contents of fout:

PRINT, fout

; Sync and close the files:

HDF_SD_ENDACCESS, SDdataset_id

HDF_SD_END, SDinterface_id

#### IDL Output

0.00000 1.00000 2.00000

3.00000 4.00000 5.00000

6.00000 7.00000 8.00000

9.00000 10.0000 11.0000

12.0000 13.0000 14.0000

## Syntax

HDF_SD_SETEXTFILE, SDdataset_id, Filename [, OFFSET=bytes]

## Arguments

### SDdataset_id

An SD dataset ID as returned by HDF_SD_SELECT.

### Filename

The name of the external file to be written.

## Keywords

### OFFSET

Set this keyword to a number of bytes from the beginning of the external file at which data writing should begin. Exercise extreme caution when using this keyword with existing files.

## Version History

4.0 | Introduced

## See Also

HDF_SD_END, HDF_SD_ENDACCESS, HDF_SD_SELECT, HDF_SD_START