
! script name: vdelete.d/dellastrec
! var_topic: delete last variational record

!A
!A NAME:
!A
!A 	Delete Last Variational Record
!A
!A DESCRIPTION:
!A
!A 	This script allows the last VDM record created to be deleted.  There
!A 	are no questions, it automatically deletes the last VDM record created.
!A

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

DIM Answer$[256]
DIM Name$[256]
DIM Destination$[256]
DEG

DeActivateUndo
Stat=LineNumberIncr(1)
Var_object=CurrentVarObject
IF NOT ValidGeometry(Var_object) THEN Leave

Stat=VarObjectName(Var_object,Name$)
IF NOT LEN(Name$) THEN Leave

Last_record= LastVarRecord
IF NOT ValidGeometry(Last_record) THEN Leave
Execute_on= IsDelLastExecOn(Last_record)
Vgroup=VRecordRefGroup(Last_record,WsVariableRef)
DelLastVarRecord
Stat= DelStrgyVarsInGrp(Vgroup)
Stat= DeleteEntity(Vgroup)

IF Execute_on THEN
Close_object=0
Output_script=0
Stat= DisplayMessage("CALCULATING CHANGES")
Stat=OutputVarObject("tempscript",Name$,"typecontrol",Close_object,Output_script)
IF Stat=1 THEN Leave
LOAD "tempscript"
ELSE
PlotAll
END IF

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