codazie character 5
Densoc character 30
I have a pricipal level 00 with this description
CodAzi Densoc
----------------------------------------------------------
00 "Indirizzi utili per regioni "
this level has 4 levels
10
20
30
40
each sublevel with has another level sample 101 or 202 or 402
and each another level sample 10101 or 10102 or 10103
On oldest fwh(16 bit) I used a listbox with tree class but now I cannot compile it
because not run ok ( perhaps there is something changed from otree listbox 16 bit version)
Now I wish create it with xbrowse
When I create the otree I used this function
- Code: Select all Expand view
Function BuildTree( oTree, oLbxTree )
oTree:= TreeBegin( "Folder1","Folder2","Folder3")
DO WHILE ! PROVVE->(Eof())
_TreeItem (AllTrim (PROVVE->CODAZI)+"."+PROVVE->DENSOC, "DBFs",,,, .F.)
TreeBegin(,)
PROVVE->(dbSkip())
DO WHILE LEN(AllTrim(PROVVE->CODAZI)) == 2 .AND. ! PROVVE->(Eof())
_TreeItem (AllTrim (PROVVE->CODAZI)+"."+PROVVE->DENSOC, "DBFs",,,, .F.)
*_TreeItem (PROVVE->DENSOC, "DBFs",,,, .F.)
TreeBegin(, )
PROVVE->(dbSkip())
DO WHILE LEN(AllTrim(PROVVE->CODAZI)) == 3 .AND. ! PROVVE->(Eof())
_TreeItem (AllTrim (PROVVE->CODAZI)+"."+PROVVE->DENSOC, "LIB",,,, .F.)
*_TreeItem (PROVVE->DENSOC, "LIB",,,, .F.)
TreeBegin(, )
PROVVE->(dbSkip())
DO WHILE LEN(AllTrim(PROVVE->CODAZI)) >= 4 .AND. ! PROVVE->(Eof())
* IF LEN(AllTrim(PROVVE->CODAZI)) >= 4
_TreeItem (AllTrim (PROVVE->CODAZI)+"."+PROVVE->DENSOC, "LOB",,,, .F.)
*_TreeItem (PROVVE->DENSOC, "LOB",,,, .F.)
* ENDIF
PROVVE->(dbSkip())
ENDDO
TreeEnd()
ENDDO
TreeEnd()
ENDDO
TreeEnd()
ENDDO
TreeEnd()
oTree:Expand()
oLbxTree:SetTree( oTree )
return nil
I made this test but not run ok
- Code: Select all Expand view
- #include "FiveWin.ch"
#include "xBrowse.ch"
REQUEST DBFCDX
REQUEST DBFFPT
EXTERNAL ordkeyno, ordkeycount,ordcreate,ordkeygoto
//---------------------//
Function Main()
Local oBrw,oWnd
RddSetDefault( "DBFCDX" )
DEFINE WINDOW oWnd TITLE "Provve test"
@0,0 XBROWSE oBrw OF oWnd
WITH OBJECT oBrw
:SetTree(BuildTree())
:oTree:OpenAll()
:CreateFromCode()
END
oWnd:oClient:=oBrw
ACTIVATE WINDOW oWnd
Return NIL
//---------------------//
Function BuildTree()
Local oTree,nTreeCount,nPrevLevel,nCurLevel,nLevelDiff
Local i,j
Local aItems := {}
USE PROVVE ALIAS PROVVE NEW SHARED
INDEX ON PROVVE->CODAZI TAG PROVVE TO PROVVE
GO TOP
do while ! provve->(eof())
aadd(aItems,{ (provve->codazi),1 ,(provve->densoc)} )
provve->(dbskip())
enddo
TREE oTree
nLevel:=aItems[1][2]
nTreeCount:=0
For i:=1 to Len(aItems)
if aItems[i][2] > nLevel
TREE
nTreeCount++
Elseif aItems[i][2] < nLevel
nPrevLevel:=nLevel
nCurLevel:=aItems[i][2]
nLevelDiff:=nPrevLevel-nCurLevel
For j:=1 to nLevelDiff
ENDTREE
nTreeCount--
Next
Endif
TREEITEM aItems[i][3] CARGO { aItems[i][1] } // Item Code
nLevel:=aItems[i][2]
Next
if nTreeCount > 0
For i:=nTreeCount To 1 Step -1
ENDTREE
Next
Endif
ENDTREE
Return oTree