idlastro / STSDAS Image manipulation: SXOPEN

[Source code]

NAME
SXOPEN
PURPOSE
Open a Space Telescope formatted (STSDAS) header file.
EXPLANATION
Saves the parameters required subsequent SX routines in
the common block Stcommn.  Optionally save the header in 
the string array Header, and the history in the string array
History.  Open the data file associated with this
header on the same unit.
CALLING SEQUENCE
SXOPEN, Unit, Fname [, Header [,History] [,Access]]
INPUTS
Unit = IDL unit used for IO.  Must be from 1 to 9.
Fname = File name of header file.  Default extension
        is .hhh for header files and .hhd for data
        files.    If an extension is supplied it must have the 
        form .xxh where xx are any alphanumeric characters. The
        data file must have extension .xxd
        No version number is allowed.  Most recent versions
        of the files are used.
OPTIONAL INPUT PARAMETER
Access = 'R' to open for read, 'W' to open for write.
OUTPUTS
Stcommn = Common block containing ST parameter blocks.
        (Long arrays.)
OPTIONAL OUTPUT PARAMETERS
Header = 80 char by N string array containing the
        names, values and comments from the FITS header.
        Use the function SXPAR to obtain individual
        parameter values.
History = String array containing the value of the
        history parameter.
COMMON BLOCKS
STCOMMN - Contains RESULT(20,10) where RESULT(i,LUN) =
0 - 121147 for consistency check, 1 - Unit for consistency,
2 - bitpix, 3 - naxis, 4 - groups (0 or 1), 5 - pcount,
6 - gcount, 7 - psize, 8 - data type as idl type code,
9 - bytes / record, 10 to 10+N-1 - dimension N,
17 = record length of file in bytes.
18 - # of groups written, 19 = gcount.
SIDE EFFECTS
The data and header files are accessed.
RESTRICTIONS
Works only for disc files.  The data file must have
must have the extension ".xxd" and the header file must
have the extension ".xxh" where x is any alphanumeric character
PROCEDURE
The header file is opened and each line is read.
Important parameters are stored in the output
parameter.  If the last two parameters are specified
the parameter names and values are stored.  The common
block STCOMMN is filled with the type of data, dimensions,
etc. for use by SXREAD.
If access is for write, each element of the header
array, which must be supplied, is written to the
header file.  The common block is filled with
relevant parameters for SXWRITE.  A keyword of "END"
ends the header.
MODIFICATION HISTORY
Written, DMS, May, 1983.
D. Lindler Feb. 1990
        Modified to allow var. record length header files.
D. Lindler April 1990   Conversion to new VMS IDL
Added /BLOCK when opening new .hhd file
Converted to IDL V5.0   W. Landsman   September 1997
Recognize unsigned datatype for V5.1 or greater   W. Landsman Jan 2000
Assume since V5.5  W. Landsman Sep 2006