
! script name: vproperty.d/updatepropfile
! var_topic: update an info packet file

!A
!A NAME:
!A
!A 	Update External Packet
!A
!A DESCRIPTION:
!A
!A 	This script updates the data in an info packet file.
!A
!B INSTRUCTIONS:
!B
!B 	SELECT PACKET ID NAME: Select the info packet that you wish to make
!B 	a table from.
!B
!C NOTES:
!C
!C 	This script assumes that the info packet name field and the file name 
!C 	are identical.
!C
!# see also - htdocs/help.d/property.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: update a user property file")

DIM Destination$[512]
DIM Answer$[512]
DIM A$[512]
DIM B$[512]
DIM Name$[512]
DIM Prop_name$[512]
DIM Prop_dir$[512]
DIM Class_dir$[512]
DIM D_label$[512]
DIM Choice$[512]
DIM Current_dir$[512]
DIM Ques$[512]

Var_object=CheckVarObject
IF ExitScript(Destination$) THEN Leave

DeActivateUndo
Stat= NamedVarStr("properties dir",WsSystemVars,"/usr/weber/database/properties/",Prop_dir$)
Start:!
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("SELECT PACKET ID NAME",Name$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Name$
CASE "CANCEL"
        Stat= DeleteEntity(Group)
        GOTO Leave
END SELECT

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

Class_directory:!
D_label$="PACKET CLASSES"
Choice$="CLASS SELECTED"
Ques$= "PACKET CLASS DIRECTORY  List  "
Answer$= SelectDirectory(Prop_dir$,"*",Ques$,D_label$,Choice$,"",Current_dir$)
IF (ExitScript(Destination$)) THEN Leave
IF  Answer$= "CANCEL" THEN Leave
Answer$= TRIM$(Answer$)
A$= Answer$
Class_dir$= BaseNamePath(Answer$,Prop_dir$)
Overwrite=1
IF NOT DoesFileExist(A$) THEN
        CREATE DIR A$
ELSE
	Stat=SetInputFormat("a1",",Y,N,")
	Stat=GetValue("OVERWRITE EXISTING PACKET  Yes or No ",Answer$)
	IF (ExitScript(Destination$)) THEN Leave
	IF Answer$= "N" THEN Leave
END IF
LowerSelectBox


Make_record:!
RecordFunctionOn
Stat=RecordDescr("UPDATE PACKET FILE:"&Class_dir$)
V1= StringConstant(Prop_dir$)
V2= StringConstant(Class_dir$)
V3= StringConstant(FileNameString(V1,V2))
Stat= StorePropertyFile(Prop_name$,V3)
RecordFunctionOff
CloseVarRecord

GOTO Start

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


