
! script name: vdelete.d/dellastobj
! var_topic: delete last variational object

!A
!A NAME:
!A
!A 	DELETE LAST VARIATIONAL OBJECT
!A
!A DESCRIPTION:
!A	
!A 	Deletes the last variational object. 
!A
!B INSTRUCTIONS:
!B
!B	BROKEN DEPENDENCY, Delete anyway, Exit: This message will
!B			appear if the delete can not be executed because of
!B			dependency. Exit returns to the 
!B			PICK OBJECT TO BE DELETED question.
!B			Delete anyway will delete the object regardless.
!B
!B 	DELETE THIS OBJECT ? Yes or No:
!B
!B 		Y - This will delete the object.
!B 		N - This will cancel the delete process for this object
!B 		    and allow the selection of a different object.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: delete last variational object")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM Descr$[256]
DIM A$[256]

Highlight_color=2

DeActivateUndo
Start:!
Var_object=CurrentVarObject
IF NOT ValidGeometry(Var_object) THEN Leave
Stat=VarObjectName(Var_object,Name$)
Stat=Highlight(Var_object,Highlight_color,0)
Stat= DisplayMessage("CHECKING FOR OBJECT DEPENDENCIES")
No_delete=VObjDeleteCheck(Var_object)
IF No_delete THEN
	Stat=SetInputFormat("a1",",E,D,")
	Stat=GetValue("BROKEN DEPENDENCY, Delete anyway, Exit",Answer$)
	IF ExitScript(Destination$) THEN Leave
	IF Answer$="D" THEN Delete_obj
	GOTO Leave
END IF

Delete_obj:!
Stat=SetInputFormat("a1",",Y,N,")
Stat=GetValue("DELETE OBJECT "&Name$&"  Yes or No",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$="N" THEN Leave

Vgroup=VObjectRefGroup(Var_object,WsVariableRef)
Stat=DeleteEntity(Var_object,WsFalse,2)
Stat= DelStrgyVarsInGrp(Vgroup)
Stat= DeleteEntity(Vgroup)

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