
! script name: vcontrol.d/recordcalcson
! var_topic: turns the calculations in a single record on.

!A
!A NAME:
!A
!A 	Record Calculations On
!A
!A DESCRIPTION:
!A
!A 	This script will turn on calculations in a single record.
!A
!B INSTRUCTIONS:
!B
!B 	PICK VARIATIONAL RECORD,   Number: Pick the VDM record.
!B
!B 		N - Enter N to allow the VDM record number to be entered.
!B
!B 	PICK VARIATIONAL OBJECT: Pick the VDM object, or enter the
!B 		name of the VDM object containing the record.
!B 		NOTE: This question is only asked if a record number has been
!B 		entered in response to the previous question.
!B
!B 	RECORD # IN OBJECT:  object_name: Enter the VDM record number of the
!B 		selected VDM object.
!B
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: record calculations on")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM Object_name$[256]
DIM Descr$[256]

DeActivateUndo
Highlight_color=4

Start:!
Pick_record:!
Stat=SetInputFormat("a1",",N,O,")
E1=PickEntity("PICK VARIATIONAL RECORD, Object,  Number",Answer$)
IF ExitScript(Destination$) THEN Leave
SELECT Answer$
CASE "O"
	GOSUB Pick_object
	Stat= ObjectCalcToggle(Var_object,WsTrue)
	Num_records= VObjectCount(Var_object)
	FOR I=1 TO Num_records
        	Var_record= VObjectRecord(Var_object,I)
        	IF (ValidGeometry(Var_record)) THEN
			Stat=Highlight(Var_record,Highlight_color,0)
			Stat= RecordCalcToggle(Var_record,WsTrue)
		END IF
	NEXT I
	GOTO Start
CASE "N"
	GOSUB Pick_object
Record_number:!
	Stat=SetInputFormat("n0","")
	Rec_number=GetValue("RECORD # IN OBJECT: "&Object_name$&"   ")
	IF ExitScript(Destination$) THEN Leave
	Var_record=VObjectRecord(Var_object,Rec_number)
	IF NOT ValidGeometry(Var_record) THEN Record_number
CASE ELSE
	IF NOT ValidGeometry(E1) THEN Pick_record
	Var_record=VarRecordParent(E1)
	IF NOT ValidGeometry(Var_record) THEN Pick_record
	Var_object=VarObjectParent(E1)
	IF NOT ValidGeometry(Var_object) THEN Pick_record
END SELECT
Stat=Highlight(Var_record,Highlight_color,0)
Stat= RecordCalcToggle(Var_record,WsTrue)

GOTO Pick_record

Pick_object:!
Nobjects= EntityTypeCount(WsVarObjectEnt)
IF Nobjects=1 THEN
	Var_object= CurrentVarObject
	IF NOT ValidGeometry(Var_object) THEN Leave
ELSE
	Var_object=PickVarObject("PICK VARIATIONAL OBJECT")
	IF ExitScript(Destination$) THEN Leave
	IF NOT ValidGeometry(Var_object) THEN Pick_object
END IF
Stat=VarObjectName(Var_object,Object_name$)
RETURN


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

