Hi!
It's been a while since I posted but almost everyday I read topics here..
I usually do xbrowse tree using DBF data..
I couldn't find an example using Array data for an xbrowse tree.. anyone? .. Mr. RAO?
Kind Regards,
Frances
#include "FiveWin.ch"
#include "xBrowse.ch"
//---------------------//
Function Main()
Local oBrw,oWnd
DEFINE WINDOW oWnd TITLE "Tree using Array"
@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:={ {"01","Computers" ,0},;
{"02","Core i3" ,1},;
{"03","Core i5" ,1},;
{"04","Furnitures" ,0},;
{"05","Tables" ,1},;
{"06","Computer Table" ,2},;
{"07","Regular Table" ,2},;
{"08","Desk" ,1},;
{"09","Computer Desk" ,2},;
{"10","Regular Desk" ,2},;
{"11","Chairs" ,1} }
TREE oTree
nLevel:=aItems[1][3]
nTreeCount:=0
For i:=1 to Len(aItems)
if aItems[i][3] > nLevel
TREE
nTreeCount++
Elseif aItems[i][3] < nLevel
nPrevLevel:=nLevel
nCurLevel:=aItems[i][3]
nLevelDiff:=nPrevLevel-nCurLevel
For j:=1 to nLevelDiff
ENDTREE
nTreeCount--
Next
Endif
TREEITEM aItems[i][2] CARGO { aItems[i][1] } // Item Code
nLevel:=aItems[i][3]
Next
if nTreeCount > 0
For i:=nTreeCount To 1 Step -1
ENDTREE
Next
Endif
ENDTREE
Return oTree
anserkk wrote:Try this.
- Code: Select all Expand view RUN
#include "FiveWin.ch"
#include "xBrowse.ch"
//---------------------//
Function Main()
Local oBrw,oWnd
DEFINE WINDOW oWnd TITLE "Tree using Array"
@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:={ {"01","Computers" ,0},;
{"02","Core i3" ,1},;
{"03","Core i5" ,1},;
{"04","Furnitures" ,0},;
{"05","Tables" ,1},;
{"06","Computer Table" ,2},;
{"07","Regular Table" ,2},;
{"08","Desk" ,1},;
{"09","Computer Desk" ,2},;
{"10","Regular Desk" ,2},;
{"11","Chairs" ,1} }
TREE oTree
nLevel:=aItems[1][3]
nTreeCount:=0
For i:=1 to Len(aItems)
if aItems[i][3] > nLevel
TREE
nTreeCount++
Elseif aItems[i][3] < nLevel
nPrevLevel:=nLevel
nCurLevel:=aItems[i][3]
nLevelDiff:=nPrevLevel-nCurLevel
For j:=1 to nLevelDiff
ENDTREE
nTreeCount--
Next
Endif
TREEITEM aItems[i][2] CARGO { aItems[i][1] } // Item Code
nLevel:=aItems[i][3]
Next
if nTreeCount > 0
For i:=nTreeCount To 1 Step -1
ENDTREE
Next
Endif
ENDTREE
Return oTree
Regards
Anser
anserkk wrote:Sorry,
I cannot find line 70 in your code. As per your message, the error occurs at line 70. The max no of lines in the code posted by you is only 61.
Did you try the sample code posted by me on your PC using your FHW ver 8.12 ?. Did it work ?
Regards
Anser
#include "FiveWin.ch"
#include "xBrowse.ch"
//---------------------//
Function Main()
Local oBrw,oWnd
DEFINE WINDOW oWnd TITLE "Tree using Array"
@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:={ {"01","Computers" ,0},;
{"02","Core i3" ,1},;
{"03","Core i5" ,1},;
{"04","Furnitures" ,0},;
{"05","Tables" ,1},;
{"06","Computer Table" ,2},;
{"07","Regular Table" ,2},;
{"08","Desk" ,1},;
{"09","Computer Desk" ,2},;
{"10","Regular Desk" ,2},;
{"11","Chairs" ,1} }
*/
Local aItems:={ {"1020-0000-0000-0000", 1,"Cuenta mayor"},;
{"1020-0001-0000-0000", 2,"Subcta"},;
{"1020-0001-0001-0000", 3,"Subsubcta"},;
{"1020-0001-0001-0001", 4,"subsubctanddetalles"} }
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
anserkk wrote:To do a test with your FWH ver, I don't have FWH 8.12 here with me right now.
Many changes has been implemented to Tree after Ver 8.12
Anyway Tree with your data is working fine here with the latest FWH version.
CUENTAS NIVEL DESCRIPCION
1020-0000-0000-0000 1 Cuenta mayor
1020-0001-0000-0000 2 Subcta
1020-0001-0001-0000 3 Subsubcta
1020-0001-0001-0001 4 subsubctanddetalles
- Code: Select all Expand view RUN
#include "FiveWin.ch"
#include "xBrowse.ch"
//---------------------//
Function Main()
Local oBrw,oWnd
DEFINE WINDOW oWnd TITLE "Tree using Array"
@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:={ {"01","Computers" ,0},;
{"02","Core i3" ,1},;
{"03","Core i5" ,1},;
{"04","Furnitures" ,0},;
{"05","Tables" ,1},;
{"06","Computer Table" ,2},;
{"07","Regular Table" ,2},;
{"08","Desk" ,1},;
{"09","Computer Desk" ,2},;
{"10","Regular Desk" ,2},;
{"11","Chairs" ,1} }
*/
Local aItems:={ {"1020-0000-0000-0000", 1,"Cuenta mayor"},;
{"1020-0001-0000-0000", 2,"Subcta"},;
{"1020-0001-0001-0000", 3,"Subsubcta"},;
{"1020-0001-0001-0001", 4,"subsubctanddetalles"} }
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
Regards
Anser
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 15 guests