
! script name: vprocesstable.d/tableinput
! var_topic: Change an entry in the process table

!A
!A NAME:
!A
!A 	Modify Process Table: Edit Entry	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows changes to be made to the process table.
!A	This script will only allow the user to change entries in
!A	the tool numbers, feed, and speed columns.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ENTRY: Pick the entry to be changed.
!B
!B 	INPUT NEW ENTRY: Enter the entry.
!B
Stat=ChangeLabelStr("ScriptNameStatus","Function: table input ")

DIM Answer$[256]
DIM A$[256]
DIM B$[256]
DIM A1$[256]
DIM Destination$[256]
DIM New_line$[10]
DIM End_line$[10]
DIM Format$[256]
DIM Table$[256]
DIM Data_name1$[256],Work_zone1$[256]
DEG

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

New_line$= "\n"
End_line$= CHR$(10)

ActivateUndo
Start:!
Etype= WsNumericEntry
Format$="noformat"

Element_loop:!
stat= SetInputFormat("n4","")
Table1=PickEntity("PICK ENTRY ")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Table1) THEN Element_loop
IF NOT IsEntityDependent(Table1) THEN
	Stat= MessageFileBox("/usr/weber/database/messages/nonvdmprtbl","ERROR")
	GOTO Element_loop
END IF
Stat= EntityNameCheck(Table1,Table$)

T1= LastPickPara
R1=TableParaRow(Table1,T1)
IF R1=1 THEN Element_loop
C1=TableParaColumn(Table1,T1)
Tnum_col=StringSearchRow(Table1,"Tool #",1,0,0,1)
IF NOT Tnum_col THEN Tnum_col=4
IF C1<Tnum_col THEN Element_loop

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

Stat= PlotDataTable(Table1,R1,C1,-1)
Stat= SetEntryHighlight(Table1,R1,C1,WsTrue)
Stat= PlotDataTable(Table1,R1,C1,0)

Stat= SetInputFormat("n4=","")
stat= SetEqualsValue(Value)
Value= GetValue("INPUT NEW ENTRY")
IF (ExitScript(Destination$)) THEN
	Stat= PlotDataTable(Table1,R1,C1,-1)
	Stat= SetEntryHighlight(Table1,R1,C1,WsFalse)
	Stat= PlotDataTable(Table1,R1,C1,0)
	GOTO Leave
END IF
Stat= EraseEntity(Table1)
Stat= SetEntryHighlight(Table1,R1,C1,WsFalse)

B$= "CHANGE ENTRY: "&VAL$(Value)

ActivateUndo
Stat= AdvanceUndoNumber("change entry")
Stat= AddItemToUndo(WsUBModifyMode,Table1)

RecordFunctionOn
Stat= RecordDescr(B$)
V1=StringConstant("Amo process table")
V2=StringConstant(Data_name1$)
V3=StringConstant(Work_zone1$)
E1= FindNamedEntity(V1)
V4= FreeParameter("Value",Value)
V5= FreeParameter("Row",ProcessTableRow(E1,V2,V3))
V6= FreeParameter("Column",C1)
V7= StringConstant(Format$)
Stat=InsertIntoTable(Table$,V4,V7,V5,V6)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
Stat= PlotEntity(Table1)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)

GOTO Element_loop

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