
! script name: edit.d/replacetext
! topic: replace  text in a dimension

!A
!A NAME:
!A
!A 	Replace Text In a Dimension.
!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: Replacement Text .
!B

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

DIM Answer$[256]
DIM Pre_text$[256]
DIM Post_text$[256]
DIM Destination$[256]
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 ValidGeometry(E2) THEN Element_loop

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

Stat= ChAdditionalText(E2,Pre_text$,Post_text$)

GOTO Start

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