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

$insert logical
declare function msg
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

ReturnedValue = DataIo       
status() = Valid$              
ValidRights = 'RWDEP'

*
begin case
   case ConvType = 'ICONV'
      convert ' ' to '' in DataIo
      for j = 1 to len(DataIo) while ReturnedValue <> ''
         if index(ValidRights, DataIo[1,1], 1) else
            ReturnedValue = ''
            status() = invalid_msg$
         end
      next j
   case ConvType = 'OCONV'
      TempBase  = ValidRights
      convert DataIo TO '' in TempBase
      convert TempBase to str(' ',len(TempBase)) in ValidRights
      ReturnedValue = ValidRights

   case otherwise$
      ReturnedValue = ''
      status() = invalid_conv$
end case
return
