* All parent values of A0 are top level branches - any self value of * nothing in spaces 5 and 6 or the value of B1 in spaces 5 and 6 are top level. * All other values in spaces 5 and 6 are sub levels and fall under the branch * of its parent cPARENT cSELF SEQ A0 1MHG && top level message header A0 2TRG 1829 && top level 1st transaction A0 5BISB10001 1829 && top level A0 9BISB10001 1829 && top level 5BISB10001 5BPIF10001 1829 && 2nd level branch, directly under 5BISB10001 5BPIF10001 5DRVF20001 1829 && 3rd level branch, directly under 5BPIF10001 5BPIF10001 5DRVF20002 1829 && 3rd level branch, directly under 5BPIF10001 5DRVF20001 6PDRF30001 1829 && 4th level branch, directly under 5DRVF20001 A0 2TRG 1830 && top level 2nd transaction A0 5BISB10001 1830 && top level A0 9BISB10001 1830 && top level 5BISB10001 5BPIF10001 1830 && 2nd level branch, directly under 5BISB10001 5BPIF10001 5DRVF20001 1830 && 3rd level branch, directly under 5BPIF10001 5BPIF10001 5DRVF20002 1830 && 3rd level branch, directly under 5BPIF10001 5DRVF20001 6PDRF30001 1830 && 4th level branch, directly under 5DRVF20001 5DRVF20001 6PDRF30002 1830 && 4th level branch, directly under 5DRVF20001 Note: 1st four characters are type i.e. 5BPI, 5BIS, 1MHG, etc. 5&6 are 'sortof' levels i.e. B1, F1, F2, etc 7-10 is a counter that denotes it is the first, 2nd, etc 0001, 0002, etc. Records are stored in this order and each 2TRG record denotes the next 'group' or transaction The records should look like this in the treeview: 1MHG && 1st Message 2TRG && 1st transaction or 'group' in this message 5BISB10001 5BPIF10001 && 1st 5BPI under this 5BIS in 1st transactioin 5DRVF20001 && 1st 5DRV under this 5BPI 5DRVF20002 && 2nd 5DRV under this 5BPI 6PDRF30001 && 1st 6PDR under this 5DRV 9BISB10001 2TRG && 2nd transaction or 'group' in this message 5BISB10001 5BPIF10001 && 1st 5BPI under this 5BIS in 2nd transaction 5DRVF20001 && 1st 5DRV under this 5BPI in 2nd transaction 5DRVF20002 && 2nd 5DRV under this 5BPI in 2nd transaction 6PDRF30001 && 1st 6PDR under this 5DRV in 2nd transaction 6PDRF30002 && 2nd 6PDR under this 5DRV in 2nd transaction 9BISB10001All of the records in the treeview are in the table 'al3parnt' and the fields are cparent, cself, seq, ckey (quid key), etc...
SELE Al3Parnt set ORDER to 0 GO TOP SCAN STORE RECNO('al3parnt') TO mrecno * al3parnt.cparent is the parent of this record or upper branch * al3parnt.cself is the identity of this record STORE al3parnt.seq TO mseq && transaction sequence number IF al3parnt.cparent = "A0" && this record's parent 'branch' A0 is always top level branch tNode = THISFORM.AddNode(oNode) && add this top level node tNode.Text = al3parnt.cSELF && this record's identity tNode.Expanded = .T. tNode.Image = 1*5 + 1 mtext = tNode.Text * Now create the child branches for this top level branch * based on the records' cparent field matching this record's cself field SCAN FOR ALLTRIM(UPPER(al3parnt.cparent)) = ALLTRIM(UPPER(mtext)) .and. al3parnt.seq=mseq xNode = THISFORM.AddNode(tNode) && add the child branch to the above parent branch xNode.Text = al3parnt.cSELF && this child branch's identity xNode.Expanded = .T. xNode.Image = 1*5 + 1 mtext = xNode.Text *!* Here is where I get stuck * Now need to process this child record's sub branches if any, but my * logic is wrong because this obviously won't work. I need to determine * how many levels it could possibly go or handle an infinite number of * sublevels (child branches) ENDSCAN ENDIF IF RECNO()<>mrecno GOTO mrecno ENDIF ENDSCANThanks to anyone willing to look at this! I get everything fine through the 2nd level only obviously...