compile subroutine rds_recipe_dop_flow_ml_valid(ConvType, DataIo, Branch, ReturnedValue)
begin condition
pre:
post:
end condition

$insert logical
$insert msg_equates
$insert dict_equates
declare function msg, get_property, set_property, fieldcount, rds_comm
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'
      DopFlowLimits = get_property( @window:'.DOP_FLOW_LIMITS', 'TEXT' )
      DataIo = iconv( DataIo, 'MD2' )
      DataIo = oconv( DataIo, 'MD2' )
      if DataIo then
	      Min = field( DopFlowLimits, '~', 1 )
	      Max = field( DopFlowLimits, '~', 2)
	      if ( Min <> '' ) and ( Max <> '' ) then
		      if ( DataIo >= Min ) and ( DataIo <= Max ) then
		         * IS WITHIN THE SPECIFIED LIMITS
		      end else
		         * JUST WARN THE USER, BUT DON'T INVALIDATE
	            MsgInfo = ''
	            MsgInfo<mtext$> = quote(DataIo):' is out of the control limits of ':quote(DopFlowLimits)
	            MsgInfo<micon$> = '!' 
	            Void = msg( '', MsgInfo )
		      end
		   end
		end else
	      MsgInfo = ''
	      MsgInfo<mtext$> = 'Invalid entry...'
	      MsgInfo<micon$> = '!' 
	      Void = msg( '', MsgInfo )
	      status() = invalid_nomsg$ 
		end 
   case ConvType = 'OCONV'
      ReturnedValue = DataIo
   case otherwise$
      ReturnedValue = ''
      status() = invalid_conv$
end case
return
