
! script name: vdatatable.d/tableedgept
! var_topic: point on the edge of a table.

!A
!A NAME:
!A
!A 	Tables: Table Edge Point		VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script creates a point along the edge of a table.
!A
!B INSTRUCTIONS:
!B
!B 	PICK TABLE: Pick the table.
!B
!B 	WHICH EDGE: Top, Right, Left, Side: Select
!B 		the edge.
!B
!B 	PARAMETER VALUE 0.0 - 1.0: Enter the
!B 		parameter value.
!B
!# see also - htdocs/help.d/datatables.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: point on table edge ")

DIM Answer$[256]
DIM A$[256]
DIM Destination$[256]
DIM Table$[256]
DIM Name$[256]
DIM Destination$[256]
DIM Para_var$[256]
DEG

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


ActivateUndo
Start:!

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

stat= SetInputFormat("a1",",L,R,T,B,")
Stat=SetEqualsValue(Num_lines)
Num_lines= GetValue("WHICH EDGE Top, Right, Bottom, Left  ",Answer$)
IF (ExitScript(Destination$)) THEN Leave

SELECT Answer$
CASE "T"
        Which_edge= 1
CASE "R"
        Which_edge= 2
CASE "B"
        Which_edge= 3
CASE "L"
        Which_edge= 4
END SELECT

stat= SetInputFormat("n4","")
Stat=SetEqualsValue(0.0)
Para_value= GetValue("PARAMETER VALUE 0.0 - 1.0 ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_para_var= LastVariableInput(Para_var$)


Stat= GenerateVarName(WsPointEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("TABLE: Table Edge Pt")
V1= FreeParameter("Which edge",Which_edge)
IF No_para_var THEN
        V2= FreeParameter("Parameter",Para_value)
	P1= TableEdgeParaPt(Table$,V2,V1)
ELSE
	P1= TableEdgeParaPt(Table$,Para_var$,V1)
END IF
Stat= NameEntity(P1,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

ActivateUndo
Stat= AdvanceUndoNumber("table edge pt")
Stat= AddItemToUndo(WsUBCreateMode,P1)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Start

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