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

!A
!A NAME:
!A
!A 	Tables: Forms: Attach Bottom	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A	Place table along the bottom of another table.
!A

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= PlotEntity(Table1)
Stat= PlotEntity(Table2)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)

GOTO Start

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