compile subroutine msg_groups_valid(ConvType, DataIo, Branch, ReturnedValue)

declare function msg, get_property, set_property, post_event
declare subroutine extract_si_keys

$insert logical
$insert msg_equates
$insert msg_groups_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$

convert @LOWER_CASE to @UPPER_CASE in DataIo

begin case
   case ConvType = 'ICONV'
       convert ' ' to '_' in DataIo
	   if rowexists( 'MSG_GROUPS', DataIo ) then
		   if @user4 = xlate( 'MSG_GROUPS', DataIo, msg_groups_entry_id$, '' ) OR DataIo = 'ALL_ACTIVE_USERS' then
			   *VALID ENTRY - RETURNING
		   end else
		      Message = 'You are only allowed to view your own groups.' 
		      Message<micon$> = 'H'
		      Void = msg( '', Message )
		      status() = invalid_nomsg$
		   end
	   end else
   		  Message = DataIo:" doesn't exist in your groups." 
	      Message<micon$> = 'H'
	      Void = msg( '', Message )
	      status() = invalid_nomsg$
	   end
   case ConvType = 'OCONV'
      convert ' ' to '_' in DataIo
      ReturnedValue = DataIo
   case otherwise$
      ReturnedValue = ''
      status() = invalid_conv$
end case
return
