
! script name: vdatatable.d/sizerow
! var_topic: auto size a row in a table

!A
!A NAME:
!A
!A 	Row Size	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script auto sizes a row of entries in a table.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ROW TO BE SIZED: Pick the row to be autosized.
!B
!B 	MINIMUM NUMBER OF LINES: Enter the minimum number of lines in a row.
!B
!# see also - htdocs/help.d/datatables.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: auto size row ")

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

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

Num_lines=1
Num_chars=0

ActivateUndo
Start:!
N1= DataTableCount
IF N1=0 THEN Leave

Element_loop:!
stat= SetInputFormat("n4","")
Element1=PickEntity("PICK ROW TO BE SIZED")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Element1) THEN Element_loop
Stat= EntityNameCheck(Element1,Table$)
T1= LastPickPara

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

Stat= SetEntryHighlight(Element1,R1,C1,WsTrue)
Stat= PlotDataTable(Element1,R1,C1,0)

stat= SetInputFormat("n0=","")
Stat=SetEqualsValue(Num_lines)
Num_lines= GetValue("MINIMUM NUMBER OF LINES",Answer$)
IF (ExitScript(Destination$)) THEN
        Stat= SetEntryHighlight(Element1,R1,C1,WsFalse)
        GOTO Leave
END IF

ActivateUndo
Stat= AdvanceUndoNumber("size column")
Stat= AddItemToUndo(WsUBModifyMode,Element1)


Stat= EraseEntity(Element1)
Stat= SetEntryHighlight(Element1,R1,C1,WsFalse)
RecordFunctionOn
Stat= RecordDescr("TABLE: size row")
V1= FreeParameter("Minimum number of lines",Num_lines)
V2= FreeParameter("Row",R1)
Stat=AutoSizeTable(Table$,0,V1,V2,0)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
Stat= PlotEntity(Element1)

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
