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

$insert logical
$insert msg_equates
$insert popup_equates
$insert company_equ
$insert names_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'
      CustID = get_property( @window:'.CUST_NO', 'TEXT' )
      NameID = get_property( @window:'.NAME_NO', 'TEXT' )
		CustPhones = xlate( 'COMPANY', CustID, company_phones$, 'X' )
		NamePhones = xlate( 'NAMES', NameID, names_phone$, 'X' )
		AllPhones = CustPhones:@vm:NamePhones
		DataIo = iconv( DataIo, '[PHONE_FORMAT]' )
		if len( DataIo ) then
	      locate DataIo in AllPhones using @vm setting Fpos else
		      MsgInfo = ''
		      MsgInfo<mtext$> = quote( oconv( DataIo, '[PHONE_FORMAT]' ) ):' not found for this customer or contact person.'
		      MsgInfo<micon$> = '!'
		      Void = msg( '', MsgInfo )
		      status() = invalid_nomsg$
	      end
	   end else
	      * SYSTEM WILL ERROR ON OCONV FROM WINDOW WHICH IS PHONE_FORMAT
	   end
   case ConvType = 'OCONV'
      * no output
      ReturnedValue = DataIo
   case otherwise$
      ReturnedValue = ''
      status() = invalid_conv$
end case
return
