
! script name: vdatatable.d/toperationloc
! var_topic: insert the location of an operation into a table

!A
!A NAME:
!A
!A 	Tables: Operation Location	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A	Insert the location of an operation into a table
!A
!# see also - htdocs/help.d/datatables.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: operation into table")

DIM Answer$[256]
DIM Name$[256]
DIM Descr$[256]
DIM Element$[256]
DIM Table$[256]
DIM Destination$[256]
DIM Point$[256]
DIM XYZFormat$[15]
DIM DiaFormat$[15]
DIM DepthFormat$[15]
DIM Operation_name$[256]
DEG

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


A= GetDefault(WsPlacesAfter)
XYZFormat$= "decimal "&VAL$(A)
DepthFormat$= "decimal "&VAL$(A)

A= GetDefault(WsRPlacesAfter)
DiaFormat$= "decimal "&VAL$(A)


ActivateUndo
Start:!
Pick_loop:Stat=SetInputFormat("n4","")
E1=PickEntity("PICK OPERATION")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_loop
Stat= EntityNameCheck(E1,Element$)
Operation=GetAssocEnt(E1,WsOperation)
IF NOT ValidGeometry(Operation) THEN Pick_loop
Stat=GetUserDataName(Operation,Operation_name$)




Pick_entry:!
stat= SetInputFormat("n4","")
Table1=PickEntity("PICK ENTRY POSITION")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Table1) THEN Pick_entry
T1= LastPickPara
Stat= EntityNameCheck(Table1,Table$)
R1=TableParaRow(Table1,T1)
C1=TableParaColumn(Table1,T1)
C2= C1+1
C3= C1+2
C4= C1+3
C5= C1+4


ActivateUndo
Stat= AdvanceUndoNumber("operation location")
Stat= AddItemToUndo(WsUBModifyMode,Table1)

Stat= EraseEntity(Table1)
RecordFunctionOn
Stat= RecordDescr("TABLE ENTRY: Operation location")

V1= FreeParameter("Row",R1)
V2= FreeParameter("Operation_name",C1)
V3= FreeParameter("X_column",C2)
V4= FreeParameter("Y_column",C3)
V5= FreeParameter("Z_column",C4)
Pt= ParameterPt(Element$,0.0)
Stat= InsertIntoTable(Table$,Operation_name$,V1,V2)
Stat= InsertIntoTable(Table$,XPointValue(Pt),XYZFormat$,V1,V3)
Stat= InsertIntoTable(Table$,YPointValue(Pt),XYZFormat$,V1,V4)
Stat= InsertIntoTable(Table$,ZPointValue(Pt),XYZFormat$,V1,V5)

Stat= TableTextOrigin(Table$,V1,V2,WsLeftCenter)
Stat= TableTextOrigin(Table$,V1,V3,V1,V5,WsRightCenter)
Stat= DeleteEntity(Pt)

RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
Stat= PlotEntity(Table1)

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Start


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