
! script name: datatable.d/insertcolumns
! topic: insert empty columns to a table

!A
!A NAME:
!A
!A 	Insert empty columns to a table
!A
!A DESCRIPTION:
!A
!A	Insert empty columns to a table
!A
!B INSTRUCTIONS:
!B
!B	PICK COLUMN TO BE INSERTED BEFORE:
!B
!B	NUMBER OF COLUMNS INSERTED:
!B
!# see also - htdocs/help.d/datatables.htm

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

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


ActivateUndo
Start:!
Element_loop:!
stat= SetInputFormat("n4","")
Table1=PickEntity("PICK COLUMN TO BE INSERTED BEFORE")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Table1) THEN Element_loop
T1= LastPickPara

R1=TableParaRow(Table1,T1)
C1=TableParaColumn(Table1,T1)

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

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

Stat= EraseEntity(Table1)
Stat= InsertTableColumns(Table1,C1,Ncols)
Stat= PlotEntity(Table1)

GOTO Element_loop

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