SUBROUTINE TW_TYPE_CONV(ConvType, DataIo, SubrLabel, 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$

BEGIN CASE
	CASE ConvType = 'ICONV'

		GoodValues = XLATE('SYSREPOSPOPUPS','LSL2**TW_TYPES',8,'X')
		ValueCnt = COUNT(GoodValues,@VM) + (GoodValues NE '')

		ReturnedValue = ''
		FOR I = 1 TO ValueCnt
			GoodValue = GoodValues<1,I,1>
			IF DataIO = GoodValue THEN
				ReturnedValue = DataIO
			END
		UNTIL ReturnedValue NE ''
		NEXT I
		IF ReturnedValue = '' THEN
			status() = INVALID_MSG$
		END

         
	CASE ConvType = 'OCONV'
		ReturnedValue = DataIo
 
	CASE OTHERWISE$
        status() = INVALID_MSG$
END CASE
RETURN
