
! script name: vproperty.d/operatorinfo
! var_topic: attach operator info to a contour

!A
!A NAME:
!A
!A 	Attach an Operator Info Packet to a group	--- VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script attaches operator information to a specified
!A 	contour.
!A
!B INSTRUCTIONS:
!B
!B	PICK GROUP .  Pick the group to associate the operator info.
!B
!B	ENTER OPERATOR INFORMATION.  Type in the operator information
!B	line to be attached to the entity.
!B
!B
!C NOTES:
!C
!C 	1) In VDM, info packets must be defined variationally.
!C
!C 	2) You can attach an entity to any info packet previously defined 
!C 	in the variational program. 
!C
!C 	3) Duplicate info packets may occur if a packet that has already
!C 	been imported within another object is imported again. 
!C 	The system will only optimize packet occurrences within objects.
!C
!C 	4) Duplicate info packets may be resolved by running cleanup.
!C
!C 	This script creates two variational records. The first record
!C 	creates an info packet. The second record attaches the info packet to
!C 	the appropriate data.
!C
!# see also - htdocs/help.d/property.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: attach a property to group")

DIM Destination$[512]
DIM Answer$[512]
DIM Name$[512]
DIM Element$[512]
DIM Prop_dir$[512]
DIM Prop_name$[512]
DIM Class_dir$[512]
DIM Filename$[512]
DIM Prop_file$[512]
DIM Ques$[512]
DIM Line_val$(120)[256]
DIM A$[256],B$[256]

Var_object=CheckVarObject
IF ExitScript(Destination$) THEN Leave

Stat= NamedVarStr("properties dir",WsSystemVars,"/usr/weber/database/properties/",Prop_dir$)
Class_dir$= "OperatorInfo"
Prop_file$= "template"
Max_len= 20

Start:!
DeActivateUndo
Filename$= FileNameString(Prop_dir$,Class_dir$,Prop_file$)

Id_number=GetExtUserValue(Filename$,"Class id number:")

Pick_group:!
Stat= PlotEntity(Group)
Stat= SetInputFormat("n4","")
Group=PickGroupEnt("PICK GROUP",0,Answer$)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Group) THEN Pick_group
Stat= EntityNameCheck(Group,Element$)
Stat=Highlight(Group,WsPickPen,WsDirArrowOff)

Grp_prop_ent= GetAssocEnt(Group,Id_number)
IF ValidGeometry(Grp_prop_ent) THEN
	Stat= SetInputFormat("a1=",",N,I,")
	Stat= SetEqualsValue(0,"N")
	Stat= GetValue("COMMENT EXISTS.  PICK New_group OR Ignore PREV. COMMENT",Answer$)
	IF Answer$="N" THEN GOTO Pick_group
END IF

Ask_ques:!
I=1
Stat= SetInputFormat("a99","")
Multi_info= NamedVarVal("multi operator info",WsSystemVars,0)
Ques$= "ENTER COMMENT"
LOOP
	IF Multi_info THEN
		Stat= GetValue(Ques$&", New_group , PROCEED ",Answer$)
	ELSE
		Stat= GetValue(Ques$&", New_group ",Answer$)
	END IF
	IF ExitScript(Destination$) THEN Leave
	Line_val$(I)= TRIM$(Answer$)
	Line_val_len= LEN(Line_val$(I))
	EXIT IF UPC$(Answer$)="PROCEED" OR UPC$(Answer$)="NEW_GROUP"
	I= I+1
	EXIT IF NOT Multi_info 
END LOOP
IF I= 1 THEN Pick_group
I= I-1

Make_prop_record:!
Stat= GenerateVarName(WsDataStringEnt,Prop_name$)
RecordFunctionOn
Stat=RecordDescr("PROPERTY: Operator information")
V1= StringConstant(Prop_dir$)
V2= StringConstant(Class_dir$)
V3= StringConstant(Prop_file$)
V4= StringConstant(FileNameString(V1,V2,V3))
V5= StringConstant("Name:")
V6= StringConstant("COMMENT")
Prop_ent= ReadUserData(Id_number,V6,V4,WsTrue)
Stat= PutUserString(Prop_ent,V5,V6)


RecordFunctionOff
FOR J= 1 TO I
A$= "Line "&VAL$(J)&":"
B$= Line_val$(J)
RecordFunctionOn
V1= StringConstant(A$)
V2= StringConstant(B$)
Stat= PutUserString(Prop_ent,V1,V2)
RecordFunctionOff
NEXT J
RecordFunctionOn
Stat= AssocUserData(Element$,Prop_ent,UserDataType(Prop_ent))
Stat= NameEntity(Prop_ent,Prop_name$)
RecordFunctionOff
CloseVarRecord
IF NOT ValidGeometry(Prop_ent) THEN
        DelLastVarRecord
	GOTO Start
END IF

GOTO Pick_group

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

