
! script name: vdatatable.d/tminpocketrad
! var_topic: insert the minimum radius of a pocket into a table.

!A
!A NAME:
!A
!A 	Tables: Minimum Pocket Radius	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A	Insert the minimum radius of a pocket into a table.
!A
!B INSTRUCTIONS:
!B
!B 	PICK AN ELEMENT OF CONTOUR/TYPES: Pick an element of the closed contour
!B 		that defines the pocket.
!B
!B 	PICK ENTRY POSITION: Pick the position in the table for the minimum
!B 		radius to be entered.
!B
!# see also - htdocs/help.d/datatables.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: min pocket radius into table")

DIM Answer$[256]
DIM Name$[256]
DIM Descr$[256]
DIM Element$[256]
DIM Table$[256]
DIM Destination$[256]
DIM Format$[15]
DEG

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

A= GetDefault(WsPlacesAfter)
Format$= "decimal "&VAL$(A)


ActivateUndo
Start:!

Stat= SetPickMask(WsPickNoSurf)
Pick_loop:Stat=SetInputFormat("n4","")
E1=PickEntity("PICK AN ELEMENT OF CONTOUR/TYPES")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_loop

Stat=Highlight(E1,WsPickPen,WsDirArrowOff)
Group= ParentGroup(E1,0)
IF NOT ValidDependency(Group) THEN Pick_loop
Stat= GroupName(Group,Element$)

stat= SetInputFormat("a1",",I,O,")
Stat=GetValue("  Inside or Outside ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$="I" THEN
        Inout= WsInside
ELSE
        Inout= WsOutside
END IF


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)

ActivateUndo
Stat= AdvanceUndoNumber("min pocket rad")
Stat= AddItemToUndo(WsUBModifyMode,Table1)

Stat= EraseEntity(Table1)
RecordFunctionOn
Stat= RecordDescr("TABLE ENTRY: Minimum pocket radius")

V1= FreeParameter("Row",R1)
V2= FreeParameter("Column",C1)
V3= FreeParameter("Inside/Outside",Inout)
Stat= InsertIntoTable(Table$,MinPocketRadius(Element$,V3),Format$,V1,V2)
Stat= TableTextOrigin(Table$,V1,V2,WsRightCenter)

RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
Stat= PlotEntity(Table1)

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Start


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