FUNCTION Notes_Comm(Branch)

DECLARE Function set_property, fieldcount, get_property, msg
DECLARE Function obj_Notes


Branches = ''
parameter=0
ReturnValue = ''
Branches = 'SET_FIELDS,STRIP_DUPS'
convert ',' to @fm in Branches
locate Branch in Branches using @fm setting Bpos then
   on bpos gosub SetFields, StripDups
end else
   Void = msg( '', 'Invalid Branch ':Bpos:' passed to notes_comm' )
end
return ReturnValue

*===========================================================================*
SetFields:   

RETURN


*===========================================================================*
StripDups:
	AllNames = ''
	
	STI = get_property( @window:".SEND_TO_INTERNAL", "ARRAY" )<1>; *get the user ids from the name field
	cnt = fieldcount( STI, @vm ); *get the user count by counting @vm
	for i = 1 to cnt
	    if STI<1,i> <> '' then
	        * there is a value and it is not null, so check to see if it already exists in the array
			if index( AllNames, STI<1,i>, 1) then; *if the user id is already in AllNames do nothing
			end else
				AllNames<1,-1> = STI<1,i>; *else the user id is unique so append it to AllNames
			end
		end
	next i

	STGI = get_property( @window:".SEND_TO_GROUP_INT", "ARRAY" ); *get the group names from the group field
	groupcnt = fieldcount( STGI, @vm ); *get the group count by counting @vm
	GroupName = ''
	for i = 1 to groupcnt
		UserNames = ''		
		if STGI<1,i> <> '' then
			GroupName = STGI<1,i>; *get the group name
			
			IF GroupName = 'ALL_ACTIVE_USERS' THEN
				UserNames = obj_Notes('AllActiveUsers')
			END ELSE
				UserNames = xlate( 'MSG_GROUPS', GroupName, 'USER_IDS', 'x' )		; *returns the user ids
			END
			
			
			namecnt = fieldcount( UserNames, @vm ); *get the number of users
			for j = 1 to namecnt
				if UserNames<1,j> <> '' then
					if index( AllNames, UserNames<1,j>, 1) then; *if the user id is already in AllNames do nothing
					end else
						AllNames<1,-1> = UserNames<1,j>; *else the user id is unique so append it to AllNames
					end
				end
			next j
		end
	next i
	*debug
	*Void = set_property( @window:'.SEND_TO_INTERNAL', 'ARRAY', AllNames:@fm ) 
	ReturnValue = AllNames
return ReturnValue
