
! script name: vdatatable.d/colappendtbls
! var_topic: merge two tables by appending the columns.

!A
!A NAME:
!A
!A 	Column append tables	VARIATIONAL
!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 which is to be appended
!B                              to the first.
!B
!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]
DIM Table1$[256]
DIM Table2$[256]

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


ActivateUndo
Start:!
Element_loop:!
Pick_table1:stat= SetInputFormat("n4","")
Table1=PickEntity("PICK FIRST 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 SECOND TABLE")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Table2) THEN Pick_table2
Stat= EntityNameCheck(Table2,Table2$)

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

Stat= EraseEntity(Table1)
RecordFunctionOn
Stat= RecordDescr("TABLE: Column Append ")
Stat= ColumnMergeTables(Table1$,Table2$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
Stat= PlotEntity(Table1)

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Element_loop

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