
! script name: draft.d/leaderballoon
! topic: construct text in a balloon

!A
!A NAME:
!A
!A 	Text Balloon with leader
!A
!A DESCRIPTION:
!A
!A 	This script allows a line of text to be placed inside a balloon.
!A
!B INSTRUCTIONS:
!B
!B 	INPUT ABS X,Y,Z: Enter the X,Y,Z coordinates for the starting position
!B 		of the line of text.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	INPUT TEXT LINE: Enter the line of text to be placed starting at the
!B 		specified coordinates.
!B
!# see also - htdocs/help.d/dynamicdim.htm
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: leader balloon ")

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

ActivateUndo
Start:!
Dynamic_position=1
Dim_type= WsTextBalloon
! Dim_type= WsLeaderBalloon


Dim_loop:!
Stat=SetInputFormat("a99","",0)
Stat=GetValue("INPUT TEXT",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Stat= BackSlashChars(Answer$,Text$)

stat= SetInputFormat("n4","")
Pstart=XyzInput("LEADER START",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pstart) THEN Dim_loop

Pmid=XyzInput("LEADER MIDDLE",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pmid) THEN Dim_loop

Pick_point:IF Dynamic_position THEN
        Pend= ParameterPt(Pmid,0)
ELSE
	Stat=SetInputFormat("n4","")
        Pend=XyzInput("LEADER END",WsXyOnly)
        IF (ExitScript(Destination$)) THEN Leave
        IF NOT ValidGeometry(Pend) THEN Pick_point
END IF

PlotOff
E1= TextBalloon(Dim_type,Text$,Pstart,Pmid,Pend)
PlotOn
Stat=DeleteEntity(Pstart)
Stat=DeleteEntity(Pend)
Stat=DeleteEntity(Pmid)

IF Dynamic_position THEN
        Which_end=1
        Vnum= LastPickView
        Stat= DynamicDimEdit(Vnum,E1,Which_end,"PICK LEADER END",WsFalse)
	IF (ExitScript(Destination$)) THEN
                Stat= DeleteEntity(E1)
                GOTO Leave
        END IF
END IF
ActivateUndo
Stat= AdvanceUndoNumber("balloon")
Stat= AddDimToUndo(WsUBCreateMode,E1)
GOTO Dim_loop

Leave:!
Stat=SetInputFormat("n4","")
Stat=DeleteEntity(Pstart)
Stat=DeleteEntity(Pend)
Stat=DeleteEntity(Pmid)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	IF Destination$= "SCRIPTSTART" THEN Start
        IF Destination$= "BACKUP" THEN Start
	 LOAD Destination$
END IF
END
