compile subroutine rds_qxj_warn_valid(ConvType, DataIo, Branch, ReturnedValue)
begin condition
pre:
post:
end condition
declare function msg, get_property, set_property

$insert logical
$insert msg_equates
$insert rds_equ
 
equ MinPreEpiQXJ$   to 24.500
equ MaxPreEpiQXJ$   to 26.000
*equ MinPostEpiQXJ$  to 29.500
*equ MaxPostEpiQXJ$  to 33.500
*equ HardCodePhilBCBRecipe$ to 149 ;* if another recipe is used for bcb then
                                  ;* would have to create an array of recipes
equ DeltaMin$       to 3.250
equ DeltaMax$       to 5.050
*
equ SSIDeltaMin$   to .085
equ SSIDeltaMax$   to .105
*  
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$
QXJPre = get_property( @window:'.QXJ_PRE', 'TEXT' )
RDSId = get_property( @window:'.RDS_NO', 'TEXT' )
RecipeNo = xlate( 'RDS', RDSId, rds_recipe_no$, 'X' )
begin case
   case ConvType = 'ICONV'
      CustID = field( get_property( @window:'.CUST_INFO', 'TEXT' ), ' ', 1 )
      if CustID = '621' then ;* IF IT IS SILICON SYSTEMS AND IT IS A POST READING THEN
         * CHECK THE DELTA SPEC
         if Branch = 'POST' then
            Delta = ( QXJPre - DataIo ) ;* CAUSE POST WILL BE LESS FOR THICK ETCH RATE
	         if ( Delta >= SSIDeltaMin$ ) and ( Delta <= SSIDeltaMax$ ) else
	            MsgInfo = ''
	            MsgInfo<mtext$> = DataIo: ' calculates a Delta of ':Delta:' Please verify the entry and speak with your supervisor or engineering.  The Delta specification is from ':SSIDeltaMin$:' to ':SSIDeltaMax$:'.'
	            MsgInfo<micon$> = '!'
	            Void = msg( '', MsgInfo )
				end	                     
         end else
            * DO NOTHING
         end
      end else
	      if Branch = 'PRE' then
	         if ( DataIo >= MinPreEpiQXJ$ ) and ( DataIo <= MaxPreEpiQXJ$ ) else
	            Range = 'Minimun = ':MinPreEpiQXJ$:' and Maximum = ':MaxPreEpiQXJ$ 
	            MsgInfo = ''
	            MsgInfo<mtext$> = DataIo: ' is out of specification...Please verify the entry and speak with your supervisor or engineering.  The specification for PRE-EPI QXJ is ':Range
	            MsgInfo<micon$> = '!'
	            Void = msg( '', MsgInfo )
	         end
	      end else
	         *if RecipeNo = HardCodePhilBCBRecipe$ then
	            Delta = DataIo - QXJPre
		         if ( Delta >= DeltaMin$ ) and ( Delta <= DeltaMax$ ) else
		            MsgInfo = ''
		            MsgInfo<mtext$> = DataIo: ' calculates a Delta of ':Delta:' Please verify the entry and speak with your supervisor or engineering.  The Delta specification is from ':DeltaMin$:' to ':DeltaMax$:' for the BCB process'
		            MsgInfo<micon$> = '!'
		            Void = msg( '', MsgInfo )
					end	                     
	         *end else 
		      *   if ( DataIo >= MinPostEpiQXJ$ ) and ( DataIo <= MaxPostEpiQXJ$ ) else
		      *      Range = 'Minimun = ':MinPostEpiQXJ$:' and Maximum = ':MaxPostEpiQXJ$ 
		      *      MsgInfo = ''
		      *     MsgInfo<mtext$> = DataIo: ' is out of specification...Please verify the entry and speak with your supervisor or engineering.  The specification for POST-EPI QXJ is ':Range
		      *      MsgInfo<micon$> = '!'
		      *      Void = msg( '', MsgInfo )
		      *   end
	         *end
	      end
	   end
   case ConvType = 'OCONV'
      * no output
      ReturnedValue = DataIo
   case otherwise$
      ReturnedValue = ''
      status() = invalid_conv$
end case
return
