idlastro / FITS ASCII & Binary Table I/O: FTGET

[Source code]

NAME
FTGET 
PURPOSE
Function to return value(s) from specified column in a FITS ASCII table
CALLING SEQUENCE
values = FTGET( h, tab, field, [ rows, nulls ] )
              or
values = FTGET( ft_str, tab, field. [rows, nulls]
INPUTS
h - FITS ASCII extension header (e.g. as returned by FITS_READ)
                      or
ft_str - FITS table structure extracted from FITS header by FTINFO
          Use of the IDL structure will improve processing speed
tab - FITS ASCII table array (e.g. as returned by FITS_READ)
field - field name or number
OPTIONAL INPUTS
rows -  scalar or vector giving row number(s)
         Row numbers start at 0.  If not supplied or set to
         -1 then values for all rows are returned
OUTPUTS
the values for the row are returned as the function value.
Null values are set to 0 or blanks for strings.
OPTIONAL OUTPUT
nulls - null value flag of same length as the returned data.
        It is set to 1 at null value positions and 0 elsewhere.
        If supplied then the optional input, rows, must also 
        be supplied.
EXAMPLE
Read the columns labeled 'WAVELENGTH' and 'FLUX' from the second
(ASCII table) extension of a FITS file 'spectra.fit'
IDL> fits_read,'spectra.fit',tab,htab,exten=2     ;Read 2nd extension
IDL> w = ftget( htab, tab,'wavelength')      ;Wavelength vector
IDL> f = ftget( htab, tab,'flux')            ;Flux vector
Slightly more efficient would be to first call FTINFO
IDL> ftinfo, htab, ft_str                     ;Extract structure
IDL> w = ftget(ft_str, tab,'wavelength')      ;Wavelength vector
IDL> f = ftget(ft_str, tab,'flux')            ;Flux vector
NOTES
(1) Use the higher-level procedure FTAB_EXT to extract vectors 
        directly from the FITS file.
(2) Use FTAB_HELP or FTHELP to determine the columns in a particular
        ASCII table.
HISTORY
coded by D. Lindler  July, 1987
Always check for null values    W. Landsman          August 1990
More informative error message  W. Landsman          Feb. 1996
Converted to IDL V5.0   W. Landsman   September 1997
Allow structure rather than FITS header  W. Landsman   May 2000
No case sensitivity in TTYPE name      W. Landsman   February 2002