
! script name: temp.d/draft_var_scal
! topic: Sample - automatically change drafting constants

!A
!A NAME:
!A
!A 	Scale Draft Variables
!A
!A DESCRIPTION:
!A
!A 	This script will automatically change the drafting constants
!A 	to the values used for drafting shafts.
!A
!B INSTRUCTIONS:
!B
!B 	There are no questions.
!B
!C NOTE:
!C
!C 	This is an unsupported sample script.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: Drafting variables")

DIM Answer$[256]
DIM Datastr$[1026]
DIM Destination$[256]
DIM File_name$[256]
DIM Name$[256]
DIM Question$[256]

JcDraftVars=12345

File_name$="/usr/weber/ascrpt/draft.d/draft_vars"
Draft_vars=FindUserData("DRAFT VARIABLES",JcDraftVars)

IF NOT ValidGeometry(Draft_vars) THEN
	Draft_vars=ReadUserData(JcDraftVars,"DRAFT VARIABLES",File_name$)
	Scale_flag=0
ELSE
	Scale_flag=GetUserValue(Draft_vars,"Scale flag:")
END IF
IF Scale_flag=0 THEN
	Text_height=GetDefault(WsTextHeight)
	Stat=PutUserValue(Draft_vars,"Original text height:",Text_height)
	Text_width=GetDefault(WsTextWidth)
	Stat=PutUserValue(Draft_vars,"Original text width:",Text_width)
	Arrow_height=GetDefault(WsArrowHeight)
	Stat=PutUserValue(Draft_vars,"Original arrow height:",Arrow_height)
	Arrow_width=GetDefault(WsArrowWidth)
	Stat=PutUserValue(Draft_vars,"Original arrow width:",Arrow_width)
	Gap_dist=GetDefault(WsGapDist)
	Stat=PutUserValue(Draft_vars,"Original gap distance:",Gap_dist)
END IF

Text_height=GetUserValue(Draft_vars,"Original text height:")
Text_width=GetUserValue(Draft_vars,"Original text width:")
Arrow_height=GetUserValue(Draft_vars,"Original arrow height:")
Arrow_width=GetUserValue(Draft_vars,"Original arrow width:")
Gap_dist=GetUserValue(Draft_vars,"Original gap distance:")

New_draft: !

	Stat=SetInputFormat("n4","")
	Size_factor=GetValue("Scale factor",Answer$)
	IF ExitScript(Destination$) THEN Leave
	Draft_text_ht=PROUND(Text_height*Size_factor,-4)
	Stat=SetDefaults(WsTextHeight,Draft_text_ht)
	Draft_text_wd=PROUND(Text_width*Size_factor,-4)
	Stat=SetDefaults(WsTextWidth,Draft_text_wd)
	Draft_arrow_ht=PROUND(Arrow_height*Size_factor,-4)
	Stat=SetDefaults(WsArrowHeight,Draft_arrow_ht)
	Draft_arrow_wd=PROUND(Arrow_width*Size_factor,-4)
	Stat=SetDefaults(WsArrowWidth,Draft_arrow_wd)
	Draft_gap_dist=PROUND(Gap_dist*Size_factor,-4)
	Stat=SetDefaults(WsGapDist,Draft_gap_dist)
	Scale_flag=1
	Stat=PutUserValue(Draft_vars,"Scale flag:",1)

Leave:!

IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF

END
