loFooBranch = CreateObject([Collection]) loFooBranch = this.getFee(Feepk, loFooBranch)May be bad practice. In the procedure getFee another object is added to the loFooBranch passed.
loFooBranch = CreateObject([Collection]) loFiReturn = this.getFee(Feepk) loFooBranch.add(loFiReturn.name, loFiReturn)Any thoughts?
SOME SAMPLE CODE: do test procedure test lotree = createobject('treecollection') loreturntree = lotree.getFoo([1]) return .t. endproc define class treecollection as collection procedure init use FeeData in 0 use FooData in 0 select 0 use FiData index on Fipk tag Fipk endproc procedure getFoo (tcpk) sele Feepk from FooData where Foopk = tcpk group by Feepk into cursor FeeCursor if reccount() = 0 return .f. else loFooBranch = createobject([collection]) loFooBranch.name = transform(Feepk) endif scan loFooBranch = this.getFee(Feepk, loFooBranch) endscan toMyRoot.add(loFiBranch.name,loFiBranch) return toMyRoot endproc procedure getFee (tcpk, toMyRoot) sele Fipk from FeeData where Feepk = tcpk group by Fipk into cursor FiCursor if reccount() = 0 return .f. else loFeeBranch = createobject([collection]) loFeeBranch.name = transform(Fipk) endif scan loFeeBranch = this.getFi(Fipk, loFeeBranch) endscan toMyRoot.add(loFeeBranch.name,loFeeBranch) return toMyRoot endproc procedure getFi (tcpk, toMyRoot) sele Fipk from FiData where Feepk = tcpk group by Fipk into cursor FiCursor if reccount() = 0 return .f. else loFiBranch = createobject([collection]) loFiBranch.name = transform(Fipk) endif scan loFiBranch.add(loFiBranch.name, Fipk) endscan toMyRoot.add(loFiBranch.name, loFiBranch) return toMyRoot endproc enddefine