
! script name: vdelete.d/deletegroup
! var_topic: hide a single entity. 

!A
!A NAME: 
!A
!A 	Delete Group. VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows a group to be deleted.
!A
!B INSTRUCTIONS:
!B
!B 	PICK GROUP TO BE DELETED: Pick the group to be deleted.
!B
!B NOTES:
!B
!B 	This is a variational delete function. The delete operation becomes
!B 	part of the variational object. This function should only be used when
!B 	entities which are created variationally are no longer needed and there
!B 	presence in the variational program is not desireable. Normally extra
!B 	elements should just be hidden.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: delete entity ")

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

Var_object=CheckVarObject
IF ExitScript(Destination$) THEN Leave

HighlightPen= 2

Pick_group:!
ActivateUndo
stat= SetInputFormat("a1",",N,")
Group=PickGroupEnt("PICK GROUP TO BE DELETED, Name ",0,Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$="N" THEN 
	GOSUB Get_named_grp
END IF
IF NOT ValidDependency(Group) THEN Pick_group
Stat=EntityNameCheck(Group,Group$)
Stat=Highlight(Group,HighlightPen,WsDirArrowOff)

Var_record=VarRecordParent(Group)
IF NOT ValidGeometry(Var_record) THEN Pick_group

ActivateUndo
Stat= AdvanceUndoNumber("delete group")
Stat= AddGroupToUndo(WsUBDeleteMode,Group$,1,WsTrue)

RecordFunctionOn
Stat=RecordDescr("DELETE: Group")
Stat=DeleteGroup(Group$,WsTrue)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Pick_group

Get_named_grp:!
Stat=ListGrpNames("GROUP NAMES","selected group","",0)
IF Stat=1 THEN Leave
Stat=SetInputFormat("a99","")
Stat=GetValue("GROUP NAME",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Group=FindNamedGrp(Answer$)
IF NOT ValidGeometry(Group) THEN Get_named_grp
Stat=SetInputFormat("n4","")
LowerSelectBox
RETURN

Leave:!
LowerSelectBox
Stat=SetInputFormat("n4","")
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
