
! script name: vdatatable.d/addrows
! var_topic: add rows to a table

!A
!A NAME:
!A
!A 	Add Rows	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	Add blank rows to the end of a table
!A
!B INSTRUCTIONS:
!B
!B 	PICK TABLE: Select the table to be modified.
!B
!B 	NUMBER OF ROWS ADDED: Number of rows 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 rows in the interior of a table use insert rows.
!B
!# see also - htdocs/help.d/datatables.htm

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

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

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


ActivateUndo
Start:!

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


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

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

Stat= EraseEntity(Table1)
RecordFunctionOn
Stat= RecordDescr("TABLE: Add rows")
V1= FreeParameter("Number rows",Nrows)
V2= FreeParameter("Addon",1)
Stat= ReDimTableRows(Table$,V1,V2)
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
