Viewing contents of file '../idllib/iuedac/iuelib/pro/codemx.pro'
;******************************************************************************
;+
;*NAME:
;
;	CODEMX
;
;*CLASS:
;
;*CATEGORY:
;
;	NEWSIPS
;
;*PURPOSE:
;
;	To determine if the variable is scalar, a vector of numpts points, or
;	neither.
;
;*CALLING SEQUENCE:
;
;	CODEMX,VARIABLE,NAME,NUMPTS,ERR
;
;*PARAMETERS:
;
;	VARIABLE  (REQ) (I) (0 1) (I L R D)
;		The data that is to be check.  It should be a scalar (err will
;		equal 1), or a vector with numpts points (err will equal 0).
;		If it is neither, err will equal -1.
;
;	NAME	(REQ) (I) (0) (S)
;		The name of the data in the variable, such as 'net flux'.
;
;	NUMPTS	(REQ) (I) (0) (I L)
;		The number of points that should be in the variable vector.
;
;	ERR	(REQ) (O) (0) (I)
;		The flag.  If 1, variable is a scalar.  If 0, variable is a
;		vector of numpts points.  If -1, variable is neither.
;
;*EXAMPLES:
;
;	readmx,'swp17851.mxlo',main,wave,flux,flags,sigma
;	codemx,flux,'flux',n_elements(wave),err
;
;*SYSTEM VARIABLES USED:
;
;	none
;
;*INTERACTIVE INPUT:
;
;	none
;
;*SUBROUTINES CALLED:
;
;	PARCHECK
;
;*FILES USED:
;
;	none
;
;*SIDE EFFECTS:
;
;*RESTRICTIONS:
;
;*NOTES:
;
;	subroutine for WRITEMX
;
;*PROCEDURE:
;
;	The size of the variable is used to determine if it is a scalar or
;	vector.  If it is neither, err is set to -1.  If it is a scalar, err
;	is set to 0.  If it is a vector, the number of points is compared to
;	numpts.  If equal, err is set to 0, else it is set to -1.
;
;*I_HELP  nn:
;
;*MODIFICATION HISTORY:
;
;	14 Jun 93  PJL	wrote
;
;-
;******************************************************************************
 pro codemx,variable,name,numpts,err
;
 npar = n_params(0)
 if (npar eq 0) then begin
    print,'CODEMX,VARIABLE,NAME,NUMPTS,ERR'
    retall
 endif  ; npar eq 0
 parcheck,npar,4,'CODEMX'
;
 svar = size(variable)
 if (svar(0) ne 0) then begin
    if (svar(0) ne 1) then begin
       print,' '
       print,name + ' must be a vector (or scalar to not be saved).'
       print,'ACTION:  Returning.'
       err = -1
       return
    endif  ; svar(0) ne 1
;
    if (svar(1) ne numpts) then begin
       print,' '
       print,'Number of points in the ' + name + 'vector not equal to'
       print,'the number of points in the wavelength vector.'
       print,'ACTION:  Returning.'
       err = -1
       return
    endif  ; svar(1) ne numpts
;
;  everything fine
;
    err = 0
 endif else begin
    print,' '
    print,name + ' not being saved.'
    err = 1
 endelse  ; svar(0) ne 0
;
 return
 end  ; codemx