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

$insert logical
$insert quote_equ
$insert msg_equates

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'
      if DataIo matches "1A2N-0N" then
          convert @lower_case to @upper_case in DataIo
          if index( DataIo, 'T', 1 ) or index( DataIo, 'M', 1 ) then
		      extract_si_keys( 'RDS', 'RDS_OLD', DataIo, Keys )
		      status() = valid$
		      RdsNo = get_property( @window:'.RDS_NO', 'TEXT' )
		      locate RdsNo in Keys using @vm setting Fpos then
		          keys = delete( Keys, 1, Fpos, 0 )
		      end
		      if Keys then
		          swap @vm with ', ' in Keys
		          MsgInfo = ''
		          MsgInfo<mtext$> = 'RDS Old # ':Quote(DataIo):' has been used in RDS number ':CrLf$:Keys
		          MsgInfo<micon$> = '!'
		          Void = msg( '', MsgInfo )
		          status() = invalid_nomsg$
		      end else
		          ReturnedValue = DataIo
		      end
		  end else
		      MsgInfo = ''
		      MsgInfo<mtext$> = 'City code is invalid...Enter T=Tempe or M=Mesa.'
		      MsgInfo<micon$> = '!'
		      Void = msg( '', MsgInfo )
		      status() = invalid_nomsg$
		  end
      end else 
          MsgInfo = ''
          MsgInfo<mtext$> = 'You must enter as "CRR-NNNN" C=City code i.e. T=Tempe or M=Mesa, RR=Reactor number i.e 01-19, NNNN=The sequential run number for the reactor.'
          MsgInfo<micon$> = '!'
          Void = msg( '', MsgInfo )
          status() = invalid_nomsg$
      end
   case ConvType = 'OCONV'
      * no output
      ReturnedValue = DataIo
   case otherwise$
      ReturnedValue = ''
      status() = invalid_conv$
end case
return
