
! script name: datatable.d/justityentry
! topic: Sample - justify text entry in a table

!A
!A NAME:
!A
!A 	Justify Text Entry in a Table
!A
!A DESCRIPTION:
!A
!A 	This script will justify the text entry in 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 entry ")

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

ActivateUndo
Num_lines=1
Num_chars=0

Start:!

stat= SetInputFormat("a1=",",L,R,C,")
Stat=SetEqualsValue(0,"C")
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
END SELECT

Element_loop:!
stat= SetInputFormat("n4","")
Element1=PickEntity("PICK ENTRY 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)

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

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

GOTO Element_loop

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