
! script name: vproperty.d/propertyvars
! var_topic: make variables from info packet fields

!A
!A NAME:
!A
!A	Variables from All Fields
!A
!A DESCRIPTION:
!A
!A	This script assigns a dependent variable to the value of each
!A	data field in a packet entity.  Numeric data becomes  numeric
!B 	variables.  String data becomes string variables.
!A
!B INSTRUCTIONS:
!B
!B	VARIABLE BASE NAME: Give the base name of the variables.
!B
!B	ENTER INFO PACKET ID NAME: Select the info packet from the selection
!B 	box.
!B
!# see also - htdocs/help.d/property.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: property field variables ")

DIM Answer$[256]
DIM A$[256]
DIM B$[256]
DIM Name$[256]
DIM Descr$[256]
DIM Element$[256]
DIM Destination$[256]
DIM Prop_name$[256]
DIM Field$[256]
DIM Field_id$[256]
DIM Field_data$[256]
DIM D_label$[256]
DIM Choice$[256]
DEG

Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

Start:!
DeActivateUndo

Name_loop:!
stat= SetInputFormat("a99","")
Stat=GetValue("VARIABLE BASE NAME",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Name$= Answer$
IF NOT ValidVariableName(Name$) THEN
        stat= SetInputFormat("a99","")
        Stat=GetValue("INVALID VARIABLE NAME, Proceed",Answer$)
        IF (ExitScript(Destination$)) THEN Leave
        GOTO Name_loop
END IF
E1= FindNamedVar(Name$,WsVariationVars)
IF ValidGeometry(E1) THEN
        stat= SetInputFormat("a99","")
        Stat=GetValue("VARIABLE NAME IN USE, Proceed",Answer$)
        IF (ExitScript(Destination$)) THEN Leave
        GOTO Name_loop
END IF

Existing_props:!
Group1= GrpOfUserProps
Group= DependentSubGroup(Group1)
Stat= DeleteEntity(Group1)
IF NOT GroupCount(Group) THEN Leave
Stat=UserSelectBox("EXISTING INFO PACKETS","Packet selected",0,WsPropGroupSelect,Group)


Pick_prop:!
Stat=SetInputFormat("a99","")
Stat=GetValue("ENTER INFO PACKET ID NAME",Prop_name$)
IF (ExitScript(Destination$)) THEN Leave
IF Prop_name$= "CANCEL" THEN Leave
LowerSelectBox

Num1= NumericPrefix(Prop_name$)
IF NOT Num1 THEN Pick_prop
Prop_ent= GroupElement(Group,Num1)
IF NOT ValidDependency(Prop_ent) THEN Pick_prop
Stat= EntityNameCheck(Prop_ent,Prop_name$)
Stat= DeleteEntity(Group)



A$= UserDataStr(Prop_ent,"Class name:")
B$=UserDataStr(Prop_ent,"Name:")
Descr$= "FIELD VARIABLES: "&A$&":"&B$&":"

RecordFunctionOn
Stat= RecordDescr(Descr$)
V1= StringConstant("Name:")
V2=CreateVariable(Name$,WsVariationVars,UserDataStr(Prop_name$,V1))
G1= PropertyVariables(Prop_name$,EntityNameStr(V2),":",WsVariationVars)
Stat= DeleteEntity(G1)
RecordFunctionOff
CloseVarRecord

GOTO Start




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