
! script name: vdatatable.d/tablecorners
! var_topic: set table corner points

!A
!A NAME:
!A
!A 	Tables: Corners		VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script will set the table corner points.
!A
!B INSTRUCTIONS:
!B
!B 	PICK TABLE TO BE SIZED: Pick the table to be sized.
!B
!B 	STARTING POINT: Pick the start point for the table.
!B
!B 	ENDING POINT: Pick the end point for the table.
!B
!# see also - htdocs/help.d/datatables.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: set table corner points ")

DIM Answer$[256]
DIM A$[256]
DIM Destination$[256]
DIM Point1$[256]
DIM Point2$[256]
DIM Table$[256]
DIM Name$[256]
DIM Destination$[256]
DEG

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


ActivateUndo
Start:!

Element_loop:!
stat= SetInputFormat("n4","")
Table1=PickEntity("PICK TABLE TO BE SIZED")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Table1) THEN Element_loop
Stat= EntityNameCheck(Table1,Table$)

Pick_point1:stat= SetInputFormat("n4","")
E1=PickEntity("STARTING POINT")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_point1
Stat= EntityNameCheck(E1,Point1$)
T1= LastPickPara
Pick_return1= CurrPickReturn
Ps= ParameterReturnPt(E1,T1,Pick_return1)

Pick_point2:Stat=SetLastPoint(Ps)
E2=PickEntity("ENDING POINT")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E2) THEN Pick_point2
Stat= EntityNameCheck(E2,Point2$)
T2= LastPickPara
Pick_return2= CurrPickReturn
Pe= ParameterReturnPt(E2,T2,Pick_return2)
Stat=SetLastPoint(Pe)

Stat= DeleteEntity(Ps)
Stat= DeleteEntity(Pe)


ActivateUndo
Stat= AdvanceUndoNumber("ch corner pts")
Stat= AddItemToUndo(WsUBModifyMode,Table1)

Stat= EraseEntity(Table1)
RecordFunctionOn
Stat= RecordDescr("TABLE: Corner points")
SELECT Pick_return1
CASE WsGeometryEnd
        Ps= ParameterReturnPt(Point1$,T1,WsGeometryEnd)
CASE WsGeometryMid
        Ps= ParameterReturnPt(Point1$,T1,WsGeometryMid)
CASE WsGeomCenter
        Ps= ParameterReturnPt(Point1$,T1,WsGeomCenter)
END SELECT
SELECT Pick_return2
CASE WsGeometryEnd
        Pe= ParameterReturnPt(Point2$,T2,WsGeometryEnd)
CASE WsGeometryMid
        Pe= ParameterReturnPt(Point2$,T2,WsGeometryMid)
CASE WsGeomCenter
        Pe= ParameterReturnPt(Point2$,T2,WsGeomCenter)
END SELECT
Stat= SetTableCorners(Table$,Ps,Pe)
Stat= DeleteEntity(Ps)
Stat= DeleteEntity(Pe)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= PlotEntity(Table1)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Element_loop

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