;+
; NAME:
;     GETDATA
; PURPOSE:
;     Returns a data record for a given record within an APC data file.
;     Use of this routine requires that the record number of the desired
;     record be known.  The file must already be open and attached to a
;     variable with ASSOC().
; CATEGORY:
;     OVRO APC DATA-ACCESS
; CALLING SEQUENCE:
;     data = getdata(rec_n,a)
; INPUTS:
;     rec_n     the record number of the desired data record
;     a         the associated variable for the file, attached
;                   with ASSOC(lun,intarr(1024))
; OPTIONAL (KEYWORD) INPUT PARAMETERS:
; ROUTINES CALLED:
; OUTPUTS:
;     data      the data record as read from the file.  If a file
;                   read error occurs, -1 is returned.
; COMMENTS:
; SIDE EFFECTS:
; RESTRICTIONS:
; MODIFICATION HISTORY:
;     Written 25-Sep-1997 by Dale Gary
;     15-Jun-1999  DG
;       Added alternate return to return a -1 if a file read error
;       occurs.
;     11-Jan-2000  DG
;       Eliminate !UNIX variable and use !VERSION instead
;-
function getdata,rec_n,a

   ON_IOERROR,altret

   ; Read the record number (rec_n) containing the data, swapping bytes
   ; if necessary

   b = a(rec_n)
   if(strlowcase(!VERSION.ARCH) eq 'sparc') then byteorder,b

   return,b

altret:
   return,-1

end
