
! script name: groups.d/combinegroups
! topic: combine groups

!A
!A NAME:
!A
!A 	Combine Groups
!A
!A DESCRIPTION:
!A
!A 	This script combines two groups.  
!A
!B INSTRUCTIONS:
!B
!B 	PICK FIRST GROUP: Pick the first group to be combined.
!B			  The second groups elements will be appended
!B			  to this group.
!B
!B 	PICK NEXT GROUP: Pick the other group to be combined.
!B			 This group will no longer exist.
!B
!C NOTE:
!C
!C	This function does not check for duplicate entries
!C	in the groups.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: combine groups ")

DIM Answer$[256]
DIM Destination$[256]


ActivateUndo
Highlight_color1=2
Highlight_color2=3
Combine_loop:!

Group1=PickGroupEnt("PICK FIRST GROUP ")
IF (ExitScript(Destination$)) THEN Leave
Stat=Highlight(Group1,Highlight_color1,0)

Group2=PickGroupEnt("PICK NEXT GROUP ")
IF (ExitScript(Destination$)) THEN Leave
Stat=Highlight(Group2,Highlight_color2,0)


Stat=Highlight(Group2,Highlight_color1,0)

ActivateUndo
Stat= AdvanceUndoNumber("combine groups")
Stat= AddItemToUndo(WsUBModifyMode,Group1)
Stat= AddGroupToUndo(WsUBModifyMode,Group2,1,WsFalse)
Stat= AddItemToUndo(WsUBDeleteMode,Group2)

stat=CombineGroups(Group1,Group2)

! delete second group 
stat= DeleteEntity(Group2)

GOTO Combine_loop

Leave:!
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
