
! script name: vprocesstable.d/deleterow
! var_topic: delete a row in the process table

!A
!A NAME:
!A
!A 	Modify Process Table: Delete Row	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A	This script will delete a row in the process table.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ROW TO BE DELETED: Pick the row to be deleted. 
!B

OPTION BASE 1
stat=ChangeLabelStr("ScriptNameStatus","Function: delete process table row")

DIM Answer$[256]
DIM A$[256]
DIM Destination$[256]
DIM Table$[256]
DIM Data_name1$[256],Work_zone1$[256]

Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave
DEG

ActivateUndo
Highlight_pen=2

Start:!
Element_loop:!
stat= SetInputFormat("n4","")
Table1=PickEntity("PICK ROW TO BE DELETED")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Table1) THEN Element_loop
IF NOT IsEntityDependent(Table1) THEN
	Stat= MessageFileBox("/usr/weber/database/messages/nonvdmprtbl","ERROR")
	GOTO Element_loop
END IF
IF NOT AreEntitiesSame(Table1,"Amo process table") THEN Element_loop
T1= LastPickPara
R1=TableParaRow(Table1,T1)
IF R1= 1 THEN Element_loop

Stat= GetTableEntryStr("Amo process table",R1,1,Data_name1$)
Stat= GetTableEntryStr("Amo process table",R1,2,Work_zone1$)

Stat= PlotDataTable("Amo process table",R1,0,Highlight_pen)

ActivateUndo
Stat= AdvanceUndoNumber("delete row")
Stat= AddItemToUndo(WsUBModifyMode,"Amo process table")

Stat= EraseEntity("Amo process table")
RecordFunctionOn
Stat= RecordDescr("TABLE: Delete process table row")
V1=StringConstant("Amo process table")
V2=StringConstant(Data_name1$)
V3=StringConstant(Work_zone1$)
E1= FindNamedEntity(V1)
V6= FreeParameter("First row",ProcessTableRow(E1,V2,V3))
Stat= DeleteTableRow(E1,V6)
Curr_record= CurrentVarRecord
CloseVarRecord
Stat= PlotEntity("Amo process table")

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)

GOTO Start

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