
! script name: vdatatable.d/fillentryon
! var_topic: change the fill color of a table entry

!A
!A NAME:
!A
!A 	Entry Fill Color  VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows the fill color of a table entry to be changed.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ENTRY: Pick the entry to be filled.
!B
!B      In the FreeParameters specifing Row and Column numbers.
!B      If Row is set to 0 it fill all rows having the column number.
!B      If Column is set to 0 fill all columns having the row number.
!B      If both are zero it will fill the entire table.
!B
!# see also - htdocs/help.d/datatables.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: fill table entry ")

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

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

Pen_color= CurrentColor
RaiseColorBox

ActivateUndo
Start:!

Element_loop:!
stat= SetInputFormat("n4a1",",R,C,")
Element1=PickEntity("PICK ENTRY  Row, Column ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "R"
	stat= SetInputFormat("n4","")
	Element1=PickEntity("PICK TABLE ROW")
	IF (ExitScript(Destination$)) THEN Leave
	IF NOT ValidDependency(Element1) THEN Element_loop
	Stat= EntityNameCheck(Element1,Table$)
	T1= LastPickPara
	R1=TableParaRow(Element1,T1)
	C1=0
CASE "C"
	stat= SetInputFormat("n4","")
        Element1=PickEntity("PICK TABLE COLUMN")
        IF (ExitScript(Destination$)) THEN Leave
        IF NOT ValidDependency(Element1) THEN Element_loop
        Stat= EntityNameCheck(Element1,Table$)
        T1= LastPickPara
        R1=0
	C1=TableParaColumn(Element1,T1)
CASE ELSE
	IF NOT ValidDependency(Element1) THEN Element_loop
	Stat= EntityNameCheck(Element1,Table$)
	T1= LastPickPara
	R1=TableParaRow(Element1,T1)
	C1=TableParaColumn(Element1,T1)
END SELECT

ActivateUndo
Stat= AdvanceUndoNumber("fill entries")
Stat= AddItemToUndo(WsUBModifyMode,Element1)

Color1= CurrentColor
Stat= PlotDataTable(Element1,R1,C1,-1)
RecordFunctionOn
Stat= RecordDescr("TABLE: Fill Entry")
V1= FreeParameter("Color",Color1)
V2= FreeParameter("Row",R1)
V3= FreeParameter("Column",C1)
Stat= SetEntryFillColor(Table$,V2,V3,V1)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
Stat= PlotDataTable(Element1,R1,C1,0)

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Element_loop

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