SUBROUTINE RI_TYPE_CONV(ConvType, DataIo, ReturnCode, ReturnedValue)

$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

status() = Valid$

IF NOT(ASSIGNED(ReturnCode)) THEN ReturnCode = ''

BEGIN CASE
   CASE ConvType = 'ICONV'
        ReturnedValue = DataIo
        
   CASE ConvType = 'OCONV'
   
   		Vals = XLATE('SYSREPOSPOPUPS','LSL2**REACT_ITEM_TYPE',8,'X')
   		Desc = ''
   		LOOP
   			Val		= Vals[1,@VM]
   			Code	= Val[1,@SVM]
   			Desc	= Val[COL2()+1,@SVM]
   			
   		UNTIL Code = DataIO OR Vals = ''
   			Vals = DELETE(Vals,1,1,0)
   		REPEAT
   		
 		
   		BEGIN CASE
   			CASE ReturnCode = 'CODE'	; ReturnedValue = Code
   			CASE ReturnCode = 'OPSREF'	; ReturnedValue = OpsRef
   			CASE ReturnCode = 'OLDCODE'	; ReturnedValue = OldCode
   			CASE 1						; ReturnedValue = Desc
   		END CASE
   		
   CASE otherwise$
        status() = invalid_msg$
        
END CASE
RETURN
