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

!A
!A NAME:
!A
!A 	Place table along the bottom of another table.
!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

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

DIM Answer$[256]
DIM A$[256]
DIM Destination$[256]
DEG


ActivateUndo
Start:!

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

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

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

Length1= TableLength(Table1)
Width1= TableWidth(Table1)
Length2= TableLength(Table2)
Width2= TableWidth(Table2)

Stat= EraseEntity(Table1)
Stat= EraseEntity(Table2)
Len1= MAX(Length1,Length2)
Stat= SetTableLenWidth(Table1,Len1,0,2)
Stat= SetTableLenWidth(Table2,Len1,0,2)
Pc1= ParameterPt(Table1,0.0)
Pc2= ParameterPt(Table1,0.5)
Stat= SetTableOrigin(Table1,Pc1,WsUpperLeft)
Stat= SetTableOrigin(Table2,Pc2,WsUpperLeft)
Stat= PlotEntity(Table1)
Stat= PlotEntity(Table2)
Stat=DeleteEntity(Pc1)
Stat=DeleteEntity(Pc2)

GOTO Start

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