
! script name: datatable.d/coljustify
! topic: Sample - justify text in a column

!A
!A NAME:
!A
!A 	Justify text in a column
!A
!A DESCRIPTION:
!A
!A 	This script will justify text in a column on a table.
!A
!B INSTRUCTIONS:
!B
!B 	JUSTIFY TEXT Left, Right, Center: This will place the entry to the
!B 		left,right, or center of the entry area. The individual lines
!B 		of a multiline entry are not justified.  The entire entry is
!B 		treated as a box and then justified.
!B
!B 			LL LowerLeft             1
!B 			ML LeftCenter            2
!B 			UL UpperLeft             3
!B 			LM LowerCenter           4
!B 			C  CenterText            5
!B 			MC UpperCenter           6
!B 			UR UpperRight            7
!B 			MR RightCenter           8
!B 			LR LowerRight            9
!B
!C NOTE:
!C
!C 	This is an unsupported sample script.
!C
!# see also - htdocs/help.d/datatables.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: justify text column ")

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

ActivateUndo
Num_lines=1
Num_chars=0
Highlight_pen=2

Start:!

Element_loop:!
stat= SetInputFormat("n4","")
Element1=PickEntity("PICK COLUMN TO BE JUSTIFIED")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Element1) THEN Element_loop
T1= LastPickPara

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

Stat= PlotDataTable(Element1,0,C1,Highlight_pen)

stat= SetInputFormat("a2",",L,R,C,UL,LL,UR,LR,C,ML,MR,UM,LM,")
Stat=SetEqualsValue(Num_lines)
Num_lines= GetValue("JUSTIFY TEXT Left, Right, Center ",Answer$)
IF (ExitScript(Destination$)) THEN Leave

SELECT Answer$
CASE "L"
        Textorig= WsLeftCenter
CASE "R"
        Textorig= WsRightCenter
CASE "C"
        Textorig= WsCenterText
CASE "UL"
        Textorig= WsUpperLeft
CASE "LL"
        Textorig= WsLowerLeft
CASE "UR"
        Textorig= WsUpperRight
CASE "LR"
        Textorig= WsLowerRight
CASE "ML"
        Textorig= WsLeftCenter
CASE "MR"
        Textorig= WsRightCenter
CASE "UM"
        Textorig= WsUpperCenter
CASE "LM"
        Textorig= WsLowerCenter
END SELECT

ActivateUndo
Stat= AdvanceUndoNumber("justify")
Stat= AddItemToUndo(WsUBModifyMode,Element1)

Stat= PlotDataTable(Element1,0,C1,-1)
Stat=TableTextOrigin(Element1,0,C1,textorig)
Stat= PlotDataTable(Element1,0,C1,0)

GOTO Element_loop

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