COMPILE SUBROUTINE CONV_XLATE( ConvType, DataIo, SubrLabel, ReturnedValue )

* Copied from XLATE_CONV to CONV_XLATE on 11/19/2013 JCH (I'm tired of trying to find these CONV routines!)

/*
   DataIo will contain the data to be used as the key
   SubrLabel will consist of three parts:   PART1*PART2
            PART1 = the tablename to XLATE from
            PART2 = the columnname or number to retrieve 
*/
begin condition
pre:
post:
end condition


$insert LOGICAL

equ valid$         to 0    ;* successful
equ invalid_msg$   to 1    ;* bad data       -   print error message window
equ invalid_conv$  to 2    ;* bad conversion -          "         "
equ invalid_nomsg$ to 3    ;* bad but do not print the error message window

ReturnedValue = DataIo        ; * save off data input by user
status() = valid$             ; * assume successful conversion



BEGIN CASE
	CASE ConvType = 'ICONV'
      ReturnedValue = DataIo
      
   CASE ConvType = 'OCONV'
      convert '*' to @fm in SubrLabel
      TableName  = SubrLabel<1>
      ColumnName = SubrLabel<2>
      ReturnedValue = xlate( TableName, ReturnedValue, ColumnName, 'X')
      IF ReturnedValue = '' THEN ReturnedValue = DataIo						;* Added by JCH 12/2/2004
      
   CASE otherwise$
      ReturnedValue = ''
      status() = invalid_conv$
      
END CASE
RETURN

