SUBROUTINE MET_PROP_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$

/*
EQU UNIT$THICK			TO CHAR(230):'m'			;* Microns
EQU UNIT$THICKA			TO CHAR(143)				;* Angstroms
EQU UNIT$RES			TO CHAR(234):'-cm'			;* Ohms.Cm
EQU UNIT$SRES			TO CHAR(234):'/':CHAR(220)	;* Ohms/Square
EQU UNIT$CRES			TO CHAR(234):'-cm'			;* Ohms.Cm
EQU UNIT$CONC			TO 'CM-3'					;* Carriers.Cubic Centimeter
EQU UNIT$STRESS			TO 'dyne/cm-2'				;* Dyne/Square Centimeter
EQU UNIT$BOW			TO CHAR(230):'m'			;* Microns
EQU UNIT$TRANS			TO CHAR(230):'m'			;* Microns
*/

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

BEGIN CASE
   CASE ConvType = 'ICONV'
   
   		Vals = XLATE('SYSREPOSPOPUPS','LSL2**MET_PROPERTY',8,'X')
				
   		LOOP
   			Val		= Vals[1,@VM]
   			Code	= Vals<1,1,1>	;* 1st column
   			InConv	= Vals<1,1,3>	;* 3rd column
   		UNTIL Code = ReturnCode OR Vals = ''
   			Vals = DELETE(Vals,1,1,0)
   		REPEAT	
   			
        ReturnedValue = ICONV(DataIo,InConv)
        
        
   CASE ConvType = 'OCONV'
   		
   		Vals = XLATE('SYSREPOSPOPUPS','LSL2**MET_PROPERTY',8,'X')
   		
   		LOOP
   			Val		= Vals[1,@VM]
   			Code	= Vals<1,1,1>	;* 1st column
   			OutConv	= Vals<1,1,4>	;* 4th column
   		UNTIL Code = ReturnCode OR Vals = ''
   			Vals = DELETE(Vals,1,1,0)
   		REPEAT	
   			
   		ReturnedValue = OCONV(DataIo,OutConv)
   		
   CASE otherwise$
        status() = invalid_msg$
        
END CASE

RETURN
