
! script name: vdatatable.d/tableentrypt
! var_topic: point on a corner of a table entry

!A
!A NAME:
!A
!A 	Tables: Table entry point		VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script creates a point along the corner of a table entry.
!A
!B INSTRUCTIONS:
!B
!B	PICK TABLE ENTRY: Pick the table entry.
!B
!B	WHICH CORNER UL, UR, LL, LR, C: Enter the position.
!B
!B 		LL LowerLeft		1
!B 		ML LeftCenter		2
!B 		UL UpperLeft		3
!B 		LM LowerCenter		4
!B 		C  CenterText		5
!B 		MC UpperCenter		6
!B 		UR UpperRight		7
!B 		MR RightCenter		8
!B 		LR LowerRight		9
!B
!# see also - htdocs/help.d/datatables.htm

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

DIM Answer$[256]
DIM A$[256]
DIM Destination$[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 ENTRY")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Table1) THEN Element_loop
Stat= EntityNameCheck(Table1,Table$)
T1= LastPickPara
R1=TableParaRow(Table1,T1)
C1=TableParaColumn(Table1,T1)

stat= SetInputFormat("a1",",L,R,T,B,")
stat= SetInputFormat("a2",",L,R,C,UL,LL,UR,LR,C,ML,MR,UM,LM,")
Stat=SetEqualsValue(Num_lines)
Stat= GetValue("WHICH CORNER TEXT UL, UR, LL, LR, C ",Answer$)
IF (ExitScript(Destination$)) THEN Leave

SELECT Answer$
CASE "L"
        Textorig= WsLeftCenter
CASE "R"
        Textorig= WsRightCenter
CASE "C"
        Textorig= WsCenterText
CASE "UL"
        Textorig= WsUpperLeft
CASE "LL"
        Textorig= WsLowerLeft
CASE "UR"
        Textorig= WsUpperRight
CASE "LR"
        Textorig= WsLowerRight
CASE "ML"
        Textorig= WsLeftCenter
CASE "MR"
        Textorig= WsRightCenter
CASE "UM"
        Textorig= WsUpperCenter
CASE "LM"
        Textorig= WsLowerCenter
CASE ELSE
        Textorig= WsUpperLeft
END SELECT



Stat= GenerateVarName(WsPointEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("TABLE: Table Entry Pt")
V1= FreeParameter("Row",R1)
V2= FreeParameter("Column",C1)
V3= FreeParameter("Which corner",textorig)
P1= TableEntryPoint(Table$,V1,V2,V3)
Stat= NameEntity(P1,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

ActivateUndo
Stat= AdvanceUndoNumber("table entry 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
