COMPILE SUBROUTINE lpd_postclean_valid(ConvType, DataIo, Branch, ReturnedValue)

DECLARE FUNCTION Msg,  Get_Property

$INSERT MSG_EQUATES
$INSERT POPUP_EQUATES
$INSERT LOGICAL
$INSERT PROD_SPEC_EQU

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
EQU CRLF$          TO CHAR(13):CHAR(10)

ReturnedValue = DataIo       
status() = Valid$

BEGIN CASE
	CASE ConvType = 'ICONV'
		PSNId = get_property( @window:'.PSN', 'TEXT' )
      
      
		SpecRec = XLATE('PROD_SPEC', PSNId,'','X')
		SpecLimit				= SpecRec<PROD_SPEC_POST_LPD$>
		PostCleanBrightlight	= SpecRec<PROD_SPEC_POST_CLEAN_BRIGHTLIGHT$>


		IF ( SpecLimit <> '' ) THEN
			IF PostCleanBrightLight NE '' THEN
				IF DataIo < SpecLimit ELSE
					MsgInfo = ''
					MsgInfo<mtext$> = DataIo:' is out of the surface specification of less than ':SpecLimit:'.'	         
					MsgInfo<micon$> = '!'
					void = Msg( '', Msginfo )
					
				END
			END
		END
		
	CASE ConvType = 'OCONV'
      * no output
      ReturnedValue = DataIo
      
   CASE OTHERWISE$
      ReturnedValue = ''
      Status() = INVALID_CONV$
      
END CASE
RETURN

