
! script name: vdatatable.d/attachbottom
! var_topic: Sample - Place table along the bottom of another table.

!A
!A NAME:
!A
!A 	Place table along the bottom of another table. VARIATIONAL
!A
!A DESCRIPTION:
!A
!A	Place table along the bottom of another table.
!A
!B INSTRUCTIONS:
!B
!B 	NO HELP AVAILABLE AT THIS TIME
!B
!C NOTE:
!C
!C 	This is an unsupported sample script.
!C
!# see also - htdocs/help.d/datatables.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: attach to bottom ")

DIM Answer$[256]
DIM A$[256]
DIM Destination$[256]
DIM Table1$[256]
DIM Table2$[256]

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


ActivateUndo
Start:!

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

Pick_table2:!
stat= SetInputFormat("n4","")
Table2=PickEntity("PICK LOWER TABLE ")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Table2) THEN Pick_table2
Stat= EntityNameCheck(Table2,Table2$)


ActivateUndo
Stat= AdvanceUndoNumber("attach bottom")
Stat= AddItemToUndo(WsUBModifyMode,Table1)
Stat= AddItemToUndo(WsUBModifyMode,Table2)

Stat= EraseEntity(Table1)
Stat= EraseEntity(Table2)

RecordFunctionOn
Stat= RecordDescr("TABLE: Attach bottom")
V1= FreeParameter("Length",MAX(TableLength(Table1$),TableLength(Table2$)))
Stat= SetTableLenWidth(Table1$,V1,0,2)
Pc1= ParameterPt(Table1$,0.0)
Pc2= ParameterPt(Table1$,0.5)
Stat= SetTableOrigin(Table1$,Pc1,WsUpperLeft)
Stat= SetTableOrigin(Table2$,Pc2,WsUpperLeft)
Stat=DeleteEntityList(Pc1,Pc2)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
Stat= PlotEntity(Table1)
Stat= PlotEntity(Table2)

GOTO Start

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