
! script name: datatable.d/addcolumns
! topic: add columns to a table

!A
!A NAME:
!A
!A 	Add Columns
!A
!A DESCRIPTION:
!A
!A 	Add  blank columns to the end of a table
!A
!B INSTRUCTIONS:
!B
!B 	PICK TABLE: Select the table to be modified.
!B
!B 	NUMBER OF COLUMNS ADDED: Number of columns added to the end.
!B
!B NOTES:
!B
!B 	The data in the table is preserved when adding columns or rows.
!B
!B 	To insert blank columns in the interior of a table use insert column.
!B
!# see also - htdocs/help.d/datatables.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: add columns ")

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

ActivateUndo
Start:!

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


stat= SetInputFormat("n0=","")
Stat=SetEqualsValue(Ncols)
Ncols= GetValue("NUMBER OF COLUMNS ADDED",Answer$)
IF (ExitScript(Destination$)) THEN Leave


ActivateUndo
Stat= AdvanceUndoNumber("add columns")
Stat= AddItemToUndo(WsUBModifyMode,Table1)

Stat= EraseEntity(Table1)
Stat= RedimTableColumns(Table1,Ncols,WsTrue)
Stat= PlotEntity(Table1)

GOTO Element_loop

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