Jewtus Posted April 8, 2015 Share Posted April 8, 2015 (edited) I'm working on a tree view trying to figure out this bug I have run into, and also to see if there is a less intense way of doing this. I've included 2 sample arrays to play with. The first array does not process the way I want it to because of repetition in columns 5 and 6. I have been trying to figure out how to make this show up correctly for either example. The other problem is that these arrays are small (only a couple dozen records) in comparison to the overall array I'm trying to process and it takes about 7 minutes to process the full array. Can someone point me in the right direction? expandcollapse popup#include <GUIConstantsEx.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <GuiTreeView.au3> Local $Test[27][6]=[['Field1','ABC','','XYZ','Testing',''], _ ['Field1','ABC','','XYZ','Testing2',''], _ ['Field1','ABC','','XYZ','Testing3',''], _ ['Field1','ABC','','ZYX','Testing',''], _ ['Field1','ABC','','ZYX','Testing2',''], _ ['Field1','ABC','','ZYX','Testing3',''], _ ['Field1','ABC','','CBA','Testing',''], _ ['Field1','ABC','','CBA','Testing2',''], _ ['Field1','ABC','','CBA','Testing3',''], _ ['Field1','ABC','','XYZ','Testing','SubTesting1'], _ ['Field1','ABC','','XYZ','Testing2','SubTesting2'], _ ['Field1','ABC','','XYZ','Testing2','SubTesting3'], _ ['Field1','ABC','','XYZ','Testing2','SubTesting4'], _ ['Field1','ABC','','XYZ','Testing3','SubTesting5'], _ ['Field1','ABC','','XYZ','Testing3','SubTesting6'], _ ['Field1','ABC','','ZYX','Testing','SubTesting1'], _ ['Field1','ABC','','ZYX','Testing2','SubTesting2'], _ ['Field1','ABC','','ZYX','Testing2','SubTesting3'], _ ['Field1','ABC','','ZYX','Testing2','SubTesting4'], _ ['Field1','ABC','','ZYX','Testing3','SubTesting5'], _ ['Field1','ABC','','ZYX','Testing3','SubTesting6'], _ ['Field1','ABC','','CBA','Testing','SubTesting1'], _ ['Field1','ABC','','CBA','Testing2','SubTesting2'], _ ['Field1','ABC','','CBA','Testing2','SubTesting3'], _ ['Field1','ABC','','CBA','Testing2','SubTesting4'], _ ['Field1','ABC','','CBA','Testing3','SubTesting5'], _ ['Field1','ABC','','CBA','Testing3','SubTesting6']] Local $Test2[20][6]=[['Field1','ABC','','XYZ','Testing',''], _ ['Field1','ABC','','XYZ','Testing2',''], _ ['Field1','ABC','','XYZ','Testing3',''], _ ['Field1','ABC','','ZYX','ZYX',''], _ ['Field1','ABC','','CBA','Testing4',''], _ ['Field1','ABC','','LMN','Testing5',''], _ ['Field1','ABC','','LMN','Testing6',''], _ ['Field1','ABC','','XYZ','Testing','Subtesting1'], _ ['Field1','ABC','','XYZ','Testing','Testing'], _ ['Field1','ABC','','XYZ','Testing2','SubTesting2'], _ ['Field1','ABC','','XYZ','Testing2','SubTesting3'], _ ['Field1','ABC','','XYZ','Testing3','SubTesting4'], _ ['Field1','ABC','','XYZ','Testing3','SubTesting5'], _ ['Field1','ABC','','ZYX','ZYX','SubTesting6'], _ ['Field1','ABC','','ZYX','ZYX','Testing'], _ ['Field1','ABC','','CBA','Testing4','CBA'], _ ['Field1','ABC','','CBA','Testing4','SubTesting7'], _ ['Field1','ABC','','LMN','Testing5','SubTesting8'], _ ['Field1','ABC','','LMN','Testing5','SubTesting9'], _ ['Field1','ABC','','LMN','Testing6','Testing6']] $Form1 = GUICreate("Form1", 616, 483, 192, 114) $idTreeView_1 = GUICtrlCreateTreeView(8, 8, 601, 433,-1, $WS_EX_CLIENTEDGE) $Button1 = GUICtrlCreateButton("Refresh1", 400, 448, 75, 25) $Button2 = GUICtrlCreateButton("Refresh2", 500, 448, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 RefreshProcess($idTreeView_1,$Test) Case $Button2 RefreshProcess($idTreeView_1,$Test2) EndSwitch WEnd Func RefreshProcess($hTreeView_1,$test='') _GUICtrlTreeView_DeleteAll($hTreeView_1) _GUICtrlTreeView_BeginUpdate($hTreeView_1) $Loop=$test $Loop2=_ArrayUnique($Loop,0,1) $Loop3=_ArrayUnique($Loop,1,1) $Loop4=_ArrayUnique($Loop,2,1) $Loop5=_ArrayUnique($Loop,3,1) $Loop6=_ArrayUnique($Loop,4,1) $Loop7=_ArrayUnique($Loop,5,1) If UBound($Loop7) >1 AND IsArray(_ArrayFindAll($Loop7,"")) then _ArrayDelete($Loop7,_ArrayFindAll($Loop7,"")[0]) $hParent = 0 For $z=1 to UBound($Loop2) - 1 $hParent = _GUICtrlTreeView_Add( $hTreeView_1, $hParent, $Loop2[$z],0,0) For $x=1 to UBound($Loop3)-1 If $Loop[_ArraySearch($Loop,$Loop3[$x])][0] = $Loop2[$z] Then $hParent2 = _GUICtrlTreeView_AddChild( $hTreeView_1, $hParent, $Loop3[$x],1,1) For $w=1 to UBound($Loop4)-1 If $Loop[_ArraySearch($Loop,$Loop4[$w])][1] = $Loop3[$x] AND $Loop[_ArraySearch($Loop,$Loop3[$x])][0] = $Loop2[$z] Then If $Loop4[$w] <> '' Then $hParent3 = _GUICtrlTreeView_AddChild( $hTreeView_1, $hParent2, $Loop4[$w],2,2) For $y=1 to UBound($Loop5)-1 If $Loop[_ArraySearch($Loop,$Loop5[$y])][2] = $Loop4[$w] AND $Loop[_ArraySearch($Loop,$Loop3[$x])][0] = $Loop2[$z] Then $hParent4 = _GUICtrlTreeView_AddChild( $hTreeView_1, $hParent3, $Loop5[$y],3,3) For $n=1 to UBound($Loop6)-1 If $Loop[_ArraySearch($Loop,$Loop6[$n])][3] = $Loop5[$y] AND $Loop[_ArraySearch($Loop,$Loop3[$x])][0] = $Loop2[$z] Then $hParent5 = _GUICtrlTreeView_AddChild( $hTreeView_1, $hParent4, $Loop6[$n],4,4) For $v=1 to UBound($Loop7)-1 If $Loop[_ArraySearch($Loop,$Loop7[$v])][4] = $Loop6[$n] Then $hParent6 = _GUICtrlTreeView_AddChild( $hTreeView_1, $hParent5, $Loop7[$v],5,5) EndIf Next EndIf Next EndIf Next Else For $y=1 to UBound($Loop5)-1 If $Loop[_ArraySearch($Loop,$Loop5[$y])][1] = $Loop3[$x] AND $Loop[_ArraySearch($Loop,$Loop3[$x])][0] = $Loop2[$z] Then $hParent4 = _GUICtrlTreeView_AddChild( $hTreeView_1, $hParent2, $Loop5[$y],3,3) For $n=1 to UBound($Loop6)-1 If $Loop[_ArraySearch($Loop,$Loop6[$n])][3] = $Loop5[$y] AND $Loop[_ArraySearch($Loop,$Loop3[$x])][0] = $Loop2[$z] AND $Loop[_ArraySearch($Loop,$Loop3[$x])][1] = $Loop3[$x] Then $hParent5 = _GUICtrlTreeView_AddChild( $hTreeView_1, $hParent4, $Loop6[$n],4,4) For $v=1 to UBound($Loop7)-1 If $Loop[_ArraySearch($Loop,$Loop7[$v])][4] = $Loop6[$n] Then $hParent6 = _GUICtrlTreeView_AddChild( $hTreeView_1, $hParent5, $Loop7[$v],5,5) EndIf Next EndIf Next EndIf Next EndIf EndIf Next EndIf Next Next _GUICtrlTreeView_EndUpdate($hTreeView_1) EndFunc Note: The master does include lines that do not have a blank column 3 and I dont want a blank in the treeview I'm using the Else statement... The other part seems to work without issue. Edited April 8, 2015 by Jewtus Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now