
! script name: vproperty.d/vrecordlayer
! var_topic: modify record layer

!A
!A NAME:
!A
!A 	Modify Record Layer	--- VARIATIONAL
!A
!A DESCRIPTION:
!A
!A	The record chosen will have its layer changed to the layer selected.
!A
!B INSTRUCTIONS:
!B
!B	LAYER NUMBER,   current layer= # : Enter the layer number to
!B		be assigned to the record.
!B
!B 	PICK VARIATIONAL RECORD,   Number:
!B
!B 	PICK VARIATIONAL OBJECT, Name:
!B
!B 	OBJECT NAME: Enter the VDM object name.  NOTE: This question is only
!B 		asked if the Name option has been selected in the previous
!B 		question.
!B
!B 	RECORD # IN OBJECT:   object_name:
!B
!# see also - htdocs/help.d/vdminfo.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: modify record layer")

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

Curr_layer= CurrentLayer
Stat=LineNumberIncr(1)
Start_obj=0
Highlight_color=2

DeActivateUndo
Start:!
Quote$=CHR$(34)
Commastr$=","
Spacestr$=" "

Stat= SetInputFormat("n0=","")
Layer1=InputLayer("LAYER NUMBER,   current layer= "&VAL$(Curr_layer))
IF ExitScript(Destination$) THEN Leave

Pick_record:!
Stat=SetInputFormat("a1",",N,C,L,")
E1=PickEntity("PICK VARIATIONAL RECORD, Number, Layer, Calculate ",Answer$)
IF ExitScript(Destination$) THEN Leave
IF UPC$(Answer$)="L" THEN Start
IF UPC$(Answer$)="C" THEN Calc_record
IF Answer$="N" THEN
	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
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 IF

Stat= SetLayer(Var_record,Layer1)

GOTO Pick_record

Calc_record:!
LowerSelectBox
Output_script=0
Stat= DisplayMessage("CALCULATING CHANGES")
Stat=OutputAllObjects("tempscript","vproperty.d/vrecordlayer",Start_obj,Output_script)
IF Stat=1 THEN Start
Stat=SetCurrentLayer(Curr_layer)
LOAD "tempscript"

GOTO Raise_box

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$)
Stat=Highlight(Var_object,Highlight_color,0)
RETURN

Leave:!
Stat=SetCurrentLayer(Curr_layer)
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
