Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to sum up the member
Message
 
To
28/05/2002 04:31:15
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00660910
Message ID:
00661905
Views:
20

How to list out all the member who is under who for example I want list out the
member who is under Member 'A' Is that possible to list to the grid or tree?


I would do that using a Treeview-control, as that represents the true structure best.

Filling the tree depends on the tree You want to use (MS, DBI, ...). I prefer the
TreView from DBI-Tech, but You can do it with the MS (that You already have <s>)
as well.

The principle is similar to what I sent You. You have an outer loop that scans
to the Member's table and adds a Parent-Node for each member. Then, before skipping
to the next member, call a subroutine, that creates the children and for each of
the children recursively calls itself if it finds children. Be careful to have all
variables in this subroutine being local and ideally make the selects into arrays.

Additionally to the parent-ID I passed in my subroutine, You will have to pass a
second parameter, the parent-level. This represents the Node-level (indentation of
the node) and is passed down adding one for each level.

That would be (*untested*) something like this
local ln_Level


ln_Level = 1


select MEMBERS
scan
    =CreateNode(MEMBERS.ID, ln_Level)
    =AddChildren(MEMBERS.ID, ln_Level)

endscan


*=====================
function AddChildren (tc_Parent, tn_ParentLevel)
*=====================
local ln_ThisLevel, ln_i
local array la_Dummy[1,2]

ln_ThisLevel = tn_ParentLevel + 1 

select ID, ...;
  from MEMBERS;
   where Parent_ID = tc_Parent;
    into array la_Dummy


if _tally # 0
   for ln_i = 1 to alen(la_Dummy, 1)
       =CreateNode(la_Dummy[ln_i, 1], ln_ThisLevel)
       =AddChildren(la_Dummy[ln_i, 1], ln_ThisLevel)
   endfor
endif

return
endfunc


*====================
function CreateNode(tc_MemberID, tn_NodeLevel)
*====================

*-- OK, This is Your task and what actually
*-- happens here depends on the Tree You use
wait window "Member: "+ tc_MemberID +" Level: "+ allt(str(tn_NodeLevel)) time 0.5

return 
endfunc
HTH
Regards from Berlin

Frank

Dietrich Datentechnik (Berlin)
Softwarekombinat Teltow (Teltow)

Frank.Dietrich@dd-tech.de
DFPUG # 327
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform