
! script name: datatable.d/colappendtbls
! topic: merge two tables by appending the columns.

!A
!A NAME:
!A
!A 	Column Append Tables
!A
!A DESCRIPTION:
!A
!A 	This script appends the second table to the right of the first.
!A
!B INSTRUCTIONS:
!B
!B 	PICK FIRST TABLE: Pick the first table.
!B
!B 	PICK SECOND TABLE: Pick the table
!B 		which is to be appended to the first.
!B
!B NOTE:
!B	
!B 	The first table is modified by this function. The second
!B 	table is left unchanged.
!B
!# see also - htdocs/help.d/datatables.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: column append tables ")

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


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

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


ActivateUndo
Stat= AdvanceUndoNumber("append tables")
Stat= AddItemToUndo(WsUBModifyMode,Table1)

Stat= EraseEntity(Table1)
Stat= ColumnMergeTables(Table1,Table2)
Stat= PlotEntity(Table1)

GOTO Element_loop

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