
! script name: vdraft.d/textballoon
! var_topic: construct text balloon

!A
!A NAME:
!A
!A 	Text Balloon	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script constructs a text balloon.
!A
!B INSTRUCTIONS:
!B
!B 	CENTER POINT: Pick the point to be used for the start of the
!B 		leader.  An arrow will be placed at this point.
!B
!B 	INPUT TEXT, None: Enter the  text to be placed in the balloon.
!B
!C NOTE:
!C
!C 	EXTENDED CHARACTER SET: Characters may be input by their ascii number.
!C 	Type in \031 for example to use the character in the font assigned to
!C 	the ascii number 31. The code must be a three digit number from 001 to
!C 	255.  Some of the extended characters like the geometric tolerancing
!C 	symbols take up more than one space so they should be bracketed with
!C 	extra spaces.
!C
!# see also - htdocs/help.d/dynamicdim.htm

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

DIM Answer$[256]
DIM Destination$[256]
DIM Dim_type$[256]
DIM Text$[256]
DIM Text1$[256]
DIM Point1$[256]
DIM Point2$[256]
DIM Point3$[256]
DIM Name$[256]
DEG


Start:!
Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave


ActivateUndo
Dim_loop:!
E1=PickEntity("CENTER POINT")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Dim_loop
T1= LastPickPara
Pick_return1= CurrPickReturn
Stat= EntityNameCheck(E1,Point1$)
Ps= ParameterReturnPt(E1,T1,Pick_return1)

Stat=DeleteEntity(Ps)

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

Stat= GenerateVarName("D",Name$)
RecordFunctionOn
Stat= RecordDescr("DIM: Text Balloon")
Stat= SetRecDelLastExec
SELECT Pick_return1
CASE WsGeometryEnd
        Ps= ParameterReturnPt(Point1$,T1,WsGeometryEnd)
CASE WsGeometryMid
        Ps= ParameterReturnPt(Point1$,T1,WsGeometryMid)
CASE WsGeomCenter
        Ps= ParameterReturnPt(Point1$,T1,WsGeomCenter)
END SELECT
V1= StringConstant(Text$)
E1= TextBalloon(WsTextBalloon,V1,Ps)
Stat= NameEntity(E1,Name$)
Stat=DeleteEntity(Ps)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= PlotEntity(E1)
Stat= PlotEntity(Point1$)
IF NOT ValidGeometry(E1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("text balloon")
	Stat= AddDimToUndo(WsUBCreateMode,E1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF

GOTO Dim_loop

Leave:!
stat= SetInputFormat("n4","")
Stat=DeleteEntityList(Ps,Pe,Pm)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
         IF Destination$= "SCRIPTSTART" THEN Start
         IF Destination$= "BACKUP" THEN Start
	 LOAD Destination$
END IF
END

