Procedure citeste_obiecte
Local lcMeniu,lcPageframe
lcMeniu=[contgest]
lcPageframe=[oprinc.pagefr1]

Create Cursor CRSOBIECTE(ID_PROG N(1),CHEIE C(20),NIVEL N(2),EXPLICATIE C(100),TATA C(20),COD C(2),ID_OBIECT N(10),ID_TATA N(10))
plCursor=.T.
citeste_meniu(90,lcmeniu,"Meniu")
citeste_pageframe(65,lcpageframe)
select * FROM crsobiecte INTO TABLE C:\crsobiecte.dbf
Endproc
************************************************************************
Procedure citeste_meniu
Lparameters lnKey,lcNumeMeniu,lcOptiune
lcKey=Chr(lnKey)
*!*	This.Nodes.Add(,1,lcKey,lcOptiune)
If plCursor
	Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey,1,lcOptiune,[ ])
Endif
lnKey2=65
*!*	k=0
*!*	Try
*!*		lcKey2=lcKey+Chr(lnKey2)
*!*		lnKey2=lnKey2+1
*!*		This.Nodes.Add(lcKey,4,lcKey2,'Utile')
*!*		If plCursor
*!*			Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey2,4,[Utile],lcKey)
*!*		Endif
*!*		For i=1 To Cntbar('utile')
*!*			lcOptiune=Prmbar('utile',i)
*!*			If !Empty(lcOptiune)
*!*				k=k+1
*!*				This.Nodes.Add(lcKey2,4,lcKey2+Padl(Alltrim(Str(k)),2,[0]),lcOptiune)
*!*				If plCursor
*!*					Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey2+Padl(Alltrim(Str(k)),2,[0]),4,lcOptiune,lcKey2)
*!*				Endif
*!*			Endif
*!*		Endfor
*!*	Catch
*!*	ENDTRY
k=0
Try
	lcKey2=lcKey+Chr(lnKey2)
	lnKey2=lnKey2+1
*!*		This.Nodes.Add(lcKey,4,lcKey2,'Initializare')
	If plCursor
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey2,4,[Actualizare],lcKey)
	Endif
	For i=1 To Cntbar('actualizar')
		lcOptiune=Prmbar('actualizar',i)
		If !Empty(lcOptiune)
			k=k+1
*!*				This.Nodes.Add(lcKey2,4,lcKey2+Padl(Alltrim(Str(k)),2,[0]),lcOptiune)
			If plCursor
				Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey2+Padl(Alltrim(Str(k)),2,[0]),4,lcOptiune,lcKey2)
			Endif
		Endif
	Endfor
Catch
Endtry
*!*	k=0
*!*	Try
*!*		lcKey2=lcKey+Chr(lnKey2)
*!*	*!*		This.Nodes.Add(lcKey,4,lcKey2,'Actualizari')
*!*		If plCursor
*!*			Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey2,4,[Actualizari],lcKey)
*!*		Endif
*!*		For i=1 To Cntbar('_1bs12qror')
*!*			lcOptiune=Prmbar('_1bs12qror',i)
*!*			If !Empty(lcOptiune)
*!*				k=k+1
*!*	*!*				This.Nodes.Add(lcKey2,4,lcKey2+Padl(Alltrim(Str(k)),2,[0]),lcOptiune)
*!*				If plCursor
*!*					Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey2+Padl(Alltrim(Str(k)),2,[0]),4,lcOptiune,lcKey2)
*!*				Endif
*!*			Endif
*!*		Endfor
*!*	Catch
*!*	Endtry
************************************************************************
Procedure citeste_pageframe
Lparameters lnKey,lcPageframe,lcTata
Local lcKey,lcProp,lcOptiune,lnNivel,lnPozitie,i,j,k,l
Store [] To lcKey,lcProp,lcOptiune
Store 0 To lnNivel,lnPozitie,i,j,k,l
If Empty(lcTata)
	lcTata=Null
	lnNivel=1
Else
	lnNivel=4
Endif
Set Exact On
With &lcPageframe
	For i=1 To .PageCount
		For j=1 To .PageCount
			If .Pages(j).PageOrder=i
				Exit
			Endif
		Endfor
		With .Pages(j)
			lcKey=Nvl(lcTata,[])+Chr(lnKey)
*!*				This.Nodes.Add(lcTata,lnNivel,lcKey,.Caption)
			lcProp="cnt"+lcKey
*!*				This.AddProperty(lcProp,0)
			If plCursor
				Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey,lnNivel,.Caption,Nvl(lcTata,[ ]))
			Endif
			lcProp="cnt"+lcKey
*!*				This.AddProperty(lcProp,0)
			Dimension copii(128,3)
			k=1
			For l=1 To .ControlCount
				Do Case
				Case  Alltrim(Upper(.Objects(l).Class))='PAGEFRAME'
					lcNume=lcPageframe+'.'+Alltrim(.Name)+'.'+Alltrim(Upper(.Objects(l).Name))
					citeste_pageframe(65,lcNume,lcKey)
				Case Alltrim(Upper(.Objects(l).Class))='CW' And .Objects(l).nid_cw>0
					lcOptiune=.Objects(l).label_item1.Caption
					lnPozitie=.Objects(l).nid_cw
					copii(lnPozitie,1)=lcOptiune
					copii(lnPozitie,2)=.Objects(l).ntip
					copii(lnPozitie,3)=.Objects(l).cmeniu
					k=k+1
				Endcase
			Endfor
			For l=1 To k-1
*!*					This.Nodes.Add(lcKey,4,lcKey+Padl(Alltrim(Str(l)),2,[0]),copii(l,1))
				If plCursor
					Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+Padl(Alltrim(Str(l)),2,[0]),4,copii(l,1),lcKey)
				Endif
*!*					If !Empty(copii(l,3))
*!*						This.adauga_meniuri(copii(l,3),copii(l,2),lcKey+Padl(Alltrim(Str(l)),2,[0]))
*!*					Else
				adauga_frunze(copii(l,2),lcKey+Padl(Alltrim(Str(l)),2,[0]))
*!*					Endif
			Endfor
		Endwith
		lnKey=lnKey+1
	Endfor
Endwith
Set Exact Off
Endproc
************************************************************************
Procedure adauga_frunze
Lparameters lnTip,lcKey
Do Case
Case lnTip=0	&&	introducere
Case lnTip=1	&&	raport
*!*		lcProp="cnt"+lcKey
*!*		This.AddProperty(lcProp,0)
*!*		This.Nodes.Add(lcKey,4,lcKey+"1","Export")
*!*		This.Nodes.Add(lcKey,4,lcKey+"2","Listare")
	If plCursor
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"1",4,"Export",lcKey)
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"2",4,"Listare",lcKey)
	Endif
Case lnTip=2	&&	registru
*!*		lcProp="cnt"+lcKey
*!*		This.AddProperty(lcProp,0)
*!*		This.Nodes.Add(lcKey,4,lcKey+"1","Export")
*!*		This.Nodes.Add(lcKey,4,lcKey+"2","Listare")
*!*		This.Nodes.Add(lcKey,4,lcKey+"3","Modificare")
*!*		This.Nodes.Add(lcKey,4,lcKey+"4","Refacere")
	If plCursor
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"1",4,"Export",lcKey)
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"2",4,"Listare",lcKey)
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"3",4,"Modificare",lcKey)
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"4",4,"Refacere",lcKey)
	Endif
Case lnTip=3	&&	balanta\inreg.
*!*		lcProp="cnt"+lcKey
*!*		This.AddProperty(lcProp,0)
*!*		This.Nodes.Add(lcKey,4,lcKey+"1","Export")
*!*		This.Nodes.Add(lcKey,4,lcKey+"2","Listare")
*!*		This.Nodes.Add(lcKey,4,lcKey+"3","Modificare")
*!*		This.Nodes.Add(lcKey,4,lcKey+"4","Refacere")
	If plCursor
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"1",4,"Export",lcKey)
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"2",4,"Listare",lcKey)
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"3",4,"Modificare",lcKey)
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"4",4,"Refacere",lcKey)
	Endif
Case lnTip=4	&&	vizualizare
*!*		lcProp="cnt"+lcKey
*!*		This.AddProperty(lcProp,0)
*!*		This.Nodes.Add(lcKey,4,lcKey+"1","Export")
*!*		This.Nodes.Add(lcKey,4,lcKey+"2","Listare")
*!*		This.Nodes.Add(lcKey,4,lcKey+"3","Modificare")
*!*		This.Nodes.Add(lcKey,4,lcKey+"4","Stergere")
*!*		This.Nodes.Add(lcKey,4,lcKey+"5","Vizualizare inreg. proprii")
*!*		This.Nodes.Add(lcKey,4,lcKey+"6","Vizualizare toate inreg.")
	If plCursor
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"1",4,"Export",lcKey)
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"2",4,"Listare",lcKey)
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"3",4,"Modificare",lcKey)
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"4",4,"Stergere",lcKey)
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"5",4,"Vizualizare inreg.proprii",lcKey)
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"6",4,"Vizualizare tot",lcKey)
	ENDIF
Case lnTip=5	&&	personalizat
*!*		lcProp="cnt"+lcKey
*!*		This.AddProperty(lcProp,0)
*!*		This.Nodes.Add(lcKey,4,lcKey+"1","Export")
*!*		This.Nodes.Add(lcKey,4,lcKey+"2","Listare")
*!*		This.Nodes.Add(lcKey,4,lcKey+"3","Modificare")
*!*		This.Nodes.Add(lcKey,4,lcKey+"4","Stergere")
*!*		This.Nodes.Add(lcKey,4,lcKey+"7","Altele...")
*!*		This.Nodes.Add(lcKey,4,lcKey+"8","Altele...")
	If plCursor
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"1",4,"Export",lcKey)
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"2",4,"Listare",lcKey)
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"3",4,"Modificare",lcKey)
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"4",4,"Stergere",lcKey)
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"7",4,"Altele...",lcKey)
		Insert Into CRSOBIECTE (CHEIE,NIVEL,EXPLICATIE,TATA) Values(lcKey+"8",4,"Altele...",lcKey)
	Endif
Endcase
Endproc
************************************************************************