Viewing contents of file '../idllib/iuedac/iuelib/pro/conmenu.pro'
;******************************************************************************
;+
;*NAME:
;
;       CONMENU
;
;*CLASS:
;
;*CATEGORY:
;
;*PURPOSE:
;
;       If no translation mode is requested, inform the user of the available
;       options and request a translation mode.  Determine if the requested
;       translation mode is a valid request.
;
;*CALLING SEQUENCE:
;
;      CONMENU,CPUPAR,cpustr,next_flag=next_flag,from_vms_system=from_vms_system
;
;*PARAMETERS:
;
;      CPUPAR	(REQ) (I/O) (0) (I)
;               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  (IEEE little-endian)
;                  SPARC  - SparcStations, Sun 4##, Macintosh  (IEEE big-endian)
;
;              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.
;
;	CONSTR	(OPT) (O) (0) (S)
;		Architecture file is being converted from.
;
;	NEXT_FLAG  (KEY) (O) (0) (I)
;               Flag set according to the architecture of the system.  VAX = 1,
;		SPARC, Mac (IEEE big-endian) = 2, and MIPSEL or 386 (IEEE
;               little- endian) = 3.
;
;	FROM_VMS_SYSTEM  (KEY) (O) (0) (I)
;               For the cases when RMS equals 1, FROM_VMS_SYSTEM is set to 1
;		for an Ultrix system and 0 for a VMS system.
;
;*EXAMPLES:
;
;*SYSTEM VARIABLES USED:
;
;       none
;
;*INTERACTIVE INPUT:
;
;       If CPUPAR is not given in the call, the user will be prompted for it.
;
;       If the value of CPUPAR is not valid, the user will be prompted for a
;       new value or to quit.
;
;*SUBROUTINES CALLED:
;
;       PARCHECK
;       PLATFORM
;
;*FILES USED:
;
;       none
;
;*SIDE EFFECTS:
;
;*RESTRICTIONS:
;
;*NOTES:
;
;       Used with CON_DB, CON_RDAF, CON_SAV, and CONVERT.
;
;*PROCEDURE:
;
;       PLATFORM is used to determine the internal data format and if the
;       Record Management Services (RMS) format needs to be considered.
;       Based on the values from PLATFORM, the allowable options are
;       determined.  If CPUPAR was not given, then the user is prompted for
;       it.  The CPUPAR value is checked to see if it is allowed.  If it is,
;       the procedure returns it.  If it is not, then the user is prompted for
;       a valid value - or to quit.
;
;*I_HELP  nn:
;
;*MODIFICATION HISTORY:
;
;        9 Jun 94  PJL  wrote - based on sections in CON_DB, CON_RDAF, CON_SAV,
;                       and CONVERT
;       20 Oct 94  PJL  added reference to Macintosh
;
;-
;******************************************************************************
 pro conmenu,cpupar,cpustr,next_flag=next_flag,from_vms_system=from_vms_system
;
 npar = n_params(0)
 if (npar eq 0) then begin
    print,'CONMENU,CPUPAR,cpustr,next_flag=next_flag,' +  $
       'from_vms_system=from_vms_system'
    retall 
 endif  ; npar eq 0
 parcheck,npar,[1,2],'CONMENU'
;
 idfmt = ' '
 platform,dummy,idfmt=idfmt,rms=rms
;
 case (idfmt) of
    'vaxformat':  begin
                     next_flag = 1
                     if (rms) then begin
                        allow = [0,2,4]
                        file_format_only = 'ULTRIX/VAX  to  VMS/VAX      '
                        from_vms_system = 0
                     endif else begin
                         allow = [2,4]
                         file_format_only = 'No Conversion Required       '
                     endelse  ; rms
                  end  ; idfmt eq 'vaxformat'
    'ieeelittle':  begin
                      next_flag = 3
                      if (rms) then begin
                         allow = [0,1,6]
                         file_format_only = 'ULTRIX/MIPSEL  to  VMS/MIPSEL'
                         from_vms_system = 1
                      endif else begin
                         allow = [1,6]
                         file_format_only = 'No Conversion Required       '
                     endelse  ; rms
                   end  ; idfmt eq 'ieeelittle'
    'ieeebig':  begin
                   next_flag = 2
                   allow = [3,5]
                   file_format_only = 'No Conversion Required       '
                end  ; idfmt eq 'ieeebig'
 endcase  ; idfmt
;
 cpustrarr = [file_format_only, $
              'VAX     to  MIPSEL           ', $
              'MIPSEL  to  VAX              ', $
              'VAX     to  SPARC            ', $
              'SPARC   to  VAX              ', $
              'MIPSEL  to  SPARC            ', $
              'SPARC   to  MIPSEL           ']
;
;  if cpupar is undefined, prompt user
;
 csize = size(cpupar)
 if (csize(1) eq 0) then begin
   ;
    select_opt:
   ;
    print,' '
    print,'Data Formats Available:'
    print,' '
    print,'  VAX    - VAXstations, MicroVAX (VMS/RMS or Ultrix)'
    print,'  MIPSEL - DECstations (VMS/RMS or Ultrix), IBM 386  ' +   $
       '[IEEE little-endian]'
    print,'  SPARC  - SparcStations, Sun 4##, Macintosh  [IEEE big-endian]'
    print,' '
    print,'  Ultrix to VMS/RMS conversion is REQUIRED for:'
    print,'    Ultrix/VAX     to  VMS/VAX'
    print,'    Ultrix/MIPSEL  to  VMS/MIPSEL'
    print,' '
    print,'  Data Conversion is NOT REQUIRED for:'
    print,'    ULTRIX/MIPSEL <-> DOS/IBM 386'
    print,'    VMS/VAX     to  Ultrix/VAX'
    print,'    VMS/MIPSEL  to  Ultrix/MIPSEL'
    print,' '
    print,'Select Conversion Option'
    print,' '
    print,'  To ABORT Conversion            Q'
    print,' '
    for i = 0,n_elements(allow) - 1 do begin
       print,'  ' + cpustrarr(allow(i)) + '  ' + strtrim(i,2)
    endfor  ; i
    print,' '
    cpupar = ''
    read,'  Option? ',cpupar
   ;
    if (strupcase(cpupar) eq 'Q') then begin
       retall
    endif  ; abort
    cpupar = fix(cpupar)
    cpupar = fix(allow(cpupar))
 endif  ; csize(1) eq 0
;
 testpar = where((allow eq cpupar),parcnt)
 if (parcnt eq 0) then begin
    print,' '
    print,'ERROR: Selected Conversion Option Not Allowed'
    print,' '
    goto,select_opt
 endif  ; disallowed conversion option
;
 cpustr = strtrim(cpustrarr(cpupar),2)
;
 return
 end  ; conmenu