>LPARAMETER iNodeIndex >LOCAL i, iTempIndex, nChanges, lnLast_Mod, lnSeekVal, oTree, loNode, oParent, lnChildren > >with Thisform > nChanges = 0 > oTree = .TList2 > oParent = oTree.Nodes(m.iNodeIndex) > iTempIndex = m.oParent.Child.FirstSibling.Index > .Log("Starting from: " + Descrip, PROGRAM(),1) > lnChildren = m.oParent.Children && Total number of children > i = 1 > *Loop through all Parent's Child Nodes > > FOR i = 1 to m.lnChildren > > loNode = oTree.Nodes(m.iTempIndex) > *lnSeekVal = val(substr(oTree.Nodes(m.iTempIndex).Key, 3)) > lnSeekVal = val(substr(m.loNode.Key, 3)) > IF SEEK(m.lnSeekVal,'ItemTree','Node_Id') > if sort_order <> m.i > .Log("Re-ordering: " + m.loNode.Key + ; > ' for parent ' + m.oParent.Key, program(), 1) > .Log("Re-ordering item: " + Descrip, PROGRAM(),1) > replace sort_order with m.i && re-orders > nChanges = m.nChanges + 1 > .lUpdateItemTree = .T. > endif > else > .Log("Seek failed on node id:" + m.loNode.Key, program(), 1) > endif > * If the Node we are on has children, call the Sub again > IF loNode.Children > 0 > nChanges = m.nChanges + .SaveChild(m.loNode.Index) > ENDIF >*!* * If we are not on the last child move to the next child Node > IF m.i <> m.lnChildren > iTempIndex = oTree.Nodes(m.iTempIndex).Next.Index > ENDIF > > ENDFOR > >ENDWITH > >return m.nChanges