Viewing contents of file '../idllib/iuedac/iuelib/pro/con_rdaf.pro'
;******************************************************************************
;+
;*NAME:
;
;    CON_RDAF 
;
;*CLASS:
;
;*CATEGORY:
;
;    IUESIPS
;
;*PURPOSE:
;
;    To convert IUE RDAF-format .dat and .lab files between SunOs
;    ULTRIX, DOS, and VMS formats, using FINDFILE and CONVERT.
;
;*CALLING SEQUENCE:
;
;    CON_RDAF,IMAGET,cpupar
;
;*PARAMETERS:
;
;    IMAGET  (REQ) (I) (S) (0)
;            Name of IUE file(s) to be converted.  Wildcards can be used.  
;
;    CPUPAR  (OPT) (I) (I) (0)
;            Parameter to identify data translation mode. 
;
;               ULTRIX/VAX  to  VMS/VAX
;                            or
;               ULTRIX/MIPSEL  to VMS/MIPSEL  0   (VMS only)
;
;               VAX     to  MIPSEL            1
;               MIPSEL  to  VAX               2
;
;               VAX     to  SPARC             3
;               SPARC   to  VAX               4
;
;               MIPSEL  to  SPARC             5
;               SPARC   to  MIPSEL            6
;
;            Supported Data Types:
;
;               VAX    - VAXstations, MicroVAX
;               MIPSEL - DECstations, IBM 386
;               SPARC  - SparcStations, Sun 4##
;
;           No Conversion is required between like data types when the
;	    destination machine uses stream files (SUNOS, ULTRIX, and DOS).
;	    Conversion is required for like data types only when the
;	    destination machine is using the VMS operating system (see 0
;	    option above).
;
;           If CPUPAR is not given in the call, the user will be prompted
;           for it.
;
;           Note that only modes in which the final data format is
;           compatible with the host operating system are allowed.
;
;*EXAMPLES:
;
;    To convert all MELO files without aperture designations (i.e., 'lg' and
;    'sm') in users account:
;
;       con_rdaf,'*l'
;
;    To convert all MELO files with aperture designation 'lg' in users account:
;
;       con_rdaf,'*llg'
;
;    To convert all MELO files with aperture designation 'sm' in users account:
;
;       con_rdaf,'*lsm'
;
;    To convert all .dat and .lab files in users account:
;
;       con_rdaf,'*'
;
;    To convert swp32199l .dat and .lab files:
;
;       con_rdaf,'swp32199l'
;
;*SYSTEM VARIABLES:
;
;    none
;
;*INTERACTIVE INPUT:
;
;    If CPUPAR is not given in the call, the user will be prompted for it.
;
;*SUBROUTINES CALLED:
;
;    PARCHECK
;    DECOMPOSE
;    CONVERT
;    CONMENU
;
;*FILES USED:
;
;    imaget given in calling sequence.
;    
;*SIDE EFFECTS
;
;*RESTRICTIONS:
;
;    Not for use with fits formated files.
;
;*NOTES:
;
;    User must be in account in which files are to be converted
;    (i.e. the path is not included in the file name)
;    If no extension is specified, .dat and .lab files are assumed.
;    If .dat is specified, only .dat files are converted.
;
;*PROCEDURE:
;
;    Before converting files, CON_RDAF uses the procedure PLATFORM to define
;    and check the allowed conversion modes.  Decompose is used to check for
;    file extensions in imaget.  If none are specified, findfile is called
;    using imaget+'.dat' and imaget+'.lab' as input.  Otherwise findfile is
;    run on imaget.  If any files are found, CONVERT is called for each entry
;    in the string array.  If no extensions are specified, all *.dat and *.lab
;    files present will be converted. 
;
;*MODIFICATION HISTORY:
;
;    Version 1 R. Thompson 3/1/90
;    3/14/90 RWT fix bug when no files are found using count keyword
;            in findfile
;    2/18/91 GRA modified for use on VAX, DEC, and SUN machines.
;                modified so that all *.lab and *.dat files will 
;                be converted, by using *.lab and *.dat as inputs
;                to FINDFILE, and using the larger of the two
;                stringarrays. CONVERT was modified to return
;                gracefully from an IO_ERROR.
;    3/28/91 PJL added PARCHECK
;    4/30/91 RWT add support for DOS
;    6/13/91 GRA merged vax and sun versions, changed "dos" to "DOS"
;    7/25/91 PJL cleaned up; tested VAX to SUN and SUN to VAX options;
;		 updated prolog
;    10/9/91 GRA globally changed all references to "syspar" to "cpupar",
;                changed cpupar to reference data formats as specified by
;                the !version.arch system variable; tested on ultrix/vax,
;                ultrix/mipsel, vms/vax, sunos/sparc; changed name from
;                CON_GO to CON_RDAF.
;   10/31/91 GRA cleaned up print statements.
;	15 Nov 93  PJL  update prolog
;	18 Nov 93  PJL  "syspar" to "cpupar"
;        9 Jun 94  PJL  replaced !version with CONMENU
;
;-
;******************************************************************************
 pro con_rdaf,imaget,cpupar
;
 npar = n_params(0)
 if (npar eq 0) then begin
    print,'CON_RDAF,IMAGET,cpupar'
    retall 
 endif  ; npar eq 0
 parcheck,npar,[1,2],'CON_RDAF'
;
;  determine (if necessary) or check cpupar
;
 conmenu,cpupar
;
 decompose,imaget,d,p,name,e,v
;
 if (e eq '') then begin
    dat_str = findfile(imaget+'.dat',count=datn) 
    lab_str = findfile(imaget+'.lab',count=labn) 
    print,' '
    print,'Found ' + strtrim(datn,2) + ' *.dat files.'
    print,' '
    print,'Found ' + strtrim(labn,2) + ' *.lab files.'
    print,' '
    if (datn ge labn) then begin
       str = dat_str
       n = datn
    endif else begin
       str = lab_str 
       n = labn
    endelse  ; datn ge labn
 endif else begin
    str = findfile(imaget,count=n)
    print,' '
    print,'Found '+strtrim(n,2)+' files.'
    print,' '
 endelse  ; e eq ''
;
 if (n gt 0) then begin
    for i=0,n-1 do begin
       fil = str(i)
       decompose,fil,d,p,name,ext,v
       if (e eq '') then begin
          convert,name,cpupar
       endif else begin
          convert,name+ext,cpupar
       endelse  ; e eq ''
    endfor  ; i
    print,' '
    print,'All specified files have been converted.'
 endif else print,'Specified file(s) not found, returning'  ; n gt 0
;
 print,' '
;
 return
 end  ; con_rdaf