
! script name: vdraftedit.d/replacetext
! var_topic: replace  text in a dimension

!A
!A NAME:
!A
!A 	Replace Text		VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows additional text to be added to a dimension
!A 	either before or after the dimension value.
!A
!B INSTRUCTIONS:
!B
!B 	PICK DIMENSION TO BE CHANGED: Pick one of the dimension lines.
!B
!B 	REPLACEMENT TEXT: Enter the Replacement Text.
!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

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

DIM Answer$[256]
DIM Pre_text$[256]
DIM Post_text$[256]
DIM Destination$[256]
DIM Name$[256]
DIM Element$[256]

Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave
DEG

ActivateUndo
Start:!
stat= SetInputFormat("a99","")
stat= GetValue("REPLACEMENT TEXT", Answer$)
IF (ExitScript(Destination$)) THEN Leave
Stat= BackSlashChars(Answer$,Pre_text$)
Post_text$= CHR$(1)

Element_loop:!
stat= SetInputFormat("n4","")
E1=PickEntity("PICK ITEM TO BE CHANGED", Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(E1) THEN Element_loop
E2= ParentDimEnt(E1)
IF NOT ValidDependency(E2) THEN Element_loop
Stat= EntityNameCheck(E2,Element$)

ActivateUndo
Stat= AdvanceUndoNumber("replace text")
Stat= AddDimToUndo(WsUBModifyMode,Element$)

RecordFunctionOn
Stat= RecordDescr("TEXT: Replace")
V1= StringConstant(Pre_text$)
V2= StringConstant(Post_text$)
Stat= ChAdditionalText(Element$,V1,V2)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Start

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