
! script name: draft.d/textline
! topic: construct line of text

!A
!A NAME:
!A
!A 	Text Line
!A
!A DESCRIPTION:
!A
!A 	This script allows a line of text to be placed at a specified position.
!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
!C NOTE:
!C
!C 	EXTENDED CHARACTER SET: Characters may be input by their ascii
!C 		number. Type in \031 for example to use the character in
!C 		the font assigned to the ascii number 31. The code must
!C 		be a three digit number from 001 to 255.  Some of the
!C 		extended characters like the geometric tolerancing
!C 		symbols take up more than one space so they should be
!C 		bracketed with extra spaces.
!C
!# see also - htdocs/help.d/dynamicdim.htm
!# see also - points.d/xyzinput.hlp

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

DIM Answer$[256]
DIM Destination$[256]
DIM Text_line$[512]
DIM Text1$[512]
DEG

ActivateUndo
Start:!
Dynamic_position=1
New_line$= "\n"
End_line$= CHR$(10)
Dim_type= WsTextLine
Text_loop:!

Stat=SetInputFormat("a99","",0)
Stat=GetValue("INPUT TEXT LINE",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Stat= BackSlashChars(Answer$,Text1$)
Stat= ReplaceString(Text1$,New_line$,End_line$,Text_line$)

IF Dynamic_position THEN
	Pc= PointXYZ(0,0,0)
ELSE
	Stat=SetInputFormat("n4","")
	Pc=XyzInput("INPUT",WsXyzInput)
	IF (ExitScript(Destination$)) THEN Leave
END IF

PlotOff
E1= TextArrow(Dim_type,Pc,Pc,Text_line$)
PlotOn
Stat=DeleteEntity(Pc)

IF Dynamic_position THEN
        Which_end=0
        Vnum= LastPickView
        Stat= DynamicDimEdit(Vnum,E1,Which_end,"PICK TEXT LOCATION",WsFalse)
	IF (ExitScript(Destination$)) THEN
                Stat= DeleteEntity(E1)
                GOTO Leave
        END IF
END IF
ActivateUndo
Stat= AdvanceUndoNumber("text")
Stat= AddDimToUndo(WsUBCreateMode,E1)
GOTO Text_loop

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